IxOsal.h 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517
  1. /**
  2. * @file IxOsal.h
  3. *
  4. * @brief Top include file for OSAL
  5. *
  6. *
  7. * @par
  8. * IXP400 SW Release version 2.0
  9. *
  10. * -- Copyright Notice --
  11. *
  12. * @par
  13. * Copyright 2001-2005, Intel Corporation.
  14. * All rights reserved.
  15. *
  16. * @par
  17. * Redistribution and use in source and binary forms, with or without
  18. * modification, are permitted provided that the following conditions
  19. * are met:
  20. * 1. Redistributions of source code must retain the above copyright
  21. * notice, this list of conditions and the following disclaimer.
  22. * 2. Redistributions in binary form must reproduce the above copyright
  23. * notice, this list of conditions and the following disclaimer in the
  24. * documentation and/or other materials provided with the distribution.
  25. * 3. Neither the name of the Intel Corporation nor the names of its contributors
  26. * may be used to endorse or promote products derived from this software
  27. * without specific prior written permission.
  28. *
  29. * @par
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
  31. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  32. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  34. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  38. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  39. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  40. * SUCH DAMAGE.
  41. *
  42. * @par
  43. * -- End of Copyright Notice --
  44. */
  45. #ifndef IxOsal_H
  46. #define IxOsal_H
  47. /* Basic types */
  48. #include "IxOsalTypes.h"
  49. /* Include assert */
  50. #include "IxOsalAssert.h"
  51. /*
  52. * Config header gives users option to choose IO MEM
  53. * and buffer management modules
  54. */
  55. #include "IxOsalConfig.h"
  56. /*
  57. * Symbol file needed by some OS.
  58. */
  59. #include "IxOsalUtilitySymbols.h"
  60. /* OS-specific header */
  61. #include "IxOsalOs.h"
  62. /**
  63. * @defgroup IxOsal Operating System Abstraction Layer (IxOsal) API
  64. *
  65. * @brief This service provides a thin layer of OS dependency services.
  66. *
  67. * This file contains the API to the functions which are some what OS dependant and would
  68. * require porting to a particular OS.
  69. * A primary focus of the component development is to make them as OS independent as possible.
  70. * All other components should abstract their OS dependency to this module.
  71. * Services overview
  72. * -# Data types, constants, defines
  73. * -# Interrupts
  74. * - bind interrupts to handlers
  75. * - unbind interrupts from handlers
  76. * - disables all interrupts
  77. * - enables all interrupts
  78. * - selectively disables interrupts
  79. * - enables an interrupt level
  80. * - disables an interrupt level
  81. * -# Memory
  82. * - allocates memory
  83. * - frees memory
  84. * - copies memory zones
  85. * - fills a memory zone
  86. * - allocates cache-safe memory
  87. * - frees cache-safe memory
  88. * - physical to virtual address translation
  89. * - virtual to physical address translation
  90. * - cache to memory flush
  91. * - cache line invalidate
  92. * -# Threads
  93. * - creates a new thread
  94. * - starts a newly created thread
  95. * - kills an existing thread
  96. * - exits a running thread
  97. * - sets the priority of an existing thread
  98. * - suspends thread execution
  99. * - resumes thread execution
  100. * -# IPC
  101. * - creates a message queue
  102. * - deletes a message queue
  103. * - sends a message to a message queue
  104. * - receives a message from a message queue
  105. * -# Thread Synchronisation
  106. * - initializes a mutex
  107. * - locks a mutex
  108. * - unlocks a mutex
  109. * - non-blocking attempt to lock a mutex
  110. * - destroys a mutex object
  111. * - initializes a fast mutex
  112. * - non-blocking attempt to lock a fast mutex
  113. * - unlocks a fast mutex
  114. * - destroys a fast mutex object
  115. * - initializes a semaphore
  116. * - posts to (increments) a semaphore
  117. * - waits on (decrements) a semaphore
  118. * - non-blocking wait on semaphore
  119. * - gets semaphore value
  120. * - destroys a semaphore object
  121. * - yields execution of current thread
  122. * -# Time functions
  123. * - yielding sleep for a number of milliseconds
  124. * - busy sleep for a number of microseconds
  125. * - value of the timestamp counter
  126. * - resolution of the timestamp counter
  127. * - system clock rate, in ticks
  128. * - current system time
  129. * - converts ixOsalTimeVal into ticks
  130. * - converts ticks into ixOsalTimeVal
  131. * - converts ixOsalTimeVal to milliseconds
  132. * - converts milliseconds to IxOsalTimeval
  133. * - "equal" comparison for IxOsalTimeval
  134. * - "less than" comparison for IxOsalTimeval
  135. * - "greater than" comparison for IxOsalTimeval
  136. * - "add" operator for IxOsalTimeval
  137. * - "subtract" operator for IxOsalTimeval
  138. * -# Logging
  139. * - sets the current logging verbosity level
  140. * - interrupt-safe logging function
  141. * -# Timer services
  142. * - schedules a repeating timer
  143. * - schedules a single-shot timer
  144. * - cancels a running timer
  145. * - displays all the running timers
  146. * -# Optional Modules
  147. * - Buffer management module
  148. * - I/O memory and endianess support module
  149. *
  150. * @{
  151. */
  152. /*
  153. * Prototypes
  154. */
  155. /* ========================== Interrupts ================================
  156. *
  157. */
  158. /**
  159. * @ingroup IxOsal
  160. *
  161. * @brief Binds an interrupt handler to an interrupt level
  162. *
  163. * @param irqLevel (in) - interrupt level
  164. * @param irqHandler (in) - interrupt handler
  165. * @param parameter (in) - custom parameter to be passed to the
  166. * interrupt handler
  167. *
  168. * Binds an interrupt handler to an interrupt level. The operation will
  169. * fail if the wrong level is selected, if the handler is NULL, or if the
  170. * interrupt is already bound. This functions binds the specified C
  171. * routine to an interrupt level. When called, the "parameter" value will
  172. * be passed to the routine.
  173. *
  174. * Reentrant: no
  175. * IRQ safe: no
  176. *
  177. * @return IX_SUCCESS if the operation succeeded or IX_FAIL otherwise
  178. */
  179. PUBLIC IX_STATUS ixOsalIrqBind (UINT32 irqLevel,
  180. IxOsalVoidFnVoidPtr irqHandler,
  181. void *parameter);
  182. /**
  183. * @ingroup IxOsal
  184. *
  185. * @brief Unbinds an interrupt handler from an interrupt level
  186. *
  187. * @param irqLevel (in) - interrupt level
  188. *
  189. * Unbinds the selected interrupt level from any previously registered
  190. * handler
  191. *
  192. * @li Reentrant: no
  193. * @li IRQ safe: no
  194. *
  195. * @return IX_SUCCESS if the operation succeeded or IX_FAIL otherwise
  196. */
  197. PUBLIC IX_STATUS ixOsalIrqUnbind (UINT32 irqLevel);
  198. /**
  199. * @ingroup IxOsal
  200. *
  201. * @brief Disables all interrupts
  202. *
  203. * @param - none
  204. *
  205. * Disables all the interrupts and prevents tasks scheduling
  206. *
  207. * @li Reentrant: no
  208. * @li IRQ safe: yes
  209. *
  210. * @return interrupt enable status prior to locking
  211. */
  212. PUBLIC UINT32 ixOsalIrqLock (void);
  213. /**
  214. * @ingroup IxOsal
  215. *
  216. * @brief Enables all interrupts
  217. *
  218. * @param irqEnable (in) - interrupt enable status, prior to interrupt
  219. * locking
  220. *
  221. * Enables the interrupts and task scheduling, cancelling the effect
  222. * of ixOsalIrqLock()
  223. *
  224. * @li Reentrant: no
  225. * @li IRQ safe: yes
  226. *
  227. * @return IX_SUCCESS if the operation succeeded or IX_FAIL otherwise
  228. */
  229. PUBLIC void ixOsalIrqUnlock (UINT32 irqEnable);
  230. /**
  231. * @ingroup IxOsal
  232. *
  233. * @brief Selectively disables interrupts
  234. *
  235. * @param irqLevel ­ new interrupt level
  236. *
  237. * Disables the interrupts below the specified interrupt level
  238. *
  239. * @li Reentrant: no
  240. * @li IRQ safe: yes
  241. *
  242. * @note Depending on the implementation this function can disable all
  243. * the interrupts
  244. *
  245. * @return previous interrupt level
  246. */
  247. PUBLIC UINT32 ixOsalIrqLevelSet (UINT32 irqLevel);
  248. /**
  249. * @ingroup IxOsal
  250. *
  251. * @brief Enables an interrupt level
  252. *
  253. * @param irqLevel ­ interrupt level to enable
  254. *
  255. * Enables the specified interrupt level
  256. *
  257. * @li Reentrant: no
  258. * @li IRQ safe: yes
  259. *
  260. * @return - none
  261. */
  262. PUBLIC void ixOsalIrqEnable (UINT32 irqLevel);
  263. /**
  264. * @ingroup IxOsal
  265. *
  266. * @brief Disables an interrupt level
  267. *
  268. * @param irqLevel ­ interrupt level to disable
  269. *
  270. * Disables the specified interrupt level
  271. *
  272. * @li Reentrant: no
  273. * @li IRQ safe: yes
  274. *
  275. * @return - none
  276. */
  277. PUBLIC void ixOsalIrqDisable (UINT32 irqLevel);
  278. /* ============================= Memory =================================
  279. *
  280. */
  281. /**
  282. * @ingroup IxOsal
  283. *
  284. * @brief Allocates memory
  285. *
  286. * @param size - memory size to allocate, in bytes
  287. *
  288. * Allocates a memory zone of a given size
  289. *
  290. * @li Reentrant: no
  291. * @li IRQ safe: no
  292. *
  293. * @return Pointer to the allocated zone or NULL if the allocation failed
  294. */
  295. PUBLIC void *ixOsalMemAlloc (UINT32 size);
  296. /**
  297. * @ingroup IxOsal
  298. *
  299. * @brief Frees memory
  300. *
  301. * @param ptr - pointer to the memory zone
  302. *
  303. * Frees a previously allocated memory zone
  304. *
  305. * @li Reentrant: no
  306. * @li IRQ safe: no
  307. *
  308. * @return - none
  309. */
  310. PUBLIC void ixOsalMemFree (void *ptr);
  311. /**
  312. * @ingroup IxOsal
  313. *
  314. * @brief Copies memory zones
  315. *
  316. * @param dest - destination memory zone
  317. * @param src - source memory zone
  318. * @param count - number of bytes to copy
  319. *
  320. * Copies count bytes from the source memory zone pointed by src into the
  321. * memory zone pointed by dest.
  322. *
  323. * @li Reentrant: no
  324. * @li IRQ safe: yes
  325. *
  326. * @return Pointer to the destination memory zone
  327. */
  328. PUBLIC void *ixOsalMemCopy (void *dest, void *src, UINT32 count);
  329. /**
  330. * @ingroup IxOsal
  331. *
  332. * @brief Fills a memory zone
  333. *
  334. * @param ptr - pointer to the memory zone
  335. * @param filler - byte to fill the memory zone with
  336. * @param count - number of bytes to fill
  337. *
  338. * Fills a memory zone with a given constant byte
  339. *
  340. * @li Reentrant: no
  341. * @li IRQ safe: yes
  342. *
  343. * @return Pointer to the memory zone
  344. */
  345. PUBLIC void *ixOsalMemSet (void *ptr, UINT8 filler, UINT32 count);
  346. /**
  347. * @ingroup IxOsal
  348. *
  349. * @brief Allocates cache-safe memory
  350. *
  351. * @param size - size, in bytes, of the allocated zone
  352. *
  353. * Allocates a cache-safe memory zone of at least "size" bytes and returns
  354. * the pointer to the memory zone. This memory zone, depending on the
  355. * platform, is either uncached or aligned on a cache line boundary to make
  356. * the CACHE_FLUSH and CACHE_INVALIDATE macros safe to use. The memory
  357. * allocated with this function MUST be freed with ixOsalCacheDmaFree(),
  358. * otherwise memory corruption can occur.
  359. *
  360. * @li Reentrant: no
  361. * @li IRQ safe: no
  362. *
  363. * @return Pointer to the memory zone or NULL if allocation failed
  364. *
  365. * @note It is important to note that cache coherence is maintained in
  366. * software by using the IX_OSAL_CACHE_FLUSH and IX_OSAL_CACHE_INVALIDATE
  367. * macros to maintain consistency between cache and external memory.
  368. */
  369. PUBLIC void *ixOsalCacheDmaMalloc (UINT32 size);
  370. /* Macros for ixOsalCacheDmaMalloc*/
  371. #define IX_OSAL_CACHE_DMA_MALLOC(size) ixOsalCacheDmaMalloc(size)
  372. /**
  373. * @ingroup IxOsal
  374. *
  375. * @brief Frees cache-safe memory
  376. *
  377. * @param ptr - pointer to the memory zone
  378. *
  379. * Frees a memory zone previously allocated with ixOsalCacheDmaMalloc()
  380. *
  381. * @li Reentrant: no
  382. * @li IRQ safe: no
  383. *
  384. * @return - none
  385. */
  386. PUBLIC void ixOsalCacheDmaFree (void *ptr);
  387. #define IX_OSAL_CACHE_DMA_FREE(ptr) ixOsalCacheDmaFree(ptr)
  388. /**
  389. * @ingroup IxOsal
  390. *
  391. * @brief physical to virtual address translation
  392. *
  393. * @param physAddr - physical address
  394. *
  395. * Converts a physical address into its equivalent MMU-mapped virtual address
  396. *
  397. * @li Reentrant: no
  398. * @li IRQ safe: yes
  399. *
  400. * @return Corresponding virtual address, as UINT32
  401. */
  402. #define IX_OSAL_MMU_PHYS_TO_VIRT(physAddr) \
  403. IX_OSAL_OS_MMU_PHYS_TO_VIRT(physAddr)
  404. /**
  405. * @ingroup IxOsal
  406. *
  407. * @brief virtual to physical address translation
  408. *
  409. * @param virtAddr - virtual address
  410. *
  411. * Converts a virtual address into its equivalent MMU-mapped physical address
  412. *
  413. * @li Reentrant: no
  414. * @li IRQ safe: yes
  415. *
  416. * @return Corresponding physical address, as UINT32
  417. */
  418. #define IX_OSAL_MMU_VIRT_TO_PHYS(virtAddr) \
  419. IX_OSAL_OS_MMU_VIRT_TO_PHYS(virtAddr)
  420. /**
  421. * @ingroup IxOsal
  422. *
  423. * @brief cache to memory flush
  424. *
  425. * @param addr - memory address to flush from cache
  426. * @param size - number of bytes to flush (rounded up to a cache line)
  427. *
  428. * Flushes the cached value of the memory zone pointed by "addr" into memory,
  429. * rounding up to a cache line. Use before the zone is to be read by a
  430. * processing unit which is not cache coherent with the main CPU.
  431. *
  432. * @li Reentrant: no
  433. * @li IRQ safe: yes
  434. *
  435. * @return - none
  436. */
  437. #define IX_OSAL_CACHE_FLUSH(addr, size) IX_OSAL_OS_CACHE_FLUSH(addr, size)
  438. /**
  439. * @ingroup IxOsal
  440. *
  441. * @brief cache line invalidate
  442. *
  443. * @param addr - memory address to invalidate in cache
  444. * @param size - number of bytes to invalidate (rounded up to a cache line)
  445. *
  446. * Invalidates the cached value of the memory zone pointed by "addr",
  447. * rounding up to a cache line. Use before reading the zone from the main
  448. * CPU, if the zone has been updated by a processing unit which is not cache
  449. * coherent with the main CPU.
  450. *
  451. * @li Reentrant: no
  452. * @li IRQ safe: yes
  453. *
  454. * @return - none
  455. */
  456. #define IX_OSAL_CACHE_INVALIDATE(addr, size) IX_OSAL_OS_CACHE_INVALIDATE(addr, size)
  457. /* ============================= Threads =================================
  458. *
  459. */
  460. /**
  461. * @ingroup IxOsal
  462. *
  463. * @brief Creates a new thread
  464. *
  465. * @param thread - handle of the thread to be created
  466. * @param threadAttr - pointer to a thread attribute object
  467. * @param startRoutine - thread entry point
  468. * @param arg - argument given to the thread
  469. *
  470. * Creates a thread given a thread handle and a thread attribute object. The
  471. * same thread attribute object can be used to create separate threads. "NULL"
  472. * can be specified as the attribute, in which case the default values will
  473. * be used. The thread needs to be explicitly started using ixOsalThreadStart().
  474. *
  475. * @li Reentrant: no
  476. * @li IRQ safe: no
  477. *
  478. * @return - IX_SUCCESS/IX_FAIL
  479. */
  480. PUBLIC IX_STATUS ixOsalThreadCreate (IxOsalThread * thread,
  481. IxOsalThreadAttr * threadAttr,
  482. IxOsalVoidFnVoidPtr startRoutine,
  483. void *arg);
  484. /**
  485. * @ingroup IxOsal
  486. *
  487. * @brief Starts a newly created thread
  488. *
  489. * @param thread - handle of the thread to be started
  490. *
  491. * Starts a thread given its thread handle. This function is to be called
  492. * only once, following the thread initialization.
  493. *
  494. * @li Reentrant: no
  495. * @li IRQ safe: no
  496. *
  497. * @return - IX_SUCCESS/IX_FAIL
  498. */
  499. PUBLIC IX_STATUS ixOsalThreadStart (IxOsalThread * thread);
  500. /**
  501. * @ingroup IxOsal
  502. *
  503. * @brief Kills an existing thread
  504. *
  505. * @param thread - handle of the thread to be killed
  506. *
  507. * Kills a thread given its thread handle.
  508. *
  509. * @li Reentrant: no
  510. * @li IRQ safe: no
  511. *
  512. * @note It is not possible to kill threads in Linux kernel mode. This
  513. * function will only send a SIGTERM signal, and it is the responsibility
  514. * of the thread to check for the presence of this signal with
  515. * signal_pending().
  516. *
  517. * @return - IX_SUCCESS/IX_FAIL
  518. */
  519. PUBLIC IX_STATUS ixOsalThreadKill (IxOsalThread * thread);
  520. /**
  521. * @ingroup IxOsal
  522. *
  523. * @brief Exits a running thread
  524. *
  525. * Terminates the calling thread
  526. *
  527. * @li Reentrant: no
  528. * @li IRQ safe: no
  529. *
  530. * @return - This function never returns
  531. */
  532. PUBLIC void ixOsalThreadExit (void);
  533. /**
  534. * @ingroup IxOsal
  535. *
  536. * @brief Sets the priority of an existing thread
  537. *
  538. * @param thread - handle of the thread
  539. * @param priority - new priority, between 0 and 255 (0 being the highest)
  540. *
  541. * Sets the thread priority
  542. *
  543. * @li Reentrant: no
  544. * @li IRQ safe: no
  545. *
  546. * @return - IX_SUCCESS/IX_FAIL
  547. */
  548. PUBLIC IX_STATUS ixOsalThreadPrioritySet (IxOsalThread * thread,
  549. UINT32 priority);
  550. /**
  551. * @ingroup IxOsal
  552. *
  553. * @brief Suspends thread execution
  554. *
  555. * @param thread - handle of the thread
  556. *
  557. * Suspends the thread execution
  558. *
  559. * @li Reentrant: no
  560. * @li IRQ safe: no
  561. *
  562. * @return - IX_SUCCESS/IX_FAIL
  563. */
  564. PUBLIC IX_STATUS ixOsalThreadSuspend (IxOsalThread * thread);
  565. /**
  566. * @ingroup IxOsal
  567. *
  568. * @brief Resumes thread execution
  569. *
  570. * @param thread - handle of the thread
  571. *
  572. * Resumes the thread execution
  573. *
  574. * @li Reentrant: no
  575. * @li IRQ safe: no
  576. *
  577. * @return - IX_SUCCESS/IX_FAIL
  578. */
  579. PUBLIC IX_STATUS ixOsalThreadResume (IxOsalThread * thread);
  580. /* ======================= Message Queues (IPC) ==========================
  581. *
  582. */
  583. /**
  584. * @ingroup IxOsal
  585. *
  586. * @brief Creates a message queue
  587. *
  588. * @param queue - queue handle
  589. * @param msgCount - maximum number of messages to hold in the queue
  590. * @param msgLen - maximum length of each message, in bytes
  591. *
  592. * Creates a message queue of msgCount messages, each containing msgLen bytes
  593. *
  594. * @li Reentrant: no
  595. * @li IRQ safe: no
  596. *
  597. * @return - IX_SUCCESS/IX_FAIL
  598. */
  599. PUBLIC IX_STATUS ixOsalMessageQueueCreate (IxOsalMessageQueue * queue,
  600. UINT32 msgCount, UINT32 msgLen);
  601. /**
  602. * @ingroup IxOsal
  603. *
  604. * @brief Deletes a message queue
  605. *
  606. * @param queue - queue handle
  607. *
  608. * Deletes a message queue
  609. *
  610. * @li Reentrant: no
  611. * @li IRQ safe: no
  612. *
  613. * @return - IX_SUCCESS/IX_FAIL
  614. */
  615. PUBLIC IX_STATUS ixOsalMessageQueueDelete (IxOsalMessageQueue * queue);
  616. /**
  617. * @ingroup IxOsal
  618. *
  619. * @brief Sends a message to a message queue
  620. *
  621. * @param queue - queue handle
  622. * @param message - message to send
  623. *
  624. * Sends a message to the message queue. The message will be copied (at the
  625. * configured size of the message) into the queue.
  626. *
  627. * @li Reentrant: yes
  628. * @li IRQ safe: yes
  629. *
  630. * @return - IX_SUCCESS/IX_FAIL
  631. */
  632. PUBLIC IX_STATUS ixOsalMessageQueueSend (IxOsalMessageQueue * queue,
  633. UINT8 * message);
  634. /**
  635. * @ingroup IxOsal
  636. *
  637. * @brief Receives a message from a message queue
  638. *
  639. * @param queue - queue handle
  640. * @param message - pointer to where the message should be copied to
  641. *
  642. * Retrieves the first message from the message queue
  643. *
  644. * @li Reentrant: yes
  645. * @li IRQ safe: yes
  646. *
  647. * @return - IX_SUCCESS/IX_FAIL
  648. */
  649. PUBLIC IX_STATUS ixOsalMessageQueueReceive (IxOsalMessageQueue * queue,
  650. UINT8 * message);
  651. /* ======================= Thread Synchronisation ========================
  652. *
  653. */
  654. /**
  655. * @ingroup IxOsal
  656. *
  657. * @brief initializes a mutex
  658. *
  659. * @param mutex - mutex handle
  660. *
  661. * Initializes a mutex object
  662. *
  663. * @li Reentrant: no
  664. * @li IRQ safe: no
  665. *
  666. * @return - IX_SUCCESS/IX_FAIL
  667. */
  668. PUBLIC IX_STATUS ixOsalMutexInit (IxOsalMutex * mutex);
  669. /**
  670. * @ingroup IxOsal
  671. *
  672. * @brief locks a mutex
  673. *
  674. * @param mutex - mutex handle
  675. * @param timeout - timeout in ms; IX_OSAL_WAIT_FOREVER (-1) to wait forever
  676. * or IX_OSAL_WAIT_NONE to return immediately
  677. *
  678. * Locks a mutex object
  679. *
  680. * @li Reentrant: yes
  681. * @li IRQ safe: no
  682. *
  683. * @return - IX_SUCCESS/IX_FAIL
  684. */
  685. PUBLIC IX_STATUS ixOsalMutexLock (IxOsalMutex * mutex, INT32 timeout);
  686. /**
  687. * @ingroup IxOsal
  688. *
  689. * @brief Unlocks a mutex
  690. *
  691. * @param mutex - mutex handle
  692. *
  693. * Unlocks a mutex object
  694. *
  695. * @li Reentrant: yes
  696. * @li IRQ safe: yes
  697. *
  698. * @return - IX_SUCCESS/IX_FAIL
  699. */
  700. PUBLIC IX_STATUS ixOsalMutexUnlock (IxOsalMutex * mutex);
  701. /**
  702. * @ingroup IxOsal
  703. *
  704. * @brief Non-blocking attempt to lock a mutex
  705. *
  706. * @param mutex - mutex handle
  707. *
  708. * Attempts to lock a mutex object, returning immediately with IX_SUCCESS if
  709. * the lock was successful or IX_FAIL if the lock failed
  710. *
  711. * @li Reentrant: yes
  712. * @li IRQ safe: no
  713. *
  714. * @return - IX_SUCCESS/IX_FAIL
  715. */
  716. PUBLIC IX_STATUS ixOsalMutexTryLock (IxOsalMutex * mutex);
  717. /**
  718. * @ingroup IxOsal
  719. *
  720. * @brief Destroys a mutex object
  721. *
  722. * @param mutex - mutex handle
  723. * @param
  724. *
  725. * Destroys a mutex object; the caller should ensure that no thread is
  726. * blocked on this mutex
  727. *
  728. * @li Reentrant: no
  729. * @li IRQ safe: no
  730. *
  731. * @return - IX_SUCCESS/IX_FAIL
  732. */
  733. PUBLIC IX_STATUS ixOsalMutexDestroy (IxOsalMutex * mutex);
  734. /**
  735. * @ingroup IxOsal
  736. *
  737. * @brief Initializes a fast mutex
  738. *
  739. * @param mutex - fast mutex handle
  740. *
  741. * Initializes a fast mutex object
  742. *
  743. * @li Reentrant: yes
  744. * @li IRQ safe: yes
  745. *
  746. * @return - IX_SUCCESS/IX_FAIL
  747. */
  748. PUBLIC IX_STATUS ixOsalFastMutexInit (IxOsalFastMutex * mutex);
  749. /**
  750. * @ingroup IxOsal
  751. *
  752. * @brief Non-blocking attempt to lock a fast mutex
  753. *
  754. * @param mutex - fast mutex handle
  755. *
  756. * Attempts to lock a fast mutex object, returning immediately with
  757. * IX_SUCCESS if the lock was successful or IX_FAIL if the lock failed
  758. *
  759. * @li Reentrant: yes
  760. * @li IRQ safe: yes
  761. *
  762. * @return - IX_SUCCESS/IX_FAIL
  763. */
  764. PUBLIC IX_STATUS ixOsalFastMutexTryLock (IxOsalFastMutex * mutex);
  765. /**
  766. * @ingroup IxOsal
  767. *
  768. * @brief Unlocks a fast mutex
  769. *
  770. * @param mutex - fast mutex handle
  771. *
  772. * Unlocks a fast mutex object
  773. *
  774. * @li Reentrant: yes
  775. * @li IRQ safe: yes
  776. *
  777. * @return - IX_SUCCESS/IX_FAIL
  778. */
  779. PUBLIC IX_STATUS ixOsalFastMutexUnlock (IxOsalFastMutex * mutex);
  780. /**
  781. * @ingroup IxOsal
  782. *
  783. * @brief Destroys a fast mutex object
  784. *
  785. * @param mutex - fast mutex handle
  786. *
  787. * Destroys a fast mutex object
  788. *
  789. * @li Reentrant: yes
  790. * @li IRQ safe: yes
  791. *
  792. * @return - IX_SUCCESS/IX_FAIL
  793. */
  794. PUBLIC IX_STATUS ixOsalFastMutexDestroy (IxOsalFastMutex * mutex);
  795. /**
  796. * @ingroup IxOsal
  797. *
  798. * @brief Initializes a semaphore
  799. *
  800. * @param semaphore - semaphore handle
  801. * @param value - initial semaphore value
  802. *
  803. * Initializes a semaphore object
  804. *
  805. * @li Reentrant: no
  806. * @li IRQ safe: no
  807. *
  808. * @return - IX_SUCCESS/IX_FAIL
  809. */
  810. PUBLIC IX_STATUS ixOsalSemaphoreInit (IxOsalSemaphore * semaphore,
  811. UINT32 value);
  812. /**
  813. * @ingroup IxOsal
  814. *
  815. * @brief Posts to (increments) a semaphore
  816. *
  817. * @param semaphore - semaphore handle
  818. *
  819. * Increments a semaphore object
  820. *
  821. * @li Reentrant: no
  822. * @li IRQ safe: yes
  823. *
  824. * @return - IX_SUCCESS/IX_FAIL
  825. */
  826. PUBLIC IX_STATUS ixOsalSemaphorePost (IxOsalSemaphore * semaphore);
  827. /**
  828. * @ingroup IxOsal
  829. *
  830. * @brief Waits on (decrements) a semaphore
  831. *
  832. * @param semaphore - semaphore handle
  833. * @param timeout - timeout, in ms; IX_OSAL_WAIT_FOREVER (-1) if the thread
  834. * is to block indefinitely or IX_OSAL_WAIT_NONE (0) if the thread is to
  835. * return immediately even if the call fails
  836. *
  837. * Decrements a semaphore, blocking if the semaphore is
  838. * unavailable (value is 0).
  839. *
  840. * @li Reentrant: no
  841. * @li IRQ safe: no
  842. *
  843. * @return - IX_SUCCESS/IX_FAIL
  844. */
  845. PUBLIC IX_STATUS ixOsalSemaphoreWait (IxOsalSemaphore * semaphore,
  846. INT32 timeout);
  847. /**
  848. * @ingroup IxOsal
  849. *
  850. * @brief Non-blocking wait on semaphore
  851. *
  852. * @param semaphore - semaphore handle
  853. *
  854. * Decrements a semaphore, not blocking the calling thread if the semaphore
  855. * is unavailable
  856. *
  857. * @li Reentrant: no
  858. * @li IRQ safe: no
  859. *
  860. * @return - IX_SUCCESS/IX_FAIL
  861. */
  862. PUBLIC IX_STATUS ixOsalSemaphoreTryWait (IxOsalSemaphore * semaphore);
  863. /**
  864. * @ingroup IxOsal
  865. *
  866. * @brief Gets semaphore value
  867. *
  868. * @param semaphore - semaphore handle
  869. * @param value - location to store the semaphore value
  870. *
  871. * Retrieves the current value of a semaphore object
  872. *
  873. * @li Reentrant: no
  874. * @li IRQ safe: no
  875. *
  876. * @return - IX_SUCCESS/IX_FAIL
  877. */
  878. PUBLIC IX_STATUS ixOsalSemaphoreGetValue (IxOsalSemaphore * semaphore,
  879. UINT32 * value);
  880. /**
  881. * @ingroup IxOsal
  882. *
  883. * @brief Destroys a semaphore object
  884. *
  885. * @param semaphore - semaphore handle
  886. *
  887. * Destroys a semaphore object; the caller should ensure that no thread is
  888. * blocked on this semaphore
  889. *
  890. * @li Reentrant: no
  891. * @li IRQ safe: no
  892. *
  893. * @return - IX_SUCCESS/IX_FAIL
  894. */
  895. PUBLIC IX_STATUS ixOsalSemaphoreDestroy (IxOsalSemaphore * semaphore);
  896. /**
  897. * @ingroup IxOsal
  898. *
  899. * @brief Yields execution of current thread
  900. *
  901. * Yields the execution of the current thread
  902. *
  903. * @li Reentrant: no
  904. * @li IRQ safe: no
  905. *
  906. * @return - none
  907. */
  908. PUBLIC void ixOsalYield (void);
  909. /* ========================== Time functions ===========================
  910. *
  911. */
  912. /**
  913. * @ingroup IxOsal
  914. *
  915. * @brief Yielding sleep for a number of milliseconds
  916. *
  917. * @param milliseconds - number of milliseconds to sleep
  918. *
  919. * The calling thread will sleep for the specified number of milliseconds.
  920. * This sleep is yielding, hence other tasks will be scheduled by the
  921. * operating system during the sleep period. Calling this function with an
  922. * argument of 0 will place the thread at the end of the current scheduling
  923. * loop.
  924. *
  925. * @li Reentrant: no
  926. * @li IRQ safe: no
  927. *
  928. * @return - none
  929. */
  930. PUBLIC void ixOsalSleep (UINT32 milliseconds);
  931. /**
  932. * @ingroup IxOsal
  933. *
  934. * @brief Busy sleep for a number of microseconds
  935. *
  936. * @param microseconds - number of microseconds to sleep
  937. *
  938. * Sleeps for the specified number of microseconds, without explicitly
  939. * yielding thread execution to the OS scheduler
  940. *
  941. * @li Reentrant: yes
  942. * @li IRQ safe: yes
  943. *
  944. * @return - none
  945. */
  946. PUBLIC void ixOsalBusySleep (UINT32 microseconds);
  947. /**
  948. * @ingroup IxOsal
  949. *
  950. * @brief XXX
  951. *
  952. * Retrieves the current timestamp
  953. *
  954. * @li Reentrant: yes
  955. * @li IRQ safe: yes
  956. *
  957. * @return - The current timestamp
  958. *
  959. * @note The implementation of this function is platform-specific. Not
  960. * all the platforms provide a high-resolution timestamp counter.
  961. */
  962. PUBLIC UINT32 ixOsalTimestampGet (void);
  963. /**
  964. * @ingroup IxOsal
  965. *
  966. * @brief Resolution of the timestamp counter
  967. *
  968. * Retrieves the resolution (frequency) of the timestamp counter.
  969. *
  970. * @li Reentrant: yes
  971. * @li IRQ safe: yes
  972. *
  973. * @return - The resolution of the timestamp counter
  974. *
  975. * @note The implementation of this function is platform-specific. Not all
  976. * the platforms provide a high-resolution timestamp counter.
  977. */
  978. PUBLIC UINT32 ixOsalTimestampResolutionGet (void);
  979. /**
  980. * @ingroup IxOsal
  981. *
  982. * @brief System clock rate, in ticks
  983. *
  984. * Retrieves the resolution (number of ticks per second) of the system clock
  985. *
  986. * @li Reentrant: no
  987. * @li IRQ safe: no
  988. *
  989. * @return - The system clock rate
  990. *
  991. * @note The implementation of this function is platform and OS-specific.
  992. * The system clock rate is not always available - e.g. Linux does not
  993. * provide this information in user mode
  994. */
  995. PUBLIC UINT32 ixOsalSysClockRateGet (void);
  996. /**
  997. * @ingroup IxOsal
  998. *
  999. * @brief Current system time
  1000. *
  1001. * @param tv - pointer to an IxOsalTimeval structure to store the current
  1002. * time in
  1003. *
  1004. * Retrieves the current system time (real-time)
  1005. *
  1006. * @li Reentrant: no
  1007. * @li IRQ safe: no
  1008. *
  1009. * @return - none
  1010. *
  1011. * @note The implementation of this function is platform-specific. Not all
  1012. * platforms have a real-time clock.
  1013. */
  1014. PUBLIC void ixOsalTimeGet (IxOsalTimeval * tv);
  1015. /* Internal function to convert timer val to ticks.
  1016. * NOTE - This should not be called by the user.
  1017. * Use the macro IX_OSAL_TIMEVAL_TO_TICKS
  1018. * OS-independent, implemented in framework.
  1019. */
  1020. PUBLIC UINT32 ixOsalTimevalToTicks (IxOsalTimeval tv);
  1021. /**
  1022. * @ingroup IxOsal
  1023. *
  1024. * @brief Converts ixOsalTimeVal into ticks
  1025. *
  1026. * @param tv - an IxOsalTimeval structure
  1027. *
  1028. * Converts an IxOsalTimeval structure into OS ticks
  1029. *
  1030. * @li Reentrant: yes
  1031. * @li IRQ safe: yes
  1032. *
  1033. * @return - Corresponding number of ticks
  1034. *
  1035. * Note: This function is OS-independent. Implemented by core.
  1036. */
  1037. #define IX_OSAL_TIMEVAL_TO_TICKS(tv) ixOsalTimevalToTicks(tv)
  1038. /* Internal function to convert ticks to timer val
  1039. * NOTE - This should not be called by the user.
  1040. * Use the macro IX_OSAL_TICKS_TO_TIMEVAL
  1041. */
  1042. PUBLIC void ixOsalTicksToTimeval (UINT32 ticks, IxOsalTimeval * pTv);
  1043. /**
  1044. * @ingroup IxOsal
  1045. *
  1046. * @brief Converts ticks into ixOsalTimeVal
  1047. *
  1048. * @param ticks - number of ticks
  1049. * @param pTv - pointer to the destination structure
  1050. *
  1051. * Converts the specified number of ticks into an IxOsalTimeval structure
  1052. *
  1053. * @li Reentrant: yes
  1054. * @li IRQ safe: yes
  1055. *
  1056. * @return - Corresponding IxOsalTimeval structure
  1057. * Note: This function is OS-independent. Implemented by core.
  1058. */
  1059. #define IX_OSAL_TICKS_TO_TIMEVAL(ticks, pTv) \
  1060. ixOsalTicksToTimeval(ticks, pTv)
  1061. /**
  1062. * @ingroup IxOsal
  1063. *
  1064. * @brief Converts ixOsalTimeVal to milliseconds
  1065. *
  1066. * @param tv - IxOsalTimeval structure to convert
  1067. *
  1068. * Converts an IxOsalTimeval structure into milliseconds
  1069. *
  1070. * @li Reentrant: yes
  1071. * @li IRQ safe: yes
  1072. *
  1073. * @return - Corresponding number of milliseconds
  1074. * Note: This function is OS-independent. Implemented by core.
  1075. */
  1076. #define IX_OSAL_TIMEVAL_TO_MS(tv) ((tv.secs * 1000) + (tv.nsecs / 1000000))
  1077. /**
  1078. * @ingroup IxOsal
  1079. *
  1080. * @brief Converts milliseconds to IxOsalTimeval
  1081. *
  1082. * @param milliseconds - number of milliseconds to convert
  1083. * @param pTv - pointer to the destination structure
  1084. *
  1085. * Converts a millisecond value into an IxOsalTimeval structure
  1086. *
  1087. * @li Reentrant: yes
  1088. * @li IRQ safe: yes
  1089. *
  1090. * @return - Corresponding IxOsalTimeval structure
  1091. * Note: This function is OS-independent. Implemented by core.
  1092. */
  1093. #define IX_OSAL_MS_TO_TIMEVAL(milliseconds, pTv) \
  1094. ((IxOsalTimeval *) pTv)->secs = milliseconds / 1000; \
  1095. ((IxOsalTimeval *) pTv)->nsecs = (milliseconds % 1000) * 1000000
  1096. /**
  1097. * @ingroup IxOsal
  1098. *
  1099. * @brief "equal" comparison for IxOsalTimeval
  1100. *
  1101. * @param tvA, tvB - IxOsalTimeval structures to compare
  1102. *
  1103. * Compares two IxOsalTimeval structures for equality
  1104. *
  1105. * @li Reentrant: yes
  1106. * @li IRQ safe: yes
  1107. *
  1108. * @return - TRUE if the structures are equal
  1109. * - FALSE otherwise
  1110. * Note: This function is OS-independant
  1111. */
  1112. #define IX_OSAL_TIME_EQ(tvA, tvB) \
  1113. ((tvA).secs == (tvB).secs && (tvA).nsecs == (tvB).nsecs)
  1114. /**
  1115. * @ingroup IxOsal
  1116. *
  1117. * @brief "less than" comparison for IxOsalTimeval
  1118. *
  1119. * @param tvA, tvB - IxOsalTimeval structures to compare
  1120. *
  1121. * Compares two IxOsalTimeval structures to determine if the first one is
  1122. * less than the second one
  1123. *
  1124. * @li Reentrant: yes
  1125. * @li IRQ safe: yes
  1126. *
  1127. * @return - TRUE if tvA < tvB
  1128. * - FALSE otherwise
  1129. * Note: This function is OS-independent. Implemented by core.
  1130. */
  1131. #define IX_OSAL_TIME_LT(tvA,tvB) \
  1132. ((tvA).secs < (tvB).secs || \
  1133. ((tvA).secs == (tvB).secs && (tvA).nsecs < (tvB).nsecs))
  1134. /**
  1135. * @ingroup IxOsal
  1136. *
  1137. * @brief "greater than" comparison for IxOsalTimeval
  1138. *
  1139. * @param tvA, tvB - IxOsalTimeval structures to compare
  1140. *
  1141. * Compares two IxOsalTimeval structures to determine if the first one is
  1142. * greater than the second one
  1143. *
  1144. * @li Reentrant: yes
  1145. * @li IRQ safe: yes
  1146. *
  1147. * @return - TRUE if tvA > tvB
  1148. * - FALSE otherwise
  1149. * Note: This function is OS-independent.
  1150. */
  1151. #define IX_OSAL_TIME_GT(tvA, tvB) \
  1152. ((tvA).secs > (tvB).secs || \
  1153. ((tvA).secs == (tvB).secs && (tvA).nsecs > (tvB).nsecs))
  1154. /**
  1155. * @ingroup IxOsal
  1156. *
  1157. * @brief "add" operator for IxOsalTimeval
  1158. *
  1159. * @param tvA, tvB - IxOsalTimeval structures to add
  1160. *
  1161. * Adds the second IxOsalTimevalStruct to the first one (equivalent to
  1162. * tvA += tvB)
  1163. *
  1164. * @li Reentrant: yes
  1165. * @li IRQ safe: yes
  1166. *
  1167. * @return - none
  1168. * Note: This function is OS-independent.
  1169. */
  1170. #define IX_OSAL_TIME_ADD(tvA, tvB) \
  1171. (tvA).secs += (tvB).secs; \
  1172. (tvA).nsecs += (tvB).nsecs; \
  1173. if ((tvA).nsecs >= IX_OSAL_BILLION) \
  1174. { \
  1175. (tvA).secs++; \
  1176. (tvA).nsecs -= IX_OSAL_BILLION; }
  1177. /**
  1178. * @ingroup IxOsal
  1179. *
  1180. * @brief "subtract" operator for IxOsalTimeval
  1181. *
  1182. * @param tvA, tvB - IxOsalTimeval structures to subtract
  1183. *
  1184. * Subtracts the second IxOsalTimevalStruct from the first one (equivalent
  1185. * to tvA -= tvB)
  1186. *
  1187. * @li Reentrant: yes
  1188. * @li IRQ safe: yes
  1189. *
  1190. * @return - none
  1191. * Note: This function is OS-independent. Implemented by core.
  1192. */
  1193. #define IX_OSAL_TIME_SUB(tvA, tvB) \
  1194. if ((tvA).nsecs >= (tvB).nsecs) \
  1195. { \
  1196. (tvA).secs -= (tvB).secs; \
  1197. (tvA).nsecs -= (tvB).nsecs; \
  1198. } \
  1199. else \
  1200. { \
  1201. (tvA).secs -= ((tvB).secs + 1); \
  1202. (tvA).nsecs += IX_OSAL_BILLION - (tvB).nsecs; \
  1203. }
  1204. /* ============================= Logging ==============================
  1205. *
  1206. */
  1207. /**
  1208. * @ingroup IxOsal
  1209. *
  1210. * @brief Interrupt-safe logging function
  1211. *
  1212. * @param level - identifier prefix for the message
  1213. * @param device - output device
  1214. * @param format - message format, in a printf format
  1215. * @param ... - up to 6 arguments to be printed
  1216. *
  1217. * IRQ-safe logging function, similar to printf. Accepts up to 6 arguments
  1218. * to print (excluding the level, device and the format). This function will
  1219. * actually display the message only if the level is lower than the current
  1220. * verbosity level or if the IX_OSAL_LOG_USER level is used. An output device
  1221. * must be specified (see IxOsalTypes.h).
  1222. *
  1223. * @li Reentrant: yes
  1224. * @li IRQ safe: yes
  1225. *
  1226. * @return - Beside the exceptions documented in the note below, the returned
  1227. * value is the number of printed characters, or -1 if the parameters are
  1228. * incorrect (NULL format, unknown output device)
  1229. *
  1230. * @note The exceptions to the return value are:
  1231. * VxWorks: The return value is 32 if the specified level is 1 and 64
  1232. * if the specified level is greater than 1 and less or equal than 9.
  1233. * WinCE: If compiled for EBOOT then the return value is always 0.
  1234. *
  1235. * @note The given print format should take into account the specified
  1236. * output device. IX_OSAL_STDOUT supports all the usual print formats,
  1237. * however a custom hex display specified by IX_OSAL_HEX would support
  1238. * only a fixed number of hexadecimal digits.
  1239. */
  1240. PUBLIC INT32 ixOsalLog (IxOsalLogLevel level,
  1241. IxOsalLogDevice device,
  1242. char *format,
  1243. int arg1,
  1244. int arg2, int arg3, int arg4, int arg5, int arg6);
  1245. /**
  1246. * @ingroup IxOsal
  1247. *
  1248. * @brief sets the current logging verbosity level
  1249. *
  1250. * @param level - new log verbosity level
  1251. *
  1252. * Sets the log verbosity level. The default value is IX_OSAL_LOG_ERROR.
  1253. *
  1254. * @li Reentrant: yes
  1255. * @li IRQ safe: yes
  1256. *
  1257. * @return - Old log verbosity level
  1258. */
  1259. PUBLIC UINT32 ixOsalLogLevelSet (UINT32 level);
  1260. /* ============================= Logging ==============================
  1261. *
  1262. */
  1263. /**
  1264. * @ingroup IxOsal
  1265. *
  1266. * @brief Schedules a repeating timer
  1267. *
  1268. * @param timer - handle of the timer object
  1269. * @param period - timer trigger period, in milliseconds
  1270. * @param priority - timer priority (0 being the highest)
  1271. * @param callback - user callback to invoke when the timer triggers
  1272. * @param param - custom parameter passed to the callback
  1273. *
  1274. * Schedules a timer to be called every period milliseconds. The timer
  1275. * will invoke the specified callback function possibly in interrupt
  1276. * context, passing the given parameter. If several timers trigger at the
  1277. * same time contention issues are dealt according to the specified timer
  1278. * priorities.
  1279. *
  1280. * @li Reentrant: no
  1281. * @li IRQ safe: no
  1282. *
  1283. * @return - IX_SUCCESS/IX_FAIL
  1284. */
  1285. PUBLIC IX_STATUS ixOsalRepeatingTimerSchedule (IxOsalTimer * timer,
  1286. UINT32 period,
  1287. UINT32 priority,
  1288. IxOsalVoidFnVoidPtr callback,
  1289. void *param);
  1290. /**
  1291. * @ingroup IxOsal
  1292. *
  1293. * @brief Schedules a single-shot timer
  1294. *
  1295. * @param timer - handle of the timer object
  1296. * @param period - timer trigger period, in milliseconds
  1297. * @param priority - timer priority (0 being the highest)
  1298. * @param callback - user callback to invoke when the timer triggers
  1299. * @param param - custom parameter passed to the callback
  1300. *
  1301. * Schedules a timer to be called after period milliseconds. The timer
  1302. * will cease to function past its first trigger. The timer will invoke
  1303. * the specified callback function, possibly in interrupt context, passing
  1304. * the given parameter. If several timers trigger at the same time contention
  1305. * issues are dealt according to the specified timer priorities.
  1306. *
  1307. * @li Reentrant: no
  1308. * @li IRQ safe: no
  1309. *
  1310. * @return - IX_SUCCESS/IX_FAIL
  1311. */
  1312. PUBLIC IX_STATUS
  1313. ixOsalSingleShotTimerSchedule (IxOsalTimer * timer,
  1314. UINT32 period,
  1315. UINT32 priority,
  1316. IxOsalVoidFnVoidPtr callback, void *param);
  1317. /**
  1318. * @ingroup IxOsal
  1319. *
  1320. * @brief Cancels a running timer
  1321. *
  1322. * @param timer - handle of the timer object
  1323. *
  1324. * Cancels a single-shot or repeating timer.
  1325. *
  1326. * @li Reentrant: no
  1327. * @li IRQ safe: yes
  1328. *
  1329. * @return - IX_SUCCESS/IX_FAIL
  1330. */
  1331. PUBLIC IX_STATUS ixOsalTimerCancel (IxOsalTimer * timer);
  1332. /**
  1333. * @ingroup IxOsal
  1334. *
  1335. * @brief displays all the running timers
  1336. *
  1337. * Displays a list with all the running timers and their parameters (handle,
  1338. * period, type, priority, callback and user parameter)
  1339. *
  1340. * @li Reentrant: no
  1341. * @li IRQ safe: no
  1342. *
  1343. * @return - none
  1344. */
  1345. PUBLIC void ixOsalTimersShow (void);
  1346. /* ============================= Version ==============================
  1347. *
  1348. */
  1349. /**
  1350. * @ingroup IxOsal
  1351. *
  1352. * @brief provides the name of the Operating System running
  1353. *
  1354. * @param osName - Pointer to a NULL-terminated string of characters
  1355. * that holds the name of the OS running.
  1356. * This is both an input and an ouput parameter
  1357. * @param maxSize - Input parameter that defines the maximum number of
  1358. * bytes that can be stored in osName
  1359. *
  1360. * Returns a string of characters that describe the Operating System name
  1361. *
  1362. * @li Reentrant: yes
  1363. * @li IRQ safe: yes
  1364. *
  1365. * return - IX_SUCCESS for successful retrieval
  1366. * - IX_FAIL if (osType == NULL | maxSize =< 0)
  1367. */
  1368. PUBLIC IX_STATUS ixOsalOsNameGet (INT8* osName, INT32 maxSize);
  1369. /**
  1370. * @ingroup IxOsal
  1371. *
  1372. * @brief provides the version of the Operating System running
  1373. *
  1374. * @param osVersion - Pointer to a NULL terminated string of characters
  1375. * that holds the version of the OS running.
  1376. * This is both an input and an ouput parameter
  1377. * @param maxSize - Input parameter that defines the maximum number of
  1378. * bytes that can be stored in osVersion
  1379. *
  1380. * Returns a string of characters that describe the Operating System's version
  1381. *
  1382. * @li Reentrant: yes
  1383. * @li IRQ safe: yes
  1384. *
  1385. * return - IX_SUCCESS for successful retrieval
  1386. * - IX_FAIL if (osVersion == NULL | maxSize =< 0)
  1387. */
  1388. PUBLIC IX_STATUS ixOsalOsVersionGet(INT8* osVersion, INT32 maxSize);
  1389. /**
  1390. * @} IxOsal
  1391. */
  1392. #endif /* IxOsal_H */