lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /**
|
| 2 | * @file oss_kernel.h
|
| 3 | * @brief ²Ù×÷ϵͳÊÊÅä²ã½Ó¿ÚÍ·Îļþ
|
| 4 | *
|
| 5 | * Copyright (C) 2017 Sanechips Technology Co., Ltd.
|
| 6 | *
|
| 7 | *
|
| 8 | */
|
| 9 |
|
| 10 | #ifndef _OSS_KERNEL_H
|
| 11 | #define _OSS_KERNEL_H
|
| 12 |
|
| 13 | /*******************************************************************************
|
| 14 | * Include header files *
|
| 15 | ******************************************************************************/
|
| 16 | #ifdef __cplusplus
|
| 17 | extern "C"
|
| 18 | {
|
| 19 | #endif
|
| 20 |
|
| 21 | /*******************************************************************************
|
| 22 | * Macro definitions *
|
| 23 | ******************************************************************************/
|
| 24 | /* ¶ÏÑÔ */
|
| 25 | /**
|
| 26 | * @brief assert¶ÏÑÔ
|
| 27 | * @param _EXP Èë²Î£¬Òì³£±í´ïʽ
|
| 28 | */
|
| 29 | #ifdef _DEBUG
|
| 30 | # if defined _OS_WIN
|
| 31 | # define zOss_ASSERT(_EXP) do {if(!(_EXP)) EXP_Handler(#_EXP, __FILE__, NULL, __LINE__);} while(0)
|
| 32 | # else
|
| 33 | # define zOss_ASSERT(_EXP) do {if(!(_EXP)) EXP_Handler(#_EXP, NULL, NULL, __LINE__);} while(0)
|
| 34 | # endif
|
| 35 | #else
|
| 36 | # define zOss_ASSERT(_EXP)
|
| 37 | #endif
|
| 38 |
|
| 39 | /**
|
| 40 | * @brief ´ø·µ»ØÖµµÄassert¶ÏÑÔ
|
| 41 | * @param _EXP Èë²Î£¬Òì³£±í´ïʽ
|
| 42 | * @param _RET Èë²Î£¬·µ»ØÖµ
|
| 43 | */
|
| 44 | #define zOss_AssertEx(_EXP, _RET) do {if(!(_EXP)) {zOss_ASSERT((_EXP)); return (_RET);}} while(0)
|
| 45 |
|
| 46 | /**
|
| 47 | * @brief ´ø·µ»ØÖµºÍ¸½¼ÓÖ´ÐвÙ×÷µÄassert¶ÏÑÔ
|
| 48 | * @param _EXP Èë²Î£¬Òì³£±í´ïʽ
|
| 49 | * @param _ACT Èë²Î£¬¸½¼ÓÖ´ÐвÙ×÷
|
| 50 | * @param _RET Èë²Î£¬·µ»ØÖµ
|
| 51 | */
|
| 52 | #define zOss_AssertExA(_EXP, _ACT, _RET) do {if(!(_EXP)) {zOss_ASSERT((_EXP)); _ACT; return (_RET);}} while(0)
|
| 53 |
|
| 54 | /**
|
| 55 | * @brief ²»´ø·µ»ØÖµµÄassert¶ÏÑÔ
|
| 56 | * @param _EXP Èë²Î£¬Òì³£±í´ïʽ
|
| 57 | */
|
| 58 | #define zOss_AssertExN(_EXP) do {if(!(_EXP)) {zOss_ASSERT((_EXP)); return;}} while(0)
|
| 59 |
|
| 60 | /* ³£Ó÷µ»ØÖµ */
|
| 61 | /**
|
| 62 | * @brief ZOSS_SUCCESSºê¶¨Òå
|
| 63 | */
|
| 64 | #define ZOSS_SUCCESS 0x0
|
| 65 |
|
| 66 | /**
|
| 67 | * @brief ZOSS_ERRORºê¶¨Òå
|
| 68 | */
|
| 69 | #define ZOSS_ERROR 0xffffffff
|
| 70 |
|
| 71 | /**
|
| 72 | * @brief ZOSS_NULLºê¶¨Òå
|
| 73 | */
|
| 74 | #define ZOSS_NULL NULL
|
| 75 |
|
| 76 | /**
|
| 77 | * @brief ÎÞЧÏß³ÌIDºê¶¨Òå
|
| 78 | */
|
| 79 | #define ZOSS_INVALID_THREAD_ID NULL
|
| 80 |
|
| 81 | /**
|
| 82 | * @brief ÎÞЧÈÎÎñIDºê¶¨Òå
|
| 83 | */
|
| 84 | #define ZOSS_INVALID_TASK_ID NULL
|
| 85 |
|
| 86 | /**
|
| 87 | * @brief ÎÞЧ¶¨Ê±Æ÷IDºê¶¨Òå
|
| 88 | */
|
| 89 | #define ZOSS_INVALID_TIMER_ID NULL
|
| 90 |
|
| 91 | /**
|
| 92 | * @brief Ïß³ÌÃû×î´ó³¤¶È
|
| 93 | */
|
| 94 | #define MAX_THREADNAME_LEN 63
|
| 95 |
|
| 96 | /**
|
| 97 | * @brief ¼ÆÊýÐźÅÁ¿Ãû³Æ×î´ó³¤¶È
|
| 98 | */
|
| 99 | #define MAX_SEMNAME_LEN 63
|
| 100 |
|
| 101 | /**
|
| 102 | * @brief »¥³âÐźÅÁ¿Ãû³Æ×î´ó³¤¶È
|
| 103 | */
|
| 104 | #define MAX_MUTEXNAME_LEN 63
|
| 105 |
|
| 106 |
|
| 107 | /**
|
| 108 | * @brief µÈ´ý³¬Ê±ÊôÐÔ£¬²»µÈ´ý
|
| 109 | */
|
| 110 | #define ZOSS_NO_WAIT 0x0
|
| 111 |
|
| 112 | /**
|
| 113 | * @brief µÈ´ý³¬Ê±ÊôÐÔ£¬Ò»Ö±µÈ´ýÏÂÈ¥
|
| 114 | */
|
| 115 | #define ZOSS_WAIT_FOREVER 0xffffffff
|
| 116 |
|
| 117 |
|
| 118 | /**
|
| 119 | * @brief »¥³âÌåÊôÐÔ£¬°´ÓÅÏȼ¶»ñÈ¡
|
| 120 | */
|
| 121 | #define ZOSS_INHERIT 0x1
|
| 122 |
|
| 123 | /**
|
| 124 | * @brief »¥³âÌåÊôÐÔ£¬°´Ë³Ðò»ñÈ¡
|
| 125 | */
|
| 126 | #define ZOSS_NO_INHERIT 0x0
|
| 127 |
|
| 128 | #ifdef _OS_LINUX
|
| 129 | # define ZOSS_PREEMPT_IRQ_THREAD (0xffffffff)
|
| 130 | #endif
|
| 131 |
|
| 132 | /*******************************************************************************
|
| 133 | * Type definitions *
|
| 134 | ******************************************************************************/
|
| 135 | /**
|
| 136 | * @brief ÐźÅÁ¿IDÊý¾ÝÀàÐͶ¨Òå
|
| 137 | */
|
| 138 | typedef VOID *ZOSS_SEMAPHORE_ID;
|
| 139 |
|
| 140 | /**
|
| 141 | * @brief »¥³âÌåIDÊý¾ÝÀàÐͶ¨Òå
|
| 142 | */
|
| 143 | typedef VOID *ZOSS_MUTEX_ID;
|
| 144 |
|
| 145 | /**
|
| 146 | * @brief ¶¨Ê±Æ÷IDÊý¾ÝÀàÐͶ¨Òå
|
| 147 | */
|
| 148 | typedef VOID *ZOSS_TIMER_ID;
|
| 149 |
|
| 150 | /**
|
| 151 | * @brief Ïß³ÌIDÊý¾ÝÀàÐͶ¨Òå
|
| 152 | */
|
| 153 | typedef VOID *ZOSS_THREAD_ID;
|
| 154 |
|
| 155 | /**
|
| 156 | * @brief ÈÎÎñIDÊý¾ÝÀàÐͶ¨Òå
|
| 157 | */
|
| 158 | typedef VOID *ZOSS_TASK_ID;
|
| 159 |
|
| 160 | /**
|
| 161 | * @brief ¶ÓÁÐIDÊý¾ÝÀàÐͶ¨Òå
|
| 162 | */
|
| 163 | typedef VOID *ZOSS_QUEUE_ID;
|
| 164 |
|
| 165 | /**
|
| 166 | * @brief ʼþIDÊý¾ÝÀàÐͶ¨Òå
|
| 167 | */
|
| 168 | typedef VOID *ZOSS_EVENT_ID;
|
| 169 |
|
| 170 | /**
|
| 171 | * @brief Ï̺߳¯ÊýÀàÐͶ¨Òå
|
| 172 | */
|
| 173 | typedef VOID (*ZOSS_THREAD_FUN)(SINT32);
|
| 174 |
|
| 175 | /**
|
| 176 | * @brief ¶¨Ê±Æ÷»Øµ÷º¯ÊýÀàÐͶ¨Òå
|
| 177 | */
|
| 178 | typedef VOID (*ZOSS_TIMER_FUN)(SINT32);
|
| 179 |
|
| 180 | /**
|
| 181 | * @brief Ï̹߳³×Óº¯ÊýÀàÐͶ¨Òå
|
| 182 | */
|
| 183 | typedef UINT32 (*THREAD_MSG_HOOK)(UINT32 msg_id, VOID *p_buf, UINT32 buf_size, UINT8 dire);
|
| 184 |
|
| 185 | #ifndef DOXYGEN_SHOULD_SKIP_THIS
|
| 186 | /* Ï̹߳ÜÀí */
|
| 187 | /**
|
| 188 | * @brief Ï̹߳ÜÀí½á¹¹
|
| 189 | * @param threadid Ïß³Ìid
|
| 190 | * @param threadname Ïß³ÌÃû³Æ
|
| 191 | * @param runstatus Ïß³ÌÔËÐÐ״̬
|
| 192 | * @param priority Ïß³ÌÓÅÏȼ¶
|
| 193 | * @param maxstack Ïß³ÌÕ»×î´óջʹÓÃÂÊ
|
| 194 | * @param cpupercent Ïß³ÌCPUÕ¼ÓÃÂÊ
|
| 195 | * @param stacksize Ï̶߳ÑÕ»´óС
|
| 196 | * @param cputime Ïß³ÌCPUÕ¼ÓÃÂÊʱ¼ä
|
| 197 | * @param topstack Ïß³ÌÕ»¶¥µØÖ·
|
| 198 | * @param runtime Ïß³ÌÔËÐÐʱ¼ä
|
| 199 | * @param RunTimeInMs
|
| 200 | * @param msgnum Ïß³ÌÏûÏ¢¶ÓÁÐÏûÏ¢Êý
|
| 201 | * @param runcount Ïß³ÌÔËÐдÎÊý
|
| 202 | * @param curpath Ï̵߳±Ç°Â·¾¶£¬ÓëosÓйØ
|
| 203 | * @param ptrf µ÷ÊÔÏ̵߳ǼDZí
|
| 204 | * @param curtaskid µ±Ç°ÈÎÎñID
|
| 205 | * @param heapsize Ïß³ÌÉêÇë¶ÑÄÚ´æ´óС
|
| 206 | * @param ubsize Ïß³ÌÉêÇëÄÚ´æ³Ø´óС
|
| 207 | * @param psmCpuTime Ïß³Ìpsm¼ÆÊ±Ê±¼ä
|
| 208 | * @param sleepTimerId Ïß³Ì˯Ãßʱ´´½¨µÄ¶¨Ê±Æ÷ID
|
| 209 | * @param sleepsem Ïß³Ì˯Ãßʱ´´½¨µÄÐźÅÁ¿ID
|
| 210 | */
|
| 211 | typedef struct
|
| 212 | {
|
| 213 | ZOSS_THREAD_ID threadid; /* Ïß³ÌID */
|
| 214 | CHAR threadname[MAX_THREADNAME_LEN + 1]; /* Ïß³ÌÃû */
|
| 215 | UINT8 runstatus; /* Ïß³ÌÔËÐÐ״̬ */
|
| 216 | UINT8 priority; /* Ïß³ÌÓÅÏȼ¶ */
|
| 217 | UINT8 maxstack; /* Ïß³ÌÕ»×î´óջʹÓÃÂÊ */
|
| 218 | FLOAT cpupercent; /* Ïß³ÌCPUÕ¼ÓÃÂÊ */
|
| 219 | UINT32 stacksize; /* Ï̶߳ÑÕ»´óС */
|
| 220 | UINT32 cputime; /* Ïß³ÌCPUÕ¼ÓÃÂÊʱ¼ä */
|
| 221 | UINT32 topstack; /* Ïß³ÌÕ»¶¥µØÖ· */
|
| 222 | UINT32 runtime; /* Ïß³ÌÔËÐÐʱ¼ä */
|
| 223 | UINT32 RunTimeInMs;
|
| 224 | UINT32 msgnum; /* Ïß³ÌÏûÏ¢¶ÓÁÐÏûÏ¢Êý */
|
| 225 | UINT32 runcount; /* Ïß³ÌÔËÐдÎÊý */
|
| 226 | CHAR *curpath; /* Ï̵߳±Ç°Â·¾¶£¬ÓëosÓÐ¹Ø */
|
| 227 | VOID *ptrf; /* µ÷ÊÔÏ̵߳ǼDZí */
|
| 228 | VOID *curtaskid; /* µ±Ç°ÈÎÎñID */
|
| 229 | UINT32 heapsize; /* Ïß³ÌÉêÇë¶ÑÄÚ´æ´óС */
|
| 230 | UINT32 ubsize; /* Ïß³ÌÉêÇëÄÚ´æ³Ø´óС */
|
| 231 | UINT32 psmCpuTime; /* Ïß³Ìpsm¼ÆÊ±Ê±¼ä */
|
| 232 | ZOSS_TIMER_ID sleepTimerId; /* Ïß³Ì˯Ãßʱ´´½¨µÄ¶¨Ê±Æ÷ID */
|
| 233 | ZOSS_SEMAPHORE_ID sleepsem; /* Ïß³Ì˯Ãßʱ´´½¨µÄÐźÅÁ¿ID */
|
| 234 | }T_ZOsa_ThreadUserArea; /* Ïß³ÌÓû§¿Õ¼ä */
|
| 235 | #endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
| 236 | /*******************************************************************************
|
| 237 | * Global variable declarations *
|
| 238 | ******************************************************************************/
|
| 239 |
|
| 240 | /*******************************************************************************
|
| 241 | * Global function declarations *
|
| 242 | ******************************************************************************/
|
| 243 | /* Ï̹߳ÜÀí */
|
| 244 |
|
| 245 | /**
|
| 246 | * @brief »ñÈ¡ÓÅÏȼ¶Öµ½Ó¿Ú
|
| 247 | * @param offset Èë²Î£¬È¡Öµ0~31
|
| 248 | * @return Èô³É¹¦£¬·µ»ØÓÅÏȼ¶ÊýÖµ£»·ñÔò·µ»ØZOSS_ERROR
|
| 249 | * @retval ÓÅÏȼ¶ÊýÖµ ³É¹¦
|
| 250 | * @retval ZOSS_ERROR ʧ°Ü
|
| 251 | * @note
|
| 252 | * @warning
|
| 253 | */
|
| 254 | UINT32 zOss_GetPrioCfg(UINT8 offset);
|
| 255 |
|
| 256 | /**
|
| 257 | * @brief ´´½¨Ï߳̽ӿÚ
|
| 258 | * @param thread_name Èë²Î£¬Ïß³ÌÃû³Æ
|
| 259 | * @param entry Èë²Î£¬Ïß³ÌÈë¿ÚʵÌ庯Êý
|
| 260 | * @param arg Èë²Î£¬Ïß³ÌʵÌ庯ÊýµÄ²ÎÊý
|
| 261 | * @param stack_size Èë²Î£¬Ïß³ÌÓµÓеĶÑÕ»´óС
|
| 262 | * @param priority Èë²Î£¬Ï̵߳ÄÓÅÏȵȼ¶0~31
|
| 263 | * @param preempt Èë²Î£¬Í¬ÓÅÏȼ¶Ïß³ÌÊÇ·ñÔÊÐíÇÀÕ¼£¬·Ç0ֵΪÇÀÕ¼Ị̈߳¬·ñÔòΪ²»¿ÉÇÀÕ¼Ị̈߳¬¼´Ö´ÐÐʱ¼äƬµ÷¶È
|
| 264 | * @param auto_start Èë²Î£¬´´½¨Ï̺߳óÊÇ·ñ×Ô¶¯Ö´ÐÐ
|
| 265 | * @return Èç¹û´´½¨³É¹¦·µ»ØÏß³ÌID£¬Ê§°Ü·µ»ØZOSS_INVALID_THREAD_ID
|
| 266 | * @retval ZOSS_THREAD_IDÀàÐ͵ÄÏß³Ìid ³É¹¦
|
| 267 | * @retval ZOSS_INVALID_THREAD_ID ʧ°Ü
|
| 268 | * @note
|
| 269 | * @warning
|
| 270 | */
|
| 271 | ZOSS_THREAD_ID zOss_CreateThread(const CHAR *thread_name, VOID (*entry)(SINT32), SINT32 arg, UINT32 stack_size, UINT32 priority, UINT32 preempt, UINT32 auto_start);
|
| 272 |
|
| 273 | /**
|
| 274 | * @brief Í˳öµ±Ç°Ï߳̽ӿÚ
|
| 275 | * @param void
|
| 276 | * @return void
|
| 277 | * @note
|
| 278 | * @warning
|
| 279 | */
|
| 280 | VOID zOss_ExitThread(VOID);
|
| 281 |
|
| 282 | /**
|
| 283 | * @brief Ïß³Ì¹ÒÆð½Ó¿Ú
|
| 284 | * @param thread_id Èë²Î£¬ÐèÒª¹ÒÆðµÄÏß³Ìid
|
| 285 | * @return Èô³É¹¦£¬·µ»ØZOSS_SUCCESS£»·ñÔòϵͳ¶ÏÑÔ
|
| 286 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 287 | * @retval ZOSS_ERROR ʧ°Ü
|
| 288 | * @note ±¾º¯Êý¿ÉÒÔÓÃÓÚÏ̵߳Ä×ÔÎÒ¹ÒÆð
|
| 289 | * @warning
|
| 290 | */
|
| 291 | UINT32 zOss_SuspendThread(ZOSS_THREAD_ID thread_id);
|
| 292 |
|
| 293 | /**
|
| 294 | * @brief Ïָ̻߳´½Ó¿Ú
|
| 295 | * @param thread_id Èë²Î£¬ÐèÒª»Ö¸´µÄÏß³Ìid
|
| 296 | * @return Èô³É¹¦£¬·µ»ØZOSS_SUCCESS£»·ñÔòϵͳ¶ÏÑÔ
|
| 297 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 298 | * @retval ZOSS_ERROR ʧ°Ü
|
| 299 | * @note
|
| 300 | * @warning
|
| 301 | */
|
| 302 | UINT32 zOss_ResumeThread(ZOSS_THREAD_ID thread_id);
|
| 303 |
|
| 304 | /**
|
| 305 | * @brief Ïß³Ì˯Ãß½Ó¿Ú
|
| 306 | * @param time_in_ms Èë²Î£¬Ï߳̽«ÒªË¯ÃßµÄʱ¼ä£¬µ¥Î»£ºms
|
| 307 | * @return void
|
| 308 | * @note
|
| 309 | * @warning
|
| 310 | */
|
| 311 | VOID zOss_Sleep(UINT32 time_in_ms);
|
| 312 |
|
| 313 | /**
|
| 314 | * @brief Ïß³Ìɾ³ý½Ó¿Ú
|
| 315 | * @param thread_id Èë²Î£¬±»É¾³ýµÄÏß³Ìid
|
| 316 | * @return Èô³É¹¦£¬·µ»ØZOSS_SUCCESS£»·ñÔòϵͳ¶ÏÑÔ
|
| 317 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 318 | * @retval ZOSS_ERROR ʧ°Ü
|
| 319 | * @note zOss_CreateThreadº¯ÊýÖÐÉêÇëµÄÏß³ÌÕ»¿Õ¼äºÍÏ߳̿ØÖÆ¿é½á¹¹¿Õ¼ä»áÔÚ
|
| 320 | * Cyg_Thread::exitº¯ÊýÖÐÊÍ·Å£¬ÒòΪÔÚcyg_thread_deleteº¯ÊýÖ´ÐÐÍêºó£¬
|
| 321 | * ºóÃæµÄËùÓдúÂëËæ×ű¾Ï̵߳ÄÏûÍö¶ø±äµÃÎÞЧÁË¡£
|
| 322 | * @warning
|
| 323 | */
|
| 324 | UINT32 zOss_DeleteThread(ZOSS_THREAD_ID thread_id);
|
| 325 |
|
| 326 | /**
|
| 327 | * @brief »ñÈ¡µ±Ç°Ïß³Ìid½Ó¿Ú
|
| 328 | * @param void
|
| 329 | * @return µ±Ç°Ïß³Ìid
|
| 330 | * @note
|
| 331 | * @warning
|
| 332 | */
|
| 333 | ZOSS_THREAD_ID zOss_GetCurThreadID(VOID);
|
| 334 |
|
| 335 | /**
|
| 336 | * @brief ¸ù¾Ý²ÎÊýÌṩµÄÏß³ÌÃû³Æ£¬²éÕÒ¸ÃÏ̵߳ÄÏß³Ìid
|
| 337 | * @param thread_name Èë²Î£¬Ïß³ÌÃû³Æ
|
| 338 | * @return Èô²éÕҳɹ¦£¬·µ»ØÏ̵߳ÄÓÐЧÏß³Ìid£»·ñÔòϵͳ¶ÏÑÔ
|
| 339 | * @note
|
| 340 | * @warning
|
| 341 | */
|
| 342 | ZOSS_THREAD_ID zOss_GetThreadIDByName(const CHAR *thread_name);
|
| 343 |
|
| 344 | /**
|
| 345 | * @brief ¸ù¾Ý²ÎÊýÌṩµÄÏß³Ìid£¬»ñÈ¡¸ÃÏ̵߳ÄÏß³ÌÃû³Æ
|
| 346 | * @param thread_id Èë²Î£¬´ý»ñÈ¡Ïß³ÌÃû³ÆµÄÏß³Ìid
|
| 347 | * @param thread_name ³ö²Î£¬Ïß³ÌÃû³Æ´æ·ÅµØÖ·
|
| 348 | * @return Èô³É¹¦£¬·µ»ØÏß³ÌÃû³ÆÖ¸Õ룻·ñÔòϵͳ¶ÏÑÔ»ò·µ»Ø¿ÕÖ¸Õë
|
| 349 | * @retval Ïß³ÌÃû³ÆÖ¸Õë ³É¹¦
|
| 350 | * @retval NULL ʧ°Ü
|
| 351 | * @note
|
| 352 | * @warning
|
| 353 | */
|
| 354 | CHAR *zOss_GetThreadName(ZOSS_THREAD_ID thread_id, CHAR *thread_name);
|
| 355 |
|
| 356 | /**
|
| 357 | * @brief ¸ù¾Ý²ÎÊýÌṩµÄÏß³Ìid£¬»ñÈ¡¸ÃÏ̵߳ÄÏß³ÌÐÅÏ¢
|
| 358 | * @param thread_id Èë²Î£¬´ý»ñÈ¡Ïß³ÌÐÅÏ¢µÄÏß³Ìid
|
| 359 | * @param thread_name ³ö²Î£¬Ïß³ÌÃû³Æ´æ·ÅµØÖ·
|
| 360 | * @param stat ³ö²Î£¬Ïß³Ì״̬´æ·ÅµØÖ·
|
| 361 | * @param priority ³ö²Î£¬Ïß³ÌÓÅÏȼ¶´æ·ÅµØÖ·
|
| 362 | * @param preempt ³ö²Î£¬Ï߳̿ÉÇÀÕ¼´æ·ÅµØÖ·
|
| 363 | * @return Èô³É¹¦£¬·µ»ØZOSS_SUCCESS£»·ñÔòϵͳ¶ÏÑÔ
|
| 364 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 365 | * @retval ZOSS_ERROR ʧ°Ü
|
| 366 | * @note
|
| 367 | * @warning
|
| 368 | */
|
| 369 | UINT32 zOss_GetThreadInfo(ZOSS_THREAD_ID thread_id, CHAR *thread_name, UINT32 *stat, UINT32 *priority, UINT32 *preempt);
|
| 370 |
|
| 371 | /**
|
| 372 | * @brief ¸ù¾Ý²ÎÊýÌṩµÄÏß³Ìid£¬ÉèÖøÃÏ̵߳ÄÏß³ÌÓÅÏȼ¶
|
| 373 | * @param thread_id Èë²Î£¬´ýÉèÖÃÓÅÏȼ¶µÄÏß³Ìid
|
| 374 | * @param priority Èë²Î£¬Ï߳̽«±»ÉèÖõÄÓÅÏȼ¶
|
| 375 | * @return Èô³É¹¦£¬·µ»ØZOSS_SUCCESS£»·ñÔòϵͳ¶ÏÑÔ
|
| 376 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 377 | * @retval ZOSS_ERROR ʧ°Ü
|
| 378 | * @note
|
| 379 | * @warning
|
| 380 | */
|
| 381 | UINT32 zOss_SetThreadPri(ZOSS_THREAD_ID thread_id, UINT32 priority);
|
| 382 |
|
| 383 | /**
|
| 384 | * @brief ¸ù¾Ý²ÎÊýÌṩµÄÏß³Ìid£¬»ñÈ¡¸ÃÏ̵߳ÄÏß³ÌÓÅÏȼ¶
|
| 385 | * @param thread_id Èë²Î£¬´ýÉèÖÃÓÅÏȼ¶µÄÏß³Ìid
|
| 386 | * @param priority ³ö²Î£¬»ñÈ¡µÄÏß³ÌÓÅÏȼ¶´æ·ÅµØÖ·
|
| 387 | * @return Èô³É¹¦£¬·µ»ØZOSS_SUCCESS£»·ñÔòϵͳ¶ÏÑÔ
|
| 388 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 389 | * @retval ZOSS_ERROR ʧ°Ü
|
| 390 | * @note
|
| 391 | * @warning
|
| 392 | */
|
| 393 | UINT32 zOss_GetThreadPri(ZOSS_THREAD_ID thread_id, UINT32 *priority);
|
| 394 |
|
| 395 | /**
|
| 396 | * @brief ÑéÖ¤Ò»¸öÏß³ÌÊÇ·ñÓÐЧ
|
| 397 | * @param threadID Èë²Î£¬´ýÑéÖ¤µÄÏß³Ìid
|
| 398 | * @return ÈôÏß³ÌÓÐЧ£¬·µ»ØZOSS_SUCCESS£»·ñÔòϵͳ¶ÏÑÔ
|
| 399 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 400 | * @retval ZOSS_ERROR ʧ°Ü
|
| 401 | * @note
|
| 402 | * @warning
|
| 403 | */
|
| 404 | UINT32 zOss_IdentifyThread(ZOSS_THREAD_ID threadID);
|
| 405 |
|
| 406 | /* Ïß³ÌÏûÏ¢¹ÜÀíÄ£¿é */
|
| 407 | /**
|
| 408 | * @brief ´ÓÄÚ´æ³ØÉêÇëÏûϢͷ+»º³åÇø£¬²¢·µ»Ø»º³åÇøÖ¸Õë
|
| 409 | * @param size Èë²Î£¬»º³åÇø´óС
|
| 410 | * @return »º³åÇøÖ¸Õë
|
| 411 | * @note ¸ÃÉêÇë½Ó¿Ú£¬»á´ø×ÅÏûϢͷһÆðÉêÇ룬µ«·µ»Ø¸øÓû§µÄÊǰþÀëÁËÏûϢͷµÄÓû§Ê¹ÓÃ¿Õ¼äµØÖ·
|
| 412 | * @warning ±ØÐëºÍzOss_ThreadRetMsgBufÅä¶ÔʵÏÖ
|
| 413 | */
|
| 414 | VOID *zOss_ThreadGetMsgBuf(UINT32 size);
|
| 415 |
|
| 416 | /**
|
| 417 | * @brief ÏòÄÚ´æ³ØÊÍ·ÅÏûϢͷ+»º³åÇø
|
| 418 | * @param p_buf Èë²Î£¬»º³åÇøÖ¸Õë
|
| 419 | * @return void
|
| 420 | * @note ¸ÃÊÍ·Å½Ó¿Ú»á´ø×ÅÏûϢͷһÆðÊÍ·Å
|
| 421 | * @warning ±ØÐëºÍzOss_ThreadGetMsgBufÅä¶ÔʵÏÖ
|
| 422 | */
|
| 423 | VOID zOss_ThreadRetMsgBuf(VOID *p_buf);
|
| 424 |
|
| 425 | /**
|
| 426 | * @brief Ïòthread_idÏ̷߳¢ËÍÏûÏ¢
|
| 427 | * @param msg_id Èë²Î£¬ÏûÏ¢id
|
| 428 | * @param p_buf Èë²Î£¬»º³åÇøÖ¸Õë
|
| 429 | * @param buf_size Èë²Î£¬»º³åÇø´óС
|
| 430 | * @param thread_id Èë²Î£¬Ä¿±êÏß³Ìid
|
| 431 | * @return ³É¹¦£¬·µ»ØZOSS_SUCCESS£¬·ñÔò·µ»ØZOSS_ERROR
|
| 432 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 433 | * @retval ZOSS_ERROR ʧ°Ü
|
| 434 | * @note ±ØÐëºÍzOss_ThreadRecvMsgÅä¶ÔʵÏÖ
|
| 435 | * @warning
|
| 436 | */
|
| 437 | UINT32 zOss_ThreadSendMsg(UINT32 msg_id, VOID *p_buf, UINT16 buf_size, ZOSS_THREAD_ID thread_id);
|
| 438 |
|
| 439 | /**
|
| 440 | * @brief Ï߳̽ÓÊÕÏûÏ¢
|
| 441 | * @param p_msg_id Èë²Î£¬ÏûÏ¢idµÄ´æ·ÅµØÖ·
|
| 442 | * @param p_buf Èë²Î£¬ÏûÏ¢Ö¸ÕëµÄ´æ·ÅµØÖ·
|
| 443 | * @param p_buf_size Èë²Î£¬ÏûÏ¢´óСµÄ´æ·ÅµØÖ·
|
| 444 | * @param timeout Èë²Î£¬½ÓÊÕÏûÏ¢µÄ³¬Ê±Ê±¼ä
|
| 445 | * @return ³É¹¦£¬·µ»ØZOSS_SUCCESS£¬·ñÔò·µ»ØZOSS_ERROR
|
| 446 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 447 | * @retval ZOSS_ERROR ʧ°Ü
|
| 448 | * @note ±ØÐëºÍzOss_ThreadSendMsgÅä¶ÔʵÏÖ
|
| 449 | * @warning
|
| 450 | */
|
| 451 | UINT32 zOss_ThreadRecvMsg(UINT32 *p_msg_id, VOID **p_buf, UINT32 *p_buf_size, UINT32 timeout);
|
| 452 |
|
| 453 | /**
|
| 454 | * @brief ×¢²áÏß³ÌÏûÏ¢¹³×Óº¯Êý
|
| 455 | * @param thread_id Èë²Î£¬Ïß³Ìid
|
| 456 | * @param type Èë²Î£¬¹³×Óº¯ÊýÀàÐÍ
|
| 457 | * @param dire Èë²Î£¬¹³×Óº¯ÊýÅäÖÃ
|
| 458 | * @param func Èë²Î£¬¹³×Óº¯ÊýÖ¸Õë
|
| 459 | * @return ³É¹¦£¬·µ»ØZOSS_SUCCESS£¬·ñÔò·µ»ØZOSS_ERROR
|
| 460 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 461 | * @retval ZOSS_ERROR ʧ°Ü
|
| 462 | * @note
|
| 463 | * @warning
|
| 464 | */
|
| 465 | UINT32 zOss_RegThreadMsgHook(ZOSS_THREAD_ID thread_id, UINT8 type, UINT8 dire, THREAD_MSG_HOOK func);
|
| 466 |
|
| 467 | /* ÏûϢͨѶ */
|
| 468 |
|
| 469 | /**
|
| 470 | * @brief ÏòÖ¸¶¨µÄÏ̷߳¢ËÍÏûÏ¢
|
| 471 | * @param thread_id Èë²Î£¬Ä¿±êÏ̵߳ÄÏß³Ìid
|
| 472 | * @param msg_ptr Èë²Î£¬ÏûÏ¢Êý¾ÝµÄÖ¸Õë
|
| 473 | * @param size Èë²Î£¬ÏûÏ¢µÄ´óС
|
| 474 | * @param timeout Èë²Î£¬·¢ËÍÏûÏ¢µÄ³¬Ê±Ê±¼ä
|
| 475 | * @return ³É¹¦£¬·µ»ØZOSS_SUCCESS£¬·ñÔò·µ»ØZOSS_ERROR
|
| 476 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 477 | * @retval ZOSS_ERROR ʧ°Ü
|
| 478 | * @note Èô²ÎÊýtimeoutÊÇZOSS_WAIT_FOREVER£¬ÔòÒ»Ö±µÈ´ýÏûÏ¢·¢Ëͳɹ¦ÔÙ·µ»Ø£»
|
| 479 | Èô²ÎÊýtimeoutÊÇZOSS_NO_WAIT£¬Ôò³¢ÊÔ·¢ËÍÏûÏ¢£¬·¢ËÍʧ°Ü£¬Ö±½Ó·µ»Ø£»
|
| 480 | ·ñÔòtimeoutÊdz¬Ê±µÄʱ¼ä£¬¼ÆËã·½·¨Êǽ«µ±Ç°ÏµÍ³Ê±¼äºÍtimeoutÏà¼Ó£¬
|
| 481 | ³ÉΪabs_timeout,È»ºóÆô¶¯Ò»¸ö¶¨Ê±Æ÷£¬Ö±ÖÁÏûÏ¢·¢Ëͳɹ¦»ò³¬Ê±
|
| 482 | * @warning
|
| 483 | */
|
| 484 | UINT32 zOss_SendMsg(ZOSS_THREAD_ID thread_id, VOID *msg_ptr, UINT32 size, UINT32 timeout);
|
| 485 |
|
| 486 | /**
|
| 487 | * @brief ½ÓÊÕÏûÏ¢
|
| 488 | * @param msg_ptr ³ö²Î£¬ÏûÏ¢Ö¸ÕëµÄ´æ·ÅµØÖ·
|
| 489 | * @param size ³ö²Î£¬ÏûÏ¢Êý¾Ý´óСµÄ´æ·ÅµØÖ·
|
| 490 | * @param timeout Èë²Î£¬½ÓÊÕÏûÏ¢µÄ³¬Ê±Ê±¼ä
|
| 491 | * @return ³É¹¦£¬·µ»ØZOSS_SUCCESS£¬·ñÔò·µ»ØZOSS_ERROR
|
| 492 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 493 | * @retval ZOSS_ERROR ʧ°Ü
|
| 494 | * @note Èô²ÎÊýtimeoutÊÇZOSS_WAIT_FOREVER£¬ÔòÒ»Ö±µÈ´ýÏûÏ¢·¢Ëͳɹ¦ÔÙ·µ»Ø£»
|
| 495 | Èô²ÎÊýtimeoutÊÇZOSS_NO_WAIT£¬Ôò³¢ÊÔ·¢ËÍÏûÏ¢£¬·¢ËÍʧ°Ü£¬Ö±½Ó·µ»Ø£»
|
| 496 | ·ñÔòtimeoutÊdz¬Ê±µÄʱ¼ä£¬¼ÆËã·½·¨Êǽ«µ±Ç°ÏµÍ³Ê±¼äºÍtimeoutÏà¼Ó£¬
|
| 497 | ³ÉΪabs_timeout,È»ºóÆô¶¯Ò»¸ö¶¨Ê±Æ÷£¬Ö±ÖÁÏûÏ¢·¢Ëͳɹ¦»ò³¬Ê±
|
| 498 | * @warning
|
| 499 | */
|
| 500 | UINT32 zOss_RecvMsg(VOID **msg_ptr, UINT32 *size, UINT32 timeout);
|
| 501 |
|
| 502 | /* ¼ÆÊýÐźÅÁ¿ */
|
| 503 | /**
|
| 504 | * @brief ´´½¨ÐźÅÁ¿
|
| 505 | * @param name_ptr Èë²Î£¬ÐźÅÁ¿µÄÃû³Æ
|
| 506 | * @param initial_count Èë²Î£¬ÐźÅÁ¿µÄ³õʼ¼ÆÊýÖµ
|
| 507 | * @return ´´½¨³É¹¦£¬·µ»ØÐźÅÁ¿µÄ¾ä±ú£»·ñÔòϵͳ¶ÏÑÔ
|
| 508 | * @note
|
| 509 | * @warning
|
| 510 | */
|
| 511 | ZOSS_SEMAPHORE_ID zOss_CreateSemaphore(const CHAR *name_ptr, UINT32 initial_count);
|
| 512 |
|
| 513 | /**
|
| 514 | * @brief »ñÈ¡ÐźÅÁ¿
|
| 515 | * @param sem_id Èë²Î£¬ÕýÔÚ»ñÈ¡µÄÐźÅÁ¿id
|
| 516 | * @param timeout Èë²Î£¬³¬Ê±¼ÆÊý
|
| 517 | * @return ³É¹¦£¬·µ»ØZOSS_SUCCESS£¬·ñÔò·µ»ØZOSS_ERROR
|
| 518 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 519 | * @retval ZOSS_ERROR ʧ°Ü
|
| 520 | * @note Èô²ÎÊýtimeoutÊÇZOSS_WAIT_FOREVER£¬ÔòÒ»Ö±µÈ´ýÏûÏ¢·¢Ëͳɹ¦ÔÙ·µ»Ø£»
|
| 521 | Èô²ÎÊýtimeoutÊÇZOSS_NO_WAIT£¬Ôò³¢ÊÔ·¢ËÍÏûÏ¢£¬·¢ËÍʧ°Ü£¬Ö±½Ó·µ»Ø£»
|
| 522 | ·ñÔòtimeoutÊdz¬Ê±µÄʱ¼ä£¬¼ÆËã·½·¨Êǽ«µ±Ç°ÏµÍ³Ê±¼äºÍtimeoutÏà¼Ó£¬
|
| 523 | ³ÉΪabs_timeout,È»ºóÆô¶¯Ò»¸ö¶¨Ê±Æ÷£¬Ö±ÖÁÏûÏ¢·¢Ëͳɹ¦»ò³¬Ê±
|
| 524 | * @warning
|
| 525 | */
|
| 526 | UINT32 zOss_GetSemaphore(ZOSS_SEMAPHORE_ID sem_id, UINT32 timeout);
|
| 527 |
|
| 528 | /**
|
| 529 | * @brief ÊÍ·ÅÐźÅÁ¿
|
| 530 | * @param sem_id Èë²Î£¬ÕýÔÚÊͷŵÄÐźÅÁ¿id
|
| 531 | * @return Èô³É¹¦£¬·µ»ØZOSS_SUCCESS£»·ñÔòϵͳ¶ÏÑÔ
|
| 532 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 533 | * @retval ZOSS_ERROR ʧ°Ü
|
| 534 | * @note
|
| 535 | * @warning
|
| 536 | */
|
| 537 | UINT32 zOss_PutSemaphore(ZOSS_SEMAPHORE_ID sem_id);
|
| 538 |
|
| 539 | /**
|
| 540 | * @brief »ñÈ¡ÐźÅÁ¿µÄµ±Ç°¼ÆÊýÖµ
|
| 541 | * @param sem_id Èë²Î£¬ÕýÔÚ±»»ñÈ¡¼ÆÊýÖµµÄÐźÅÁ¿id
|
| 542 | * @return ¸ÃÐźÅÁ¿µÄµ±Ç°¼ÆÊýÖµ
|
| 543 | * @note
|
| 544 | * @warning
|
| 545 | */
|
| 546 | UINT32 zOss_GetSemaphoreCount(ZOSS_SEMAPHORE_ID sem_id);
|
| 547 |
|
| 548 | /**
|
| 549 | * @brief ɾ³ýÐźÅÁ¿
|
| 550 | * @param sem_id Èë²Î£¬±»É¾³ýµÄÐźÅÁ¿id
|
| 551 | * @return Èô³É¹¦£¬·µ»ØZOSS_SUCCESS£»·ñÔòϵͳ¶ÏÑÔ
|
| 552 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 553 | * @retval ZOSS_ERROR ʧ°Ü
|
| 554 | * @note
|
| 555 | * @warning
|
| 556 | */
|
| 557 | UINT32 zOss_DeleteSemaphore(ZOSS_SEMAPHORE_ID sem_id);
|
| 558 |
|
| 559 | /* »¥³âÐźÅÁ¿ */
|
| 560 | /**
|
| 561 | * @brief ´´½¨»¥³âÌå
|
| 562 | * @param name_ptr Èë²Î£¬»¥³âÌåÃû³Æ
|
| 563 | * @param priority_inherit Èë²Î£¬»¥³âÌåÊôÐÔ£¬Èç¹ûÊÇZOSS_INHERIT£¬ÔòÏß³ÌÖ®¼ä°´
|
| 564 | ÓÅÏȼ¶Ë³Ðò»ñÈ¡»¥³âÌ壻Èç¹ûÊÇZOSS_NO_INHERIT£¬Ôò°´µÈ´ýµÄ˳Ðò»ñÈ¡
|
| 565 | »¥³âÌå
|
| 566 | * @return Èô³É¹¦£¬·µ»Ø´´½¨µÄ»¥³âÌå¾ä±ú£»·ñÔòϵͳ¶ÏÑÔ
|
| 567 | * @note
|
| 568 | * @warning
|
| 569 | */
|
| 570 | ZOSS_MUTEX_ID zOss_CreateMutex(const CHAR *name_ptr, UINT32 priority_inherit);
|
| 571 |
|
| 572 | /**
|
| 573 | * @brief »ñÈ¡»¥³âÌå
|
| 574 | * @param mutex_id Èë²Î£¬´ý»ñÈ¡µÄ»¥³âÌåid
|
| 575 | * @param timeout Èë²Î£¬»ñÈ¡µÄ³¬Ê±Ê±¼ä
|
| 576 | * @return ³É¹¦£¬·µ»ØZOSS_SUCCESS£¬·ñÔò·µ»ØZOSS_ERROR
|
| 577 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 578 | * @retval ZOSS_ERROR ʧ°Ü
|
| 579 | * @note
|
| 580 | * @warning
|
| 581 | */
|
| 582 | UINT32 zOss_GetMutex(ZOSS_MUTEX_ID mutex_id, UINT32 timeout);
|
| 583 |
|
| 584 | /**
|
| 585 | * @brief ÊÍ·Å»¥³âÌå
|
| 586 | * @param mutex_id Èë²Î£¬´ýÊͷŵĻ¥³âÌåid
|
| 587 | * @return Èô³É¹¦£¬·µ»ØZOSS_SUCCESS£»·ñÔòϵͳ¶ÏÑÔ
|
| 588 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 589 | * @retval ZOSS_ERROR ʧ°Ü
|
| 590 | * @note
|
| 591 | * @warning
|
| 592 | */
|
| 593 | UINT32 zOss_PutMutex(ZOSS_MUTEX_ID mutex_id);
|
| 594 |
|
| 595 | /**
|
| 596 | * @brief Ïú»Ù»¥³âÌå
|
| 597 | * @param mutex_id Èë²Î£¬´ýÏú»ÙµÄ»¥³âÌåid
|
| 598 | * @return Èô³É¹¦£¬·µ»ØZOSS_SUCCESS£»·ñÔòϵͳ¶ÏÑÔ
|
| 599 | * @retval ZOSS_SUCCESS ³É¹¦
|
| 600 | * @retval ZOSS_ERROR ʧ°Ü
|
| 601 | * @note
|
| 602 | * @warning
|
| 603 | */
|
| 604 | UINT32 zOss_DeleteMutex(ZOSS_MUTEX_ID mutex_id);
|
| 605 |
|
| 606 | /* ʱ¼ä */
|
| 607 | /**
|
| 608 | * @brief »ñÈ¡²Ù×÷ϵͳµÄµ±Ç°µÎ´ðÊý
|
| 609 | * @param void
|
| 610 | * @return ·µ»Ø²Ù×÷ϵͳµÄµ±Ç°µÎ´ðÊý
|
| 611 | * @retval µÎ´ðÊý
|
| 612 | * @note
|
| 613 | * @warning
|
| 614 | */
|
| 615 | UINT32 zOss_GetTickCount(VOID);
|
| 616 |
|
| 617 | #ifndef DOXYGEN_SHOULD_SKIP_THIS
|
| 618 | /* CPUʹÓÃÂÊͳ¼Æ */
|
| 619 | UINT8 zOss_GetCPU(VOID);
|
| 620 |
|
| 621 | /* Òì³£´¦Àí */
|
| 622 | VOID EXP_Handler(const CHAR *pExp, const CHAR *pcFileName, const CHAR *pcFuncName, SINT32 dwLineNum);
|
| 623 |
|
| 624 | #endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
| 625 | /*******************************************************************************
|
| 626 | * Inline function implementations *
|
| 627 | ******************************************************************************/
|
| 628 |
|
| 629 | #ifdef __cplusplus
|
| 630 | }
|
| 631 | #endif
|
| 632 |
|
| 633 | #endif // #ifndef _OSS_KERNEL_H
|
| 634 |
|