trcEventBuffer.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. /*
  2. * Percepio Trace Recorder for Tracealyzer v4.9.2
  3. * Copyright 2023 Percepio AB
  4. * www.percepio.com
  5. *
  6. * SPDX-License-Identifier: Apache-2.0
  7. *
  8. * The implementation for the event buffer.
  9. */
  10. #include <trcRecorder.h>
  11. #if (TRC_USE_TRACEALYZER_RECORDER == 1) && (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
  12. traceResult xTraceEventBufferInitialize(TraceEventBuffer_t* pxTraceEventBuffer, uint32_t uiOptions,
  13. uint8_t* puiBuffer, uint32_t uiSize)
  14. {
  15. /* This should never fail */
  16. TRC_ASSERT(pxTraceEventBuffer != (void*)0);
  17. /* This should never fail */
  18. TRC_ASSERT(puiBuffer != (void*)0);
  19. /* This should never fail */
  20. TRC_ASSERT(uiSize != 0u);
  21. pxTraceEventBuffer->uiOptions = uiOptions;
  22. pxTraceEventBuffer->uiHead = 0u;
  23. pxTraceEventBuffer->uiTail = 0u;
  24. pxTraceEventBuffer->uiSize = uiSize;
  25. pxTraceEventBuffer->uiFree = uiSize;
  26. pxTraceEventBuffer->puiBuffer = puiBuffer;
  27. pxTraceEventBuffer->uiSlack = 0u;
  28. pxTraceEventBuffer->uiNextHead = 0u;
  29. pxTraceEventBuffer->uiTimerWraparounds = 0u;
  30. (void)xTraceSetComponentInitialized(TRC_RECORDER_COMPONENT_EVENT_BUFFER);
  31. return TRC_SUCCESS;
  32. }
  33. /**
  34. * @brief Pops the oldest event from the Event Buffer.
  35. *
  36. * @param[in] pxTraceEventBuffer Pointer to initialized trace event buffer.
  37. *
  38. * @retval TRC_FAIL Failure
  39. * @retval TRC_SUCCESS Success
  40. */
  41. static traceResult prvTraceEventBufferPop(TraceEventBuffer_t *pxTraceEventBuffer)
  42. {
  43. uint32_t uiFreeSize = 0u;
  44. /* Get size of event we are freeing */
  45. /* This should never fail */
  46. TRC_ASSERT_ALWAYS_EVALUATE(xTraceEventGetSize(((void*)&(pxTraceEventBuffer->puiBuffer[pxTraceEventBuffer->uiTail])), &uiFreeSize) == TRC_SUCCESS); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  47. pxTraceEventBuffer->uiFree += uiFreeSize;
  48. /* Update tail to point to the new last event */
  49. pxTraceEventBuffer->uiTail = (pxTraceEventBuffer->uiTail + uiFreeSize) % pxTraceEventBuffer->uiSize;
  50. return TRC_SUCCESS;
  51. }
  52. static traceResult prvTraceEventBufferAllocPop(TraceEventBuffer_t *pxTraceEventBuffer)
  53. {
  54. uint32_t uiFreeSize = 0u;
  55. /* Check if tail is in, or at the start of the slack area. We do not want to call
  56. * a free when in the slack area since it would read garbage data and free would
  57. * become undefined.
  58. */
  59. if (pxTraceEventBuffer->uiTail >= (pxTraceEventBuffer->uiSize - pxTraceEventBuffer->uiSlack))
  60. {
  61. /* Tail was in the slack area, wrap back to the start of the buffer. */
  62. pxTraceEventBuffer->uiTail = 0u;
  63. }
  64. else
  65. {
  66. /* Get size of event we are freeing (this should never fail) */
  67. TRC_ASSERT_ALWAYS_EVALUATE(xTraceEventGetSize(((void*)&(pxTraceEventBuffer->puiBuffer[pxTraceEventBuffer->uiTail])), &uiFreeSize) == TRC_SUCCESS); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  68. /* Update tail to point to the new last event */
  69. pxTraceEventBuffer->uiTail = (pxTraceEventBuffer->uiTail + uiFreeSize) % pxTraceEventBuffer->uiSize;
  70. }
  71. return TRC_SUCCESS;
  72. }
  73. traceResult xTraceEventBufferAlloc(TraceEventBuffer_t *pxTraceEventBuffer, uint32_t uiSize, void **ppvData)
  74. {
  75. uint32_t uiFreeSpace;
  76. uint32_t uiHead;
  77. uint32_t uiTail;
  78. uint32_t uiBufferSize;
  79. /* This should never fail */
  80. TRC_ASSERT(pxTraceEventBuffer != (void*)0);
  81. /* This should never fail */
  82. TRC_ASSERT(ppvData != (void*)0);
  83. uiBufferSize = pxTraceEventBuffer->uiSize;
  84. TRC_ASSERT(uiBufferSize != 0u);
  85. /* Check if the data size is larger than the buffer */
  86. /* This should never fail */
  87. TRC_ASSERT(uiSize <= uiBufferSize);
  88. /* Handle overwrite buffer allocation, since this kind of allocation modifies
  89. * both head and tail it should only be used for internal buffers without any
  90. * flushing calls (Streaming Ringbuffer)
  91. */
  92. if (pxTraceEventBuffer->uiOptions == TRC_EVENT_BUFFER_OPTION_OVERWRITE)
  93. {
  94. if (pxTraceEventBuffer->uiHead >= pxTraceEventBuffer->uiTail)
  95. {
  96. /* Do we have enough space to directly allocate from the buffer? */
  97. if ((uiBufferSize - pxTraceEventBuffer->uiHead) > uiSize)
  98. {
  99. *ppvData = &pxTraceEventBuffer->puiBuffer[pxTraceEventBuffer->uiHead]; /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  100. pxTraceEventBuffer->uiNextHead = (pxTraceEventBuffer->uiHead + uiSize) % uiBufferSize;
  101. }
  102. /* There wasn't enough space for a direct alloc, handle freeing up
  103. * space and wrapping. */
  104. else
  105. {
  106. /* Free space until there is enough space for a contiguous
  107. * allocation */
  108. do
  109. {
  110. (void)prvTraceEventBufferAllocPop(pxTraceEventBuffer);
  111. uiFreeSpace = pxTraceEventBuffer->uiTail - sizeof(uint32_t);
  112. } while (uiFreeSpace < uiSize);
  113. /* Calculate slack from the wrapping */
  114. pxTraceEventBuffer->uiSlack = uiBufferSize - pxTraceEventBuffer->uiHead;
  115. /* Wrap head */
  116. pxTraceEventBuffer->uiHead = 0u;
  117. /* Allocate data */
  118. *ppvData = pxTraceEventBuffer->puiBuffer;
  119. pxTraceEventBuffer->uiNextHead = (pxTraceEventBuffer->uiHead + uiSize) % uiBufferSize;
  120. }
  121. }
  122. else
  123. {
  124. uiFreeSpace = pxTraceEventBuffer->uiTail - pxTraceEventBuffer->uiHead - sizeof(uint32_t);
  125. /* Check if we have to free space */
  126. if (uiFreeSpace < uiSize)
  127. {
  128. /* Check if this is a wrapping alloc */
  129. if ((pxTraceEventBuffer->uiSize - pxTraceEventBuffer->uiHead) < uiSize)
  130. {
  131. /* To avoid uiHead and uiTail from becoming the same we want to
  132. * pop any events that would make uiTail equal uiHead before
  133. * wrapping the head. */
  134. do
  135. {
  136. (void)prvTraceEventBufferAllocPop(pxTraceEventBuffer);
  137. } while (pxTraceEventBuffer->uiTail == 0u);
  138. pxTraceEventBuffer->uiSlack = pxTraceEventBuffer->uiSize - pxTraceEventBuffer->uiHead;
  139. pxTraceEventBuffer->uiHead = 0u;
  140. }
  141. do
  142. {
  143. (void)prvTraceEventBufferAllocPop(pxTraceEventBuffer);
  144. uiFreeSpace = pxTraceEventBuffer->uiTail - pxTraceEventBuffer->uiHead - sizeof(uint32_t);
  145. } while (uiFreeSpace < uiSize);
  146. if (pxTraceEventBuffer->uiTail == 0u)
  147. {
  148. *ppvData = &pxTraceEventBuffer->puiBuffer[pxTraceEventBuffer->uiHead]; /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  149. }
  150. }
  151. /* Alloc data */
  152. *ppvData = &pxTraceEventBuffer->puiBuffer[pxTraceEventBuffer->uiHead]; /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  153. pxTraceEventBuffer->uiNextHead = (pxTraceEventBuffer->uiHead + uiSize);
  154. }
  155. }
  156. else
  157. {
  158. /* Since a consumer could potentially update tail (free) during the procedure
  159. * we have to save it here to avoid problems with it changing during this call.
  160. */
  161. uiHead = pxTraceEventBuffer->uiHead;
  162. uiTail = pxTraceEventBuffer->uiTail;
  163. if (uiHead >= uiTail)
  164. {
  165. uiFreeSpace = (uiBufferSize - uiHead - sizeof(uint32_t)) + uiTail;
  166. if (uiFreeSpace < uiSize)
  167. {
  168. *ppvData = 0;
  169. return TRC_FAIL;
  170. }
  171. /* Copy data */
  172. if ((uiBufferSize - uiHead) > uiSize)
  173. {
  174. *ppvData = &pxTraceEventBuffer->puiBuffer[pxTraceEventBuffer->uiHead]; /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  175. pxTraceEventBuffer->uiNextHead = (uiHead + uiSize) % uiBufferSize;
  176. }
  177. else
  178. {
  179. uiFreeSpace = uiTail;
  180. if (uiFreeSpace < uiSize)
  181. {
  182. *ppvData = 0;
  183. return TRC_FAIL;
  184. }
  185. /* Calculate slack */
  186. pxTraceEventBuffer->uiSlack = uiBufferSize - uiHead;
  187. *ppvData = pxTraceEventBuffer->puiBuffer;
  188. pxTraceEventBuffer->uiNextHead = (uiHead + pxTraceEventBuffer->uiSlack + uiSize) % uiBufferSize;
  189. }
  190. }
  191. else
  192. {
  193. uiFreeSpace = uiTail - uiHead - sizeof(uint32_t);
  194. if (uiFreeSpace < uiSize)
  195. {
  196. *ppvData = 0;
  197. return TRC_FAIL;
  198. }
  199. /* Alloc data */
  200. *ppvData = &pxTraceEventBuffer->puiBuffer[pxTraceEventBuffer->uiHead]; /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  201. pxTraceEventBuffer->uiNextHead = (uiHead + uiSize);
  202. }
  203. }
  204. return TRC_SUCCESS;
  205. }
  206. traceResult xTraceEventBufferAllocCommit(TraceEventBuffer_t *pxTraceEventBuffer, const void *pvData, uint32_t uiSize, int32_t *piBytesWritten)
  207. {
  208. (void)pvData;
  209. /* This should never fail */
  210. TRC_ASSERT_ALWAYS_EVALUATE(xTraceTimestampGetWraparounds(&pxTraceEventBuffer->uiTimerWraparounds) == TRC_SUCCESS);
  211. /* Advance head location */
  212. pxTraceEventBuffer->uiHead = pxTraceEventBuffer->uiNextHead;
  213. /* Update bytes written */
  214. *piBytesWritten = (int32_t)uiSize;
  215. return TRC_SUCCESS;
  216. }
  217. traceResult xTraceEventBufferPush(TraceEventBuffer_t *pxTraceEventBuffer, void *pvData, uint32_t uiSize, int32_t *piBytesWritten)
  218. {
  219. uint32_t uiBufferSize;
  220. uint32_t uiHead;
  221. uint32_t uiTail;
  222. uint32_t uiFreeSpace;
  223. /* This should never fail */
  224. TRC_ASSERT(pxTraceEventBuffer != (void*)0);
  225. /* This should never fail */
  226. TRC_ASSERT(pvData != (void*)0);
  227. uiBufferSize = pxTraceEventBuffer->uiSize;
  228. TRC_ASSERT(uiBufferSize != 0u);
  229. /* Check if the data size is larger than the buffer */
  230. /* This should never fail */
  231. TRC_ASSERT(uiSize <= uiBufferSize);
  232. /* Check byte alignment */
  233. /* This should never fail */
  234. TRC_ASSERT((uiSize % 4u) == 0u);
  235. /* Ensure bytes written start at 0 */
  236. /* This should never fail */
  237. TRC_ASSERT(piBytesWritten != (void*)0);
  238. *piBytesWritten = 0;
  239. /* This should never fail */
  240. TRC_ASSERT_ALWAYS_EVALUATE(xTraceTimestampGetWraparounds(&pxTraceEventBuffer->uiTimerWraparounds) == TRC_SUCCESS);
  241. /* In ring buffer mode we cannot provide lock free access since the producer modified
  242. * the head and tail variables in the same call. This option is only safe when used
  243. * with an internal buffer (streaming snapshot) which no consumer accesses.
  244. */
  245. switch (pxTraceEventBuffer->uiOptions)
  246. {
  247. case TRC_EVENT_BUFFER_OPTION_OVERWRITE:
  248. uiHead = pxTraceEventBuffer->uiHead;
  249. /* If there isn't enough space in the buffer pop events until there is */
  250. while (pxTraceEventBuffer->uiFree < uiSize)
  251. {
  252. (void)prvTraceEventBufferPop(pxTraceEventBuffer);
  253. }
  254. /* Copy data */
  255. if ((uiBufferSize - uiHead) > uiSize)
  256. {
  257. TRC_MEMCPY(&pxTraceEventBuffer->puiBuffer[uiHead], pvData, uiSize); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  258. }
  259. else
  260. {
  261. TRC_MEMCPY(&pxTraceEventBuffer->puiBuffer[uiHead], pvData, (uiBufferSize - uiHead)); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  262. TRC_MEMCPY(pxTraceEventBuffer->puiBuffer, (void*)(&((uint8_t*)pvData)[(uiBufferSize - uiHead)]), (uiSize - (uiBufferSize - uiHead))); /*cstat !MISRAC2012-Rule-11.5 Suppress pointer checks*/ /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  263. }
  264. pxTraceEventBuffer->uiFree -= uiSize;
  265. pxTraceEventBuffer->uiHead = (uiHead + uiSize) % uiBufferSize;
  266. *piBytesWritten = (int32_t)uiSize;
  267. break;
  268. case TRC_EVENT_BUFFER_OPTION_SKIP:
  269. /* Since a consumer could potentially update tail (free) during the procedure
  270. * we have to save it here to avoid problems with the push algorithm.
  271. */
  272. uiHead = pxTraceEventBuffer->uiHead;
  273. uiTail = pxTraceEventBuffer->uiTail;
  274. if (uiHead >= uiTail)
  275. {
  276. uiFreeSpace = (uiBufferSize - uiHead - sizeof(uint32_t)) + uiTail;
  277. if (uiFreeSpace < uiSize)
  278. {
  279. *piBytesWritten = 0;
  280. return TRC_SUCCESS;
  281. }
  282. /* Copy data */
  283. if ((uiBufferSize - uiHead) > uiSize)
  284. {
  285. TRC_MEMCPY(&pxTraceEventBuffer->puiBuffer[pxTraceEventBuffer->uiHead], pvData, uiSize); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  286. }
  287. else
  288. {
  289. TRC_MEMCPY(&pxTraceEventBuffer->puiBuffer[uiHead], pvData, (uiBufferSize - uiHead)); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  290. TRC_MEMCPY(pxTraceEventBuffer->puiBuffer, (void*)(&((uint8_t*)pvData)[(uiBufferSize - uiHead)]), (uiSize - (uiBufferSize - uiHead))); /*cstat !MISRAC2012-Rule-11.5 Suppress pointer checks*/ /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  291. }
  292. pxTraceEventBuffer->uiHead = (uiHead + uiSize) % uiBufferSize;
  293. }
  294. else
  295. {
  296. uiFreeSpace = uiTail - uiHead - sizeof(uint32_t);
  297. if (uiFreeSpace < uiSize)
  298. {
  299. *piBytesWritten = 0;
  300. return TRC_SUCCESS;
  301. }
  302. /* Copy data */
  303. TRC_MEMCPY(&pxTraceEventBuffer->puiBuffer[pxTraceEventBuffer->uiHead], pvData, uiSize); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  304. pxTraceEventBuffer->uiHead = (uiHead + uiSize);
  305. }
  306. *piBytesWritten = (int32_t)uiSize;
  307. break;
  308. default:
  309. return TRC_FAIL;
  310. }
  311. return TRC_SUCCESS;
  312. }
  313. traceResult xTraceEventBufferTransferAll(TraceEventBuffer_t* pxTraceEventBuffer, int32_t* piBytesWritten)
  314. {
  315. int32_t iBytesWritten = 0;
  316. int32_t iSumBytesWritten = 0;
  317. uint32_t uiHead;
  318. uint32_t uiTail;
  319. uint32_t uiSlack;
  320. /* This should never fail */
  321. TRC_ASSERT(pxTraceEventBuffer != (void*)0);
  322. /* This should never fail */
  323. TRC_ASSERT(piBytesWritten != (void*)0);
  324. uiHead = pxTraceEventBuffer->uiHead;
  325. uiTail = pxTraceEventBuffer->uiTail;
  326. uiSlack = pxTraceEventBuffer->uiSlack;
  327. /* Check if core event buffer is empty */
  328. if (uiHead == uiTail)
  329. {
  330. /* Make sure this value is set in case it was passed uninitialized. */
  331. *piBytesWritten = 0;
  332. return TRC_SUCCESS;
  333. }
  334. /* Check if we can do a direct write or if we have to handle wrapping */
  335. if (uiHead > uiTail)
  336. {
  337. /* No wrapping */
  338. (void)xTraceStreamPortWriteData(&pxTraceEventBuffer->puiBuffer[uiTail], (uiHead - uiTail), &iBytesWritten); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  339. }
  340. else
  341. {
  342. /* Wrapping */
  343. /* Try to write: tail -> end of buffer */
  344. (void)xTraceStreamPortWriteData(&pxTraceEventBuffer->puiBuffer[uiTail], (pxTraceEventBuffer->uiSize - uiTail - uiSlack), &iBytesWritten); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  345. /* Did we manage to write all bytes? */
  346. if ((uint32_t)iBytesWritten == (pxTraceEventBuffer->uiSize - uiTail - uiSlack))
  347. {
  348. /* uiTail is moved to start of buffer */
  349. pxTraceEventBuffer->uiTail = 0u;
  350. iSumBytesWritten = iBytesWritten;
  351. /* We zero this here in case it does not get zeroed by the streamport. This isn't really a problem with our
  352. * streamports, but there has been cases with custom streamport forgetting to set this to 0 if there is no
  353. * data to write. */
  354. iBytesWritten = 0;
  355. /* Try to write: start of buffer -> head */
  356. (void)xTraceStreamPortWriteData(&pxTraceEventBuffer->puiBuffer[0], uiHead, &iBytesWritten); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  357. }
  358. }
  359. /* Move tail */
  360. pxTraceEventBuffer->uiTail += (uint32_t)iBytesWritten;
  361. iSumBytesWritten += iBytesWritten;
  362. *piBytesWritten = iSumBytesWritten;
  363. return TRC_SUCCESS;
  364. }
  365. traceResult xTraceEventBufferTransferChunk(TraceEventBuffer_t* pxTraceEventBuffer, uint32_t uiChunkSize, int32_t* piBytesWritten)
  366. {
  367. int32_t iBytesWritten = 0;
  368. uint32_t uiHead;
  369. uint32_t uiTail;
  370. uint32_t uiSlack;
  371. uint32_t uiBytesToWrite;
  372. /* This should never fail */
  373. TRC_ASSERT(pxTraceEventBuffer != (void*)0);
  374. /* This should never fail */
  375. TRC_ASSERT(piBytesWritten != (void*)0);
  376. uiHead = pxTraceEventBuffer->uiHead;
  377. uiTail = pxTraceEventBuffer->uiTail;
  378. uiSlack = pxTraceEventBuffer->uiSlack;
  379. /* Check if core event buffer is empty */
  380. if (uiHead == uiTail)
  381. {
  382. /* Make sure this value is set in case it was passed uninitialized. */
  383. *piBytesWritten = 0;
  384. return TRC_SUCCESS;
  385. }
  386. /* Check if we can do a direct write or if we have to handle wrapping */
  387. if (uiHead > uiTail)
  388. {
  389. uiBytesToWrite = uiHead - uiTail;
  390. if (uiBytesToWrite > uiChunkSize)
  391. {
  392. uiBytesToWrite = uiChunkSize;
  393. }
  394. (void)xTraceStreamPortWriteData(&pxTraceEventBuffer->puiBuffer[uiTail], uiBytesToWrite, &iBytesWritten); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  395. pxTraceEventBuffer->uiTail += (uint32_t)iBytesWritten;
  396. }
  397. else
  398. {
  399. uiBytesToWrite = pxTraceEventBuffer->uiSize - uiTail - uiSlack;
  400. if (uiBytesToWrite > uiChunkSize)
  401. {
  402. uiBytesToWrite = uiChunkSize;
  403. }
  404. (void)xTraceStreamPortWriteData(&pxTraceEventBuffer->puiBuffer[uiTail], uiBytesToWrite, &iBytesWritten); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
  405. /* Check if we managed to write until the end or not, if we didn't we
  406. * add the number of bytes written. If we managed to write the last
  407. * segment, reset tail to 0. */
  408. if ((uiTail + (uint32_t)iBytesWritten) == (pxTraceEventBuffer->uiSize - uiSlack))
  409. {
  410. pxTraceEventBuffer->uiTail = 0u;
  411. }
  412. else
  413. {
  414. pxTraceEventBuffer->uiTail += (uint32_t)iBytesWritten;
  415. }
  416. }
  417. *piBytesWritten = iBytesWritten;
  418. return TRC_SUCCESS;
  419. }
  420. traceResult xTraceEventBufferClear(TraceEventBuffer_t* pxTraceEventBuffer)
  421. {
  422. /* This should never fail */
  423. TRC_ASSERT(pxTraceEventBuffer != (void*)0);
  424. pxTraceEventBuffer->uiHead = 0u;
  425. pxTraceEventBuffer->uiTail = 0u;
  426. pxTraceEventBuffer->uiFree = pxTraceEventBuffer->uiSize;
  427. pxTraceEventBuffer->uiSlack = 0u;
  428. pxTraceEventBuffer->uiNextHead = 0u;
  429. return TRC_SUCCESS;
  430. }
  431. #endif