3
3
* SPDX-License-Identifier: Apache-2.0
4
4
*/
5
5
6
- /*******************************************************************************
7
-
8
- RTOS-SPECIFIC INFORMATION FOR XTENSA RTOS ASSEMBLER SOURCES
9
- (FreeRTOS Port)
10
-
11
- This header is the primary glue between generic Xtensa RTOS support
12
- sources and a specific RTOS port for Xtensa. It contains definitions
13
- and macros for use primarily by Xtensa assembly coded source files.
14
-
15
- Macros in this header map callouts from generic Xtensa files to specific
16
- RTOS functions. It may also be included in C source files.
17
-
18
- Xtensa RTOS ports support all RTOS-compatible configurations of the Xtensa
19
- architecture, using the Xtensa hardware abstraction layer (HAL) to deal
20
- with configuration specifics.
21
-
22
- Should be included by all Xtensa generic and RTOS port-specific sources.
23
-
24
- *******************************************************************************/
6
+ /*
7
+ * RTOS-SPECIFIC INFORMATION FOR XTENSA RTOS ASSEMBLER SOURCES
8
+ * (FreeRTOS Port)
9
+ *
10
+ * This header is the primary glue between generic Xtensa RTOS support
11
+ * sources and a specific RTOS port for Xtensa. It contains definitions
12
+ * and macros for use primarily by Xtensa assembly coded source files.
13
+ *
14
+ * Macros in this header map callouts from generic Xtensa files to specific
15
+ * RTOS functions. It may also be included in C source files.
16
+ *
17
+ * Xtensa RTOS ports support all RTOS-compatible configurations of the Xtensa
18
+ * architecture, using the Xtensa hardware abstraction layer (HAL) to deal
19
+ * with configuration specifics.
20
+ *
21
+ * Should be included by all Xtensa generic and RTOS port-specific sources.
22
+ */
25
23
26
24
#ifndef XTENSA_RTOS_H
27
25
#define XTENSA_RTOS_H
@@ -38,9 +36,9 @@ Should be included by all Xtensa generic and RTOS port-specific sources.
38
36
39
37
40
38
/*
41
- Convert FreeRTOSConfig definitions to XTENSA definitions.
42
- However these can still be overridden from the command line.
43
- */
39
+ * Convert FreeRTOSConfig definitions to XTENSA definitions.
40
+ * However these can still be overridden from the command line.
41
+ */
44
42
45
43
#ifndef XT_SIMULATOR
46
44
#if CONFIG_SIMULATOR_XTENSA
@@ -72,8 +70,8 @@ However these can still be overridden from the command line.
72
70
73
71
74
72
/*
75
- Name of RTOS (for messages).
76
- */
73
+ * Name of RTOS (for messages).
74
+ */
77
75
#define XT_RTOS_NAME Zephyr
78
76
79
77
/*
@@ -83,104 +81,102 @@ Name of RTOS (for messages).
83
81
#undef XT_RTOS_IS_FREE_RTOS
84
82
85
83
/*
86
- Check some Xtensa configuration requirements and report error if not met.
87
- Error messages can be customize to the RTOS port.
88
- */
84
+ * Check some Xtensa configuration requirements and report error if not met.
85
+ * Error messages can be customize to the RTOS port.
86
+ */
89
87
90
88
#if !XCHAL_HAVE_XEA2
91
89
#error "Zephyr/Xtensa requires XEA2 (exception architecture 2)."
92
90
#endif
93
91
94
- /*******************************************************************************
95
-
96
- RTOS CALLOUT MACROS MAPPED TO RTOS PORT-SPECIFIC FUNCTIONS.
97
-
98
- Define callout macros used in generic Xtensa code to interact with the RTOS.
99
- The macros are simply the function names for use in calls from assembler code.
100
- Some of these functions may call back to generic functions in xtensa_context.h .
101
-
102
- ****************************************************************************** */
92
+ /*
93
+ * RTOS CALLOUT MACROS MAPPED TO RTOS PORT-SPECIFIC FUNCTIONS.
94
+ *
95
+ * Define callout macros used in generic Xtensa code to interact with the RTOS.
96
+ * The macros are simply the function names for use in calls from assembler
97
+ * code.
98
+ * Some of these functions may call back to generic functions in
99
+ * xtensa_context.h .
100
+ */
103
101
104
102
/*
105
- Inform RTOS of entry into an interrupt handler that will affect it.
106
- Allows RTOS to manage switch to any system stack and count nesting level.
107
- Called after minimal context has been saved, with interrupts disabled.
108
- RTOS port can call0 _xt_context_save to save the rest of the context.
109
- May only be called from assembly code by the 'call0' instruction.
103
+ * Inform RTOS of entry into an interrupt handler that will affect it.
104
+ * Allows RTOS to manage switch to any system stack and count nesting level.
105
+ * Called after minimal context has been saved, with interrupts disabled.
106
+ * RTOS port can call0 _xt_context_save to save the rest of the context.
107
+ * May only be called from assembly code by the 'call0' instruction.
110
108
*/
111
109
// void XT_RTOS_INT_ENTER(void)
112
110
#define XT_RTOS_INT_ENTER _zxt_int_enter
113
111
114
112
/*
115
- Inform RTOS of completion of an interrupt handler, and give control to
116
- RTOS to perform thread/task scheduling, switch back from any system stack
117
- and restore the context, and return to the exit dispatcher saved in the
118
- stack frame at XT_STK_EXIT. RTOS port can call0 _xt_context_restore
119
- to save the context saved in XT_RTOS_INT_ENTER via _xt_context_save,
120
- leaving only a minimal part of the context to be restored by the exit
121
- dispatcher. This function does not return to the place it was called from.
122
- May only be called from assembly code by the 'call0' instruction.
123
- */
124
- // void XT_RTOS_INT_EXIT(void)
113
+ * Inform RTOS of completion of an interrupt handler, and give control to
114
+ * RTOS to perform thread/task scheduling, switch back from any system stack
115
+ * and restore the context, and return to the exit dispatcher saved in the
116
+ * stack frame at XT_STK_EXIT. RTOS port can call0 _xt_context_restore
117
+ * to save the context saved in XT_RTOS_INT_ENTER via _xt_context_save,
118
+ * leaving only a minimal part of the context to be restored by the exit
119
+ * dispatcher. This function does not return to the place it was called from.
120
+ * May only be called from assembly code by the 'call0' instruction.
121
+ */
125
122
#define XT_RTOS_INT_EXIT _zxt_int_exit
126
123
127
124
/*
128
- Inform RTOS of the occurrence of a tick timer interrupt.
129
- If RTOS has no tick timer, leave XT_RTOS_TIMER_INT undefined.
130
- May be coded in or called from C or assembly, per ABI conventions.
131
- RTOS may optionally define XT_TICK_PER_SEC in its own way (eg. macro).
132
- */
133
- // void XT_RTOS_TIMER_INT(void)
125
+ * Inform RTOS of the occurrence of a tick timer interrupt.
126
+ * If RTOS has no tick timer, leave XT_RTOS_TIMER_INT undefined.
127
+ * May be coded in or called from C or assembly, per ABI conventions.
128
+ * RTOS may optionally define XT_TICK_PER_SEC in its own way (eg. macro).
129
+ */
134
130
#define XT_RTOS_TIMER_INT _zxt_timer_int
135
131
#define XT_TICK_PER_SEC CONFIG_SYS_CLOCK_TICKS_PER_SEC
136
132
137
133
/*
138
- Return in a15 the base address of the co-processor state save area for the
139
- thread that triggered a co-processor exception, or 0 if no thread was running.
140
- The state save area is structured as defined in xtensa_context.h and has size
141
- XT_CP_SIZE. Co-processor instructions should only be used in thread code, never
142
- in interrupt handlers or the RTOS kernel. May only be called from assembly code
143
- and by the 'call0' instruction. A result of 0 indicates an unrecoverable error.
144
- The implementation may use only a2-4, a15 (all other regs must be preserved).
145
- */
146
- // void* XT_RTOS_CP_STATE(void)
134
+ * Return in a15 the base address of the co-processor state save area for the
135
+ * thread that triggered a co-processor exception, or 0 if no thread was
136
+ * running.
137
+ * The state save area is structured as defined in xtensa_context.h and has size
138
+ * XT_CP_SIZE. Co-processor instructions should only be used in thread code,
139
+ * never in interrupt handlers or the RTOS kernel. May only be called from
140
+ * assembly code and by the 'call0' instruction. A result of 0 indicates an
141
+ * unrecoverable error.
142
+ *
143
+ * The implementation may use only a2-4, a15 (all other regs must be preserved).
144
+ */
147
145
#define XT_RTOS_CP_STATE _zxt_task_coproc_state
148
146
149
147
150
- /*******************************************************************************
151
-
152
- HOOKS TO DYNAMICALLY INSTALL INTERRUPT AND EXCEPTION HANDLERS PER LEVEL.
153
-
154
- This Xtensa RTOS port provides hooks for dynamically installing exception
155
- and interrupt handlers to facilitate automated testing where each test
156
- case can install its own handler for user exceptions and each interrupt
157
- priority (level). This consists of an array of function pointers indexed
158
- by interrupt priority, with index 0 being the user exception handler hook.
159
- Each entry in the array is initially 0, and may be replaced by a function
160
- pointer of type XT_INTEXC_HOOK. A handler may be uninstalled by installing 0.
161
-
162
- The handler for low and medium priority obeys ABI conventions so may be coded
163
- in C. For the exception handler, the cause is the contents of the EXCCAUSE
164
- reg, and the result is -1 if handled, else the cause (still needs handling).
165
- For interrupt handlers, the cause is a mask of pending enabled interrupts at
166
- that level, and the result is the same mask with the bits for the handled
167
- interrupts cleared (those not cleared still need handling). This allows a test
168
- case to either pre-handle or override the default handling for the exception
169
- or interrupt level (see xtensa_vectors.S).
170
-
171
- High priority handlers (including NMI) must be coded in assembly, are always
172
- called by 'call0' regardless of ABI, must preserve all registers except a0,
173
- and must not use or modify the interrupted stack. The hook argument 'cause'
174
- is not passed and the result is ignored, so as not to burden the caller with
175
- saving and restoring a2 (it assumes only one interrupt per level - see the
176
- discussion in high priority interrupts in xtensa_vectors.S). The handler
177
- therefore should be coded to prototype 'void h(void)' even though it plugs
178
- into an array of handlers of prototype 'unsigned h(unsigned)'.
179
-
180
- To enable interrupt/exception hooks, compile the RTOS with '-DXT_INTEXC_HOOKS'.
181
-
182
- *******************************************************************************/
183
-
148
+ /*
149
+ * HOOKS TO DYNAMICALLY INSTALL INTERRUPT AND EXCEPTION HANDLERS PER LEVEL.
150
+ *
151
+ * This Xtensa RTOS port provides hooks for dynamically installing exception
152
+ * and interrupt handlers to facilitate automated testing where each test
153
+ * case can install its own handler for user exceptions and each interrupt
154
+ * priority (level). This consists of an array of function pointers indexed
155
+ * by interrupt priority, with index 0 being the user exception handler hook.
156
+ * Each entry in the array is initially 0, and may be replaced by a function
157
+ * pointer of type XT_INTEXC_HOOK. A handler may be uninstalled by installing 0.
158
+ *
159
+ * The handler for low and medium priority obeys ABI conventions so may be coded
160
+ * in C. For the exception handler, the cause is the contents of the EXCCAUSE
161
+ * reg, and the result is -1 if handled, else the cause (still needs handling).
162
+ * For interrupt handlers, the cause is a mask of pending enabled interrupts at
163
+ * that level, and the result is the same mask with the bits for the handled
164
+ * interrupts cleared (those not cleared still need handling). This allows a
165
+ * test case to either pre-handle or override the default handling for the
166
+ * exception or interrupt level (see xtensa_vectors.S).
167
+ *
168
+ * High priority handlers (including NMI) must be coded in assembly, are always
169
+ * called by 'call0' regardless of ABI, must preserve all registers except a0,
170
+ * and must not use or modify the interrupted stack. The hook argument 'cause'
171
+ * is not passed and the result is ignored, so as not to burden the caller with
172
+ * saving and restoring a2 (it assumes only one interrupt per level - see the
173
+ * discussion in high priority interrupts in xtensa_vectors.S). The handler
174
+ * therefore should be coded to prototype 'void h(void)' even though it plugs
175
+ * into an array of handlers of prototype 'unsigned h(unsigned)'.
176
+ *
177
+ * To enable interrupt/exception hooks, compile the RTOS with
178
+ * '-DXT_INTEXC_HOOKS'.
179
+ */
184
180
#define XT_INTEXC_HOOK_NUM (1 + XCHAL_NUM_INTLEVELS + XCHAL_HAVE_NMI)
185
181
186
182
#ifndef __ASSEMBLER__
@@ -189,29 +185,17 @@ extern volatile XT_INTEXC_HOOK _xt_intexc_hooks[XT_INTEXC_HOOK_NUM];
189
185
#endif
190
186
191
187
192
- /*******************************************************************************
193
-
194
- CONVENIENCE INCLUSIONS.
195
-
196
- Ensures RTOS specific files need only include this one Xtensa-generic header.
197
- These headers are included last so they can use the RTOS definitions above.
198
-
199
- *******************************************************************************/
188
+ /*
189
+ * CONVENIENCE INCLUSIONS.
190
+ *
191
+ * Ensures RTOS specific files need only include this one Xtensa-generic header.
192
+ * These headers are included last so they can use the RTOS definitions above.
193
+ */
200
194
201
195
#include "xtensa_context.h"
202
196
203
197
#ifdef XT_RTOS_TIMER_INT
204
198
#include "xtensa_timer.h"
205
199
#endif
206
200
207
-
208
- /*******************************************************************************
209
-
210
- Xtensa Port Version.
211
-
212
- *******************************************************************************/
213
-
214
- #define XTENSA_PORT_VERSION 1.5.0
215
- #define XTENSA_PORT_VERSION_STRING "1.5.0"
216
-
217
201
#endif /* XTENSA_RTOS_H */
0 commit comments