WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
crypto_osal_adapt.h
浏览该文件的文档.
1
9#ifndef CRYPTO_OSAL_ADAPT_H
10#define CRYPTO_OSAL_ADAPT_H
11
12#include "crypto_osal_lib.h"
14#include "osal_addr.h"
15
16#ifdef __cplusplus
17#if __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20#endif /* __cplusplus */
21
22/* Timer. */
23#ifndef crypto_msleep
24#define crypto_msleep osal_msleep
25#endif
26
27#ifndef crypto_udelay
28#define crypto_udelay osal_udelay
29#endif
30
31/* map. */
32#ifndef crypto_ioremap_nocache
33#define crypto_ioremap_nocache osal_ioremap_nocache
34#define crypto_iounmap osal_iounmap
35#endif
36
37/* Mutex. */
38#ifndef crypto_mutex_init
39#define crypto_mutex osal_mutex
40#define crypto_mutex_init osal_mutex_init
41#define crypto_mutex_destroy osal_mutex_destroy
42#define crypto_mutex_lock osal_mutex_lock
43#define crypto_mutex_unlock osal_mutex_unlock
44#endif
45
46/* deep sleep vote & other process. */
47#ifndef crypto_service_preprocess
48#define crypto_service_preprocess()
49#define crypto_service_postprocess()
50#endif
51
52/* Log. */
53#ifndef crypto_print
54#define crypto_print osal_printk
55#endif
56
57#if !defined(CRYPTO_LOG_DEF)
58#define crypto_log_fmt(LOG_LEVEL_LABEL, fmt, ...) \
59 crypto_print("[%s:%d]" LOG_LEVEL_LABEL ": " fmt, __func__, __LINE__, ##__VA_ARGS__)
60
61#ifndef CRYPTO_LOG_LEVEL
62#define CRYPTO_LOG_LEVEL 0
63#endif
64#if defined(CRYPTO_LOG_LEVEL) && (CRYPTO_LOG_LEVEL == 0)
65#define crypto_log_err(fmt, ...) crypto_log_fmt("ERROR", fmt, ##__VA_ARGS__)
66#define crypto_log_warn(fmt, ...)
67#define crypto_log_notice(fmt, ...)
68#define crypto_log_dbg(fmt, ...)
69#define crypto_log_trace(fmt, ...)
70#elif defined(CRYPTO_LOG_LEVEL) && (CRYPTO_LOG_LEVEL == 1)
71#define crypto_log_err(fmt, ...) crypto_log_fmt("ERROR", fmt, ##__VA_ARGS__)
72#define crypto_log_warn(fmt, ...) crypto_log_fmt("WARN:", fmt, ##__VA_ARGS__)
73#define crypto_log_notice(fmt, ...)
74#define crypto_log_dbg(fmt, ...)
75#define crypto_log_trace(fmt, ...)
76#elif defined(CRYPTO_LOG_LEVEL) && (CRYPTO_LOG_LEVEL == 2)
77#define crypto_log_err(fmt, ...) crypto_log_fmt("ERROR", fmt, ##__VA_ARGS__)
78#define crypto_log_warn(fmt, ...) crypto_log_fmt("WARN:", fmt, ##__VA_ARGS__)
79#define crypto_log_notice(fmt, ...) crypto_log_fmt("NOTICE", fmt, ##__VA_ARGS__)
80#define crypto_log_dbg(fmt, ...)
81#define crypto_log_trace(fmt, ...)
82#elif defined(CRYPTO_LOG_LEVEL) && (CRYPTO_LOG_LEVEL == 3)
83#define crypto_log_err(fmt, ...) crypto_log_fmt("ERROR", fmt, ##__VA_ARGS__)
84#define crypto_log_warn(fmt, ...) crypto_log_fmt("WARN:", fmt, ##__VA_ARGS__)
85#define crypto_log_notice(fmt, ...) crypto_log_fmt("NOTICE", fmt, ##__VA_ARGS__)
86#define crypto_log_dbg(fmt, ...) crypto_log_fmt("DBG", fmt, ##__VA_ARGS__)
87#define crypto_log_trace(fmt, ...)
88#elif defined(CRYPTO_LOG_LEVEL) && (CRYPTO_LOG_LEVEL == 4)
89#define crypto_log_err(fmt, ...) crypto_log_fmt("ERROR", fmt, ##__VA_ARGS__)
90#define crypto_log_warn(fmt, ...) crypto_log_fmt("WARN:", fmt, ##__VA_ARGS__)
91#define crypto_log_notice(fmt, ...) crypto_log_fmt("NOTICE", fmt, ##__VA_ARGS__)
92#define crypto_log_dbg(fmt, ...) crypto_log_fmt("DBG", fmt, ##__VA_ARGS__)
93#define crypto_log_trace(fmt, ...) crypto_log_fmt("TRACE", fmt, ##__VA_ARGS__)
94#endif
95
96#endif
97
98/* Malloc. */
99#ifndef crypto_malloc
100#define crypto_malloc(x) (((x) > 0) ? osal_kmalloc((x), OSAL_GFP_KERNEL) : TD_NULL)
101#define crypto_free(x) {if (((x) != TD_NULL)) osal_kfree(x);}
102#endif
103
104/* align check */
105#ifndef crypto_addr_align_check
106#define crypto_addr_align_check(addr) ((((addr) % 4) != 0) ? TD_FALSE : TD_TRUE)
107#endif
108
109/* ioctl_cmd. */
110#ifndef CRYPTO_IOCTL_CMD_DEF
111#define crypto_ioctl_cmd osal_ioctl_cmd
112#endif
113
114/* copy from/to user. */
115td_s32 crypto_copy_from_user(td_void *to, unsigned long to_len, const td_void *from, unsigned long from_len);
116td_s32 crypto_copy_to_user(td_void *to, unsigned long to_len, const td_void *from, unsigned long from_len);
117
118/* crypto dump functions. */
119void crypto_dump_data(const char *name, const td_u8 *data, td_u32 data_len);
120void crypto_dump_phys_addr(const char *name, const td_phys_addr_t phys_addr, td_u32 data_len);
121
122/* Check the Validation of but_attr. */
123td_bool crypto_data_buf_check(const crypto_buf_attr *buf_attr, td_u32 length);
124
125/* Crypto Owner Operation. */
126#if !defined(crypto_owner) && (CRYPTO_ERROR_ENV != ERROR_ENV_NOOS)
127#define crypto_owner long
128#define crypto_owner_dump(owner) crypto_log_dbg("Owner's pid is 0x%x\n", owner)
129static inline td_s32 crypto_get_owner(crypto_owner *owner)
130{
131 if (owner == TD_NULL) {
132 return CRYPTO_FAILURE;
133 }
134 *owner = crypto_getpid();
135 return CRYPTO_SUCCESS;
136}
137#endif
138
139#ifdef __cplusplus
140#if __cplusplus
141}
142#endif /* __cplusplus */
143#endif /* __cplusplus */
144
145#endif
#define crypto_getpid()
Definition crypto_osal_lib.h:29
@ CRYPTO_FAILURE
Definition crypto_errno.h:134
@ CRYPTO_SUCCESS
Definition crypto_errno.h:133
void crypto_dump_data(const char *name, const td_u8 *data, td_u32 data_len)
Definition crypto_drv_common.c:143
td_s32 crypto_copy_from_user(td_void *to, unsigned long to_len, const td_void *from, unsigned long from_len)
void crypto_dump_phys_addr(const char *name, const td_phys_addr_t phys_addr, td_u32 data_len)
Definition crypto_osal_lib.c:36
td_bool crypto_data_buf_check(const crypto_buf_attr *buf_attr, td_u32 length)
Definition crypto_osal_lib.c:41
td_s32 crypto_copy_to_user(td_void *to, unsigned long to_len, const td_void *from, unsigned long from_len)
Definition crypto_common_struct.h:19
unsigned char td_u8
Definition td_type.h:36
td_u8 td_bool
Definition td_type.h:50
void td_void
Definition td_type.h:49
unsigned int td_u32
Definition td_type.h:38
#define TD_NULL
Definition td_type.h:30
int td_s32
Definition td_type.h:44
unsigned int td_phys_addr_t
Definition td_type.h:74
Definition hal_uart_v151_regs_def.h:38