WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
dfx_adapt_layer.h
浏览该文件的文档.
1/*
2 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2022-2023. All rights reserved.
3 */
4#ifndef DFX_ADAPT_LAYER_H
5#define DFX_ADAPT_LAYER_H
6
7#include <stdbool.h>
8#include "securec.h"
10#include "dfx_resource_id.h"
11#include "diag_config.h"
12#include "soc_osal.h"
13#include "soc_log.h"
14#include "systick.h"
15#include "cmsis_os2.h"
16#include "dfx_system_init.h"
17
25
26static inline uint32_t dfx_int_lock(void)
27{
28 return osal_irq_lock();
29}
30
31static inline void dfx_int_restore(uint32_t state)
32{
33 osal_irq_restore(state);
34}
35
36static inline void dfx_sleep(uint32_t ms)
37{
38 osDelay(ms);
39}
40
41static inline void *dfx_malloc_permanent(uint32_t id, uint32_t size)
42{
43 unused(id);
44 return osal_vmalloc(size);
45}
46
47static inline void *dfx_malloc(uint32_t id, uint32_t size)
48{
49 unused(id);
50 return osal_vmalloc(size);
51}
52
53static inline void *dfx_zalloc(uint32_t id, uint32_t size)
54{
55 unused(id);
56 return osal_vzalloc(size);
57}
58
59static inline void dfx_free(uint32_t id, void *addr)
60{
61 unused(id);
62 osal_vfree(addr);
63}
64
65static inline uint32_t dfx_get_cur_second(void)
66{
67 return (uint32_t)uapi_systick_get_s();
68}
69
70/* Event 接口 */
71static inline int32_t dfx_event_write(dfx_event_id_t event_id)
72{
73 unused(event_id);
74 return ERRCODE_SUCC;
75}
76
77/* Msg 接口 */
78static inline errcode_t dfx_msg_write(uint32_t msg_id, uint8_t *msg, uint16_t msg_len, bool wait)
79{
80 uint32_t timeout = (wait) ? OSAL_MSGQ_WAIT_FOREVER : 0;
81 uint8_t msg_data[DFX_MSG_MAX_SIZE + DFX_MSG_ID_LEN];
82
83 *(uint32_t*)msg_data = msg_id;
84
85 if ((msg != NULL) && (memcpy_s(&msg_data[DFX_MSG_ID_LEN], DFX_MSG_MAX_SIZE, msg, msg_len) != EOK)) {
86 return ERRCODE_FAIL;
87 }
88
91}
92
93/*
94 * 文件传输消息发送接口
95 * 如文件传输未单独创建线程,可使用dfx_msg_write适配
96 * 如文件传输单独创建线程,使用g_dfx_transmit_queue_id发送消息
97 */
98static inline errcode_t transmit_msg_write(uint32_t msg_id, uint8_t *msg, uint16_t msg_len, bool wait)
99{
100 return dfx_msg_write(msg_id, msg, msg_len, wait);
101}
102
103static inline int32_t dfx_msg_queue_is_full(unsigned long queue_id)
104{
105 return osal_msg_queue_is_full(queue_id);
106}
107
108/* TIMER接口 */
111typedef void (*temp_osal_handler)(unsigned long data);
112static inline errcode_t dfx_timer_init(dfx_timer *timer, dfx_timer_handler handler, uintptr_t data, uint32_t ms)
113{
114 timer->handler = (temp_osal_handler)handler;
115 timer->data = data;
116 timer->interval = ms;
117 return osal_timer_init(timer);
118}
119
120static inline int32_t dfx_timer_start(dfx_timer *timer, uint32_t ms)
121{
122 unused(ms);
123 return osal_timer_start(timer);
124}
125
126static inline int32_t dfx_timer_stop(dfx_timer *timer)
127{
128 return osal_timer_stop(timer);
129}
130
131static inline int32_t dfx_timer_destroy(dfx_timer *timer)
132{
133 return osal_timer_destroy(timer);
134}
135
136/* machine 接口 */
137static inline uint32_t dfx_machine_get_id(void)
138{
139 return 0;
140}
141
142static inline char *dfx_machine_get_name(void)
143{
144 return "unknown";
145}
146
147/* fault 处理 */
148static inline void dfx_fault_event_data(uint32_t event_id, const uint8_t *data, uint16_t len)
149{
150 unused(event_id);
151 unused(data);
152 unused(len);
153}
154
155/* flash 读写 */
156static inline uint32_t dfx_flash_read(uint8_t opt_type, uint32_t offset, const uint8_t *buf, uint32_t size)
157{
158 unused(opt_type);
159 unused(offset);
160 unused(buf);
161 unused(size);
162 return size;
163}
164
165static inline uint32_t dfx_flash_write(uint8_t opt_type, unsigned offset, const uint8_t *buf, uint32_t size,
166 bool do_erase)
167{
168 unused(opt_type);
169 unused(offset);
170 unused(buf);
171 unused(size);
172 unused(do_erase);
173 return size;
174}
175
176/*
177 * flash擦除数据接口
178 */
179static inline errcode_t dfx_flash_erase(uint8_t opt_type, const uint32_t offset, const uint32_t size)
180{
181 unused(opt_type);
182 unused(offset);
183 unused(size);
184 return ERRCODE_SUCC;
185}
186
187static inline void dfx_watchdog_kick(void)
188{
189}
190
191static inline errcode_t dfx_pm_add_sleep_veto(void)
192{
193 return ERRCODE_SUCC;
194}
195
196static inline errcode_t dfx_pm_remove_sleep_veto(void)
197{
198 return ERRCODE_SUCC;
199}
200
201static inline errcode_t dfx_log_get_level(uint8_t core, const uint8_t *level)
202{
203 unused(core);
204 unused(level);
205 return ERRCODE_SUCC;
206}
207
208static inline errcode_t dfx_log_set_level(uint8_t core, uint8_t level)
209{
210 unused(core);
211 unused(level);
212 return ERRCODE_SUCC;
213}
214
215#define dfx_log_debug(fmt...)
216#define dfx_log_info(fmt...)
217#define dfx_log_err(fmt...) printf(fmt)
218
219#define dfx_assert(x) ((void)0)
220
221#endif /* DFX_ADAPT_LAYER_H */
#define NULL
Definition common_def.h:21
#define unused(var)
Definition common_def.h:49
void(* temp_osal_handler)(unsigned long data)
Definition dfx_adapt_layer.h:111
dfx_flash_op_type_t
Definition dfx_adapt_layer.h:18
@ FLASH_OP_TYPE_OTA
Definition dfx_adapt_layer.h:19
@ FLASH_OP_TYPE_FLASH_DATA
Definition dfx_adapt_layer.h:21
@ FLASH_OP_TYPE_LOG_FILE
Definition dfx_adapt_layer.h:20
@ FLASH_OP_TYPE_USER
Definition dfx_adapt_layer.h:22
@ FLASH_OP_TYPE_MAX
Definition dfx_adapt_layer.h:23
void(* dfx_timer_handler)(uintptr_t data)
Definition dfx_adapt_layer.h:110
osal_timer dfx_timer
Definition dfx_adapt_layer.h:109
dfx_event_id_t
Definition dfx_resource_id.h:15
unsigned long dfx_get_osal_queue_id(void)
Definition dfx_system_init.c:83
#define DFX_MSG_MAX_SIZE
Definition diag_config.h:11
#define DFX_MSG_ID_LEN
Definition diag_config.h:12
#define ERRCODE_SUCC
Definition errcode.h:35
uint32_t errcode_t
Definition of error code.
Definition errcode.h:30
#define ERRCODE_FAIL
Definition errcode.h:36
uint64_t uapi_systick_get_s(void)
获取Systick计数秒值。
Definition systick.c:85
void osal_vfree(void *addr)
release memory allocd by vmalloc().
Definition osal_addr.c:117
void * osal_vmalloc(unsigned long size)
alloc virtually contiguous memory.
Definition osal_addr.c:95
void * osal_vzalloc(unsigned long size)
alloc virtually contiguous memory.
Definition osal_addr.c:104
unsigned int osal_irq_lock(void)
Disable all interrupts.
Definition osal_interrupt.c:110
void osal_irq_restore(unsigned int irq_status)
Restore interrupts.
Definition osal_interrupt.c:130
int osal_msg_queue_is_full(unsigned long queue_id)
Check whether the message queue is full.
Definition osal_msgqueue.c:69
int osal_msg_queue_write_copy(unsigned long queue_id, void *buffer_addr, unsigned int buffer_size, unsigned int timeout)
Write data into a queue.
Definition osal_msgqueue.c:31
int osal_timer_stop(osal_timer *timer)
Deactivate a timer.
Definition osal_timer.c:159
int osal_timer_destroy(osal_timer *timer)
destroy the timer.
Definition osal_timer.c:177
int osal_timer_start(osal_timer *timer)
start a timer.
Definition osal_timer.c:144
int osal_timer_init(osal_timer *timer)
Initialize the timer.
Definition osal_timer.c:88
#define OSAL_MSGQ_WAIT_FOREVER
Definition osal_msgqueue.h:21
errno_t memcpy_s(void *dest, size_t destMax, const void *src, size_t count)
#define EOK
Definition securec.h:57
#define OSAL_SUCCESS
Definition soc_osal.h:104
Definition osal_timer.h:18
unsigned int interval
Definition osal_timer.h:22
void(* handler)(unsigned long)
Definition osal_timer.h:20
unsigned long data
Definition osal_timer.h:21
unsigned int uintptr_t
Definition td_type.h:65
Definition hal_uart_v151_regs_def.h:38