• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 /**
17  * @file hks_param.h
18  *
19  * @brief Declares operate params interface.
20  *
21  * @since 8
22  */
23 
24 #ifndef HKS_PARAM_H
25 #define HKS_PARAM_H
26 
27 #include "hks_type.h"
28 
29 #define HKS_PARAM_SET_MAX_SIZE (4 * 1024 * 1024)
30 #define HKS_DEFAULT_PARAM_SET_SIZE 512
31 #define HKS_DEFAULT_PARAM_CNT ((uint32_t)((HKS_DEFAULT_PARAM_SET_SIZE - sizeof(struct HksParamSet)) / \
32     sizeof(struct HksParam)))
33 #define HKS_TAG_TYPE_MASK (0xF << 28)
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /**
40  * @brief Init parameter set
41  * @param paramSet required parameter set
42  * @return error code, see hks_type.h
43  */
44 HKS_API_EXPORT int32_t HksInitParamSet(struct HksParamSet **paramSet);
45 
46 /**
47  * @brief Add parameter set
48  * @param paramSet required parameter set
49  * @param params params need to add
50  *
51  * @param paramCnt numbers of params
52  * @return error code, see hks_type.h
53  */
54 HKS_API_EXPORT int32_t HksAddParams(struct HksParamSet *paramSet,
55     const struct HksParam *params, uint32_t paramCnt);
56 
57 /**
58  * @brief Build parameter set
59  * @param paramSet required parameter set
60  * @return error code, see hks_type.h
61  */
62 HKS_API_EXPORT int32_t HksBuildParamSet(struct HksParamSet **paramSet);
63 
64 /**
65  * @brief Free parameter set
66  * @param paramSet required parameter set
67  * @return error code, see hks_type.h
68  */
69 HKS_API_EXPORT void HksFreeParamSet(struct HksParamSet **paramSet);
70 
71 /**
72  * @brief Get parameter set
73  * @param inParamSet required parameter set
74  * @param inParamSetSize input patamSet size
75  * @param outParamSet output parameter set
76  * @return error code, see hks_type.h
77  */
78 HKS_API_EXPORT int32_t HksGetParamSet(const struct HksParamSet *inParamSet, uint32_t inParamSetSize,
79     struct HksParamSet **outParamSet);
80 
81 /**
82  * @brief Get parameter
83  * @param paramSet required parameter set
84  * @param tag param's tag
85  * @param param output param
86  * @return error code, see hks_type.h
87  */
88 HKS_API_EXPORT int32_t HksGetParam(const struct HksParamSet *paramSet, uint32_t tag, struct HksParam **param);
89 
90 /**
91  * @brief Fresh parameter set
92  * @param paramSet required parameter set
93  * @param isCopy is copy or not
94  * @return error code, see hks_type.h
95  */
96 HKS_API_EXPORT int32_t HksFreshParamSet(struct HksParamSet *paramSet, bool isCopy);
97 
98 /**
99  * @brief Check param set tag
100  * @param paramSet required parameter set
101  * @return error code, see hks_type.h
102  */
103 HKS_API_EXPORT int32_t HksCheckParamSetTag(const struct HksParamSet *paramSet);
104 
105 /**
106  * @brief Check param set
107  * @param paramSet required parameter set
108  * @param size paramset size
109  * @return error code, see hks_type.h
110  */
111 HKS_API_EXPORT int32_t HksCheckParamSet(const struct HksParamSet *paramSet, uint32_t size);
112 
113 /**
114  * @brief Check param whether match or not
115  * @param baseParam one param
116  * @param param another param
117  * @return error code, see hks_type.h
118  */
119 HKS_API_EXPORT int32_t HksCheckParamMatch(const struct HksParam *baseParam, const struct HksParam *param);
120 
121 /**
122  * @brief Check param set tag
123  * @param paramSet required parameter set
124  * @return error code, see hks_type.h
125  */
126 HKS_API_EXPORT int32_t HksCheckParamSetTag(const struct HksParamSet *paramSet);
127 
128 /**
129  * @brief Check whether the tag exists
130  * @param params required parameter
131  * @param paramsCnt paramter size
132  * @param targetParamSet target paramset
133  * @return error code, see hks_type.h
134  */
135 HKS_API_EXPORT int32_t HksCheckIsTagAlreadyExist(const struct HksParam *params, uint32_t paramsCnt,
136     const struct HksParamSet *targetParamSet);
137 
138 /**
139  * @brief Get tag type
140  * @param tag the tag
141  * @return tag type, see hks_type.h
142  */
143 HKS_API_EXPORT enum HksTagType GetTagType(enum HksTag tag);
144 
145 HKS_API_EXPORT int32_t HksDeleteTagsFromParamSet(const uint32_t *tag, uint32_t tagCount,
146     const struct HksParamSet *paramSet, struct HksParamSet **outParamSet);
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
152 #endif /* HKS_PARAM_H */
153