1 /* 2 * Copyright (c) 2021 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 HKS_PARAM_H 17 #define HKS_PARAM_H 18 19 #include "hks_type.h" 20 21 #define HKS_PARAM_SET_MAX_SIZE (4 * 1024 * 1024) 22 #define HKS_DEFAULT_PARAM_SET_SIZE 512 23 #define HKS_DEFAULT_PARAM_CNT ((uint32_t)((HKS_DEFAULT_PARAM_SET_SIZE - sizeof(struct HksParamSet)) / \ 24 sizeof(struct HksParam))) 25 #define HKS_TAG_TYPE_MASK (0xF << 28) 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 HKS_API_EXPORT int32_t HksInitParamSet(struct HksParamSet **paramSet); 32 33 HKS_API_EXPORT int32_t HksAddParams(struct HksParamSet *paramSet, 34 const struct HksParam *params, uint32_t paramCnt); 35 36 HKS_API_EXPORT int32_t HksBuildParamSet(struct HksParamSet **paramSet); 37 38 HKS_API_EXPORT void HksFreeParamSet(struct HksParamSet **paramSet); 39 40 HKS_API_EXPORT int32_t HksGetParamSet(const struct HksParamSet *fromParamSet, uint32_t fromParamSetSize, 41 struct HksParamSet **paramSet); 42 43 HKS_API_EXPORT int32_t HksGetParam(const struct HksParamSet *paramSet, uint32_t tag, struct HksParam **param); 44 45 HKS_API_EXPORT int32_t HksFreshParamSet(struct HksParamSet *paramSet, bool isCopy); 46 47 HKS_API_EXPORT int32_t HksCheckParamSetTag(const struct HksParamSet *paramSet); 48 49 HKS_API_EXPORT int32_t HksCheckParamSet(const struct HksParamSet *paramSet, uint32_t size); 50 51 HKS_API_EXPORT int32_t HksCheckParamMatch(const struct HksParam *baseParam, const struct HksParam *param); 52 53 HKS_API_EXPORT int32_t HksCheckParamSetTag(const struct HksParamSet *paramSet); 54 55 HKS_API_EXPORT int32_t HksCheckIsTagAlreadyExist(const struct HksParam *params, uint32_t paramsCnt, 56 const struct HksParamSet *targetParamSet); 57 58 HKS_API_EXPORT enum HksTagType GetTagType(enum HksTag tag); 59 60 #ifdef __cplusplus 61 } 62 #endif 63 64 #endif /* HKS_PARAM_H */ 65