• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
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  * Description: hal common header. \n
16  *
17  * History: \n
18  * 2023-03-22, Create file. \n
19  */
20 #ifndef HAL_COMMON_H
21 #define HAL_COMMON_H
22 
23 #include "crypto_type.h"
24 #include "crypto_osal_lib.h"
25 
26 /************************************************** common check log start************************************/
27 #ifndef hal_crypto_check_param
28 #define hal_crypto_check_param(module, cond) do { \
29     crypto_check_param(ERROR_LAYER_HAL, module, cond, ERROR_INVALID_PARAM); \
30 } while (0)
31 #endif
32 
33 #ifndef hal_crypto_check_param_null
34 #define hal_crypto_check_param_null(module, _val) do { \
35     crypto_check_param_null(ERROR_LAYER_HAL, module, _val); \
36 } while (0)
37 #endif
38 
39 #ifndef hal_crypto_pke_check_param
40 #define hal_crypto_pke_check_param(cond) do { \
41     hal_crypto_check_param(ERROR_MODULE_PKE, cond); \
42 } while (0)
43 #endif
44 
45 #ifndef hal_crypto_pke_check_param_null
46 #define hal_crypto_pke_check_param_null(_val) do { \
47     hal_crypto_check_param_null(ERROR_MODULE_PKE, _val); \
48 } while (0)
49 #endif
50 /************************************************** common check log end************************************/
51 
52 typedef enum {
53     CRYPTO_CPU_TYPE_SCPU,
54     CRYPTO_CPU_TYPE_ACPU,
55     CRYPTO_CPU_TYPE_HPPCPU,
56     CRYPTO_CPU_TYPE_PCPU,
57     CRYPTO_CPU_TYPE_AIDSP,
58     CRYPTO_CPU_TYPE_INVALID
59 } crypto_cpu_type;
60 
61 typedef enum {
62     IN_NODE_TYPE_FIRST = 1 << 0,
63     IN_NODE_TYPE_NORMAL = 1 << 1,
64     IN_NODE_TYPE_LAST = 1 << 2,
65     /* CCM. */
66     IN_NODE_TYPE_CCM_N = 1 << 3,
67     IN_NODE_TYPE_CCM_AAD = 1 << 4,
68     IN_NODE_TYPE_CCM_P = 1 << 5,
69     IN_NODE_TYPE_CCM_LAST = 1 << 6,
70     /* GCM. */
71     IN_NODE_TYPE_GCM_FIRST = 1 << 7,
72     IN_NODE_TYPE_GCM_A = 1 << 8,
73     IN_NODE_TYPE_GCM_P = 1 << 9,
74     IN_NODE_TYPE_GCM_LEN = 1 << 10,
75     IN_NODE_TYPE_GCM_GHASH = 1 << 11,
76     IN_NODE_TYPE_GCM_IV = 1 << 12,
77 } in_node_type_e;
78 
79 typedef td_s32 (*drv_wait_condition_func)(const td_void *param);
80 typedef td_s32 (*crypto_wait_timeout_interruptible)(crypto_wait_t *wait, drv_wait_condition_func func,
81     const td_void *param, const td_ulong timeout_ms);
82 
83 #endif