Percepio Trace Recorder v4.11.0
Loading...
Searching...
No Matches
trcHardwarePort.h
1/*
2 * Trace Recorder for Tracealyzer v4.11.0
3 * Copyright 2025 Percepio AB
4 * www.percepio.com
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 *
8 * The hardware abstraction layer for the trace recorder.
9 */
10
11#ifndef TRC_HARDWARE_PORT_H
12#define TRC_HARDWARE_PORT_H
13
14#include <trcDefines.h>
15
16/*
17 * @brief
18 * This macro must be used as name for the variable in the critical section allocation.
19 * Example: #define TRACE_ALLOC_CRITICAL_SECTION uint32_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
20 */
21#define TRACE_ALLOC_CRITICAL_SECTION_NAME xTraceCriticalSectionStatus
22
23#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NOT_SET)
24 #error "TRC_CFG_HARDWARE_PORT not selected - see trcConfig.h"
25#endif
26
27/*******************************************************************************
28 * TRC_IRQ_PRIORITY_ORDER
29 *
30 * Macro which should be defined as an integer of 0 or 1.
31 *
32 * This should be 0 if lower IRQ priority values implies higher priority
33 * levels, such as on ARM Cortex M. If the opposite scheme is used, i.e.,
34 * if higher IRQ priority values means higher priority, this should be 1.
35 *
36 * This setting is not critical. It is used only to sort and colorize the
37 * interrupts in priority order, in case you record interrupts using
38 * the vTraceStoreISRBegin and vTraceStoreISREnd routines.
39 *
40 ******************************************************************************
41 *
42 * HWTC Macros
43 *
44 * These macros provides a hardware isolation layer representing the
45 * hardware timer/counter used for the event timestamping.
46 *
47 * TRC_HWTC_COUNT: How to read the current value of the timer/counter.
48 *
49 * TRC_HWTC_TYPE: Tells the type of timer/counter used for TRC_HWTC_COUNT:
50 *
51 * - TRC_FREE_RUNNING_32BIT_INCR:
52 * Free-running 32-bit timer/counter, counting upwards from 0.
53 *
54 * - TRC_FREE_RUNNING_32BIT_DECR
55 * Free-running 32-bit timer/counter, counting downwards from 0xFFFFFFFF.
56 *
57 * - TRC_OS_TIMER_INCR
58 * Periodic timer that drives the OS tick interrupt, counting upwards
59 * from 0 until (TRC_HWTC_PERIOD-1).
60 *
61 * - TRC_OS_TIMER_DECR
62 * Periodic timer that drives the OS tick interrupt, counting downwards
63 * from TRC_HWTC_PERIOD-1 until 0.
64 *
65 * - TRC_CUSTOM_TIMER_INCR
66 * A custom timer or counter independent of the OS tick, counting
67 * downwards from TRC_HWTC_PERIOD-1 until 0. (Currently only supported
68 * in streaming mode).
69 *
70 * - TRC_CUSTOM_TIMER_DECR
71 * A custom timer independent of the OS tick, counting downwards
72 * from TRC_HWTC_PERIOD-1 until 0. (Currently only supported
73 * in streaming mode).
74 *
75 * TRC_HWTC_PERIOD: The number of HWTC_COUNT ticks until the timer wraps
76 * around. If using TRC_FREE_RUNNING_32BIT_INCR/DECR, this should be 0.
77 *
78 * TRC_HWTC_FREQ_HZ: The clock rate of the TRC_HWTC_COUNT counter in Hz. If using
79 * TRC_OS_TIMER_INCR/DECR, this is should be TRC_HWTC_PERIOD * TRC_TICK_RATE_HZ.
80 * If using a free-running timer, this is often TRACE_CPU_CLOCK_HZ (if running at
81 * the core clock rate). If using TRC_CUSTOM_TIMER_INCR/DECR, this should match
82 * the clock rate of your custom timer (i.e., TRC_HWTC_COUNT). If the default value
83 * of TRC_HWTC_FREQ_HZ is incorrect for your setup, you can override it by calling
84 * vTraceSetFrequency before calling vTraceEnable.
85 *
86 * TRC_HWTC_DIVISOR (used in snapshot mode only):
87 * In snapshot mode, the timestamp resolution is TRC_HWTC_FREQ_HZ/TRC_HWTC_DIVISOR.
88 * If the timer frequency is very high (hundreds of MHz), we recommend increasing
89 * the TRC_HWTC_DIVISOR prescaler, to reduce the bandwidth needed to store
90 * timestamps. This since extra "XTS" events are inserted if the time since the
91 * previous event exceeds a certain limit (255 or 65535 depending on event type).
92 * It is advised to keep the time between most events below 65535 native ticks
93 * (after division by TRC_HWTC_DIVISOR) to avoid frequent XTS events.
94 ******************************************************************************/
95
96#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NOT_SET)
97 #error "TRC_CFG_HARDWARE_PORT not selected - see trcConfig.h"
98#endif
99
100#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Win32)
101/* This can be used as a template for any free-running 32-bit counter */
102void vTraceTimerReset(void);
103uint32_t uiTraceTimerGetFrequency(void);
104uint32_t uiTraceTimerGetValue(void);
105
106#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
107#define TRC_HWTC_COUNT ((TraceUnsignedBaseType_t)uiTraceTimerGetValue())
108#define TRC_HWTC_PERIOD 0
109#define TRC_HWTC_DIVISOR 1
110#define TRC_HWTC_FREQ_HZ ((TraceUnsignedBaseType_t)uiTraceTimerGetFrequency())
111
112#define TRC_IRQ_PRIORITY_ORDER 1
113
114#define TRC_PORT_SPECIFIC_INIT() vTraceTimerReset()
115
116#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Win64)
117/* This can be used as a template for any free-running 32-bit counter */
118void vTraceTimerReset(void);
119uint32_t uiTraceTimerGetFrequency(void);
120uint32_t uiTraceTimerGetValue(void);
121
122#define TRC_BASE_TYPE int64_t
123
124#define TRC_UNSIGNED_BASE_TYPE uint64_t
125
126#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
127#define TRC_HWTC_COUNT ((TraceUnsignedBaseType_t)uiTraceTimerGetValue())
128#define TRC_HWTC_PERIOD 0
129#define TRC_HWTC_DIVISOR 1
130#define TRC_HWTC_FREQ_HZ ((TraceUnsignedBaseType_t)uiTraceTimerGetFrequency())
131
132#define TRC_IRQ_PRIORITY_ORDER 1
133
134#define TRC_PORT_SPECIFIC_INIT() vTraceTimerReset()
135
136#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_HWIndependent)
137 /* Timestamping by OS tick only (typically 1 ms resolution) */
138 #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
139 #define TRC_HWTC_COUNT 0
140 #define TRC_HWTC_PERIOD 1
141 #define TRC_HWTC_DIVISOR 1
142 #define TRC_HWTC_FREQ_HZ TRC_TICK_RATE_HZ
143
144 /* Set the meaning of IRQ priorities in ISR tracing - see above */
145 #define TRC_IRQ_PRIORITY_ORDER NOT_SET
146
147/* This hardware port is deprecated and should not be used due to the low timer accuracy. */
148#error TRC_HARDWARE_PORT_HWIndependent is deprecated
149
150#elif ((TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_Cortex_M) || (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_Cortex_M_NRF_SD))
151
152 #ifndef __CORTEX_M
153 #error "Can't find the CMSIS API. Please include your processor's header file in trcConfig.h"
154 #endif
155
156#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_Cortex_M)
157 #define TRACE_ALLOC_CRITICAL_SECTION() TraceUnsignedBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
158 #define TRACE_ENTER_CRITICAL_SECTION() {TRACE_ALLOC_CRITICAL_SECTION_NAME = __get_PRIMASK(); __set_PRIMASK(1);} /* PRIMASK disables ALL interrupts - allows for tracing in any ISR */
159 #define TRACE_EXIT_CRITICAL_SECTION() {__set_PRIMASK(TRACE_ALLOC_CRITICAL_SECTION_NAME);}
160#else
161 #include "nrf_nvic.h"
162 #define TRACE_ALLOC_CRITICAL_SECTION() TraceUnsignedBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
163 #define TRACE_ENTER_CRITICAL_SECTION() {(void) sd_nvic_critical_region_enter((uint8_t*)&TRACE_ALLOC_CRITICAL_SECTION_NAME);}
164 #define TRACE_EXIT_CRITICAL_SECTION() {(void) sd_nvic_critical_region_exit((uint8_t)TRACE_ALLOC_CRITICAL_SECTION_NAME);}
165#endif
166
167 /**************************************************************************
168 * For Cortex-M3, M4 and M7, the DWT cycle counter is used for timestamping.
169 * For Cortex-M0 and M0+, the SysTick timer is used since DWT is not
170 * available. Systick timestamping can also be forced on Cortex-M3, M4 and
171 * M7 by defining the preprocessor directive TRC_CFG_ARM_CM_USE_SYSTICK,
172 * either directly below or in trcConfig.h.
173 *
174 * #define TRC_CFG_ARM_CM_USE_SYSTICK
175 **************************************************************************/
176
177 #if ((__CORTEX_M >= 0x03) && (! defined TRC_CFG_ARM_CM_USE_SYSTICK))
178
179 void xTraceHardwarePortInitCortexM(void);
180
181 #define TRC_REG_DEMCR (*(volatile uint32_t*)0xE000EDFC)
182 #define TRC_REG_DWT_CTRL (*(volatile uint32_t*)0xE0001000)
183 #define TRC_REG_DWT_CYCCNT (*(volatile uint32_t*)0xE0001004)
184 #define TRC_REG_DWT_EXCCNT (*(volatile uint32_t*)0xE000100C)
185
186 #define TRC_REG_ITM_LOCKACCESS (*(volatile uint32_t*)0xE0001FB0)
187 #define TRC_ITM_LOCKACCESS_UNLOCK (0xC5ACCE55)
188
189 /* Bit mask for TRCENA bit in DEMCR - Global enable for DWT and ITM */
190 #define TRC_DEMCR_TRCENA (1 << 24)
191
192 /* Bit mask for NOPRFCNT bit in DWT_CTRL. If 1, DWT_EXCCNT is not supported */
193 #define TRC_DWT_CTRL_NOPRFCNT (1 << 24)
194
195 /* Bit mask for NOCYCCNT bit in DWT_CTRL. If 1, DWT_CYCCNT is not supported */
196 #define TRC_DWT_CTRL_NOCYCCNT (1 << 25)
197
198 /* Bit mask for EXCEVTENA_ bit in DWT_CTRL. Set to 1 to enable DWT_EXCCNT */
199 #define TRC_DWT_CTRL_EXCEVTENA (1 << 18)
200
201 /* Bit mask for EXCEVTENA_ bit in DWT_CTRL. Set to 1 to enable DWT_CYCCNT */
202 #define TRC_DWT_CTRL_CYCCNTENA (1)
203
204 #define TRC_PORT_SPECIFIC_INIT() xTraceHardwarePortInitCortexM()
205
206 #define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
207 #define TRC_HWTC_COUNT TRC_REG_DWT_CYCCNT
208 #define TRC_HWTC_PERIOD 0
209 #define TRC_HWTC_DIVISOR 4
210 #define TRC_HWTC_FREQ_HZ TRACE_CPU_CLOCK_HZ
211 #define TRC_IRQ_PRIORITY_ORDER 0
212
213 #else
214 /* Uses the lower bits of the 64-bit free running timer in the RP2040. SysTick can not be used since it is different for both cores. */
215 #if defined(_CMSIS_RP2040_H_) || defined(RP2040_H)
216 #define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
217 #define TRC_HWTC_COUNT (*((volatile uint32_t*)0x4005400c))
218 #define TRC_HWTC_PERIOD 0
219 #define TRC_HWTC_DIVISOR 1
220 #define TRC_HWTC_FREQ_HZ 1000000
221 #define TRC_IRQ_PRIORITY_ORDER 0
222 #else
223 #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
224 #define TRC_HWTC_COUNT (*((volatile uint32_t*)0xE000E018))
225 #define TRC_HWTC_PERIOD ((*((volatile uint32_t*)0xE000E014)) + 1)
226 #define TRC_HWTC_DIVISOR 4
227 #define TRC_HWTC_FREQ_HZ TRACE_CPU_CLOCK_HZ
228 #define TRC_IRQ_PRIORITY_ORDER 0
229 #endif
230
231 #endif
232
233#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Renesas_RX600)
234 #define TRACE_ALLOC_CRITICAL_SECTION() TraceBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
235 #define TRACE_ENTER_CRITICAL_SECTION() { TRACE_ALLOC_CRITICAL_SECTION_NAME = TRC_KERNEL_PORT_SET_INTERRUPT_MASK(); }
236 #define TRACE_EXIT_CRITICAL_SECTION() { TRC_KERNEL_PORT_CLEAR_INTERRUPT_MASK(TRACE_ALLOC_CRITICAL_SECTION_NAME); }
237
238 #include <iodefine.h>
239
240 #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
241 #define TRC_HWTC_COUNT (CMT0.CMCNT)
242
243 #define TRC_HWTC_PERIOD (CMT0.CMCOR + 1)
244 #define TRC_HWTC_DIVISOR 1
245 #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
246 #define TRC_IRQ_PRIORITY_ORDER 1
247
248#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_MICROCHIP_PIC32)
249
250 #define TRACE_ALLOC_CRITICAL_SECTION() TraceBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
251 #define TRACE_ENTER_CRITICAL_SECTION() { TRACE_ALLOC_CRITICAL_SECTION_NAME = TRC_KERNEL_PORT_SET_INTERRUPT_MASK(); }
252 #define TRACE_EXIT_CRITICAL_SECTION() { TRC_KERNEL_PORT_CLEAR_INTERRUPT_MASK(TRACE_ALLOC_CRITICAL_SECTION_NAME); }
253
254 #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
255 #define TRC_HWTC_COUNT (TMR1)
256 #define TRC_HWTC_PERIOD (PR1 + 1)
257 #define TRC_HWTC_DIVISOR 1
258 #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
259 #define TRC_IRQ_PRIORITY_ORDER 1
260
261#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_TMS570_RM48)
262
263 #define TRC_RTIFRC0 *((uint32_t *)0xFFFFFC10)
264 #define TRC_RTICOMP0 *((uint32_t *)0xFFFFFC50)
265 #define TRC_RTIUDCP0 *((uint32_t *)0xFFFFFC54)
266
267 #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
268 #define TRC_HWTC_COUNT (TRC_RTIFRC0 - (TRC_RTICOMP0 - TRC_RTIUDCP0))
269 #define TRC_HWTC_PERIOD (TRC_RTIUDCP0)
270 #define TRC_HWTC_DIVISOR 1
271 #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
272 #define TRC_IRQ_PRIORITY_ORDER 0
273
274#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Atmel_AT91SAM7)
275
276 /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */
277
278 #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
279 #define TRC_HWTC_COUNT ((uint32_t)(AT91C_BASE_PITC->PITC_PIIR & 0xFFFFF))
280 #define TRC_HWTC_PERIOD ((uint32_t)(AT91C_BASE_PITC->PITC_PIMR + 1))
281 #define TRC_HWTC_DIVISOR 1
282 #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
283 #define TRC_IRQ_PRIORITY_ORDER 1
284
285#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Atmel_UC3A0)
286
287 /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO*/
288
289 /* For Atmel AVR32 (AT32UC3A) */
290
291 #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
292 #define TRC_HWTC_COUNT ((uint32_t)sysreg_read(AVR32_COUNT))
293 #define TRC_HWTC_PERIOD ((uint32_t)(sysreg_read(AVR32_COMPARE) + 1))
294 #define TRC_HWTC_DIVISOR 1
295 #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
296 #define TRC_IRQ_PRIORITY_ORDER 1
297
298#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NXP_LPC210X)
299
300 /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */
301
302 /* Tested with LPC2106, but should work with most LPC21XX chips. */
303
304 #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
305 #define TRC_HWTC_COUNT *((uint32_t *)0xE0004008 )
306 #define TRC_HWTC_PERIOD *((uint32_t *)0xE0004018 )
307 #define TRC_HWTC_DIVISOR 1
308 #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
309 #define TRC_IRQ_PRIORITY_ORDER 0
310
311#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_MSP430)
312
313 /* UNOFFICIAL PORT - NOT YET VERIFIED */
314
315 #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
316 #define TRC_HWTC_COUNT (TA0R)
317 #define TRC_HWTC_PERIOD (((uint16_t)TACCR0)+1)
318 #define TRC_HWTC_DIVISOR 1
319 #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
320 #define TRC_IRQ_PRIORITY_ORDER 1
321
322#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_PPC405)
323
324 /* UNOFFICIAL PORT - NOT YET VERIFIED */
325
326 #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
327 #define TRC_HWTC_COUNT mfspr(0x3db)
328 #define TRC_HWTC_PERIOD (TRACE_CPU_CLOCK_HZ / TRC_TICK_RATE_HZ)
329 #define TRC_HWTC_DIVISOR 1
330 #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
331 #define TRC_IRQ_PRIORITY_ORDER 0
332
333#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_PPC440)
334
335 /* UNOFFICIAL PORT */
336
337 /* This should work with most PowerPC chips */
338
339 #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
340 #define TRC_HWTC_COUNT mfspr(0x016)
341 #define TRC_HWTC_PERIOD (TRACE_CPU_CLOCK_HZ / TRC_TICK_RATE_HZ)
342 #define TRC_HWTC_DIVISOR 1
343 #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
344 #define TRC_IRQ_PRIORITY_ORDER 0
345
346#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_MICROBLAZE)
347
348 /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */
349
350 /* This should work with most Microblaze configurations.
351 * It uses the AXI Timer 0 - the tick interrupt source.
352 * If an AXI Timer 0 peripheral is available on your hardware platform, no modifications are required.
353 */
354 #include <xtmrctr_l.h>
355
356 #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
357 #define TRC_HWTC_COUNT XTmrCtr_GetTimerCounterReg( XPAR_TMRCTR_0_BASEADDR, 0 )
358 #define TRC_HWTC_PERIOD (XTmrCtr_GetLoadReg( XPAR_TMRCTR_0_BASEADDR, 0) + 1)
359 #define TRC_HWTC_DIVISOR 16
360 #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
361 #define TRC_IRQ_PRIORITY_ORDER 0
362
363#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_ZyncUltraScaleR5)
364
365 extern uint32_t cortex_a9_r5_enter_critical(void);
366 extern void cortex_a9_r5_exit_critical(uint32_t irq_already_masked_at_enter);
367
368 #define TRACE_ALLOC_CRITICAL_SECTION() TraceUnsignedBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
369
370 #define TRACE_ENTER_CRITICAL_SECTION() { TRACE_ALLOC_CRITICAL_SECTION_NAME = (TraceUnsignedBaseType_t)cortex_a9_r5_enter_critical(); }
371
372 #define TRACE_EXIT_CRITICAL_SECTION() { cortex_a9_r5_exit_critical((uint32_t)TRACE_ALLOC_CRITICAL_SECTION_NAME); }
373
374 #include <xttcps_hw.h>
375
376 #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
377 #define TRC_HWTC_COUNT (*(volatile uint32_t *)(configTIMER_BASEADDR + XTTCPS_COUNT_VALUE_OFFSET))
378 #define TRC_HWTC_PERIOD (*(volatile uint32_t *)(configTIMER_BASEADDR + XTTCPS_INTERVAL_VAL_OFFSET))
379 #define TRC_HWTC_DIVISOR 16
380 #define TRC_HWTC_FREQ_HZ (TRC_HWTC_PERIOD * TRC_TICK_RATE_HZ)
381 #define TRC_IRQ_PRIORITY_ORDER 0
382
383 #if defined(__GNUC__) || defined(__ICCARM__)
384
385 static inline uint32_t prvGetCPSR(void)
386 {
387 unsigned long ret;
388 /* GCC-style assembly for getting the CPSR/APSR register, where the system execution mode is found. */
389 asm volatile (" mrs %0, cpsr" : "=r" (ret) : /* no inputs */ );
390 return ret;
391 }
392 #else
393 #error "Only GCC and IAR supported!"
394 #endif
395
396#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Altera_NiosII)
397
398 /* OFFICIAL PORT */
399
400 #include <system.h>
401 #include <altera_avalon_timer_regs.h>
402 #include <sys/alt_irq.h>
403
404 #define TRACE_ALLOC_CRITICAL_SECTION() alt_irq_context TRACE_ALLOC_CRITICAL_SECTION_NAME;
405 #define TRACE_ENTER_CRITICAL_SECTION(){TRACE_ALLOC_CRITICAL_SECTION_NAME = alt_irq_disable_all();}
406 #define TRACE_EXIT_CRITICAL_SECTION() {alt_irq_enable_all(TRACE_ALLOC_CRITICAL_SECTION_NAME);}
407
408 #define NOT_SET 1
409
410 /* The base address for the sustem timer set.
411 * The name user for the system timer can be found in the BSP editor.
412 * If the name of the timer is sys_tmr SYSTEM_TIMER_BASE should be set to SYS_TMR_BASE.
413 */
414 #define SYSTEM_TIMER_BASE NOT_SET
415
416 #if (SYSTEM_TIMER == NOT_SET)
417 #error "Set SYSTEM_TIMER_BASE to the timer base used for system ticks."
418 #endif
419
420 static inline uint32_t altera_nios2_GetTimerSnapReg(void)
421 {
422 /* A processor can read the current counter value by first writing to either snapl or snaph to request a coherent snapshot of the counter,
423 * and then reading snapl and snaph for the full 32-bit value.
424 */
425 IOWR_ALTERA_AVALON_TIMER_SNAPL(SYSTEM_TIMER_BASE, 0);
426 return (IORD_ALTERA_AVALON_TIMER_SNAPH(SYSTEM_TIMER_BASE) << 16) | IORD_ALTERA_AVALON_TIMER_SNAPL(SYSTEM_TIMER_BASE);
427 }
428
429 #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
430 #define TRC_HWTC_COUNT altera_nios2_GetTimerSnapReg()
431 #define TRC_HWTC_PERIOD (configCPU_CLOCK_HZ / configTICK_RATE_HZ )
432 #define TRC_HWTC_DIVISOR 16
433 #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
434 #define TRC_IRQ_PRIORITY_ORDER 0
435
436#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_CORTEX_A9)
437
438 /**************************************************************************
439 * This hardware port only supports FreeRTOS and the GCC compiler at the
440 * moment, due to the implementation of critical sections (trcKernelPort.h).
441 *
442 * Assuming FreeRTOS is used:
443 *
444 * For critical sections, this uses vTaskEnterCritical is when called from
445 * task context and ulPortSetInterruptMask when called from ISR context.
446 * Thus, it does not disable all ISRs. This means that the trace recorder
447 * can only be called from ISRs with priority less or equal to
448 * configMAX_API_CALL_INTERRUPT_PRIORITY (like FreeRTOS fromISR functions).
449 *
450 * This hardware port has been tested on a Xilinx Zync 7000 (Cortex-A9).
451
452 **************************************************************************/
453
454
455 extern uint32_t cortex_a9_r5_enter_critical(void);
456 extern void cortex_a9_r5_exit_critical(uint32_t irq_already_masked_at_enter);
457
458 #define TRACE_ALLOC_CRITICAL_SECTION() TraceUnsignedBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
459 #define TRACE_ENTER_CRITICAL_SECTION() { TRACE_ALLOC_CRITICAL_SECTION_NAME = (TraceUnsignedBaseType_t)cortex_a9_r5_enter_critical(); }
460 #define TRACE_EXIT_CRITICAL_SECTION() { cortex_a9_r5_exit_critical((uint32_t)TRACE_ALLOC_CRITICAL_SECTION_NAME); }
461
462 /* INPUT YOUR PERIPHERAL BASE ADDRESS HERE (0xF8F00000 for Xilinx Zynq 7000)*/
463 #define TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS 0
464
465 #if (TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS == 0)
466 #error "Please specify TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS."
467 #endif
468
469 #define TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET 0x0600
470 #define TRC_CA9_MPCORE_PRIVCTR_PERIOD_REG (*(volatile uint32_t*)(TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x00))
471 #define TRC_CA9_MPCORE_PRIVCTR_COUNTER_REG (*(volatile uint32_t*)(TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x04))
472 #define TRC_CA9_MPCORE_PRIVCTR_CONTROL_REG (*(volatile uint32_t*)(TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x08))
473
474 #define TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_MASK 0x0000FF00
475 #define TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_SHIFT 8
476 #define TRC_CA9_MPCORE_PRIVCTR_PRESCALER (((TRC_CA9_MPCORE_PRIVCTR_CONTROL_REG & TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_MASK) >> TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_SHIFT) + 1)
477
478 #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
479 #define TRC_HWTC_COUNT TRC_CA9_MPCORE_PRIVCTR_COUNTER_REG
480 #define TRC_HWTC_PERIOD (TRC_CA9_MPCORE_PRIVCTR_PERIOD_REG + 1)
481
482 /****************************************************************************************
483 NOTE: The private timer ticks with a very high frequency (half the core-clock usually),
484 depending on the prescaler used. If a low prescaler is used, the number of HW ticks between
485 the trace events gets large, and thereby inefficient to store (sometimes extra events are
486 needed). To improve efficiency, you may use the TRC_HWTC_DIVISOR as an additional prescaler.
487 *****************************************************************************************/
488 #define TRC_HWTC_DIVISOR 1
489
490 #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
491 #define TRC_IRQ_PRIORITY_ORDER 0
492
493 #if defined(__GNUC__) || defined(__ICCARM__)
494
495 static inline uint32_t prvGetCPSR(void)
496 {
497 unsigned long ret;
498 /* GCC-style assembly for getting the CPSR/APSR register, where the system execution mode is found. */
499 asm volatile (" mrs %0, cpsr" : "=r" (ret) : /* no inputs */ );
500 return ret;
501 }
502 #else
503 #error "Only GCC and IAR supported!"
504 #endif
505
506#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_CYCLONE_V_HPS)
507 #include "alt_clock_manager.h"
508
509
510 extern uint32_t cortex_a9_r5_enter_critical(void);
511 extern void cortex_a9_r5_exit_critical(uint32_t irq_already_masked_at_enter);
512
513 #define TRACE_ALLOC_CRITICAL_SECTION() TraceUnsignedBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
514 #define TRACE_ENTER_CRITICAL_SECTION() { TRACE_ALLOC_CRITICAL_SECTION_NAME = (TraceUnsignedBaseType_t)cortex_a9_r5_enter_critical(); }
515 #define TRACE_EXIT_CRITICAL_SECTION() { cortex_a9_r5_exit_critical((uint32_t)TRACE_ALLOC_CRITICAL_SECTION_NAME); }
516
517 #define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
518 #define TRC_HWTC_COUNT *((uint32_t *)0xFFFEC200)
519 #define TRC_HWTC_PERIOD 0
520 #define TRC_HWTC_DIVISOR 1
521 #define TRC_HWTC_FREQ_HZ (({ \
522 uint32_t __freq; \
523 alt_clk_freq_get( ALT_CLK_MPU_PERIPH, &__freq ); \
524 __freq; \
525 }))
526 #define TRC_IRQ_PRIORITY_ORDER 0
527
528 #if defined(__GNUC__) || defined(__ICCARM__)
529 /* For Arm Cortex-A and Cortex-R in general. */
530 static inline uint32_t prvGetCPSR(void)
531 {
532 unsigned long ret;
533 /* GCC-style assembly for getting the CPSR/APSR register, where the system execution mode is found. */
534 __asm__ __volatile__(" mrs %0, cpsr" : "=r" (ret) : /* no inputs */ );
535 return ret;
536 }
537 #else
538 #error "Only GCC and IAR supported!"
539 #endif
540
541#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ZEPHYR)
542 #ifdef CONFIG_64BIT
543 #define TRC_BASE_TYPE int64_t
544 #define TRC_UNSIGNED_BASE_TYPE uint64_t
545 #else
546 #define TRC_BASE_TYPE int32_t
547 #define TRC_UNSIGNED_BASE_TYPE uint32_t
548 #endif
549
550 #define TRACE_ALLOC_CRITICAL_SECTION() TraceBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
551 #define TRACE_ENTER_CRITICAL_SECTION() { TRACE_ALLOC_CRITICAL_SECTION_NAME = irq_lock(); }
552 #define TRACE_EXIT_CRITICAL_SECTION() { irq_unlock(TRACE_ALLOC_CRITICAL_SECTION_NAME); }
553
554 #define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
555 #define TRC_HWTC_COUNT k_cycle_get_32()
556 #define TRC_HWTC_PERIOD (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / CONFIG_SYS_CLOCK_TICKS_PER_SEC)
557 #define TRC_HWTC_DIVISOR 4
558 #define TRC_HWTC_FREQ_HZ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC
559 #define TRC_IRQ_PRIORITY_ORDER 0 // Lower IRQ priority values are more significant
560
561 #define TRC_PORT_SPECIFIC_INIT()
562
563#elif ((TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XTensa_LX6) || (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XTensa_LX7))
568 #if CONFIG_FREERTOS_UNICORE == 1
569
570 #define TRACE_ALLOC_CRITICAL_SECTION() TraceUnsignedBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
571 #define TRACE_ENTER_CRITICAL_SECTION() {TRACE_ALLOC_CRITICAL_SECTION_NAME = __extension__({ unsigned __tmp; \
572 __asm__ __volatile__("rsil %0, 15\n" \
573 : "=a" (__tmp) : : "memory" ); \
574 __tmp;});}
575 #define TRACE_EXIT_CRITICAL_SECTION() {portCLEAR_INTERRUPT_MASK_FROM_ISR(TRACE_ALLOC_CRITICAL_SECTION_NAME);}
576
577 #define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
578 #define TRC_HWTC_COUNT ({ unsigned int __ccount; \
579 __asm__ __volatile__("rsr.ccount %0" : "=a"(__ccount)); \
580 __ccount; })
581#ifdef CONFIG_IDF_TARGET_ESP32
582 #define TRC_HWTC_FREQ_HZ (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 1000000)
583#elif defined(CONFIG_IDF_TARGET_ESP32S2)
584 #define TRC_HWTC_FREQ_HZ (CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ * 1000000)
585#else
586 #error "Invalid IDF target, check your sdkconfig."
587#endif
588 #define TRC_HWTC_PERIOD 0
589 #define TRC_HWTC_DIVISOR 4
590 #define TRC_IRQ_PRIORITY_ORDER 0
591 #else
597 uint32_t prvGetSMPTimestamp();
598
599 #define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
600 #define TRC_HWTC_COUNT prvGetSMPTimestamp()
601 #define TRC_HWTC_FREQ_HZ 1000000
602 #define TRC_HWTC_PERIOD 0
603 #define TRC_HWTC_DIVISOR 4
604 #define TRC_IRQ_PRIORITY_ORDER 0
605 #endif
606
607 #if !defined(TRC_HWTC_FREQ_HZ)
608 #error "The XTensa LX6/LX7 trace hardware clock frequency is not defined."
609 #endif
610
611#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_RISCV_RV32I)
612 #define TRACE_ALLOC_CRITICAL_SECTION() TraceUnsignedBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
613 #define TRACE_ENTER_CRITICAL_SECTION() __asm__ __volatile__("csrr %0, mstatus \n\t" \
614 "csrci mstatus, 8 \n\t" \
615 "andi %0, %0, 8 \n\t" \
616 : "=r"(TRACE_ALLOC_CRITICAL_SECTION_NAME))
617 #define TRACE_EXIT_CRITICAL_SECTION() __asm__ __volatile__("csrr a1, mstatus \n\t" \
618 "or %0, %0, a1 \n\t" \
619 "csrs mstatus, %0 \n\t" \
620 : \
621 : "r" (TRACE_ALLOC_CRITICAL_SECTION_NAME) \
622 : "a1")
623 #define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
624 #define TRC_HWTC_COUNT ({ unsigned int __count; \
625 __asm__ __volatile__("rdcycle %0" : "=r"(__count)); \
626 __count; })
627 #define TRC_HWTC_PERIOD 0
628 #define TRC_HWTC_DIVISOR 1
629 #define TRC_HWTC_FREQ_HZ 16000000
630 #define TRC_IRQ_PRIORITY_ORDER 0
631
632#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XMOS_XCOREAI)
633 #define TRC_PORT_SPECIFIC_INIT()
634 #define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
635 #define TRC_HWTC_COUNT xscope_gettime()
636 #define TRC_HWTC_PERIOD (configCPU_CLOCK_HZ / configTICK_RATE_HZ )
637 #define TRC_HWTC_DIVISOR 4
638 #define TRC_HWTC_FREQ_HZ 100000000
639 #define TRC_IRQ_PRIORITY_ORDER 0
640
641#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_POWERPC_Z4)
642
643 /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */
644
645 #define TRACE_ALLOC_CRITICAL_SECTION() TraceBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
646 #define TRACE_ENTER_CRITICAL_SECTION() { TRACE_ALLOC_CRITICAL_SECTION_NAME = TRC_KERNEL_PORT_SET_INTERRUPT_MASK(); }
647 #define TRACE_EXIT_CRITICAL_SECTION() { TRC_KERNEL_PORT_CLEAR_INTERRUPT_MASK(TRACE_ALLOC_CRITICAL_SECTION_NAME); }
648
649 #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
650 //#define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING
651 #define TRC_HWTC_COUNT PIT.TIMER[configTICK_PIT_CHANNEL].CVAL.R // must be the PIT channel used for the systick
652 #define TRC_HWTC_PERIOD ((configPIT_CLOCK_HZ / configTICK_RATE_HZ) - 1U) // TODO FIXME or maybe not -1? what's the right "period" value?
653 #define TRC_HWTC_FREQ_HZ configPIT_CLOCK_HZ
654 #define TRC_HWTC_DIVISOR 1
655 #define TRC_IRQ_PRIORITY_ORDER 1 // higher IRQ priority values are more significant
656
657#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARMv8AR_A32)
658 extern uint32_t cortex_a9_r5_enter_critical(void);
659 extern void cortex_a9_r5_exit_critical(uint32_t irq_already_masked_at_enter);
660
661 #define TRACE_ALLOC_CRITICAL_SECTION() TraceUnsignedBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
662 #define TRACE_ENTER_CRITICAL_SECTION() { TRACE_ALLOC_CRITICAL_SECTION_NAME = (TraceUnsignedBaseType_t)cortex_a9_r5_enter_critical(); }
663 #define TRACE_EXIT_CRITICAL_SECTION() { cortex_a9_r5_exit_critical((uint32_t)TRACE_ALLOC_CRITICAL_SECTION_NAME); }
664
665 #include <cmsis_compiler.h>
666
667 #define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
668 #define TRC_HWTC_COUNT ((uint32_t)__get_CNTPCT())
669 #define TRC_HWTC_PERIOD 0
670 #define TRC_HWTC_DIVISOR 16
671 #define TRC_HWTC_FREQ_HZ (R_GSC->CNTFID0)
672 #define TRC_IRQ_PRIORITY_ORDER 0
673
674 #if defined(__GNUC__) || defined(__ICCARM__)
675 /* For Arm Cortex-A and Cortex-R in general. */
676 static inline uint32_t prvGetCPSR(void)
677 {
678 unsigned long ret;
679 /* GCC-style assembly for getting the CPSR/APSR register, where the system execution mode is found. */
680 __asm volatile (" mrs %0, cpsr" : "=r" (ret) : /* no inputs */ );
681 return ret;
682 }
683 #else
684 #error "Only GCC and IAR supported!"
685 #endif
686
687#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ADSP_SC5XX_SHARC)
688
689 #define TRACE_ALLOC_CRITICAL_SECTION() TraceUnsignedBaseType_t TRACE_ALLOC_CRITICAL_SECTION_NAME;
690 #define TRACE_ENTER_CRITICAL_SECTION() {TRACE_ALLOC_CRITICAL_SECTION_NAME = (TraceUnsignedBaseType_t)portSET_INTERRUPT_MASK_FROM_ISR();}
691 #define TRACE_EXIT_CRITICAL_SECTION() {portCLEAR_INTERRUPT_MASK_FROM_ISR((UBaseType_t)TRACE_ALLOC_CRITICAL_SECTION_NAME);}
692
693 #define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
694 #define TRC_HWTC_COUNT ( *pREG_CGU0_TSCOUNT0 )
695 #define TRC_HWTC_PERIOD 1
696 #define TRC_HWTC_DIVISOR 1
697 #define TRC_HWTC_FREQ_HZ ( configCPU_CLOCK_HZ >> 1u )
698
699 #define TRC_PORT_SPECIFIC_INIT() {*pREG_CGU0_TSCTL |= BITM_CGU_TSCTL_EN;}
700
701 /* Set the meaning of IRQ priorities in ISR tracing - see above */
702 #define TRC_IRQ_PRIORITY_ORDER 1
703
704#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_APPLICATION_DEFINED)
705
706 #if !( defined (TRC_HWTC_TYPE) && defined (TRC_HWTC_COUNT) && defined (TRC_HWTC_PERIOD) && defined (TRC_HWTC_FREQ_HZ) && defined (TRC_IRQ_PRIORITY_ORDER) )
707 #error "The hardware port is not completely defined!"
708 #endif
709
710#elif (TRC_CFG_HARDWARE_PORT != TRC_HARDWARE_PORT_NOT_SET)
711
712 #error "TRC_CFG_HARDWARE_PORT had unsupported value!"
713 #define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_NOT_SET
714
715#endif
716
717#ifndef TRC_HWTC_DIVISOR
718 #define TRC_HWTC_DIVISOR 1
719#endif
720
721#ifndef TRC_PORT_SPECIFIC_INIT
722 #define TRC_PORT_SPECIFIC_INIT()
723#endif
724
725/* If Win32 port */
726#ifdef WIN32
727
728 #undef _WIN32_WINNT
729 #define _WIN32_WINNT 0x0600
730
731 /* Standard includes. */
732 #include <stdio.h>
733 #include <windows.h>
734 #include <direct.h>
735
736 /***************************************************************************
737 * The Win32 port by default saves the trace to file and then kills the
738 * program when the recorder is stopped, to facilitate quick, simple tests
739 * of the recorder.
740 ***************************************************************************/
741 #define WIN32_PORT_SAVE_WHEN_STOPPED 1
742 #define WIN32_PORT_EXIT_WHEN_STOPPED 1
743
744#endif
745
746#if (TRC_CFG_HARDWARE_PORT != TRC_HARDWARE_PORT_NOT_SET)
747
748 #ifndef TRC_HWTC_TYPE
749 #error "TRC_HWTC_TYPE is not set!"
750 #endif
751
752 #ifndef TRC_HWTC_COUNT
753 #error "TRC_HWTC_COUNT is not set!"
754 #endif
755
756 #ifndef TRC_HWTC_PERIOD
757 #error "TRC_HWTC_PERIOD is not set!"
758 #endif
759
760 #ifndef TRC_HWTC_DIVISOR
761 #error "TRC_HWTC_DIVISOR is not set!"
762 #endif
763
764 #ifndef TRC_IRQ_PRIORITY_ORDER
765 #error "TRC_IRQ_PRIORITY_ORDER is not set!"
766 #elif (TRC_IRQ_PRIORITY_ORDER != 0) && (TRC_IRQ_PRIORITY_ORDER != 1)
767 #error "TRC_IRQ_PRIORITY_ORDER has bad value!"
768 #endif
769
770 #if (TRC_HWTC_DIVISOR < 1)
771 #error "TRC_HWTC_DIVISOR must be a non-zero positive value!"
772 #endif
773
774 #ifndef TRC_HWTC_FREQ_HZ
775 #error "TRC_HWTC_FREQ_HZ not defined!"
776 #endif
777
778#endif
779
780/* If a custom TRC_CFG_ALLOC_CRITICAL_SECTION is defined it will override the default definition */
781#ifdef TRC_CFG_ALLOC_CRITICAL_SECTION
782#undef TRACE_ALLOC_CRITICAL_SECTION
783#define TRACE_ALLOC_CRITICAL_SECTION() TRC_CFG_ALLOC_CRITICAL_SECTION()
784#endif
785
786/* If a custom TRC_CFG_ENTER_CRITICAL_SECTION is defined it will override the default definition */
787#ifdef TRC_CFG_ENTER_CRITICAL_SECTION
788#undef TRACE_ENTER_CRITICAL_SECTION
789#define TRACE_ENTER_CRITICAL_SECTION() TRC_CFG_ENTER_CRITICAL_SECTION()
790#endif
791
792/* If a custom TRC_CFG_EXIT_CRITICAL_SECTION is defined it will override the default definition */
793#ifdef TRC_CFG_EXIT_CRITICAL_SECTION
794#undef TRACE_EXIT_CRITICAL_SECTION
795#define TRACE_EXIT_CRITICAL_SECTION() TRC_CFG_EXIT_CRITICAL_SECTION()
796#endif
797
798#ifndef TRACE_ALLOC_CRITICAL_SECTION
799#define TRACE_ALLOC_CRITICAL_SECTION() TRC_KERNEL_PORT_ALLOC_CRITICAL_SECTION()
800#endif
801#ifndef TRACE_ENTER_CRITICAL_SECTION
802#define TRACE_ENTER_CRITICAL_SECTION() TRC_KERNEL_PORT_ENTER_CRITICAL_SECTION()
803#endif
804#ifndef TRACE_EXIT_CRITICAL_SECTION
805#define TRACE_EXIT_CRITICAL_SECTION() TRC_KERNEL_PORT_EXIT_CRITICAL_SECTION()
806#endif
807
808#endif /*TRC_HARDWARE_PORT_H*/