1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef COMMON_NATIVE_INCLUDE_EDM_FUNC_CODE_H
17#define COMMON_NATIVE_INCLUDE_EDM_FUNC_CODE_H
18
19#include <map>
20#include <string>
21#include <vector>
22
23namespace OHOS {
24namespace EDM {
25/*
26 * FuncCode layout
27 *
28 * +-----+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
29 * | Bit |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|09|08|07|06|05|04|03|02|01|00|
30 * +-----+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
31 * |Field|       Reserved        |SystemFlag |                                 Code                      |
32 * +-----+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
33 * |Field|       Reserved        |PolicyFlag |OperateType|  PolicyCode                                   |
34 * +-----+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
35 */
36
37enum class FuncFlag {
38    SERVICE_FLAG = 0,
39    POLICY_FLAG = 1,
40    UNKNOWN = 0xF,
41};
42
43enum class FuncOperateType {
44    GET = 0,
45    SET = 1,
46    REMOVE = 2,
47    UNKNOWN = 0xF,
48};
49
50#define FUNC_TO_FLAG(CODE) (((CODE) & 0x00F00000) >> 20)
51#define FUNC_TO_OPERATE(CODE) (((CODE) & 0x000F0000) >> 16)
52#define FUNC_TO_POLICY(CODE) (((CODE) & 0x0000FFFF))
53#define SERVICE_FLAG(CODE) ((((CODE) & 0x00F00000) >> 20) == 0)
54#define POLICY_FLAG(CODE) ((((CODE) & 0x00F00000) >> 20) == 1)
55#define CREATE_FUNC_CODE(FLAG, OPERATE_TYPE, POLICY) (((FLAG) << 20) | ((OPERATE_TYPE) << 16) | (POLICY))
56#define POLICY_FUNC_CODE(OPERATE_TYPE, POLICY) CREATE_FUNC_CODE(1, OPERATE_TYPE, POLICY)
57} // namespace EDM
58} // namespace OHOS
59#endif // COMMON_NATIVE_INCLUDE_EDM_FUNC_CODE_H
60