forked from percepio/TraceRecorderSource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrcEvent.c
727 lines (509 loc) · 22.8 KB
/
trcEvent.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
/*
* Percepio Trace Recorder for Tracealyzer v4.7.0
* Copyright 2023 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The implementation for events.
*/
#include <trcRecorder.h>
#if (TRC_USE_TRACEALYZER_RECORDER == 1)
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
/*cstat !MISRAC2004-19.4 Suppress macro check*/
#define VERIFY_EVENT_SIZE(i) \
if ((i) > (uint32_t)(TRC_MAX_BLOB_SIZE)) \
{ \
(void)xTraceDiagnosticsSetIfHigher(TRC_DIAGNOSTICS_BLOB_MAX_BYTES_TRUNCATED, (int32_t)((TraceUnsignedBaseType_t)((i) - (uint32_t)(TRC_MAX_BLOB_SIZE)))); \
(i) = (uint32_t)(TRC_MAX_BLOB_SIZE); \
}
TraceEventDataTable_t *pxTraceEventDataTable TRC_CFG_RECORDER_DATA_ATTRIBUTE;
traceResult xTraceEventInitialize(TraceEventDataTable_t* pxBuffer)
{
TraceCoreEventData_t* pxCoreEventData;
uint32_t i, j;
/* This should never fail */
TRC_ASSERT(pxBuffer != (void*)0);
pxTraceEventDataTable = pxBuffer;
for (i = 0u; i < (uint32_t)(TRC_CFG_CORE_COUNT); i++)
{
pxCoreEventData = &pxTraceEventDataTable->coreEventData[i];
pxCoreEventData->eventCounter = 0u;
for (j = 0u; j < ((uint32_t)(TRC_CFG_MAX_ISR_NESTING) + 1u); j++)
{
RESET_EVENT_DATA(&pxCoreEventData->eventData[j]);
}
}
xTraceSetComponentInitialized(TRC_RECORDER_COMPONENT_EVENT);
return TRC_SUCCESS;
}
traceResult xTraceEventCreate0(uint32_t uiEventCode)
{
TraceEvent0_t* pxEventData = (void*)0;
int32_t iBytesCommitted = 0;
TRACE_ALLOC_CRITICAL_SECTION();
/* We need to check this */
if (!xTraceIsRecorderEnabled())
{
return TRC_FAIL;
}
TRACE_ENTER_CRITICAL_SECTION();
pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter++;
if (xTraceStreamPortAllocate(sizeof(TraceEvent0_t), (void**)&pxEventData) == TRC_FAIL) /*cstat !MISRAC2004-11.4 !MISRAC2012-Rule-11.3 Suppress pointer checks*/
{
TRACE_EXIT_CRITICAL_SECTION();
return TRC_FAIL;
}
SET_BASE_EVENT_DATA(pxEventData, uiEventCode, 0, pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter); /*cstat !MISRAC2012-Rule-11.5 Suppress pointer checks*/
(void)xTraceStreamPortCommit(pxEventData, sizeof(TraceEvent0_t), &iBytesCommitted);
TRACE_EXIT_CRITICAL_SECTION();
/* We need to use iBytesCommitted for the above call but do not use the value,
* remove potential warnings */
(void)iBytesCommitted;
return TRC_SUCCESS;
}
traceResult xTraceEventCreate1(uint32_t uiEventCode, TraceUnsignedBaseType_t uxParam1)
{
TraceEvent1_t* pxEventData = (void*)0;
int32_t iBytesCommitted = 0;
TRACE_ALLOC_CRITICAL_SECTION();
/* We need to check this */
if (!xTraceIsRecorderEnabled())
{
return TRC_FAIL;
}
TRACE_ENTER_CRITICAL_SECTION();
pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter++;
if (xTraceStreamPortAllocate(sizeof(TraceEvent1_t), (void**)&pxEventData) == TRC_FAIL) /*cstat !MISRAC2004-11.4 !MISRAC2012-Rule-11.3 Suppress pointer checks*/
{
TRACE_EXIT_CRITICAL_SECTION();
return TRC_FAIL;
}
SET_BASE_EVENT_DATA(pxEventData, uiEventCode, 1, pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter); /*cstat !MISRAC2012-Rule-11.5 Suppress pointer checks*/
pxEventData->uxParams[0] = uxParam1;
(void)xTraceStreamPortCommit(pxEventData, sizeof(TraceEvent1_t), &iBytesCommitted);
TRACE_EXIT_CRITICAL_SECTION();
/* We need to use iBytesCommitted for the above call but do not use the value,
* remove potential warnings */
(void)iBytesCommitted;
return TRC_SUCCESS;
}
traceResult xTraceEventCreate2(uint32_t uiEventCode, TraceUnsignedBaseType_t uxParam1, TraceUnsignedBaseType_t uxParam2)
{
TraceEvent2_t* pxEventData = (void*)0;
int32_t iBytesCommitted = 0;
TRACE_ALLOC_CRITICAL_SECTION();
/* We need to check this */
if (!xTraceIsRecorderEnabled())
{
return TRC_FAIL;
}
TRACE_ENTER_CRITICAL_SECTION();
pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter++;
if (xTraceStreamPortAllocate(sizeof(TraceEvent2_t), (void**)&pxEventData) == TRC_FAIL) /*cstat !MISRAC2004-11.4 !MISRAC2012-Rule-11.3 Suppress pointer checks*/
{
TRACE_EXIT_CRITICAL_SECTION();
return TRC_FAIL;
}
SET_BASE_EVENT_DATA(pxEventData, uiEventCode, 2, pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter); /*cstat !MISRAC2012-Rule-11.5 Suppress pointer checks*/
pxEventData->uxParams[0] = uxParam1;
pxEventData->uxParams[1] = uxParam2;
(void)xTraceStreamPortCommit(pxEventData, sizeof(TraceEvent2_t), &iBytesCommitted);
TRACE_EXIT_CRITICAL_SECTION();
/* We need to use iBytesCommitted for the above call but do not use the value,
* remove potential warnings */
(void)iBytesCommitted;
return TRC_SUCCESS;
}
traceResult xTraceEventCreate3(uint32_t uiEventCode, TraceUnsignedBaseType_t uxParam1, TraceUnsignedBaseType_t uxParam2, TraceUnsignedBaseType_t uxParam3)
{
TraceEvent3_t* pxEventData = (void*)0;
int32_t iBytesCommitted = 0;
TRACE_ALLOC_CRITICAL_SECTION();
/* We need to check this */
if (!xTraceIsRecorderEnabled())
{
return TRC_FAIL;
}
TRACE_ENTER_CRITICAL_SECTION();
pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter++;
if (xTraceStreamPortAllocate(sizeof(TraceEvent3_t), (void**)&pxEventData) == TRC_FAIL) /*cstat !MISRAC2004-11.4 !MISRAC2012-Rule-11.3 Suppress pointer checks*/
{
TRACE_EXIT_CRITICAL_SECTION();
return TRC_FAIL;
}
SET_BASE_EVENT_DATA(pxEventData, uiEventCode, 3, pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter); /*cstat !MISRAC2012-Rule-11.5 Suppress pointer checks*/
pxEventData->uxParams[0] = uxParam1;
pxEventData->uxParams[1] = uxParam2;
pxEventData->uxParams[2] = uxParam3;
(void)xTraceStreamPortCommit(pxEventData, sizeof(TraceEvent3_t), &iBytesCommitted);
TRACE_EXIT_CRITICAL_SECTION();
/* We need to use iBytesCommitted for the above call but do not use the value,
* remove potential warnings */
(void)iBytesCommitted;
return TRC_SUCCESS;
}
traceResult xTraceEventCreate4(uint32_t uiEventCode, TraceUnsignedBaseType_t uxParam1, TraceUnsignedBaseType_t uxParam2, TraceUnsignedBaseType_t uxParam3, TraceUnsignedBaseType_t uxParam4)
{
TraceEvent4_t* pxEventData = (void*)0;
int32_t iBytesCommitted = 0;
TRACE_ALLOC_CRITICAL_SECTION();
/* We need to check this */
if (!xTraceIsRecorderEnabled())
{
return TRC_FAIL;
}
TRACE_ENTER_CRITICAL_SECTION();
pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter++;
if (xTraceStreamPortAllocate(sizeof(TraceEvent4_t), (void**)&pxEventData) == TRC_FAIL) /*cstat !MISRAC2004-11.4 !MISRAC2012-Rule-11.3 Suppress pointer checks*/
{
TRACE_EXIT_CRITICAL_SECTION();
return TRC_FAIL;
}
SET_BASE_EVENT_DATA(pxEventData, uiEventCode, 4, pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter); /*cstat !MISRAC2012-Rule-11.5 Suppress pointer checks*/
pxEventData->uxParams[0] = uxParam1;
pxEventData->uxParams[1] = uxParam2;
pxEventData->uxParams[2] = uxParam3;
pxEventData->uxParams[3] = uxParam4;
(void)xTraceStreamPortCommit(pxEventData, sizeof(TraceEvent4_t), &iBytesCommitted);
TRACE_EXIT_CRITICAL_SECTION();
/* We need to use iBytesCommitted for the above call but do not use the value,
* remove potential warnings */
(void)iBytesCommitted;
return TRC_SUCCESS;
}
traceResult xTraceEventCreate5(uint32_t uiEventCode, TraceUnsignedBaseType_t uxParam1, TraceUnsignedBaseType_t uxParam2, TraceUnsignedBaseType_t uxParam3, TraceUnsignedBaseType_t uxParam4, TraceUnsignedBaseType_t uxParam5)
{
TraceEvent5_t* pxEventData = (void*)0;
int32_t iBytesCommitted = 0;
TRACE_ALLOC_CRITICAL_SECTION();
/* We need to check this */
if (!xTraceIsRecorderEnabled())
{
return TRC_FAIL;
}
TRACE_ENTER_CRITICAL_SECTION();
pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter++;
if (xTraceStreamPortAllocate(sizeof(TraceEvent5_t), (void**)&pxEventData) == TRC_FAIL) /*cstat !MISRAC2004-11.4 !MISRAC2012-Rule-11.3 Suppress pointer checks*/
{
TRACE_EXIT_CRITICAL_SECTION();
return TRC_FAIL;
}
SET_BASE_EVENT_DATA(pxEventData, uiEventCode, 5, pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter); /*cstat !MISRAC2012-Rule-11.5 Suppress pointer checks*/
pxEventData->uxParams[0] = uxParam1;
pxEventData->uxParams[1] = uxParam2;
pxEventData->uxParams[2] = uxParam3;
pxEventData->uxParams[3] = uxParam4;
pxEventData->uxParams[4] = uxParam5;
(void)xTraceStreamPortCommit(pxEventData, sizeof(TraceEvent5_t), &iBytesCommitted);
TRACE_EXIT_CRITICAL_SECTION();
/* We need to use iBytesCommitted for the above call but do not use the value,
* remove potential warnings */
(void)iBytesCommitted;
return TRC_SUCCESS;
}
traceResult xTraceEventCreate6(uint32_t uiEventCode, TraceUnsignedBaseType_t uxParam1, TraceUnsignedBaseType_t uxParam2, TraceUnsignedBaseType_t uxParam3, TraceUnsignedBaseType_t uxParam4, TraceUnsignedBaseType_t uxParam5, TraceUnsignedBaseType_t uxParam6)
{
TraceEvent6_t* pxEventData = (void*)0;
int32_t iBytesCommitted = 0;
TRACE_ALLOC_CRITICAL_SECTION();
/* We need to check this */
if (!xTraceIsRecorderEnabled())
{
return TRC_FAIL;
}
TRACE_ENTER_CRITICAL_SECTION();
pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter++;
if (xTraceStreamPortAllocate(sizeof(TraceEvent6_t), (void**)&pxEventData) == TRC_FAIL) /*cstat !MISRAC2004-11.4 !MISRAC2012-Rule-11.3 Suppress pointer checks*/
{
TRACE_EXIT_CRITICAL_SECTION();
return TRC_FAIL;
}
SET_BASE_EVENT_DATA(pxEventData, uiEventCode, 6, pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter); /*cstat !MISRAC2012-Rule-11.5 Suppress pointer checks*/
pxEventData->uxParams[0] = uxParam1;
pxEventData->uxParams[1] = uxParam2;
pxEventData->uxParams[2] = uxParam3;
pxEventData->uxParams[3] = uxParam4;
pxEventData->uxParams[4] = uxParam5;
pxEventData->uxParams[5] = uxParam6;
(void)xTraceStreamPortCommit(pxEventData, sizeof(TraceEvent6_t), &iBytesCommitted);
TRACE_EXIT_CRITICAL_SECTION();
/* We need to use iBytesCommitted for the above call but do not use the value,
* remove potential warnings */
(void)iBytesCommitted;
return TRC_SUCCESS;
}
traceResult xTraceEventBeginRawOffline(uint32_t uiSize, TraceEventHandle_t* pxEventHandle)
{
int32_t ISR_nesting = 0;
TraceEventData_t* pxEventData;
TraceCoreEventData_t* pxCoreEventData;
TRACE_ALLOC_CRITICAL_SECTION();
/* We need to check this */
if (xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT) == 0U)
{
return TRC_FAIL;
}
/* This should never fail */
TRC_ASSERT(pxEventHandle != (void*)0);
TRACE_ENTER_CRITICAL_SECTION();
pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter++;
pxCoreEventData = &pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()];
/* We backup the local variable to the CORE specific variable */
pxCoreEventData->TRACE_ALLOC_CRITICAL_SECTION_NAME = TRACE_ALLOC_CRITICAL_SECTION_NAME;
(void)xTraceISRGetCurrentNesting(&ISR_nesting);
/* We add 1 since xTraceISRGetCurrentNesting(...) returns -1 if no ISR is active */
pxEventData = &pxCoreEventData->eventData[ISR_nesting + 1];
/* This should never fail */
TRC_ASSERT_CUSTOM_ON_FAIL(pxEventData->pvBlob == 0, TRACE_EXIT_CRITICAL_SECTION(); return TRC_FAIL; );
VERIFY_EVENT_SIZE(uiSize); /*cstat !MISRAC2012-Rule-17.8 Suppress modified function parameter check*/
pxEventData->size = ((uiSize + (sizeof(uint32_t) - 1u)) / sizeof(uint32_t)) * sizeof(uint32_t); /* 4-byte align */
pxEventData->offset = 0u;
/* This can fail and we should handle it */
if (xTraceStreamPortAllocate(pxEventData->size, &pxEventData->pvBlob) == TRC_FAIL)
{
TRACE_EXIT_CRITICAL_SECTION();
return TRC_FAIL;
}
*pxEventHandle = (TraceEventHandle_t)pxEventData;
return TRC_SUCCESS;
}
traceResult xTraceEventBeginRawOfflineBlocking(uint32_t uiSize, TraceEventHandle_t* pxEventHandle)
{
TraceEventData_t* pxEventData;
TraceCoreEventData_t* pxCoreEventData;
int32_t ISR_nesting = 0;
uint32_t uiAttempts = 0u;
TRACE_ALLOC_CRITICAL_SECTION();
/* We need to check this */
if (xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT) == 0U)
{
return TRC_FAIL;
}
/* This should never fail */
TRC_ASSERT(pxEventHandle != (void*)0);
TRACE_ENTER_CRITICAL_SECTION();
pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventCounter++;
pxCoreEventData = &pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()];
/* We backup the local variable to the CORE specific variable */
pxCoreEventData->TRACE_ALLOC_CRITICAL_SECTION_NAME = TRACE_ALLOC_CRITICAL_SECTION_NAME;
(void)xTraceGetCurrentISRNesting(&ISR_nesting);
/* We add 1 since xTraceISRGetCurrentNesting(...) returns -1 if no ISR is active */
pxEventData = &pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()].eventData[ISR_nesting + 1];
/* This should never fail */
TRC_ASSERT_CUSTOM_ON_FAIL(pxEventData->pvBlob == 0, TRACE_EXIT_CRITICAL_SECTION(); return TRC_FAIL; );
VERIFY_EVENT_SIZE(uiSize); /*cstat !MISRAC2012-Rule-17.8 Suppress modified function parameter check*/
pxEventData->size = ((uiSize + (sizeof(uint32_t) - 1u)) / sizeof(uint32_t)) * sizeof(uint32_t); /* 4-byte align */
pxEventData->offset = 0u;
/* This can fail and we should handle it */
while (xTraceStreamPortAllocate(pxEventData->size, &pxEventData->pvBlob) != TRC_SUCCESS)
{
uiAttempts++;
}
*pxEventHandle = (TraceEventHandle_t)pxEventData;
return TRC_SUCCESS;
}
traceResult xTraceEventEndOffline(TraceEventHandle_t xEventHandle)
{
TraceEventData_t* pxEventData = (TraceEventData_t*)xEventHandle;
const TraceCoreEventData_t* pxCoreEventData;
int32_t iBytesCommitted = 0;
TRACE_ALLOC_CRITICAL_SECTION()
pxCoreEventData = &pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()];
/* We restore the CORE specific variable to the local variable before any EXIT */
TRACE_ALLOC_CRITICAL_SECTION_NAME = pxCoreEventData->TRACE_ALLOC_CRITICAL_SECTION_NAME;
/* This should never fail */
TRC_ASSERT_CUSTOM_ON_FAIL(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT), TRACE_EXIT_CRITICAL_SECTION(); return TRC_FAIL; );
/* This should never fail */
TRC_ASSERT_CUSTOM_ON_FAIL(pxEventData != (void*)0, TRACE_EXIT_CRITICAL_SECTION(); return TRC_FAIL; );
/* This should never fail */
TRC_ASSERT_CUSTOM_ON_FAIL(pxEventData->pvBlob != (void*)0, TRACE_EXIT_CRITICAL_SECTION(); return TRC_FAIL; );
(void)xTraceStreamPortCommit(pxEventData->pvBlob, pxEventData->size, &iBytesCommitted);
/* We need to use iBytesCommitted for the above call but do not use the value,
* remove potential warnings */
(void)iBytesCommitted;
RESET_EVENT_DATA(pxEventData);
TRACE_EXIT_CRITICAL_SECTION();
return TRC_SUCCESS;
}
traceResult xTraceEventEndOfflineBlocking(TraceEventHandle_t xEventHandle)
{
TraceEventData_t* pxEventData = (TraceEventData_t*)xEventHandle;
const TraceCoreEventData_t* pxCoreEventData;
int32_t iBytesCommitted;
uint32_t uiByteOffset = 0u;
uint8_t *pubBlob;
TRACE_ALLOC_CRITICAL_SECTION()
pxCoreEventData = &pxTraceEventDataTable->coreEventData[TRC_CFG_GET_CURRENT_CORE()];
/* We restore the CORE specific variable to the local variable before any EXIT */
TRACE_ALLOC_CRITICAL_SECTION_NAME = pxCoreEventData->TRACE_ALLOC_CRITICAL_SECTION_NAME;
/* This should never fail */
TRC_ASSERT_CUSTOM_ON_FAIL(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT), TRACE_EXIT_CRITICAL_SECTION(); return TRC_FAIL; );
/* This should never fail */
TRC_ASSERT_CUSTOM_ON_FAIL(pxEventData != (void*)0, TRACE_EXIT_CRITICAL_SECTION(); return TRC_FAIL; );
/* This should never fail */
TRC_ASSERT_CUSTOM_ON_FAIL(pxEventData->pvBlob != (void*)0, TRACE_EXIT_CRITICAL_SECTION(); return TRC_FAIL; );
pubBlob = (uint8_t*)pxEventData->pvBlob; /*cstat !MISRAC2012-Rule-11.5 Suppress pointer checks*/
while (pxEventData->size > uiByteOffset)
{
iBytesCommitted = 0;
(void)xTraceStreamPortCommit((void*)&pubBlob[uiByteOffset], pxEventData->size - uiByteOffset, &iBytesCommitted); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
uiByteOffset += (uint32_t)iBytesCommitted;
}
RESET_EVENT_DATA(pxEventData);
TRACE_EXIT_CRITICAL_SECTION();
return TRC_SUCCESS;
}
traceResult xTraceEventAddData(TraceEventHandle_t xEventHandle, const uint32_t* const puiData, uint32_t uiSize)
{
uint32_t i;
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT));
/* This should never fail */
TRC_ASSERT(xEventHandle != 0);
/* This should never fail */
TRC_ASSERT(puiData != (void*)0);
/* This should never fail */
TRC_ASSERT((((TraceEventData_t*)xEventHandle)->offset + (uiSize * sizeof(uint32_t))) <= ((TraceEventData_t*)xEventHandle)->size);
for (i = 0u; i < uiSize; i++)
{
TRC_EVENT_ADD_32(xEventHandle, puiData[i]); /*cstat !MISRAC2004-17.4_b We need to access a specific part of the buffer*/
}
return TRC_SUCCESS;
}
#if ((TRC_CFG_USE_TRACE_ASSERT) == 1)
traceResult xTraceEventGetSize(const void* const pvAddress, uint32_t* puiSize)
{
/* This should never fail */
TRC_ASSERT(pvAddress != (void*)0);
/* This should never fail */
TRC_ASSERT(puiSize != (void*)0);
/* This should never fail */
TRC_ASSERT((sizeof(TraceEvent0_t) + ((uint32_t)(uint16_t)(TRC_EVENT_GET_PARAM_COUNT(((const TraceEvent0_t*)pvAddress)->EventID)) * sizeof(uint32_t))) <= (uint32_t)(TRC_MAX_BLOB_SIZE)); /*cstat !MISRAC2012-Rule-11.5 Suppress pointer checks*/
return TRC_EVENT_GET_SIZE(pvAddress, puiSize);
}
traceResult xTraceEventGetRawData(TraceEventHandle_t xEventHandle, uint32_t uiOffset, uint32_t uiSize, void** ppvData)
{
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT));
/* This should never fail */
TRC_ASSERT(xEventHandle != 0);
/* This should never fail */
TRC_ASSERT(ppvData != (void*)0);
/* This should never fail */
TRC_ASSERT((uiOffset + uiSize) <= ((TraceEventData_t*)xEventHandle)->size);
return TRC_EVENT_GET_RAW_DATA(xEventHandle, uiOffset, uiSize, ppvData);
}
traceResult xTraceEventGetPayload(const TraceEventHandle_t xEventHandle, uint32_t uiOffset, uint32_t uiSize, void** ppvData)
{
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT));
/* This should never fail */
TRC_ASSERT(xEventHandle != 0);
/* This should never fail */
TRC_ASSERT(ppvData != (void*)0);
/* This should never fail */
TRC_ASSERT((uiOffset + uiSize) <= ((const TraceEventData_t*)xEventHandle)->size);
return TRC_EVENT_GET_PAYLOAD(xEventHandle, uiOffset, uiSize, ppvData);
}
traceResult xTraceEventPayloadRemaining(const TraceEventHandle_t xEventHandle, uint32_t* puiValue)
{
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT));
/* This should never fail */
TRC_ASSERT(xEventHandle != 0);
/* This should never fail */
TRC_ASSERT(puiValue != (void*)0);
/* This should never fail */
TRC_ASSERT(((const TraceEventData_t*)xEventHandle)->pvBlob != (void*)0);
return TRC_EVENT_PAYLOAD_REMAINING(xEventHandle, puiValue);
}
traceResult xTraceEventPayloadUsed(const TraceEventHandle_t xEventHandle, uint32_t* puiValue)
{
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT));
/* This should never fail */
TRC_ASSERT(xEventHandle != 0);
/* This should never fail */
TRC_ASSERT(puiValue != (void*)0);
/* This should never fail */
TRC_ASSERT(((const TraceEventData_t*)xEventHandle)->pvBlob != (void*)0);
return TRC_EVENT_PAYLOAD_USED(xEventHandle, puiValue);
}
traceResult xTraceEventPayloadSize(const TraceEventHandle_t xEventHandle, uint32_t* puiValue)
{
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT));
/* This should never fail */
TRC_ASSERT(xEventHandle != 0);
/* This should never fail */
TRC_ASSERT(puiValue != (void*)0);
/* This should never fail */
TRC_ASSERT(((const TraceEventData_t*)xEventHandle)->pvBlob != (void*)0);
return TRC_EVENT_PAYLOAD_SIZE(xEventHandle, puiValue);
}
traceResult xTraceEventAddPointer(TraceEventHandle_t xEventHandle, void* pvAddress)
{
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT));
/* This should never fail */
TRC_ASSERT(xEventHandle != 0);
/* This should never fail */
TRC_ASSERT((((TraceEventData_t*)xEventHandle)->offset + sizeof(void*)) <= ((TraceEventData_t*)xEventHandle)->size);
/* Make sure we are writing at void* aligned offset */
/* This should never fail */
TRC_ASSERT((((TraceEventData_t*)xEventHandle)->offset & (sizeof(void*) - 1u)) == 0u);
return TRC_EVENT_ADD_POINTER(xEventHandle, pvAddress);
}
traceResult xTraceEventAddUnsignedBaseType(TraceEventHandle_t xEventHandle, TraceUnsignedBaseType_t uxValue)
{
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT));
/* This should never fail */
TRC_ASSERT(xEventHandle != 0);
/* This should never fail */
TRC_ASSERT((((TraceEventData_t*)xEventHandle)->offset + sizeof(TraceUnsignedBaseType_t)) <= ((TraceEventData_t*)xEventHandle)->size);
/* Make sure we are writing at TraceUnsignedBaseType_t aligned offset */
/* This should never fail */
TRC_ASSERT((((TraceEventData_t*)xEventHandle)->offset & (sizeof(TraceUnsignedBaseType_t) - 1u)) == 0u);
return TRC_EVENT_ADD_UNSIGNED_BASE_TYPE(xEventHandle, uxValue);
}
traceResult xTraceEventAdd32(TraceEventHandle_t xEventHandle, uint32_t value)
{
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT));
/* This should never fail */
TRC_ASSERT(xEventHandle != 0);
/* This should never fail */
TRC_ASSERT((((TraceEventData_t*)xEventHandle)->offset + sizeof(uint32_t)) <= ((TraceEventData_t*)xEventHandle)->size);
/* Make sure we are writing at 32-bit aligned offset */
/* This should never fail */
TRC_ASSERT((((TraceEventData_t*)xEventHandle)->offset & 3u) == 0u);
return TRC_EVENT_ADD_32(xEventHandle, value);
}
traceResult xTraceEventAdd16(TraceEventHandle_t xEventHandle, uint16_t value)
{
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT));
/* This should never fail */
TRC_ASSERT(xEventHandle != 0);
/* This should never fail */
TRC_ASSERT((((TraceEventData_t*)xEventHandle)->offset + sizeof(uint16_t)) <= ((TraceEventData_t*)xEventHandle)->size);
/* Make sure we are writing at 16-bit aligned offset */
/* This should never fail */
TRC_ASSERT((((TraceEventData_t*)xEventHandle)->offset & 1u) == 0u);
return TRC_EVENT_ADD_16(xEventHandle, value);
}
traceResult xTraceEventAdd8(TraceEventHandle_t xEventHandle, uint8_t value)
{
/* This should never fail */
TRC_ASSERT(xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_EVENT));
/* This should never fail */
TRC_ASSERT(xEventHandle != 0);
/* This should never fail */
TRC_ASSERT((((TraceEventData_t*)xEventHandle)->offset + sizeof(uint8_t)) <= ((TraceEventData_t*)xEventHandle)->size);
return TRC_EVENT_ADD_8(xEventHandle, value);
}
#endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */