blob: 313ccd46bace874fbb8370a36bb218215ba0dbe2 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/**
2 * @file oss_sup.h
3 * @brief ossÄ£¿é¸½¼Ó¹¦ÄÜ
4 *
5 * Copyright (C) 2017 Sanechips Technology Co., Ltd.
6 *
7 *
8 */
9
10#ifndef _OSS_SUP_H
11#define _OSS_SUP_H
12
13/*******************************************************************************
14 * Include header files *
15 ******************************************************************************/
16#include "ramdump.h"
17#ifdef __cplusplus
18extern "C"
19{
20#endif
21
22
23/*******************************************************************************
24 * Macro definitions *
25 ******************************************************************************/
26#ifndef DOXYGEN_SHOULD_SKIP_THIS
27/* ÉèÖûò»ñȡʼþÊôÐÔ */
28#define ZOSS_EVENTS_OR 0x00
29#define ZOSS_EVENTS_AND 0x01
30#define ZOSS_EVENTS_OR_CLEAR 0x02
31#define ZOSS_EVENTS_AND_CLEAR 0x03
32
33/* ÉèÖûص÷º¯ÊýÀàÐÍ */
34#define ZOSS_SETHOOKFLAG_MONI 0x01 /* ÏûÏ¢¼à¿Ø */
35#define ZOSS_SETHOOKFLAG_TRACK 0x02 /* ÏßÐÔ¸ú×Ù */
36#define ZOSS_SETHOOKFLAG_INTER 0x03 /* ÏûÏ¢½Ø»ñ */
37#define ZOSS_SETHOOK_SEND 0x01 /* zOss_SendMsgÏûÏ¢À©Õ¹ */
38#define ZOSS_SETHOOK_SEND_DATA 0x02 /* zOss_SendMsgÏûÏ¢À©Õ¹ */
39#define ZOSS_SETHOOK_GET_ALL_ID 0x03 /* zOss_GetAllTaskIDÀ©Õ¹ */
40#define ZOSS_SETHOOK_GET_ID 0x04 /* zOss_GetTaskIDÀ©Õ¹ */
41#define ZOSS_SETHOOK_GET_NAME 0x05 /* zOss_GetTaskNameÀ©Õ¹ */
42
43/* ÈÎÎñÏûϢ״̬ */
44#define ZOSS_MSGSENDTYPE_MSG 0x01 /* ·¢ËÍÏûÏ¢ */
45#define ZOSS_MSGSENDTYPE_DATA 0x02 /* ·¢ËÍÊý¾Ý */
46#define ZOSS_MSGSENDTYPE_INTER 0x03 /* ÔÚÖжÏÖз¢ËÍ */
47#define ZOSS_MSGSENDTYPE_TIMER 0x04 /* ¶¨Ê±Æ÷ÏûÏ¢ */
48
49/* ÈÎÎñ״̬»ú */
50#define ZOSS_STATUS_INIT 0x01 /* ³õʼ̬ */
51#define ZOSS_STATUS_WORK 0x02 /* ¹¤×÷̬ */
52#define ZOSS_STATUS_IDLE 0x03 /* ¿ÕÏÐ̬ */
53#define ZOSS_STATUS_USERBASE 0x04 /* Óû§×´Ì¬×Ô¶¨Òå */
54
55/* ÈÎÎñÔËÐÐ״̬ */
56#define ZOSS_STATE_STOPPED 0x01 /* ÈÎÎñÔÝÍ£ */
57#define ZOSS_STATE_IDLE 0x02 /* ÈÎÎñ¿ÕÏÐ */
58#define ZOSS_STATE_READY 0x03 /* ÈÎÎñ¾ÍÐ÷ */
59#define ZOSS_STATE_RUN 0x04 /* ÈÎÎñÔËÐÐ */
60
61/* ÏûÏ¢²¶»ñ·½Ïò */
62#define ZOSS_MSGDIRE_IN 0x01 /* ÊäÈëÏûÏ¢²¶»ñ */
63#define ZOSS_MSGDIRE_OUT 0x02 /* Êä³öÏûÏ¢²¶»ñ */
64#define ZOSS_MSGDIRE_INOUT 0x03 /* Ë«Ïò²¶»ñ */
65
66/* ÏûÏ¢·¢ËÍÓÅÏȼ¶ */
67#define ZOSS_QUEUE_MSG_PRI_NORMAL 0x00 /* normal priority message£¬¼´·Åµ½ÏûÏ¢¶ÓÁÐβ */
68#define ZOSS_QUEUE_MSG_PRI_URGENT 0x01 /* urgent priority message£¬¼´·Åµ½ÏûÏ¢¶ÓÁÐÊ× */
69
70/* ÅäÖòÎÊý×î´ó³¤¶È */
71#define MAX_EVENTNAME_LEN 63 /* ʼþ×éÃû³Æ×î´ó³¤¶È */
72#define MAX_QUEUENAME_LEN 63 /* ×î´óÏûÏ¢¶ÓÁÐÃû³¤¶È */
73#define ZOSS_MAX_TASKNAME_LEN 63 /* ÈÎÎñÃû³¤¶È */
74#define SHELL_CMD_LENGTH 31 /* shellÃüÁîµÄ×î´ó³¤¶È */
75#define SHELL_CMD_PARAM_NUM 12 /* shellÃüÁî²ÎÊýµÄ×î´ó¸öÊý */
76#define SHELL_CMD_PARAM_LENGTH 23 /* shellÃüÁî²ÎÊýµÄ×î´ó³¤¶È */
77
78/* ´òÓ¡ */
79#define zOss_Printf zTools_Printf
80#define PRINT_LEVEL_ALLWAYS 0x00 /* ±¾¼¶±ð×ÜÊÇ´òÓ¡ */
81#define PRINT_LEVEL_DEBUG 0x01 /* µ÷ÊÔ¼¶±ð */
82#define PRINT_LEVEL_NORMAL 0x02 /* ÆÕͨ¼¶±ð */
83#define PRINT_LEVEL_SEVERE 0x03 /* ÑÏÖØ¼¶±ð */
84#define PRINT_LEVEL_ABNORMAL 0x04 /* Òì³£¼¶±ð */
85#define PRINT_LEVEL_RAM 0x05 /* ´òÓ¡µ½ÄÚ´æ,½öÔÚ´òÓ¡´úÀíÖÐʹÓà */
86#define PRINT_LEVEL_FORBID 0xff /* ²»´òÓ¡ */
87
88/* NV ECC*/
89#define ZOSS_NV_ECC_LOG_NR (6)
90#define ZOSS_NV_ECC_WORK (1)
91#define ZOSS_NV_ECC_BACKUP (2)
92#define ZOSS_NV_ECC_BOTH (3)
93#endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS
94
95/*******************************************************************************
96 * Type definitions *
97 ******************************************************************************/
98#ifndef DOXYGEN_SHOULD_SKIP_THIS
99/* Ë«ÏòÁ´±íÄ£¿é */
100typedef struct tag_NODE
101{
102 struct tag_NODE *next;
103 struct tag_NODE *previous;
104}T_ZOss_Node;
105
106typedef struct
107{
108 SINT32 count;
109 T_ZOss_Node *HEAD;
110 T_ZOss_Node *TAIL;
111}T_ZOss_List;
112
113/* »·Ðλº³åÄ£¿é */
114typedef struct
115{
116 SINT32 pToBuf; /* offset from start of buffer where to write next */
117 SINT32 pFromBuf; /* offset from start of buffer where to read next */
118 SINT32 bufSize; /* size of ring in bytes */
119 CHAR *buf; /* pointer to start of buffer */
120}T_ZOss_Ring, *T_ZOss_RingId;
121
122/* ¶¨Ê±Æ÷¹ÜÀíÄ£¿é 20130415ÒÆÖÁosa.h*/
123
124/* ITCÄ£¿é 20130523 ɾ³ý*/
125
126/* ramdump ¹Ò½Óº¯ÊýÀàÐÍ */
127typedef VOID (*T_zOss_RamdumpHookFunc)(VOID);
128
129/* ÏûÏ¢¹ÜÀíÄ£¿é */
130typedef struct
131{
132 T_ZOss_Node node;
133 ZOSS_TASK_ID t_task_id; /* Ä¿±êÈÎÎñID */
134 ZOSS_TASK_ID s_task_id; /* Ô´ÈÎÎñID */
135 UINT32 msgID; /* ÏûÏ¢ID */
136 UINT16 msgLen; /* ÏûÏ¢Ì峤¶È */
137 UINT8 send_state; /* ÏûÏ¢·¢ËÍ״̬ */
138}T_ZOss_TaskMsgHead; /* ÏûϢͷ */
139
140typedef struct
141{
142 VOID *msgbuf;
143 UINT16 msgLenEX;
144}T_ZOss_TaskMsg; /* ÏûÏ¢Ìå */
145
146typedef UINT32 (*TASK_SEND_HOOK)(T_ZOss_TaskMsgHead *buf, UINT8 dire);
147
148/* ÈÎÎñ¹ÜÀíÄ£¿é */
149typedef VOID (*FUNC_TASKENTRY)(UINT8 state, UINT32 msg_id, UINT8 *buf, UINT16 msg_len, UINT8 *private_data);
150
151typedef struct struTCB
152{
153 T_ZOss_Node node; /* Ë«ÏòÁ´±í½áµã */
154 UINT32 type; /* Çø·ÖÊÇ·ñSDLÈÎÎñ */
155 UINT32 count; /* ÈÎÎñÖ´ÐеĴÎÊý */
156 CHAR task_name[ZOSS_MAX_TASKNAME_LEN + 1]; /* ÈÎÎñÃû,³¤¶È×î´ó63 */
157 FUNC_TASKENTRY taskEntry; /* ÈÎÎñÈë¿Ú */
158 TASK_SEND_HOOK HookEntry[3]; /* »Øµ÷º¯Êý */
159 ZOSS_TASK_ID task_id; /* ÈÎÎñID */
160 ZOSS_TASK_ID sender_task_id; /* ÏûÏ¢Ô´ÈÎÎñID */
161 ZOSS_THREAD_ID thread_id; /* ËùÔÚÏß³ÌID */
162 T_ZOss_List msg_queue; /* ÈÎÎñÏûÏ¢¶ÓÁÐÁ´±í */
163 UINT32 stack_size; /* ¶ÑÕ»´óС */
164 UINT32 priority; /* ÈÎÎñÓÅÏȼ¶(0-31) */
165 UINT32 private_data_len; /* ˽ÓÐÊý¾Ý³¤¶È */
166 UINT32 time; /* ÈÎÎñ´´½¨Ê±¼ä */
167 UINT32 stack_used; /* ÒÑÓöÑÕ»´óС */
168 UINT32 task_time; /* ÈÎÎñ¿ªÊ¼Ê±¼ä */
169 UINT32 msg_id; /* µ±Ç°ÈÎÎñÏûÏ¢ID */
170 UINT8 dire[4]; /* ÏûÏ¢²¶»ñ·½Ïò */
171 UINT8 thread_no; /* Ï̺߳Š*/
172 UINT8 run_status; /* ÔËÐÐ×´¿ö */
173 UINT8 state; /* ÈÎÎñ״̬ */
174 UINT8 *taskData; /* ÈÎÎñÊý¾ÝÇøÖ¸Õë */
175 struct struTCB *next;
176 UINT32 cputime; /* ÈÎÎñÔËÐÐcpuʱ¼ä */
177 FLOAT cpupercent; /* ÈÎÎñcpuÕ¼ÓÃÂÊ */
178 UINT32 runtime; /* ÈÎÎñÔËÐÐʱ¼ä */
179 UINT32 malloc_size; /* ÈÎÎñËùÓÃmalloc´óС */
180 UINT32 ub_size; /* ÈÎÎñËùÓÃÄÚ´æ³Ø´óС */
181 UINT8 reserved[4]; /* ±£Áô룬µÚÒ»¸ö×Ö½ÚΪϵͳ¾²Ì¬ÈÎÎñ±ê־λ */
182}T_ZOss_TCB; /* ÈÎÎñ¿ØÖÆ¿é */
183
184typedef struct
185{
186 UINT8 is_use;
187 CHAR task_name[ZOSS_MAX_TASKNAME_LEN + 1];
188 FUNC_TASKENTRY task_entry;
189 UINT32 priority;
190 UINT32 stack_size;
191 UINT32 private_data_len;
192 UINT8 process_no;
193 UINT8 ack_flag;
194#ifdef _USE_HAL_HRDTST
195 BOOL hardTestFlag;
196#endif
197}T_ZOss_TaskTabItem; /* ÈÎÎñµÇ¼Ç±í */
198
199/* SDLÈÎÎñ */
200typedef struct
201{
202 T_ZOss_Node node; /* ±£Áô */
203 UINT32 type; /* Çø·ÖÊÇ·ñSDLÈÎÎñ */
204 SINT32 index; /* Ë÷Òý */
205 UINT32 self_id;
206 ZOSS_THREAD_ID thread_id; /* ËùÔÚÏß³ÌID */
207 VOID *self;
208 TASK_SEND_HOOK HookEntry[3]; /* »Øµ÷º¯Êý */
209 UINT8 dire[4]; /* ÏûÏ¢²¶»ñ·½Ïò */
210}T_ZOss_SDLTCB; /* SDLÈÎÎñ¿ØÖÆ¿é */
211
212typedef struct signalcode_desc
213{
214 UINT32 selfid;
215 CHAR task_name[ZOSS_MAX_TASKNAME_LEN + 1];
216} T_ZOss_SignalCode_Desc;
217
218typedef struct
219{
220 UINT32 selfid;
221 ZOSS_TASK_ID task_id;
222}tasksdl_desc;
223/* shellÃüÁî */
224typedef struct
225{
226 CHAR cmd[SHELL_CMD_LENGTH + 1]; /* ÃüÁî×Ö·û´®³¤¶È */
227 CHAR para[SHELL_CMD_PARAM_NUM][SHELL_CMD_PARAM_LENGTH + 1]; /* ²ÎÊý */
228 UINT32 paraCount; /* ²ÎÊý¸öÊý */
229}T_Shell_CommandMessage; /* sehllÃüÁîÏûÏ¢½á¹¹Ìå */
230
231typedef VOID (*Shell_Func)(T_Shell_CommandMessage *CmdMsg); /* shellÃüÁîʵÏÖº¯ÊýÖ¸Õë */
232
233/* ¶¯Ì¬ÅäÖÃÀàÐͶ¨Òå */
234typedef struct
235{
236 UINT8 (*pPrioMap)[32];
237}T_OSA_PARAM;
238
239typedef struct
240{
241 UINT32 ub_pool_num; /* ÄÚ´æ³Ø¸öÊý, ×î´ó²»Äܳ¬¹ý255 */
242 T_ZOss_UBPOOL *UBPool; /* ÄÚ´æ³ØÅäÖñíÖ¸Õë */
243}T_MEM_PARAM; /* ÄÚ´æÄ£¿é */
244
245typedef struct
246{
247 UINT32 max_task_num; /* ×î´óÈÎÎñÊý */
248 UINT32 max_schthread_num; /* µ÷¶ÈÏß³ÌÊý£¬×î¶à10 */
249 UINT32 max_msg_queue_len; /* ÈÎÎñÏûÏ¢¶ÓÁг¤¶È */
250 UINT32 deadloop_time; /* ËÀÑ­»·ÅжÏʱ¼ä, µ¥Î»s */
251}T_TASK_PARAM; /* ÈÎÎñÄ£¿é */
252
253typedef struct
254{
255 UINT32 SchPrio; /* ¶¨Ê±Æ÷µ÷¶ÈÏß³ÌÓÅÏȼ¶0-9 */
256 UINT32 CallBackStack; /* ¶¨Ê±Æ÷»Øµ÷º¯ÊýÏ̶߳ÑÕ» */
257 UINT32 CallBackPrio; /* ¶¨Ê±Æ÷»Øµ÷º¯ÊýÏß³ÌÓÅÏȼ¶£¬±ØÐëµÍÓÚµ÷¶ÈÏß³ÌÓÅÏȼ¶£¬Ò»°ãΪSchPrio+1 */
258 UINT32 MinTimeLen; /* ¶¨Ê±Æ÷×îСµÄ³¬Ê±Ê±¼ä,µ¥Î»ºÁÃë */
259 UINT32 MaxTimeNum; /* ×î´ó¶¨Ê±Æ÷¸öÊý */
260}T_TIMER_PARAM; /* ¶¨Ê±Æ÷Ä£¿é */
261
262typedef struct
263{
264 UINT32 DeadLoopCheckTime; /* ËÀÑ­»·¼ì²éʱ¼ä */
265 UINT32 UpdateCPUTime; /* Ë¢ÐÂCPUʹÓÃÂÊʱ¼ä */
266 UINT32 DeamonStartTime; /* ϵͳ³õʼ»¯ºóExcepÈÎÎñÆô¶¯µÄʱ¼ä */
267}T_EXCEP_PARAM; /* Ò쳣ģ¿é */
268
269typedef struct
270{
271 T_ZOss_TaskTabItem *pSysm_TaskItemTab;
272 UINT32 task_num;
273}T_SYSM_PARAM; /* sysmÄ£¿é */
274
275typedef struct
276{
277 UINT32 *pNvAddrCfg;
278 UINT32 addrCfgNum;
279 VOID *pRevNvCfg;
280 UINT32 revNvCfgNum;
281 UINT32 NV_Work_Area_Base_Addr; /* NV¹¤×÷Çø»ùµØÖ· */
282 UINT32 NV_Start_Backup_Base_Addr; /* ±¸·Ý¿éµÄÆðʼµØÖ· */
283 UINT32 NV_Backup_Area_Base_Addr; /* NV±¸·ÝÇø»ùµØÖ· */
284 UINT32 NV_Backup_Area_Size; /* NV±¸·ÝÇø´óС */
285 UINT32 NV_Factory_Area_Base_Addr; /* NV³ö³§Çø»ùµØÖ· */
286 UINT32 NV_Factory_Area_Size; /* NV³ö³§Çø´óС */
287 UINT32 NV_Work_Area_Symbol_Addr; /* ¹¤×÷ÇøÐ´±ê־λµØÖ· */
288 UINT32 NV_Backup_Area_Symbol_Addr; /* ±¸·ÝÇøÐ´±ê־λµØÖ· */
289 UINT32 NV_Factory_Area_Symbol_Addr; /* ³ö³§Çø±ê־λµØÖ· */
290 UINT32 NV_Reset_Factory_Symbol_Addr; /* »Ö¸´³ö³§ÉèÖñêÖ¾µØÖ· */
291 UINT32 NV_Ecc_log_Addr; /* Ecc Log¹¤×÷ÇøµØÖ· */
292 UINT32 NV_Block_Size; /* ¿é´óС */
293}T_NVRAM_PARAM; /* NVRAMÇøÓòµØÖ·ÐÅÏ¢ */
294
295typedef struct
296{
297 UINT8 count;
298 UINT8 index;
299 UINT8 type[ZOSS_NV_ECC_LOG_NR];
300 UINT32 tick[ZOSS_NV_ECC_LOG_NR];
301 UINT32 addr[ZOSS_NV_ECC_LOG_NR];
302}T_ZOss_NvEccLog;
303
304typedef struct
305{
306 UINT32 Work_Area_Base_Addr; /* vSIM¹¤×÷Çø»ùµØÖ· */
307 UINT32 Backup_Area_Base_Addr; /* vSIM±¸·ÝÇø»ùµØÖ· */
308 UINT32 Factory_Area_Base_Addr; /* vSIM³ö³§Çø»ùµØÖ· */
309 UINT32 Area_Size; /* vSIMµ¥¸öÇø´óС */
310 UINT32 Work_Area_Symbol_Addr; /* ¹¤×÷ÇøÐ´±ê־λµØÖ· */
311 UINT32 Backup_Area_Symbol_Addr; /* ±¸·ÝÇøÐ´±ê־λµØÖ· */
312 UINT32 Factory_Area_Symbol_Addr; /* ³ö³§Çø±ê־λµØÖ· */
313}T_vSIM_PARAM;
314
315typedef struct
316{
317 CHAR WinDisk[4]; /* windowsÅÌ·û */
318 CHAR LinuxPath[20]; /* ÀàlinuxÉ豸Ãû */
319 CHAR Format[20]; /* ÎļþϵͳÀàÐÍ */
320 CHAR Device[20]; /* É豸Ãû */
321 CHAR Params[100]; /* Ïà¹Ø²ÎÊý */
322 CHAR Manager[40]; /* ¹ÜÀíÏß³ÌÃû */
323}T_OSA_DISKMAP;
324
325typedef struct
326{
327 T_OSA_DISKMAP *diskMap;
328 UINT32 diskNum;
329}T_DISK_PARAM;
330
331typedef VOID (*ramdump_Hook)(VOID);
332
333typedef struct
334{
335 ramdump_Hook ramdump_Process_PreHook;
336 ramdump_Hook ramdump_Process_AftHook;
337}T_zOss_RamdumpOpt;
338
339
340typedef VOID (*ramdump_IoInit)(VOID);
341typedef VOID (*ramdump_IoReadData)(UINT8 *buffer, UINT32 size);
342typedef VOID (*ramdump_IoWriteData)(UINT8 *buffer, UINT32 size);
343typedef VOID (*ramdump_IoFinish)(VOID);
344
345typedef struct
346{
347 ramdump_IoInit init;
348 ramdump_IoReadData read;
349 ramdump_IoWriteData write;
350 ramdump_IoFinish finish;
351} T_zOss_RamdumpIoOpt;
352
353typedef struct
354{
355 UINT32 baseForServer;
356 UINT32 baseForSelf;
357 UINT32 baseForCopy;
358 UINT32 size;
359} T_zOss_RamdumpRegion;
360
361typedef struct
362{
363 T_OSA_PARAM OsaCfg; /* osaÅäÖÃ */
364 T_DISK_PARAM DiskMap; /* ´ÅÅÌÓ³ÉäÅäÖà */
365 T_MEM_PARAM MemCfg; /* ÄÚ´æÅäÖà */
366 T_TASK_PARAM TaskCfg; /* ÈÎÎñÅäÖà */
367 T_TIMER_PARAM TimerCfg; /* ¶¨Ê±Æ÷ÅäÖà */
368 T_EXCEP_PARAM ExcepCfg; /* Òì³£ÅäÖà */
369 T_SYSM_PARAM SysmCfg; /* sysmtÅäÖÃ */
370 T_NVRAM_PARAM NvramCfg; /* NvÅäÖÃ */
371 T_vSIM_PARAM vSIMCfg; /* vSimÅäÖÃ */
372#ifdef _USE_PSM
373#ifdef _USE_PSM_NEW_FRAMEWORK
374 T_zPsm_Param PsmCfg; /* PsmÅäÖÃ */
375#else
376 T_PSM_PARAM PsmCfg; /* PsmÅäÖÃ */
377#endif
378#endif
379}T_OSS_PARAM; /* Õû¸öOSS¶¯Ì¬ÅäÖÃÀàÐÍ */
380
381typedef enum
382{
383 SYS_RESET_TO_NORMAL,
384 SYS_RESET_TO_CHARGER,
385 SYS_RESET_TO_ALRAM,
386 SYS_RESET_TO_EXCEPTRESET,
387 SYS_MAX_RESET_TYPE,
388} T_ZOssSys_RESET_TYPE;
389#endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS
390
391/*******************************************************************************
392 * Global variable declarations *
393 ******************************************************************************/
394
395
396/*******************************************************************************
397 * Global function declarations *
398 ******************************************************************************/
399#ifndef DOXYGEN_SHOULD_SKIP_THIS
400/* OSAÄ£¿é³õʼ»¯ */
401UINT32 OSA_Init(VOID);
402
403/* ϵͳ¹ÜÀíÄ£¿é */
404UINT32 zOss_Init(VOID);
405UINT32 zOss_TaskInit(VOID);
406UINT32 zOss_Start(VOID);
407VOID zOss_TaskStartOK(VOID);
408UINT32 zOss_SysPowerdown(VOID);
409VOID zOss_SysSoftReset(T_ZOssSys_RESET_TYPE type);
410T_OSS_PARAM *zOss_GetOssCfg(VOID);
411
412/* ÈÎÎñ¹ÜÀíÄ£¿é */
413UINT32 zOss_Task_HookSet(UINT8 type, VOID *HookFunc);
414ZOSS_TASK_ID zOss_CreateTask(const CHAR *task_name, FUNC_TASKENTRY task_entry, UINT32 stack_size, UINT32 priority, UINT32 private_data_len, UINT8 pno);
415UINT32 zOss_DeleteTask(ZOSS_TASK_ID task_id);
416UINT32 zOss_GetTaskInfo(ZOSS_TASK_ID task_id, T_ZOss_TCB *task_info);
417CHAR *zOss_GetTaskName(ZOSS_TASK_ID task_id);
418UINT32 zOss_GetAllTaskID(ZOSS_TASK_ID *task_id_arr);
419ZOSS_TASK_ID zOss_GetTaskID(const CHAR *task_name);
420ZOSS_TASK_ID zOss_GetSelfTaskID(VOID);
421UINT32 zOss_SetState(UINT8 next_state);
422UINT32 zOss_RegTaskSendHook(ZOSS_TASK_ID task_id, UINT8 hooktype, UINT8 dire, TASK_SEND_HOOK intercept_Entry);
423UINT32 zOss_TaskSend(UINT32 msg_id, const VOID *msg_buf, UINT16 msg_len, ZOSS_TASK_ID task_id);
424UINT32 zOss_TaskSendData(UINT32 msg_id, VOID *buf, UINT16 msg_len, ZOSS_TASK_ID task_id);
425ZOSS_TASK_ID zOss_Sender(VOID);
426
427/* ramdump */
428#ifdef _USE_MULTI_CORE_RAMDUMP
429VOID zOss_RamdumpSetOperation(T_zOss_RamdumpOpt *funcObjPtr);
430VOID zOss_RamdumpConfigureMem(T_zOss_RamdumpRegion *regionInfo);
431#else
432VOID zOss_RamdumpConfigureMem(UINT32 base, UINT32 size, UINT32 map_base, UINT32 copy_base);
433VOID zOss_RamdumpHookInstall(T_zOss_RamdumpHookFunc hook);
434#endif
435VOID zOss_RamdumpSetIoOpt(T_zOss_RamdumpIoOpt hook);
436
437/* NV²Ù×÷½Ó¿Ú */
438UINT32 zOss_NvItemWrite(UINT32 NvItemID, UINT8 *NvItemData, UINT32 NvItemLen);
439UINT32 zOss_NvItemRead(UINT32 NvItemID, UINT8 *NvItemData, UINT32 NvItemLen);
440UINT32 zOss_ResetNVFactory(VOID);
441UINT32 zOss_NvramFlush(VOID);
442VOID zOss_NvSetErrorAddr(UINT32 addr);
443BOOL zOss_NvInResume(VOID);
444VOID zOss_NvCheck(VOID);
445VOID zOss_NvWriteFactory(VOID);
446VOID zOss_NvScanBackUpArea(VOID);
447UINT32 zOss_NvGetEccLogInfo(T_ZOss_NvEccLog *logInfo);
448UINT32 zOss_ChangeNvroAttr(int writable);
449UINT32 Nvram_Flush(VOID);
450UINT32 Nvram_Finish(VOID);
451
452/* VSIM²Ù×÷½Ó¿Ú */
453UINT32 zOss_vSIMInit(VOID);
454UINT32 zOss_vSIMDataRead(UINT32 addr, VOID *data, UINT32 len);
455UINT32 zOss_vSIMDataWrite(UINT32 addr, VOID *data, UINT32 len);
456UINT32 zOss_vSIMFacWrite(VOID *data, UINT32 len);
457UINT32 zOss_vSIMRecovery(VOID);
458
459/* ´òÓ¡ */
460UINT32 zTools_Printf(UINT32 nModNo, UINT8 nPrintLevel, const VOID *pFormat, ...);
461VOID zOss_RamLog(CHAR *rambuf, UINT32 restrict);
462VOID zOss_RamPrintf(VOID);
463
464/* ά²â */
xf.lidf7f8ba2024-09-12 23:53:34 -0700465UINT32 zOss_DebugInfoRecord(char *id, const VOID *pFormat, ...);
lh9ed821d2023-04-07 01:36:19 -0700466
467/* shellÄ£¿é */
468UINT32 zOss_AddShellCmd(const CHAR *cmd_name, const Shell_Func func, const CHAR *description);
469
470/* ¿´ÃŹ· */
471VOID zOss_WatchDogEnable(BOOL enable);
472
473/* CRCУÑé */
474UINT8 Comm_CrcCalc(const UINT8 *buf, UINT8 len);
475SINT32 Comm_CrcCheck(UINT8 *buf, UINT8 len, UINT8 crc);
476
477/* µãµÆÄ£¿é */
478VOID zOss_SetTransDataFlag(VOID);
479BOOL zOss_GetTransDataFlag(VOID);
480
481/* ʼþ×é */
482ZOSS_EVENT_ID zOss_CreateEvent(const CHAR *name);
483UINT32 zOss_GetEvent(ZOSS_EVENT_ID eventId, UINT32 events, UINT32 getOptions, UINT32 *pEventsReceived, UINT32 timeout);
484UINT32 zOss_SetEvent(ZOSS_EVENT_ID eventId, UINT32 events, UINT32 setOptions);
485UINT32 zOss_DeleteEvent(ZOSS_EVENT_ID eventId);
486UINT32 zOss_QueryEvent(ZOSS_EVENT_ID eventId);
487BOOL zOss_WaitingEvent(ZOSS_EVENT_ID eventId);
488
489/* »·Ðλº³å */
490BOOL zOss_RingIsEmpty(T_ZOss_RingId ring_id);
491BOOL zOss_RingIsFull(T_ZOss_RingId ring_id);
492T_ZOss_RingId zOss_RingCreate(SINT32 nbytes);
493SINT32 zOss_RingBufGet(T_ZOss_RingId ring_id, CHAR *buffer, SINT32 maxbytes);
494SINT32 zOss_RingBufPut(T_ZOss_RingId ring_id, CHAR *buffer, SINT32 nbytes);
495SINT32 zOss_RingFreeBytes(T_ZOss_RingId ring_id);
496SINT32 zOss_RingNBytes(T_ZOss_RingId ring_id);
497VOID zOss_RingDelete(T_ZOss_RingId ring_id);
498VOID zOss_RingFlush(T_ZOss_RingId ring_id);
499VOID zOss_RingMoveAhead(T_ZOss_RingId ring_id, SINT32 n);
500VOID zOss_RingPutAhead(T_ZOss_RingId ring_id, CHAR byte, SINT32 offset);
501
502/* ÏûÏ¢¶ÓÁÐ */
503ZOSS_QUEUE_ID zOss_QueueCreate(const CHAR *queue_name, UINT32 maxMsgs, UINT32 maxMsgLen);
504UINT32 zOss_QueueSend(ZOSS_QUEUE_ID queue_id, VOID *msg_ptr, UINT32 size, UINT32 timeout, UINT32 priority);
505UINT32 zOss_QueueRecv(ZOSS_QUEUE_ID queue_id, VOID *buffer, UINT32 maxsize, UINT32 timeout);
506UINT32 zOss_QueueFreeCount(ZOSS_QUEUE_ID queue_id);
507UINT32 zOss_QueueDelete(ZOSS_QUEUE_ID queue_id);
508
509/* ¹ÜµÀ */
510UINT32 zOss_PipeDevCreate(const CHAR *name, SINT32 nBytes);
511UINT32 zOss_PipeDevDelete(const CHAR *name, BOOL force);
512
513/* Cahce½Ó¿Ú */
514VOID zOss_CacheCleanRange(UINT32 base, UINT32 size);
515VOID zOss_CacheInvalidateRange(UINT32 base, UINT32 size);
516VOID zOss_CacheCleanRangeFast(UINT32 base, UINT32 size);
517VOID zOss_CacheInvalidateRangeFast(UINT32 base, UINT32 size);
518VOID zOss_IoRemapPages(VOID *base, UINT32 size);
519
520/* svÉèÖûñÈ¡½Ó¿Ú */
521UINT8 zOss_GetSvConfig(VOID);
522VOID zOss_SetSvConfig(UINT8 sv);
523
524/* ¶¨Ê±Æ÷¹ÜÀíÄ£¿é */
525#ifdef _USE_PSM
526VOID zOss_SetTimer_PsmFlag(ZOSS_TIMER_ID time_id, BOOL Flag);
527UINT32 zOss_GetPs_SleepTimer(VOID);
528#endif
529
530#endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS
531
532/**
533 * @brief ÉèÖ÷ÇÖÜÆÚÐÔÈÎÎñ¶¨Ê±Æ÷
534 * @param time_len Èë²Î£¬Ê±³¤£¬µ¥Î»£ºms
535 * @param msg_id Èë²Î£¬¶¨Ê±µ½ºó,·¢Ë͸øÉèÖö¨Ê±Æ÷ÈÎÎñµÄÏûÏ¢id
536 * @param arg Èë²Î£¬¸½¼Ó²ÎÊý,¶¨´«µÝ¸øÈÎÎñÈë¿Úº¯ÊýµÄbufÐβδËʱmsg_lenֵΪ4(sizeof(UINT32/arg))
537 * @return ³É¹¦:ÏàÓ¦µÄ¶¨Ê±Æ÷±êʶ; ʧ°Ü:ZOSS_INVALID_TIMER_ID
538 * @retval ZOSS_TIMER_IDÀàÐ͵ıêʶ ³É¹¦
539 * @retval ZOSS_INVALID_TIMER_ID ʧ°Ü
540 * @note ÉèÖÃʱ¿ÌΪ²Î¿¼µã,¾­¹ýÖ¸¶¨Ê±¼äºó, ÏòÉèÖö¨Ê±Æ÷µÄÈÎÎñ·¢ËÍÖ¸¶¨ÏûÏ¢²¢×Ô¶¯ÊͷŶ¨Ê±Æ÷ËùÕ¼×ÊÔ´
541 * @warning ±ØÐèÔÚÈÎÎñÄÚµ÷ÓÃ
542 */
543ZOSS_TIMER_ID zOss_SetRelativeTimer(UINT32 time_len, UINT32 msg_id, UINT32 arg);
544
545/**
546 * @brief ÉèÖ÷ÇÖÜÆÚÐÔÈÎÎñ¶¨Ê±Æ÷ÏòÄ¿±êÈÎÎñ·¢ËÍÏûÏ¢
547 * @param time_len Èë²Î£¬Ê±³¤£¬µ¥Î»£ºms
548 * @param msg_id Èë²Î£¬¶¨Ê±µ½ºó,·¢Ë͸øÉèÖö¨Ê±Æ÷ÈÎÎñµÄÏûÏ¢id
549 * @param arg Èë²Î£¬¸½¼Ó²ÎÊý,¶¨´«µÝ¸øÈÎÎñÈë¿Úº¯ÊýµÄbufÐβδËʱmsg_lenֵΪ4(sizeof(UINT32/arg))
550 * @param desk_task_id Èë²Î£¬Ö¸¶¨Ä¿±êÈÎÎñ£¬Èç¹ûÄ¿±êÈÎÎñΪ¿Õʱ£¬½«·¢ËÍÉèÖö¨Ê±Æ÷µÄÈÎÎñ
551 * @return ³É¹¦:ÏàÓ¦µÄ¶¨Ê±Æ÷±êʶ; ʧ°Ü:ZOSS_INVALID_TIMER_ID
552 * @retval ZOSS_TIMER_IDÀàÐ͵ıêʶ ³É¹¦
553 * @retval ZOSS_INVALID_TIMER_ID ʧ°Ü
554 * @note
555 * @warning
556 */
557ZOSS_TIMER_ID zOss_SetRelativeTimerByTaskId(UINT32 time_len, UINT32 msg_id, UINT32 arg, ZOSS_TASK_ID desk_task_id);
558
559/**
560 * @brief ÉèÖÃÖÜÆÚÐÔÈÎÎñ¶¨Ê±Æ÷
561 * @param time_len Èë²Î£¬Ê±³¤£¬µ¥Î»£ºms
562 * @param msg_id Èë²Î£¬¶¨Ê±µ½ºó,·¢Ë͸øÉèÖö¨Ê±Æ÷ÈÎÎñµÄÏûÏ¢id
563 * @param arg Èë²Î£¬¸½¼Ó²ÎÊý,¶¨´«µÝ¸øÈÎÎñÈë¿Úº¯ÊýµÄbufÐβδËʱmsg_lenֵΪ4(sizeof(UINT32/arg))
564 * @return ³É¹¦:ÏàÓ¦µÄ¶¨Ê±Æ÷±êʶ; ʧ°Ü:ZOSS_INVALID_TIMER_ID
565 * @retval ZOSS_TIMER_IDÀàÐ͵ıêʶ ³É¹¦
566 * @retval ZOSS_INVALID_TIMER_ID ʧ°Ü
567 * @note ÉèÖÃʱ¿ÌΪ²Î¿¼µã,¾­¹ýÖ¸¶¨Ê±¼äºó, ÏòÉèÖö¨Ê±Æ÷µÄÈÎÎñ·¢ËÍÖ¸¶¨ÏûÏ¢²¢×Ô¶¯ÊͷŶ¨Ê±Æ÷ËùÕ¼×ÊÔ´
568 * @warning ±ØÐèÔÚÈÎÎñÄÚµ÷ÓÃ
569 */
570ZOSS_TIMER_ID zOss_SetLoopTimer(UINT32 time_len, UINT32 msg_id, UINT32 arg);
571
572/**
573 * @brief ÉèÖÃÖÜÆÚÐÔÈÎÎñ¶¨Ê±Æ÷ÏòÄ¿±êÈÎÎñ·¢ËÍÏûÏ¢
574 * @param time_len Èë²Î£¬Ê±³¤£¬µ¥Î»£ºms
575 * @param msg_id Èë²Î£¬¶¨Ê±µ½ºó,·¢Ë͸øÉèÖö¨Ê±Æ÷ÈÎÎñµÄÏûÏ¢id
576 * @param arg Èë²Î£¬¸½¼Ó²ÎÊý,¶¨´«µÝ¸øÈÎÎñÈë¿Úº¯ÊýµÄbufÐβδËʱmsg_lenֵΪ4(sizeof(UINT32/arg))
577 * @param desk_task_id Èë²Î£¬Ö¸¶¨Ä¿±êÈÎÎñ£¬Èç¹ûÄ¿±êÈÎÎñΪ¿Õʱ£¬½«·¢ËÍÉèÖö¨Ê±Æ÷µÄÈÎÎñ
578 * @return ³É¹¦:ÏàÓ¦µÄ¶¨Ê±Æ÷±êʶ; ʧ°Ü:ZOSS_INVALID_TIMER_ID
579 * @retval ZOSS_TIMER_IDÀàÐ͵ıêʶ ³É¹¦
580 * @retval ZOSS_INVALID_TIMER_ID ʧ°Ü
581 * @note
582 * @warning
583 */
584ZOSS_TIMER_ID zOss_SetLoopTimerByTaskId(UINT32 time_len, UINT32 msg_id, UINT32 arg, ZOSS_TASK_ID desk_task_id);
585
586/**
587 * @brief ´´½¨¶¨Ê±Æ÷º¯Êý
588 * @param tm_name Èë²Î£¬¶¨Ê±Æ÷Ãû³Æ
589 * @param tm_callback Èë²Î£¬¶¨Ê±µ½ºóÐèÒªµ÷ÓõĻص÷º¯Êý
590 * @param tm_param Èë²Î£¬»Øµ÷º¯ÊýµÄÈë²Î
591 * @param bPeriod Èë²Î£¬TRUE£ºÖÜÆÚÐÔ¶¨Ê±Æ÷£»FALSE£º·ÇÖÜÆÚÐÔ¶¨Ê±Æ÷
592 * @return ³É¹¦:ÏàÓ¦µÄ¶¨Ê±Æ÷±êʶ; ʧ°Ü:ZOSS_INVALID_TIMER_ID
593 * @retval ZOSS_TIMER_IDÀàÐ͵ıêʶ ³É¹¦
594 * @retval ZOSS_INVALID_TIMER_ID ʧ°Ü
595 * @note ´´½¨ºÃÖ®ºó¿ÉÒÔµ÷ÓÃzOss_StartTimer()Æô¶¯¶¨Ê±Æ÷
596 * @warning
597 */
598ZOSS_TIMER_ID zOss_CreateTimer(const CHAR *tm_name, ZOSS_TIMER_FUN tm_callback, SINT32 tm_param, BOOL bPeriod);
599
600/**
601 * @brief Æô¶¯¶¨Ê±Æ÷º¯Êý,Æô¶¯Ê±¿ÌΪ²Î¿¼µã,¾­¹ýÖ¸¶¨Ê±¼äºó,µ÷Óûص÷º¯Êý
602 * @param timer_id Èë²Î£¬¶¨Ê±Æ÷id
603 * @param time_len Èë²Î£¬¶¨Ê±Æ÷ʱ³¤£¬µ¥Î»£ºms
604 * @param tm_callback Èë²Î£¬¶¨Ê±µ½ºóÒªµ÷ÓõĻص÷º¯Êý
605 * @param tm_param Èë²Î£¬»Øµ÷º¯ÊýµÄÈë²Î
606 * @return ³É¹¦:ZOSS_SUCCESS;ʧ°ÜZOSS_ERROR
607 * @retval ZOSS_SUCCESS ³É¹¦
608 * @retval ZOSS_ERROR ʧ°Ü
609 * @note
610 * @warning Èç¹û»Øµ÷º¯ÊýÖ´ÐÐʱ¼ä´óÓÚ¶¨Ê±Æ÷ʱ³¤,¿ÉÄÜ»áÔì³É´íÎó»ò¶¨Ê±Æ÷²»±»ÕýÈ·µ÷¶È
611 */
612UINT32 zOss_StartTimer(ZOSS_TIMER_ID timer_id, UINT32 time_len, ZOSS_TIMER_FUN tm_callback, SINT32 tm_param);
613
614/**
615 * @brief Í£Ö¹¶¨Ê±Æ÷¼ÆÊ±º¯Êý
616 * @param timer_id Èë²Î£¬¶¨Ê±Æ÷id
617 * @return ³É¹¦:ZOSS_SUCCESS;ʧ°ÜZOSS_ERROR
618 * @retval ZOSS_SUCCESS ³É¹¦
619 * @retval ZOSS_ERROR ʧ°Ü
620 * @note
621 * @warning
622 */
623UINT32 zOss_StopTimer(ZOSS_TIMER_ID timer_id);
624
625/**
626 * @brief ÔÝÍ£Ö¸¶¨¶¨Ê±Æ÷µÄ¼ÆÊ±
627 * @param timer_id Èë²Î£¬¶¨Ê±Æ÷id
628 * @return ³É¹¦:ZOSS_SUCCESS;ʧ°ÜZOSS_ERROR
629 * @retval ZOSS_SUCCESS ³É¹¦
630 * @retval ZOSS_ERROR ʧ°Ü
631 * @note ÔÝÍ£µÄͬʱ¼Ç¼ÏÂÊ£ÓàµÄÏà¶Ôʱ¼ä£¬µ÷ÓÃzOss_ResumeTime()º¯Êýºó¼ÌÐø¼ÆÊ±£»
632 Èç¹û¶¨Ê±Æ÷ÕýÔÚ±»µ÷¶È,ÔòÖ´ÐÐÍ굱ǰµ÷¶ÈºóÔÝÍ£¼ÆÊ±¡£
633 * @warning
634 */
635UINT32 zOss_PauseTimer(ZOSS_TIMER_ID timer_id);
636
637/**
638 * @brief ʹÔÝÍ£µÄ¶¨Ê±Æ÷¼ÌÐø¼ÆÊ±
639 * @param timer_id Èë²Î£¬¶¨Ê±Æ÷id
640 * @return ³É¹¦:ZOSS_SUCCESS;ʧ°ÜZOSS_ERROR
641 * @retval ZOSS_SUCCESS ³É¹¦
642 * @retval ZOSS_ERROR ʧ°Ü
643 * @note
644 * @warning
645 */
646UINT32 zOss_ResumeTimer(ZOSS_TIMER_ID timer_id);
647
648/**
649 * @brief ɾ³ýÖ¸¶¨µÄ¶¨Ê±Æ÷
650 * @param timer_id Èë²Î£¬¶¨Ê±Æ÷id
651 * @return ³É¹¦:ZOSS_SUCCESS;ʧ°ÜZOSS_ERROR
652 * @retval ZOSS_SUCCESS ³É¹¦
653 * @retval ZOSS_ERROR ʧ°Ü
654 * @note
655 * @warning
656 */
657UINT32 zOss_KillTimer(ZOSS_TIMER_ID timer_id);
658
659/*******************************************************************************
660 * Inline function implementations *
661 ******************************************************************************/
662#ifndef DOXYGEN_SHOULD_SKIP_THIS
663/* Ë«ÏòÁ´±í */
664#if defined (_OS_TOS) || defined (_OS_LINUX)
665/**************************************************************************
666* º¯ÊýÃû³Æ: zOss_ListInit
667* ¹¦ÄÜÃèÊö: ³õʼ»¯Ë«ÏòÁ´±í
668* ²ÎÊý˵Ã÷£º
669 (IN)
670 pList:Á´±íÖ¸Õë
671 (OUT)
672* ·µ »Ø Öµ:
673**************************************************************************/
674static inline VOID zOss_ListInit(T_ZOss_List *pList)
675{
676 zOss_AssertExN(pList != NULL);
677
678 pList->HEAD = NULL;
679 pList->TAIL = NULL;
680 pList->count = 0;
681}
682
683/**************************************************************************
684* º¯ÊýÃû³Æ: zOss_ListCount
685* ¹¦ÄÜÃèÊö: »ñÈ¡Á´±íÏÂ×ܹ²µÄ½ÚµãÊý
686* ²ÎÊý˵Ã÷£º
687 (IN)
688 pList:Á´±íÖ¸Õë
689 (OUT)
690* ·µ »Ø Öµ: ½Úµã¸öÊý
691**************************************************************************/
692static inline SINT32 zOss_ListCount(T_ZOss_List *pList)
693{
694 return (pList->count);
695}
696
697/**************************************************************************
698* º¯ÊýÃû³Æ: zOss_ListDelete
699* ¹¦ÄÜÃèÊö: ÒÆ³ýÁ´±íÖÐÖ¸¶¨µÄ½Úµã
700* ²ÎÊý˵Ã÷£º
701 (IN)
702 pList:Á´±íÖ¸Õë
703 pNode:´ýɾ³ý½ÚµãÖ¸Õë
704 (OUT)
705* ·µ »Ø Öµ:
706**************************************************************************/
707static inline VOID zOss_ListDelete(T_ZOss_List *pList, T_ZOss_Node *pNode)
708{
709 if (pNode->previous != NULL)
710 {
711 pNode->previous->next = pNode->next;
712 }
713 else
714 {
715 pList->HEAD = pNode->next;
716 }
717
718 if (pNode->next != NULL)
719 {
720 pNode->next->previous = pNode->previous;
721 }
722 else
723 {
724 pList->TAIL = pNode->previous;
725 }
726
727 /* update node count */
728 pList->count--;
729}
730
731/**************************************************************************
732* º¯ÊýÃû³Æ: zOss_ListFirst
733* ¹¦ÄÜÃèÊö: »ñÈ¡Á´±íµÄÊ×½Úµã
734* ²ÎÊý˵Ã÷£º
735 (IN)
736 pList:Á´±íÖ¸Õë
737 (OUT)
738* ·µ »Ø Öµ: ½ÚµãÖ¸Õë(µ±Á´±íÖÐûÓнڵãʱ£¬·µ»Ø¿Õ)
739**************************************************************************/
740static inline T_ZOss_Node* zOss_ListFirst(T_ZOss_List *pList)
741{
742 return (pList->HEAD);
743}
744
745/**************************************************************************
746* º¯ÊýÃû³Æ: zOss_ListInsert
747* ¹¦ÄÜÃèÊö: ÏòÁ´±íÖ¸¶¨µÄ½Úµãºó²åÈë½Úµã
748* ²ÎÊý˵Ã÷£º
749 (IN)
750 pList:Á´±íÖ¸Õë
751 pPrev:²åÈëµã½ÚµãÖ¸Õ룬µ±pPrevΪ¿Õʱ£¬±íʾ²åÈëµ½Á´±íÊ×λÖÃ
752 pNode:´ý²åÈëµÄ½ÚµãÖ¸Õë
753 (OUT)
754* ·µ »Ø Öµ:
755**************************************************************************/
756static inline VOID zOss_ListInsert (T_ZOss_List *pList, T_ZOss_Node *pPrev, T_ZOss_Node *pNode)
757{
758 T_ZOss_Node *pNext = NULL;
759
760 if (pPrev != NULL)
761 {
762 pNext = pPrev->next; /* make prev node point fwd to new */
763 pPrev->next = pNode;
764 }
765 else
766 {
767 pNext = pList->HEAD; /* new node is to be first in list */
768 pList->HEAD = pNode;
769 }
770
771 if (pNext != NULL)
772 {
773 pNext->previous = pNode; /* make next node point back to new */
774 }
775 else
776 {
777 pList->TAIL = pNode; /* new node is to be last in list */
778 }
779
780 /* set pointers in new node, and update node count */
781 pNode->next = pNext;
782 pNode->previous = pPrev;
783
784 pList->count++;
785}
786
787/**************************************************************************
788* º¯ÊýÃû³Æ: zOss_ListAdd
789* ¹¦ÄÜÃèÊö: ÏòÁ´±íβÌí¼Ó½Úµã
790* ²ÎÊý˵Ã÷£º
791 (IN)
792 pList:Á´±íÖ¸Õë
793 pNode:´ýÌí¼Ó½ÚµãÖ¸Õë
794 (OUT)
795* ·µ »Ø Öµ:
796**************************************************************************/
797static inline VOID zOss_ListAdd (T_ZOss_List *pList, T_ZOss_Node *pNode)
798{
799 zOss_ListInsert(pList, pList->TAIL, pNode);
800}
801
802/**************************************************************************
803* º¯ÊýÃû³Æ: zOss_ListLast
804* ¹¦ÄÜÃèÊö: »ñȡָ¶¨½ÚµãµÄºóÒ»½Úµã
805* ²ÎÊý˵Ã÷£º
806 (IN)
807 pNode:Ö¸¶¨½ÚµãÖ¸Õë
808 (OUT)
809* ·µ »Ø Öµ: ½ÚµãÖ¸Õë(µ±Á´±íÖÐûÓнڵãʱ£¬·µ»Ø¿Õ)
810**************************************************************************/
811static inline T_ZOss_Node* zOss_ListLast(T_ZOss_List *pList)
812{
813 return (pList->TAIL);
814}
815
816/**************************************************************************
817* º¯ÊýÃû³Æ: zOss_ListNext
818* ¹¦ÄÜÃèÊö: »ñȡָ¶¨½ÚµãµÄǰһ½Úµã
819* ²ÎÊý˵Ã÷£º
820 (IN)
821 pNode:½ÚµãÖ¸Õë
822 (OUT)
823* ·µ »Ø Öµ: ½ÚµãÖ¸Õë(µ±´«Èë½ÚµãÊÇÁ´±í×îºóÒ»¸ö½Úµãʱ£¬·µ»Ø¿Õ)
824**************************************************************************/
825static inline T_ZOss_Node* zOss_ListNext(T_ZOss_Node *pNode)
826{
827 return (pNode->next);
828}
829
830/**************************************************************************
831* º¯ÊýÃû³Æ: zOss_ListPrevious
832* ¹¦ÄÜÃèÊö: »ñȡָ¶¨½ÚµãµÄǰһ½Úµã
833* ²ÎÊý˵Ã÷£º
834 (IN)
835 pNode:Ö¸¶¨½ÚµãÖ¸Õë
836 (OUT)
837* ·µ »Ø Öµ: ½ÚµãÖ¸Õë(µ±´«Èë½ÚµãÊÇÁ´±íµÚÒ»¸ö½Úµãʱ£¬·µ»Ø¿Õ)
838**************************************************************************/
839static inline T_ZOss_Node *zOss_ListPrevious(T_ZOss_Node *pNode)
840{
841 return (pNode->previous);
842}
843
844/**************************************************************************
845* º¯ÊýÃû³Æ: zOss_ListNStep
846* ¹¦ÄÜÃèÊö: »ñÈ¡ÓëÖ¸¶¨½Úµã¼ä¸ônStepµÄ½Úµã
847* ²ÎÊý˵Ã÷£º
848 (IN)
849 pNode:½ÚµãÖ¸Õë
850 nStep:¼ä¸ôÊý. ÕýÊý:²éÕÒnext½Úµã£¬¸ºÊý²éÕÒprevious½Úµã
851 (OUT)
852* ·µ »Ø Öµ: ½ÚµãÖ¸Õë(µ±ÔÚ¼ä¸ônStepÄÚµ½´ïÁ´±íβʱ£¬·µ»Ø¿Õ)
853**************************************************************************/
854static inline T_ZOss_Node *zOss_ListNStep(T_ZOss_Node *pNode, SINT32 nStep)
855{
856 int i = 0;
857
858 if (nStep > 0)
859 {
860 for (i = nStep; i > 0; i--)
861 {
862 pNode = pNode->next;
863
864 if (pNode == NULL)
865 {
866 break;
867 }
868 }
869 }
870 else
871 {
872 for (i = nStep; i < 0; i++)
873 {
874 pNode = pNode->previous;
875
876 if (pNode == NULL)
877 {
878 break;
879 }
880 }
881 }
882 return (pNode);
883}
884
885/**************************************************************************
886* º¯ÊýÃû³Æ: zOss_ListFind
887* ¹¦ÄÜÃèÊö: ²éÕÒÁ´±íÖеĽڵã
888* ²ÎÊý˵Ã÷£º
889 (IN)
890 pList:Á´±íÖ¸Õë
891 pNode:´ý²éÕÒ½ÚµãÖ¸Õë
892 (OUT)
893* ·µ »Ø Öµ: Á´±íÖÐÓÐÖ¸¶¨½Úµã:½ÚµãÔÚÁ´±íÖеÄË÷Òý(´Ó1¿ªÊ¼)£¬
894 Á´±íÖÐÎÞÖ¸¶¨½Úµã:-1
895**************************************************************************/
896static inline SINT32 zOss_ListFind (T_ZOss_List *pList, T_ZOss_Node *pNode)
897{
898 T_ZOss_Node *pNextNode = NULL;
899 int iNodePosition = 1;
900
901 pNextNode = zOss_ListFirst (pList);
902
903 while ((pNextNode != NULL) && (pNextNode != pNode))
904 {
905 iNodePosition++;
906
907 pNextNode = zOss_ListNext (pNextNode);
908 }
909
910 if (pNextNode != NULL)
911 {
912 return (iNodePosition);
913 }
914 else
915 {
916 return (-1);
917 }
918}
919
920/**************************************************************************
921* º¯ÊýÃû³Æ: zOss_ListConnect
922* ¹¦ÄÜÃèÊö: ½«Á½¸öÁ´±íÁ´½ÓÔÚÒ»Æð
923* ²ÎÊý˵Ã÷£º
924 (IN)
925 pList1: Á´±í1
926 pList2: Á´±í2
927 (OUT)
928* ·µ»ØÖµ:
929* ˵Ã÷£º ½«pList2Á´½Óµ½pList1β²¿£»pList2µÄÁ´±íÍ·ÄÚÈݲ»»á¸Ä±ä
930**************************************************************************/
931static inline VOID zOss_ListConnect(T_ZOss_List *pList1, T_ZOss_List *pList2)
932{
933 if (pList1->count == 0)
934 {
935 pList1->HEAD = pList2->HEAD;
936 pList1->TAIL = pList2->TAIL;
937 }
938 else
939 {
940 if (pList2->count != 0)
941 {
942 pList1->TAIL ->next = pList2->HEAD;
943 pList2->HEAD->previous = pList1->TAIL;
944 pList1->TAIL = pList2->TAIL;
945 }
946 }
947 pList1->count += pList2->count;
948}
949#else
950VOID zOss_ListInit(T_ZOss_List *pList);
951T_ZOss_Node *zOss_ListFirst(T_ZOss_List *pList);
952T_ZOss_Node *zOss_ListLast(T_ZOss_List *pList);
953T_ZOss_Node *zOss_ListNext(T_ZOss_Node *pNode);
954T_ZOss_Node *zOss_ListPrevious(T_ZOss_Node *pNode);
955T_ZOss_Node *zOss_ListNStep(T_ZOss_Node *pNode, SINT32 nStep);
956SINT32 zOss_ListCount(T_ZOss_List *pList);
957SINT32 zOss_ListFind(T_ZOss_List *pList, T_ZOss_Node *pNode);
958VOID zOss_ListAdd(T_ZOss_List *pList, T_ZOss_Node *pNode);
959VOID zOss_ListDelete(T_ZOss_List *pList, T_ZOss_Node *pNode);
960VOID zOss_ListInsert(T_ZOss_List *pList, T_ZOss_Node *pPrev, T_ZOss_Node *pNode);
961VOID zOss_ListConnect(T_ZOss_List *pList1, T_ZOss_List *pList2);
962#endif
963
964#endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS
965
966
967#ifdef __cplusplus
968}
969#endif
970
971#endif // #ifndef _OSS_SUP_H