osl_ext.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. /*
  2. * OS Abstraction Layer Extension - the APIs defined by the "extension" API
  3. * are only supported by a subset of all operating systems.
  4. *
  5. * Portions of this code are copyright (c) 2020 Cypress Semiconductor Corporation
  6. *
  7. * Copyright (C) 1999-2020, Broadcom Corporation
  8. *
  9. * Unless you and Broadcom execute a separate written software license
  10. * agreement governing use of this software, this software is licensed to you
  11. * under the terms of the GNU General Public License version 2 (the "GPL"),
  12. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  13. * following added to such license:
  14. *
  15. * As a special exception, the copyright holders of this software give you
  16. * permission to link this software with independent modules, and to copy and
  17. * distribute the resulting executable under terms of your choice, provided that
  18. * you also meet, for each linked independent module, the terms and conditions of
  19. * the license of that module. An independent module is a module which is not
  20. * derived from this software. The special exception does not apply to any
  21. * modifications of the software.
  22. *
  23. * Notwithstanding the above, under no circumstances may you combine this
  24. * software in any way with any other Broadcom software provided under a license
  25. * other than the GPL, without Broadcom's express prior written consent.
  26. *
  27. *
  28. * <<Broadcom-WL-IPTag/Open:>>
  29. *
  30. * $Id: osl_ext.h 627993 2016-03-29 10:07:29Z $
  31. */
  32. #ifndef _osl_ext_h_
  33. #define _osl_ext_h_
  34. /* ---- Include Files ---------------------------------------------------- */
  35. #if defined(TARGETOS_symbian)
  36. #include <e32def.h>
  37. #include <symbian_osl_ext.h>
  38. #elif defined(THREADX)
  39. #include <threadx_osl_ext.h>
  40. #else
  41. #define OSL_EXT_DISABLED
  42. #endif // endif
  43. /* Include base operating system abstraction. */
  44. #include <osl.h>
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif // endif
  48. /* ---- Constants and Types ---------------------------------------------- */
  49. /* -----------------------------------------------------------------------
  50. * Generic OS types.
  51. */
  52. typedef enum osl_ext_status_t
  53. {
  54. OSL_EXT_SUCCESS,
  55. OSL_EXT_ERROR,
  56. OSL_EXT_TIMEOUT
  57. } osl_ext_status_t;
  58. #define OSL_EXT_STATUS_DECL(status) osl_ext_status_t status;
  59. #define OSL_EXT_TIME_FOREVER ((osl_ext_time_ms_t)(-1))
  60. typedef unsigned int osl_ext_time_ms_t;
  61. typedef unsigned int osl_ext_time_us_t;
  62. typedef unsigned int osl_ext_event_bits_t;
  63. typedef unsigned int osl_ext_interrupt_state_t;
  64. /* -----------------------------------------------------------------------
  65. * Timers.
  66. */
  67. typedef enum
  68. {
  69. /* One-shot timer. */
  70. OSL_EXT_TIMER_MODE_ONCE,
  71. /* Periodic timer. */
  72. OSL_EXT_TIMER_MODE_REPEAT
  73. } osl_ext_timer_mode_t;
  74. /* User registered callback and parameter to invoke when timer expires. */
  75. typedef void* osl_ext_timer_arg_t;
  76. typedef void (*osl_ext_timer_callback)(osl_ext_timer_arg_t arg);
  77. /* -----------------------------------------------------------------------
  78. * Tasks.
  79. */
  80. /* Task entry argument. */
  81. typedef void* osl_ext_task_arg_t;
  82. /* Task entry function. */
  83. typedef void (*osl_ext_task_entry)(osl_ext_task_arg_t arg);
  84. /* Abstract task priority levels. */
  85. typedef enum
  86. {
  87. OSL_EXT_TASK_IDLE_PRIORITY,
  88. OSL_EXT_TASK_LOW_PRIORITY,
  89. OSL_EXT_TASK_LOW_NORMAL_PRIORITY,
  90. OSL_EXT_TASK_NORMAL_PRIORITY,
  91. OSL_EXT_TASK_HIGH_NORMAL_PRIORITY,
  92. OSL_EXT_TASK_HIGHEST_PRIORITY,
  93. OSL_EXT_TASK_TIME_CRITICAL_PRIORITY,
  94. /* This must be last. */
  95. OSL_EXT_TASK_NUM_PRIORITES
  96. } osl_ext_task_priority_t;
  97. #ifndef OSL_EXT_DISABLED
  98. /* ---- Variable Externs ------------------------------------------------- */
  99. /* ---- Function Prototypes ---------------------------------------------- */
  100. /* --------------------------------------------------------------------------
  101. ** Semaphore
  102. */
  103. /****************************************************************************
  104. * Function: osl_ext_sem_create
  105. *
  106. * Purpose: Creates a counting semaphore object, which can subsequently be
  107. * used for thread notification.
  108. *
  109. * Parameters: name (in) Name to assign to the semaphore (must be unique).
  110. * init_cnt (in) Initial count that the semaphore should have.
  111. * sem (out) Newly created semaphore.
  112. *
  113. * Returns: OSL_EXT_SUCCESS if the semaphore was created successfully, or an
  114. * error code if the semaphore could not be created.
  115. *****************************************************************************
  116. */
  117. osl_ext_status_t osl_ext_sem_create(char *name, int init_cnt, osl_ext_sem_t *sem);
  118. /****************************************************************************
  119. * Function: osl_ext_sem_delete
  120. *
  121. * Purpose: Destroys a previously created semaphore object.
  122. *
  123. * Parameters: sem (mod) Semaphore object to destroy.
  124. *
  125. * Returns: OSL_EXT_SUCCESS if the semaphore was deleted successfully, or an
  126. * error code if the semaphore could not be created.
  127. *****************************************************************************
  128. */
  129. osl_ext_status_t osl_ext_sem_delete(osl_ext_sem_t *sem);
  130. /****************************************************************************
  131. * Function: osl_ext_sem_give
  132. *
  133. * Purpose: Increments the count associated with the semaphore. This will
  134. * cause one thread blocked on a take to wake up.
  135. *
  136. * Parameters: sem (mod) Semaphore object to give.
  137. *
  138. * Returns: OSL_EXT_SUCCESS if the semaphore was given successfully, or an
  139. * error code if the semaphore could not be created.
  140. *****************************************************************************
  141. */
  142. osl_ext_status_t osl_ext_sem_give(osl_ext_sem_t *sem);
  143. /****************************************************************************
  144. * Function: osl_ext_sem_take
  145. *
  146. * Purpose: Decrements the count associated with the semaphore. If the count
  147. * is less than zero, then the calling task will become blocked until
  148. * another thread does a give on the semaphore. This function will only
  149. * block the calling thread for timeout_msec milliseconds, before
  150. * returning with OSL_EXT_TIMEOUT.
  151. *
  152. * Parameters: sem (mod) Semaphore object to take.
  153. * timeout_msec (in) Number of milliseconds to wait for the
  154. * semaphore to enter a state where it can be
  155. * taken.
  156. *
  157. * Returns: OSL_EXT_SUCCESS if the semaphore was taken successfully, or an
  158. * error code if the semaphore could not be created.
  159. *****************************************************************************
  160. */
  161. osl_ext_status_t osl_ext_sem_take(osl_ext_sem_t *sem, osl_ext_time_ms_t timeout_msec);
  162. /* --------------------------------------------------------------------------
  163. ** Mutex
  164. */
  165. /****************************************************************************
  166. * Function: osl_ext_mutex_create
  167. *
  168. * Purpose: Creates a mutex object, which can subsequently be used to control
  169. * mutually exclusion of resources.
  170. *
  171. * Parameters: name (in) Name to assign to the mutex (must be unique).
  172. * mutex (out) Mutex object to initialize.
  173. *
  174. * Returns: OSL_EXT_SUCCESS if the mutex was created successfully, or an
  175. * error code if the mutex could not be created.
  176. *****************************************************************************
  177. */
  178. osl_ext_status_t osl_ext_mutex_create(char *name, osl_ext_mutex_t *mutex);
  179. /****************************************************************************
  180. * Function: osl_ext_mutex_delete
  181. *
  182. * Purpose: Destroys a previously created mutex object.
  183. *
  184. * Parameters: mutex (mod) Mutex object to destroy.
  185. *
  186. * Returns: OSL_EXT_SUCCESS if the mutex was deleted successfully, or an
  187. * error code if the mutex could not be created.
  188. *****************************************************************************
  189. */
  190. osl_ext_status_t osl_ext_mutex_delete(osl_ext_mutex_t *mutex);
  191. /****************************************************************************
  192. * Function: osl_ext_mutex_acquire
  193. *
  194. * Purpose: Acquires the indicated mutual exclusion object. If the object is
  195. * currently acquired by another task, then this function will wait
  196. * for timeout_msec milli-seconds before returning with OSL_EXT_TIMEOUT.
  197. *
  198. * Parameters: mutex (mod) Mutex object to acquire.
  199. * timeout_msec (in) Number of milliseconds to wait for the mutex.
  200. *
  201. * Returns: OSL_EXT_SUCCESS if the mutex was acquired successfully, or an
  202. * error code if the mutex could not be created.
  203. *****************************************************************************
  204. */
  205. osl_ext_status_t osl_ext_mutex_acquire(osl_ext_mutex_t *mutex, osl_ext_time_ms_t timeout_msec);
  206. /****************************************************************************
  207. * Function: osl_ext_mutex_release
  208. *
  209. * Purpose: Releases the indicated mutual exclusion object. This makes it
  210. * available for another task to acquire.
  211. *
  212. * Parameters: mutex (mod) Mutex object to release.
  213. *
  214. * Returns: OSL_EXT_SUCCESS if the mutex was released successfully, or an
  215. * error code if the mutex could not be created.
  216. *****************************************************************************
  217. */
  218. osl_ext_status_t osl_ext_mutex_release(osl_ext_mutex_t *mutex);
  219. /* --------------------------------------------------------------------------
  220. ** Timers
  221. */
  222. /****************************************************************************
  223. * Function: osl_ext_timer_create
  224. *
  225. * Purpose: Creates a timer object.
  226. *
  227. * Parameters: name (in) Name of timer.
  228. * timeout_msec (in) Invoke callback after this number of milliseconds.
  229. * mode (in) One-shot or periodic timer.
  230. * func (in) Callback function to invoke on timer expiry.
  231. * arg (in) Argument to callback function.
  232. * timer (out) Timer object to create.
  233. *
  234. * Note: The function callback occurs in interrupt context. The application is
  235. * required to provide context switch for the callback if required.
  236. *
  237. * Returns: OSL_EXT_SUCCESS if the timer was created successfully, or an
  238. * error code if the timer could not be created.
  239. *****************************************************************************
  240. */
  241. osl_ext_status_t
  242. osl_ext_timer_create(char *name, osl_ext_time_ms_t timeout_msec, osl_ext_timer_mode_t mode,
  243. osl_ext_timer_callback func, osl_ext_timer_arg_t arg, osl_ext_timer_t *timer);
  244. /****************************************************************************
  245. * Function: osl_ext_timer_delete
  246. *
  247. * Purpose: Destroys a previously created timer object.
  248. *
  249. * Parameters: timer (mod) Timer object to destroy.
  250. *
  251. * Returns: OSL_EXT_SUCCESS if the timer was created successfully, or an
  252. * error code if the timer could not be created.
  253. *****************************************************************************
  254. */
  255. osl_ext_status_t osl_ext_timer_delete(osl_ext_timer_t *timer);
  256. /****************************************************************************
  257. * Function: osl_ext_timer_start
  258. *
  259. * Purpose: Start a previously created timer object.
  260. *
  261. * Parameters: timer (in) Timer object.
  262. * timeout_msec (in) Invoke callback after this number of milliseconds.
  263. * mode (in) One-shot or periodic timer.
  264. *
  265. * Returns: OSL_EXT_SUCCESS if the timer was created successfully, or an
  266. * error code if the timer could not be created.
  267. *****************************************************************************
  268. */
  269. osl_ext_status_t
  270. osl_ext_timer_start(osl_ext_timer_t *timer,
  271. osl_ext_time_ms_t timeout_msec, osl_ext_timer_mode_t mode);
  272. /****************************************************************************
  273. * Function: osl_ext_timer_start
  274. *
  275. * Purpose: Start a previously created timer object.
  276. *
  277. * Parameters: timer (in) Timer object.
  278. * timeout_usec (in) Invoke callback after this number of micro-seconds.
  279. * mode (in) One-shot or periodic timer.
  280. *
  281. * Returns: OSL_EXT_SUCCESS if the timer was created successfully, or an
  282. * error code if the timer could not be created.
  283. *****************************************************************************
  284. */
  285. osl_ext_status_t
  286. osl_ext_timer_start_us(osl_ext_timer_t *timer,
  287. osl_ext_time_us_t timeout_usec, osl_ext_timer_mode_t mode);
  288. /****************************************************************************
  289. * Function: osl_ext_timer_stop
  290. *
  291. * Purpose: Stop a previously created timer object.
  292. *
  293. * Parameters: timer (in) Timer object.
  294. *
  295. * Returns: OSL_EXT_SUCCESS if the timer was created successfully, or an
  296. * error code if the timer could not be created.
  297. *****************************************************************************
  298. */
  299. osl_ext_status_t
  300. osl_ext_timer_stop(osl_ext_timer_t *timer);
  301. /****************************************************************************
  302. * Function: osl_ext_time_get
  303. *
  304. * Purpose: Returns incrementing time counter.
  305. *
  306. * Parameters: None.
  307. *
  308. * Returns: Returns incrementing time counter in msec.
  309. *****************************************************************************
  310. */
  311. osl_ext_time_ms_t osl_ext_time_get(void);
  312. /* --------------------------------------------------------------------------
  313. ** Tasks
  314. */
  315. /****************************************************************************
  316. * Function: osl_ext_task_create
  317. *
  318. * Purpose: Create a task.
  319. *
  320. * Parameters: name (in) Pointer to task string descriptor.
  321. * stack (in) Pointer to stack. NULL to allocate.
  322. * stack_size (in) Stack size - in bytes.
  323. * priority (in) Abstract task priority.
  324. * func (in) A pointer to the task entry point function.
  325. * arg (in) Value passed into task entry point function.
  326. * task (out) Task to create.
  327. *
  328. * Returns: OSL_EXT_SUCCESS if the task was created successfully, or an
  329. * error code if the task could not be created.
  330. *****************************************************************************
  331. */
  332. #define osl_ext_task_create(name, stack, stack_size, priority, func, arg, task) \
  333. osl_ext_task_create_ex((name), (stack), (stack_size), (priority), 0, (func), \
  334. (arg), TRUE, (task))
  335. /****************************************************************************
  336. * Function: osl_ext_task_create_ex
  337. *
  338. * Purpose: Create a task with autostart option.
  339. *
  340. * Parameters: name (in) Pointer to task string descriptor.
  341. * stack (in) Pointer to stack. NULL to allocate.
  342. * stack_size (in) Stack size - in bytes.
  343. * priority (in) Abstract task priority.
  344. * func (in) A pointer to the task entry point function.
  345. * arg (in) Value passed into task entry point function.
  346. * autostart (in) TRUE to start task after creation.
  347. * task (out) Task to create.
  348. *
  349. * Returns: OSL_EXT_SUCCESS if the task was created successfully, or an
  350. * error code if the task could not be created.
  351. *****************************************************************************
  352. */
  353. osl_ext_status_t osl_ext_task_create_ex(char* name,
  354. void *stack, unsigned int stack_size, osl_ext_task_priority_t priority,
  355. osl_ext_time_ms_t timslice_msec, osl_ext_task_entry func, osl_ext_task_arg_t arg,
  356. bool autostart, osl_ext_task_t *task);
  357. /****************************************************************************
  358. * Function: osl_ext_task_delete
  359. *
  360. * Purpose: Destroy a task.
  361. *
  362. * Parameters: task (mod) Task to destroy.
  363. *
  364. * Returns: OSL_EXT_SUCCESS if the task was created successfully, or an
  365. * error code if the task could not be created.
  366. *****************************************************************************
  367. */
  368. osl_ext_status_t osl_ext_task_delete(osl_ext_task_t *task);
  369. /****************************************************************************
  370. * Function: osl_ext_task_is_running
  371. *
  372. * Purpose: Returns current running task.
  373. *
  374. * Parameters: None.
  375. *
  376. * Returns: osl_ext_task_t of current running task.
  377. *****************************************************************************
  378. */
  379. osl_ext_task_t *osl_ext_task_current(void);
  380. /****************************************************************************
  381. * Function: osl_ext_task_yield
  382. *
  383. * Purpose: Yield the CPU to other tasks of the same priority that are
  384. * ready-to-run.
  385. *
  386. * Parameters: None.
  387. *
  388. * Returns: OSL_EXT_SUCCESS if successful, else error code.
  389. *****************************************************************************
  390. */
  391. osl_ext_status_t osl_ext_task_yield(void);
  392. /****************************************************************************
  393. * Function: osl_ext_task_yield
  394. *
  395. * Purpose: Yield the CPU to other tasks of the same priority that are
  396. * ready-to-run.
  397. *
  398. * Parameters: None.
  399. *
  400. * Returns: OSL_EXT_SUCCESS if successful, else error code.
  401. *****************************************************************************
  402. */
  403. osl_ext_status_t osl_ext_task_yield(void);
  404. /****************************************************************************
  405. * Function: osl_ext_task_suspend
  406. *
  407. * Purpose: Suspend a task.
  408. *
  409. * Parameters: task (mod) Task to suspend.
  410. *
  411. * Returns: OSL_EXT_SUCCESS if the task was suspended successfully, or an
  412. * error code if the task could not be suspended.
  413. *****************************************************************************
  414. */
  415. osl_ext_status_t osl_ext_task_suspend(osl_ext_task_t *task);
  416. /****************************************************************************
  417. * Function: osl_ext_task_resume
  418. *
  419. * Purpose: Resume a task.
  420. *
  421. * Parameters: task (mod) Task to resume.
  422. *
  423. * Returns: OSL_EXT_SUCCESS if the task was resumed successfully, or an
  424. * error code if the task could not be resumed.
  425. *****************************************************************************
  426. */
  427. osl_ext_status_t osl_ext_task_resume(osl_ext_task_t *task);
  428. /****************************************************************************
  429. * Function: osl_ext_task_enable_stack_check
  430. *
  431. * Purpose: Enable task stack checking.
  432. *
  433. * Parameters: None.
  434. *
  435. * Returns: OSL_EXT_SUCCESS if successful, else error code.
  436. *****************************************************************************
  437. */
  438. osl_ext_status_t osl_ext_task_enable_stack_check(void);
  439. /* --------------------------------------------------------------------------
  440. ** Queue
  441. */
  442. /****************************************************************************
  443. * Function: osl_ext_queue_create
  444. *
  445. * Purpose: Create a queue.
  446. *
  447. * Parameters: name (in) Name to assign to the queue (must be unique).
  448. * buffer (in) Queue buffer. NULL to allocate.
  449. * size (in) Size of the queue.
  450. * queue (out) Newly created queue.
  451. *
  452. * Returns: OSL_EXT_SUCCESS if the queue was created successfully, or an
  453. * error code if the queue could not be created.
  454. *****************************************************************************
  455. */
  456. osl_ext_status_t osl_ext_queue_create(char *name,
  457. void *queue_buffer, unsigned int queue_size,
  458. osl_ext_queue_t *queue);
  459. /****************************************************************************
  460. * Function: osl_ext_queue_delete
  461. *
  462. * Purpose: Destroys a previously created queue object.
  463. *
  464. * Parameters: queue (mod) Queue object to destroy.
  465. *
  466. * Returns: OSL_EXT_SUCCESS if the queue was deleted successfully, or an
  467. * error code if the queue could not be deleteed.
  468. *****************************************************************************
  469. */
  470. osl_ext_status_t osl_ext_queue_delete(osl_ext_queue_t *queue);
  471. /****************************************************************************
  472. * Function: osl_ext_queue_send
  473. *
  474. * Purpose: Send/add data to the queue. This function will not block the
  475. * calling thread if the queue is full.
  476. *
  477. * Parameters: queue (mod) Queue object.
  478. * data (in) Data pointer to be queued.
  479. *
  480. * Returns: OSL_EXT_SUCCESS if the data was queued successfully, or an
  481. * error code if the data could not be queued.
  482. *****************************************************************************
  483. */
  484. osl_ext_status_t osl_ext_queue_send(osl_ext_queue_t *queue, void *data);
  485. /****************************************************************************
  486. * Function: osl_ext_queue_send_synchronous
  487. *
  488. * Purpose: Send/add data to the queue. This function will block the
  489. * calling thread until the data is dequeued.
  490. *
  491. * Parameters: queue (mod) Queue object.
  492. * data (in) Data pointer to be queued.
  493. *
  494. * Returns: OSL_EXT_SUCCESS if the data was queued successfully, or an
  495. * error code if the data could not be queued.
  496. *****************************************************************************
  497. */
  498. osl_ext_status_t osl_ext_queue_send_synchronous(osl_ext_queue_t *queue, void *data);
  499. /****************************************************************************
  500. * Function: osl_ext_queue_receive
  501. *
  502. * Purpose: Receive/remove data from the queue. This function will only
  503. * block the calling thread for timeout_msec milliseconds, before
  504. * returning with OSL_EXT_TIMEOUT.
  505. *
  506. * Parameters: queue (mod) Queue object.
  507. * timeout_msec (in) Number of milliseconds to wait for the
  508. * data from the queue.
  509. * data (out) Data pointer received/removed from the queue.
  510. *
  511. * Returns: OSL_EXT_SUCCESS if the data was dequeued successfully, or an
  512. * error code if the data could not be dequeued.
  513. *****************************************************************************
  514. */
  515. osl_ext_status_t osl_ext_queue_receive(osl_ext_queue_t *queue,
  516. osl_ext_time_ms_t timeout_msec, void **data);
  517. /****************************************************************************
  518. * Function: osl_ext_queue_count
  519. *
  520. * Purpose: Returns the number of items in the queue.
  521. *
  522. * Parameters: queue (mod) Queue object.
  523. * count (out) Data pointer received/removed from the queue.
  524. *
  525. * Returns: OSL_EXT_SUCCESS if the count was returned successfully, or an
  526. * error code if the count is invalid.
  527. *****************************************************************************
  528. */
  529. osl_ext_status_t osl_ext_queue_count(osl_ext_queue_t *queue, int *count);
  530. /* --------------------------------------------------------------------------
  531. ** Event
  532. */
  533. /****************************************************************************
  534. * Function: osl_ext_event_create
  535. *
  536. * Purpose: Creates a event object, which can subsequently be used to
  537. * notify and trigger tasks.
  538. *
  539. * Parameters: name (in) Name to assign to the event (must be unique).
  540. * event (out) Event object to initialize.
  541. *
  542. * Returns: OSL_EXT_SUCCESS if the event was created successfully, or an
  543. * error code if the event could not be created.
  544. *****************************************************************************
  545. */
  546. osl_ext_status_t osl_ext_event_create(char *name, osl_ext_event_t *event);
  547. /****************************************************************************
  548. * Function: osl_ext_event_delete
  549. *
  550. * Purpose: Destroys a previously created event object.
  551. *
  552. * Parameters: event (mod) Event object to destroy.
  553. *
  554. * Returns: OSL_EXT_SUCCESS if the event was created successfully, or an
  555. * error code if the event could not be created.
  556. *****************************************************************************
  557. */
  558. osl_ext_status_t osl_ext_event_delete(osl_ext_event_t *event);
  559. /****************************************************************************
  560. * Function: osl_ext_event_get
  561. *
  562. * Purpose: Get event from specified event object.
  563. *
  564. * Parameters: event (mod) Event object to get.
  565. * requested (in) Requested event to get.
  566. * timeout_msec (in) Number of milliseconds to wait for the event.
  567. * event_bits (out) Event bits retrieved.
  568. *
  569. * Returns: OSL_EXT_SUCCESS if the event was created successfully, or an
  570. * error code if the event could not be created.
  571. *****************************************************************************
  572. */
  573. osl_ext_status_t osl_ext_event_get(osl_ext_event_t *event,
  574. osl_ext_event_bits_t requested, osl_ext_time_ms_t timeout_msec,
  575. osl_ext_event_bits_t *event_bits);
  576. /****************************************************************************
  577. * Function: osl_ext_event_set
  578. *
  579. * Purpose: Set event of specified event object.
  580. *
  581. * Parameters: event (mod) Event object to set.
  582. * event_bits (in) Event bits to set.
  583. *
  584. * Returns: OSL_EXT_SUCCESS if the event was created successfully, or an
  585. * error code if the event could not be created.
  586. *****************************************************************************
  587. */
  588. osl_ext_status_t osl_ext_event_set(osl_ext_event_t *event,
  589. osl_ext_event_bits_t event_bits);
  590. /* --------------------------------------------------------------------------
  591. ** Interrupt
  592. */
  593. /****************************************************************************
  594. * Function: osl_ext_interrupt_disable
  595. *
  596. * Purpose: Disable CPU interrupt.
  597. *
  598. * Parameters: None.
  599. *
  600. * Returns: The interrupt state before disable for restoring interrupt.
  601. *****************************************************************************
  602. */
  603. osl_ext_interrupt_state_t osl_ext_interrupt_disable(void);
  604. /****************************************************************************
  605. * Function: osl_ext_interrupt_restore
  606. *
  607. * Purpose: Restore CPU interrupt state.
  608. *
  609. * Parameters: state (in) Interrupt state to restore returned from
  610. * osl_ext_interrupt_disable().
  611. *
  612. * Returns: None.
  613. *****************************************************************************
  614. */
  615. void osl_ext_interrupt_restore(osl_ext_interrupt_state_t state);
  616. #else
  617. /* ---- Constants and Types ---------------------------------------------- */
  618. /* Interrupt control */
  619. #define OSL_INTERRUPT_SAVE_AREA
  620. #define OSL_DISABLE
  621. #define OSL_RESTORE
  622. /* Semaphore. */
  623. #define osl_ext_sem_t
  624. #define OSL_EXT_SEM_DECL(sem)
  625. /* Mutex. */
  626. #define osl_ext_mutex_t
  627. #define OSL_EXT_MUTEX_DECL(mutex)
  628. /* Timer. */
  629. #define osl_ext_timer_t
  630. #define OSL_EXT_TIMER_DECL(timer)
  631. /* Task. */
  632. #define osl_ext_task_t void
  633. #define OSL_EXT_TASK_DECL(task)
  634. /* Queue. */
  635. #define osl_ext_queue_t
  636. #define OSL_EXT_QUEUE_DECL(queue)
  637. /* Event. */
  638. #define osl_ext_event_t
  639. #define OSL_EXT_EVENT_DECL(event)
  640. /* ---- Variable Externs ------------------------------------------------- */
  641. /* ---- Function Prototypes ---------------------------------------------- */
  642. #define osl_ext_sem_create(name, init_cnt, sem) (OSL_EXT_SUCCESS)
  643. #define osl_ext_sem_delete(sem) (OSL_EXT_SUCCESS)
  644. #define osl_ext_sem_give(sem) (OSL_EXT_SUCCESS)
  645. #define osl_ext_sem_take(sem, timeout_msec) (OSL_EXT_SUCCESS)
  646. #define osl_ext_mutex_create(name, mutex) (OSL_EXT_SUCCESS)
  647. #define osl_ext_mutex_delete(mutex) (OSL_EXT_SUCCESS)
  648. #define osl_ext_mutex_acquire(mutex, timeout_msec) (OSL_EXT_SUCCESS)
  649. #define osl_ext_mutex_release(mutex) (OSL_EXT_SUCCESS)
  650. #define osl_ext_timer_create(name, timeout_msec, mode, func, arg, timer) \
  651. (OSL_EXT_SUCCESS)
  652. #define osl_ext_timer_delete(timer) (OSL_EXT_SUCCESS)
  653. #define osl_ext_timer_start(timer, timeout_msec, mode) (OSL_EXT_SUCCESS)
  654. #define osl_ext_timer_stop(timer) (OSL_EXT_SUCCESS)
  655. #define osl_ext_time_get() (0)
  656. #define osl_ext_task_create(name, stack, stack_size, priority, func, arg, task) \
  657. (OSL_EXT_SUCCESS)
  658. #define osl_ext_task_delete(task) (OSL_EXT_SUCCESS)
  659. #define osl_ext_task_current() (NULL)
  660. #define osl_ext_task_yield() (OSL_EXT_SUCCESS)
  661. #define osl_ext_task_enable_stack_check() (OSL_EXT_SUCCESS)
  662. #define osl_ext_queue_create(name, queue_buffer, queue_size, queue) \
  663. (OSL_EXT_SUCCESS)
  664. #define osl_ext_queue_delete(queue) (OSL_EXT_SUCCESS)
  665. #define osl_ext_queue_send(queue, data) (OSL_EXT_SUCCESS)
  666. #define osl_ext_queue_send_synchronous(queue, data) (OSL_EXT_SUCCESS)
  667. #define osl_ext_queue_receive(queue, timeout_msec, data) \
  668. (OSL_EXT_SUCCESS)
  669. #define osl_ext_queue_count(queue, count) (OSL_EXT_SUCCESS)
  670. #define osl_ext_event_create(name, event) (OSL_EXT_SUCCESS)
  671. #define osl_ext_event_delete(event) (OSL_EXT_SUCCESS)
  672. #define osl_ext_event_get(event, requested, timeout_msec, event_bits) \
  673. (OSL_EXT_SUCCESS)
  674. #define osl_ext_event_set(event, event_bits) (OSL_EXT_SUCCESS)
  675. #define osl_ext_interrupt_disable(void)
  676. #define osl_ext_interrupt_restore(state)
  677. #endif /* OSL_EXT_DISABLED */
  678. #ifdef __cplusplus
  679. }
  680. #endif // endif
  681. #endif /* _osl_ext_h_ */