1 | /** |
---|
2 | * @file rtems/score/cpu.h |
---|
3 | */ |
---|
4 | |
---|
5 | /* |
---|
6 | * This include file contains information pertaining to the C4x |
---|
7 | * processor. |
---|
8 | * |
---|
9 | * COPYRIGHT (c) 1989-2006. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | * |
---|
16 | * $Id$ |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_SCORE_CPU_H |
---|
20 | #define _RTEMS_SCORE_CPU_H |
---|
21 | |
---|
22 | #ifdef __cplusplus |
---|
23 | extern "C" { |
---|
24 | #endif |
---|
25 | |
---|
26 | #include <rtems/score/c4x.h> /* pick up machine definitions */ |
---|
27 | #ifndef ASM |
---|
28 | #include <rtems/score/types.h> |
---|
29 | #endif |
---|
30 | |
---|
31 | /* conditional compilation parameters */ |
---|
32 | |
---|
33 | /* |
---|
34 | * Should the calls to _Thread_Enable_dispatch be inlined? |
---|
35 | * |
---|
36 | * If TRUE, then they are inlined. |
---|
37 | * If FALSE, then a subroutine call is made. |
---|
38 | * |
---|
39 | * Basically this is an example of the classic trade-off of size |
---|
40 | * versus speed. Inlining the call (TRUE) typically increases the |
---|
41 | * size of RTEMS while speeding up the enabling of dispatching. |
---|
42 | * [NOTE: In general, the _Thread_Dispatch_disable_level will |
---|
43 | * only be 0 or 1 unless you are in an interrupt handler and that |
---|
44 | * interrupt handler invokes the executive.] When not inlined |
---|
45 | * something calls _Thread_Enable_dispatch which in turns calls |
---|
46 | * _Thread_Dispatch. If the enable dispatch is inlined, then |
---|
47 | * one subroutine call is avoided entirely.] |
---|
48 | * |
---|
49 | * C4x Specific Information: |
---|
50 | * |
---|
51 | * We might as well try to inline this code until there is a |
---|
52 | * code space problem. |
---|
53 | */ |
---|
54 | |
---|
55 | #define CPU_INLINE_ENABLE_DISPATCH TRUE |
---|
56 | |
---|
57 | /* |
---|
58 | * Should the body of the search loops in _Thread_queue_Enqueue_priority |
---|
59 | * be unrolled one time? In unrolled each iteration of the loop examines |
---|
60 | * two "nodes" on the chain being searched. Otherwise, only one node |
---|
61 | * is examined per iteration. |
---|
62 | * |
---|
63 | * If TRUE, then the loops are unrolled. |
---|
64 | * If FALSE, then the loops are not unrolled. |
---|
65 | * |
---|
66 | * The primary factor in making this decision is the cost of disabling |
---|
67 | * and enabling interrupts (_ISR_Flash) versus the cost of rest of the |
---|
68 | * body of the loop. On some CPUs, the flash is more expensive than |
---|
69 | * one iteration of the loop body. In this case, it might be desirable |
---|
70 | * to unroll the loop. It is important to note that on some CPUs, this |
---|
71 | * code is the longest interrupt disable period in RTEMS. So it is |
---|
72 | * necessary to strike a balance when setting this parameter. |
---|
73 | * |
---|
74 | * C4x Specific Information: |
---|
75 | * |
---|
76 | * We might as well unroll this loop until there is a reason not to do so. |
---|
77 | */ |
---|
78 | |
---|
79 | #define CPU_UNROLL_ENQUEUE_PRIORITY TRUE |
---|
80 | |
---|
81 | /* |
---|
82 | * Does RTEMS manage a dedicated interrupt stack in software? |
---|
83 | * |
---|
84 | * If TRUE, then a stack is allocated in _Interrupt_Manager_initialization. |
---|
85 | * If FALSE, nothing is done. |
---|
86 | * |
---|
87 | * If the CPU supports a dedicated interrupt stack in hardware, |
---|
88 | * then it is generally the responsibility of the BSP to allocate it |
---|
89 | * and set it up. |
---|
90 | * |
---|
91 | * If the CPU does not support a dedicated interrupt stack, then |
---|
92 | * the porter has two options: (1) execute interrupts on the |
---|
93 | * stack of the interrupted task, and (2) have RTEMS manage a dedicated |
---|
94 | * interrupt stack. |
---|
95 | * |
---|
96 | * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. |
---|
97 | * |
---|
98 | * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and |
---|
99 | * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is |
---|
100 | * possible that both are FALSE for a particular CPU. Although it |
---|
101 | * is unclear what that would imply about the interrupt processing |
---|
102 | * procedure on that CPU. |
---|
103 | * |
---|
104 | * C4x Specific Information: |
---|
105 | * |
---|
106 | * Initial investigation indicates a software managed stack will be needed. |
---|
107 | * But the implementation does not currently include support for one. |
---|
108 | */ |
---|
109 | |
---|
110 | #define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE |
---|
111 | |
---|
112 | /* |
---|
113 | * Does the CPU follow the simple vectored interrupt model? |
---|
114 | * |
---|
115 | * If TRUE, then RTEMS allocates the vector table it internally manages. |
---|
116 | * If FALSE, then the BSP is assumed to allocate and manage the vector |
---|
117 | * table |
---|
118 | * |
---|
119 | * C4x Specific Information: |
---|
120 | * |
---|
121 | * XXX document implementation including references if appropriate |
---|
122 | */ |
---|
123 | #define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE |
---|
124 | |
---|
125 | /* |
---|
126 | * Does this CPU have hardware support for a dedicated interrupt stack? |
---|
127 | * |
---|
128 | * If TRUE, then it must be installed during initialization. |
---|
129 | * If FALSE, then no installation is performed. |
---|
130 | * |
---|
131 | * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. |
---|
132 | * |
---|
133 | * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and |
---|
134 | * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is |
---|
135 | * possible that both are FALSE for a particular CPU. Although it |
---|
136 | * is unclear what that would imply about the interrupt processing |
---|
137 | * procedure on that CPU. |
---|
138 | * |
---|
139 | * C4x Specific Information: |
---|
140 | * |
---|
141 | * XXXanswer |
---|
142 | * |
---|
143 | * Initial investigation indicates a software managed stack will be needed. |
---|
144 | */ |
---|
145 | |
---|
146 | #define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE |
---|
147 | |
---|
148 | /* |
---|
149 | * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? |
---|
150 | * |
---|
151 | * If TRUE, then the memory is allocated during initialization. |
---|
152 | * If FALSE, then the memory is allocated during initialization. |
---|
153 | * |
---|
154 | * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. |
---|
155 | * |
---|
156 | * C4x Specific Information: |
---|
157 | * |
---|
158 | * XXXanswer |
---|
159 | * |
---|
160 | * Until we know what to do with the memory, we should not allocated it. |
---|
161 | */ |
---|
162 | |
---|
163 | #define CPU_ALLOCATE_INTERRUPT_STACK FALSE |
---|
164 | |
---|
165 | /* |
---|
166 | * Does the RTEMS invoke the user's ISR with the vector number and |
---|
167 | * a pointer to the saved interrupt frame (1) or just the vector |
---|
168 | * number (0)? |
---|
169 | * |
---|
170 | * C4x Specific Information: |
---|
171 | * |
---|
172 | * XXXanswer |
---|
173 | * |
---|
174 | * The interrupt code will have to be written before this is answered |
---|
175 | * but the answer should be yes. |
---|
176 | */ |
---|
177 | |
---|
178 | #define CPU_ISR_PASSES_FRAME_POINTER 1 |
---|
179 | |
---|
180 | /* |
---|
181 | * Does the CPU have hardware floating point? |
---|
182 | * |
---|
183 | * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. |
---|
184 | * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. |
---|
185 | * |
---|
186 | * If there is a FP coprocessor such as the i387 or mc68881, then |
---|
187 | * the answer is TRUE. |
---|
188 | * |
---|
189 | * The macro name "C4X_HAS_FPU" should be made CPU specific. |
---|
190 | * It indicates whether or not this CPU model has FP support. For |
---|
191 | * example, it would be possible to have an i386_nofp CPU model |
---|
192 | * which set this to false to indicate that you have an i386 without |
---|
193 | * an i387 and wish to leave floating point support out of RTEMS. |
---|
194 | * |
---|
195 | * C4x Specific Information: |
---|
196 | * |
---|
197 | * See c4x.h for more details but the bottom line is that the |
---|
198 | * few extended registers required to be preserved across subroutines |
---|
199 | * calls are considered part of the integer context. This eliminates |
---|
200 | * overhead. |
---|
201 | * |
---|
202 | * The C4X_HAS_FPU refers to the extended precision registers R0-R7 |
---|
203 | * (plus R8-R11 on some models). |
---|
204 | * |
---|
205 | * XXX check that we even need to have the context area pointer in |
---|
206 | * the TCB in this case. |
---|
207 | */ |
---|
208 | |
---|
209 | #if ( C4X_HAS_FPU == 1 ) |
---|
210 | #define CPU_HARDWARE_FP TRUE |
---|
211 | #else |
---|
212 | #define CPU_HARDWARE_FP FALSE |
---|
213 | #endif |
---|
214 | #define CPU_SOFTWARE_FP FALSE |
---|
215 | |
---|
216 | /* |
---|
217 | * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? |
---|
218 | * |
---|
219 | * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. |
---|
220 | * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. |
---|
221 | * |
---|
222 | * If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. |
---|
223 | * |
---|
224 | * C4x Specific Information: |
---|
225 | * |
---|
226 | * There is no known reason to make all tasks include the extended |
---|
227 | * precision registers (i.e. floating point context). |
---|
228 | */ |
---|
229 | |
---|
230 | #define CPU_ALL_TASKS_ARE_FP FALSE |
---|
231 | |
---|
232 | /* |
---|
233 | * Should the IDLE task have a floating point context? |
---|
234 | * |
---|
235 | * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task |
---|
236 | * and it has a floating point context which is switched in and out. |
---|
237 | * If FALSE, then the IDLE task does not have a floating point context. |
---|
238 | * |
---|
239 | * Setting this to TRUE negatively impacts the time required to preempt |
---|
240 | * the IDLE task from an interrupt because the floating point context |
---|
241 | * must be saved as part of the preemption. |
---|
242 | * |
---|
243 | * C4x Specific Information: |
---|
244 | * |
---|
245 | * There is no known reason to make the IDLE task floating point and |
---|
246 | * no point in wasting the memory or increasing the context switch |
---|
247 | * time for the IDLE task. |
---|
248 | */ |
---|
249 | |
---|
250 | #define CPU_IDLE_TASK_IS_FP FALSE |
---|
251 | |
---|
252 | /* |
---|
253 | * Should the saving of the floating point registers be deferred |
---|
254 | * until a context switch is made to another different floating point |
---|
255 | * task? |
---|
256 | * |
---|
257 | * If TRUE, then the floating point context will not be stored until |
---|
258 | * necessary. It will remain in the floating point registers and not |
---|
259 | * disturned until another floating point task is switched to. |
---|
260 | * |
---|
261 | * If FALSE, then the floating point context is saved when a floating |
---|
262 | * point task is switched out and restored when the next floating point |
---|
263 | * task is restored. The state of the floating point registers between |
---|
264 | * those two operations is not specified. |
---|
265 | * |
---|
266 | * If the floating point context does NOT have to be saved as part of |
---|
267 | * interrupt dispatching, then it should be safe to set this to TRUE. |
---|
268 | * |
---|
269 | * Setting this flag to TRUE results in using a different algorithm |
---|
270 | * for deciding when to save and restore the floating point context. |
---|
271 | * The deferred FP switch algorithm minimizes the number of times |
---|
272 | * the FP context is saved and restored. The FP context is not saved |
---|
273 | * until a context switch is made to another, different FP task. |
---|
274 | * Thus in a system with only one FP task, the FP context will never |
---|
275 | * be saved or restored. |
---|
276 | * |
---|
277 | * C4x Specific Information: |
---|
278 | * |
---|
279 | * There is no reason to avoid the deferred FP switch logic on this |
---|
280 | * CPU family. |
---|
281 | */ |
---|
282 | |
---|
283 | #define CPU_USE_DEFERRED_FP_SWITCH TRUE |
---|
284 | |
---|
285 | /* |
---|
286 | * Does this port provide a CPU dependent IDLE task implementation? |
---|
287 | * |
---|
288 | * If TRUE, then the routine _CPU_Thread_Idle_body |
---|
289 | * must be provided and is the default IDLE thread body instead of |
---|
290 | * _CPU_Thread_Idle_body. |
---|
291 | * |
---|
292 | * If FALSE, then use the generic IDLE thread body if the BSP does |
---|
293 | * not provide one. |
---|
294 | * |
---|
295 | * This is intended to allow for supporting processors which have |
---|
296 | * a low power or idle mode. When the IDLE thread is executed, then |
---|
297 | * the CPU can be powered down. |
---|
298 | * |
---|
299 | * The order of precedence for selecting the IDLE thread body is: |
---|
300 | * |
---|
301 | * 1. BSP provided |
---|
302 | * 2. CPU dependent (if provided) |
---|
303 | * 3. generic (if no BSP and no CPU dependent) |
---|
304 | * |
---|
305 | * C4x Specific Information: |
---|
306 | * |
---|
307 | * There is currently no reason to avoid using the generic implementation. |
---|
308 | * In the future, a C4x specific IDLE thread body may be added to take |
---|
309 | * advantage of low power modes. |
---|
310 | */ |
---|
311 | |
---|
312 | #define CPU_PROVIDES_IDLE_THREAD_BODY FALSE |
---|
313 | |
---|
314 | /* |
---|
315 | * Does the stack grow up (toward higher addresses) or down |
---|
316 | * (toward lower addresses)? |
---|
317 | * |
---|
318 | * If TRUE, then the grows upward. |
---|
319 | * If FALSE, then the grows toward smaller addresses. |
---|
320 | * |
---|
321 | * C4x Specific Information: |
---|
322 | * |
---|
323 | * The system stack grows from low to high memory. |
---|
324 | * |
---|
325 | * C4x Specific Information: |
---|
326 | * |
---|
327 | * This setting was derived from the discussion of stack management |
---|
328 | * in section 6.1 (p. 6-29) System and User Stack Management of the |
---|
329 | * TMS32C3x User's Guide (rev L, July 1997) which states: "A push |
---|
330 | * performs a preincrement, and a pop performs a postdecrement of the |
---|
331 | * system-stack pointer." There are instructions for making "a stack" |
---|
332 | * run from high to low memory but this appears to be the exception. |
---|
333 | */ |
---|
334 | |
---|
335 | #define CPU_STACK_GROWS_UP TRUE |
---|
336 | |
---|
337 | /* |
---|
338 | * The following is the variable attribute used to force alignment |
---|
339 | * of critical RTEMS structures. On some processors it may make |
---|
340 | * sense to have these aligned on tighter boundaries than |
---|
341 | * the minimum requirements of the compiler in order to have as |
---|
342 | * much of the critical data area as possible in a cache line. |
---|
343 | * |
---|
344 | * The placement of this macro in the declaration of the variables |
---|
345 | * is based on the syntactically requirements of the GNU C |
---|
346 | * "__attribute__" extension. For example with GNU C, use |
---|
347 | * the following to force a structures to a 32 byte boundary. |
---|
348 | * |
---|
349 | * __attribute__ ((aligned (32))) |
---|
350 | * |
---|
351 | * NOTE: Currently only the Priority Bit Map table uses this feature. |
---|
352 | * To benefit from using this, the data must be heavily |
---|
353 | * used so it will stay in the cache and used frequently enough |
---|
354 | * in the executive to justify turning this on. |
---|
355 | * |
---|
356 | * C4x Specific Information: |
---|
357 | * |
---|
358 | * The C4x is word oriented and there should be no alignment issues. |
---|
359 | */ |
---|
360 | |
---|
361 | #define CPU_STRUCTURE_ALIGNMENT |
---|
362 | |
---|
363 | /* |
---|
364 | * Define what is required to specify how the network to host conversion |
---|
365 | * routines are handled. |
---|
366 | * |
---|
367 | * C4x Specific Information: |
---|
368 | * |
---|
369 | */ |
---|
370 | |
---|
371 | #define CPU_BIG_ENDIAN TRUE |
---|
372 | #define CPU_LITTLE_ENDIAN FALSE |
---|
373 | |
---|
374 | /* |
---|
375 | * The following defines the number of bits actually used in the |
---|
376 | * interrupt field of the task mode. How those bits map to the |
---|
377 | * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). |
---|
378 | * |
---|
379 | * C4x Specific Information: |
---|
380 | * |
---|
381 | * Currently we are only supporting interrupt levels 0 (all on) and |
---|
382 | * 1 (all off). Levels 2-255 COULD be looked up in a user provided |
---|
383 | * table that gives GIE and IE Mask settings. But this is not the |
---|
384 | * case today. |
---|
385 | */ |
---|
386 | |
---|
387 | #define CPU_MODES_INTERRUPT_MASK 0x000000FF |
---|
388 | |
---|
389 | /* |
---|
390 | * Processor defined structures required for cpukit/score. |
---|
391 | * |
---|
392 | * C4x Specific Information: |
---|
393 | * |
---|
394 | * XXXanswer |
---|
395 | */ |
---|
396 | |
---|
397 | /* may need to put some structures here. */ |
---|
398 | |
---|
399 | /* |
---|
400 | * Contexts |
---|
401 | * |
---|
402 | * Generally there are 2 types of context to save. |
---|
403 | * 1. Interrupt registers to save |
---|
404 | * 2. Task level registers to save |
---|
405 | * |
---|
406 | * This means we have the following 3 context items: |
---|
407 | * 1. task level context stuff:: Context_Control |
---|
408 | * 2. floating point task stuff:: Context_Control_fp |
---|
409 | * 3. special interrupt level context :: Context_Control_interrupt |
---|
410 | * |
---|
411 | * On some processors, it is cost-effective to save only the callee |
---|
412 | * preserved registers during a task context switch. This means |
---|
413 | * that the ISR code needs to save those registers which do not |
---|
414 | * persist across function calls. It is not mandatory to make this |
---|
415 | * distinctions between the caller/callee saves registers for the |
---|
416 | * purpose of minimizing context saved during task switch and on interrupts. |
---|
417 | * If the cost of saving extra registers is minimal, simplicity is the |
---|
418 | * choice. Save the same context on interrupt entry as for tasks in |
---|
419 | * this case. |
---|
420 | * |
---|
421 | * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then |
---|
422 | * care should be used in designing the context area. |
---|
423 | * |
---|
424 | * On some CPUs with hardware floating point support, the Context_Control_fp |
---|
425 | * structure will not be used or it simply consist of an array of a |
---|
426 | * fixed number of bytes. This is done when the floating point context |
---|
427 | * is dumped by a "FP save context" type instruction and the format |
---|
428 | * is not really defined by the CPU. In this case, there is no need |
---|
429 | * to figure out the exact format -- only the size. Of course, although |
---|
430 | * this is enough information for RTEMS, it is probably not enough for |
---|
431 | * a debugger such as gdb. But that is another problem. |
---|
432 | * |
---|
433 | * C4x Specific Information: |
---|
434 | * |
---|
435 | * From email with Michael Hayes: |
---|
436 | * > > But what are the rules for what is passed in what registers? |
---|
437 | * |
---|
438 | * Args are passed in the following registers (in order): |
---|
439 | * |
---|
440 | * AR2, R2, R3, RC, RS, RE |
---|
441 | * |
---|
442 | * However, the first and second floating point values are always in R2 |
---|
443 | * and R3 (and all other floats are on the stack). Structs are always |
---|
444 | * passed on the stack. If the last argument is an ellipsis, the |
---|
445 | * previous argument is passed on the stack so that its address can be |
---|
446 | * taken for the stdargs macros. |
---|
447 | * |
---|
448 | * > > What is assumed to be preserved across calls? |
---|
449 | * |
---|
450 | * AR3, AR4, AR5, AR6, AR7 |
---|
451 | * R4, R5, R8 (using STI/LDI) |
---|
452 | * R6, R7 (using STF/LDF) |
---|
453 | * |
---|
454 | * > > What is assumed to be scratch registers? |
---|
455 | * |
---|
456 | * R0, R1, R2, R3, AR0, AR1, AR2, IR0, IR1, BK, RS, RE, RC, R9, R10, R11 |
---|
457 | * |
---|
458 | * Based on this information, the task specific context is quite small |
---|
459 | * but the interrupt context is much larger. In fact, it could |
---|
460 | * easily be argued that there is no point in distinguishing between |
---|
461 | * integer and floating point contexts on the Cxx since there is |
---|
462 | * so little context involved. So that is the decision made. |
---|
463 | * |
---|
464 | * Not Mentioned in list: DP |
---|
465 | * |
---|
466 | * Assumed to be global resources: |
---|
467 | * |
---|
468 | * C3X: IE, IF, and IOF |
---|
469 | * C4X: DIE, IIF, and IIF |
---|
470 | */ |
---|
471 | |
---|
472 | |
---|
473 | typedef struct { |
---|
474 | unsigned int st; |
---|
475 | unsigned int ar3; |
---|
476 | unsigned int ar4; |
---|
477 | unsigned int ar5; |
---|
478 | unsigned int ar6; |
---|
479 | unsigned int ar7; |
---|
480 | unsigned int r4_sti; /* other part of register is in interrupt context */ |
---|
481 | unsigned int r5_sti; /* other part of register is in interrupt context */ |
---|
482 | unsigned int r6_stf; /* other part of register is in interrupt context */ |
---|
483 | unsigned int r7_stf; /* other part of register is in interrupt context */ |
---|
484 | #ifdef _TMS320C40 |
---|
485 | unsigned int r8_sti; /* other part of register is in interrupt context */ |
---|
486 | #endif |
---|
487 | unsigned int sp; |
---|
488 | } Context_Control; |
---|
489 | |
---|
490 | #define _CPU_Context_Get_SP( _context ) \ |
---|
491 | (_context)->sp |
---|
492 | |
---|
493 | typedef struct { |
---|
494 | } Context_Control_fp; |
---|
495 | |
---|
496 | /* |
---|
497 | * This is the order the interrupt entry code pushes the registers. |
---|
498 | */ |
---|
499 | |
---|
500 | typedef struct { |
---|
501 | void *interrupted; |
---|
502 | unsigned int st; |
---|
503 | unsigned int ar2; /* because the vector numbers goes here */ |
---|
504 | unsigned int ar0; |
---|
505 | unsigned int ar1; |
---|
506 | unsigned int dp; |
---|
507 | unsigned int ir0; |
---|
508 | unsigned int ir1; |
---|
509 | unsigned int rs; |
---|
510 | unsigned int re; |
---|
511 | unsigned int rc; |
---|
512 | unsigned int bk; |
---|
513 | unsigned int r0_sti; |
---|
514 | unsigned int r0_stf; |
---|
515 | unsigned int r1_sti; |
---|
516 | unsigned int r1_stf; |
---|
517 | unsigned int r2_sti; |
---|
518 | unsigned int r2_stf; |
---|
519 | unsigned int r3_sti; |
---|
520 | unsigned int r3_stf; |
---|
521 | unsigned int r4_stf; /* other part of register is in basic context */ |
---|
522 | unsigned int r5_stf; /* other part of register is in basic context */ |
---|
523 | unsigned int r6_sti; /* other part of register is in basic context */ |
---|
524 | unsigned int r7_sti; /* other part of register is in basic context */ |
---|
525 | |
---|
526 | #ifdef _TMS320C40 |
---|
527 | unsigned int r8_sti; /* other part of register is in basic context */ |
---|
528 | unsigned int r9_sti; |
---|
529 | unsigned int r9_stf; |
---|
530 | unsigned int r10_sti; |
---|
531 | unsigned int r10_stf; |
---|
532 | unsigned int r11_sti; |
---|
533 | unsigned int r11_stf; |
---|
534 | #endif |
---|
535 | |
---|
536 | } CPU_Interrupt_frame; |
---|
537 | |
---|
538 | /* |
---|
539 | * Macros to access C4X specific additions to the CPU Table |
---|
540 | * |
---|
541 | * C4x Specific Information: |
---|
542 | * |
---|
543 | * XXXanswer |
---|
544 | */ |
---|
545 | |
---|
546 | /* There are no CPU specific additions to the CPU Table for this port. */ |
---|
547 | |
---|
548 | #if 0 |
---|
549 | /* |
---|
550 | * This variable is optional. It is used on CPUs on which it is difficult |
---|
551 | * to generate an "uninitialized" FP context. It is filled in by |
---|
552 | * _CPU_Initialize and copied into the task's FP context area during |
---|
553 | * _CPU_Context_Initialize. |
---|
554 | * |
---|
555 | * C4x Specific Information: |
---|
556 | * |
---|
557 | * Unused |
---|
558 | */ |
---|
559 | |
---|
560 | SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context; |
---|
561 | #endif |
---|
562 | |
---|
563 | /* |
---|
564 | * On some CPUs, RTEMS supports a software managed interrupt stack. |
---|
565 | * This stack is allocated by the Interrupt Manager and the switch |
---|
566 | * is performed in _ISR_Handler. These variables contain pointers |
---|
567 | * to the lowest and highest addresses in the chunk of memory allocated |
---|
568 | * for the interrupt stack. Since it is unknown whether the stack |
---|
569 | * grows up or down (in general), this give the CPU dependent |
---|
570 | * code the option of picking the version it wants to use. |
---|
571 | * |
---|
572 | * NOTE: These two variables are required if the macro |
---|
573 | * CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. |
---|
574 | * |
---|
575 | * C4x Specific Information: |
---|
576 | * |
---|
577 | * XXXanswer |
---|
578 | */ |
---|
579 | |
---|
580 | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
---|
581 | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
---|
582 | |
---|
583 | /* |
---|
584 | * Nothing prevents the porter from declaring more CPU specific variables. |
---|
585 | * |
---|
586 | * C4x Specific Information: |
---|
587 | * |
---|
588 | * XXXanswer |
---|
589 | */ |
---|
590 | |
---|
591 | /* XXX: if needed, put more variables here */ |
---|
592 | |
---|
593 | /* |
---|
594 | * The size of the floating point context area. On some CPUs this |
---|
595 | * will not be a "sizeof" because the format of the floating point |
---|
596 | * area is not defined -- only the size is. This is usually on |
---|
597 | * CPUs with a "floating point save context" instruction. |
---|
598 | * |
---|
599 | * C4x Specific Information: |
---|
600 | * |
---|
601 | * If we decide to have a separate floating point context, then |
---|
602 | * the answer is the size of the data structure. Otherwise, we |
---|
603 | * need to define it as 0 to let upper level configuration work. |
---|
604 | */ |
---|
605 | |
---|
606 | #if ( C4X_HAS_FPU == 1 ) |
---|
607 | #define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) |
---|
608 | #else |
---|
609 | #define CPU_CONTEXT_FP_SIZE 0 |
---|
610 | #endif |
---|
611 | |
---|
612 | /* |
---|
613 | * Amount of extra stack (above minimum stack size) required by |
---|
614 | * MPCI receive server thread. Remember that in a multiprocessor |
---|
615 | * system this thread must exist and be able to process all directives. |
---|
616 | * |
---|
617 | * C4x Specific Information: |
---|
618 | * |
---|
619 | * XXXanswer |
---|
620 | */ |
---|
621 | |
---|
622 | #define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 |
---|
623 | |
---|
624 | /* |
---|
625 | * This defines the number of entries in the ISR_Vector_table managed |
---|
626 | * by RTEMS. |
---|
627 | * |
---|
628 | * C4x Specific Information: |
---|
629 | * |
---|
630 | * Based on the information provided in section 7.6.1 (p. 7-26) |
---|
631 | * titled "TMS320C30 and TMS320C31 Interrupt Vector Table" and section |
---|
632 | * 7.6.2 "TMS320C32 Interrupt Vector Table" of the TMS32C3x User's |
---|
633 | * Guide (rev L, July 1997), vectors are numbered 0x00 - 0x3F. Thus |
---|
634 | * there are 0x40 or 64 vectors. |
---|
635 | */ |
---|
636 | |
---|
637 | #define CPU_INTERRUPT_NUMBER_OF_VECTORS 0x40 |
---|
638 | #define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) |
---|
639 | |
---|
640 | /* |
---|
641 | * This is defined if the port has a special way to report the ISR nesting |
---|
642 | * level. Most ports maintain the variable _ISR_Nest_level. |
---|
643 | */ |
---|
644 | |
---|
645 | #define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE |
---|
646 | |
---|
647 | /* |
---|
648 | * Should be large enough to run all RTEMS tests. This ensures |
---|
649 | * that a "reasonable" small application should not have any problems. |
---|
650 | * |
---|
651 | * C4x Specific Information: |
---|
652 | * |
---|
653 | * XXXanswer |
---|
654 | */ |
---|
655 | |
---|
656 | #define CPU_STACK_MINIMUM_SIZE (1024) |
---|
657 | |
---|
658 | /* |
---|
659 | * CPU's worst alignment requirement for data types on a byte boundary. This |
---|
660 | * alignment does not take into account the requirements for the stack. |
---|
661 | * |
---|
662 | * C4x Specific Information: |
---|
663 | * |
---|
664 | * XXXanswer |
---|
665 | * As best I can tell, there are no restrictions since this is a word |
---|
666 | * -- not byte -- oriented archtiecture. |
---|
667 | */ |
---|
668 | |
---|
669 | #define CPU_ALIGNMENT 0 |
---|
670 | |
---|
671 | /* |
---|
672 | * This number corresponds to the byte alignment requirement for the |
---|
673 | * heap handler. This alignment requirement may be stricter than that |
---|
674 | * for the data types alignment specified by CPU_ALIGNMENT. It is |
---|
675 | * common for the heap to follow the same alignment requirement as |
---|
676 | * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, |
---|
677 | * then this should be set to CPU_ALIGNMENT. |
---|
678 | * |
---|
679 | * NOTE: This does not have to be a power of 2. It does have to |
---|
680 | * be greater or equal to than CPU_ALIGNMENT. |
---|
681 | * |
---|
682 | * C4x Specific Information: |
---|
683 | * |
---|
684 | * XXXanswer |
---|
685 | * |
---|
686 | * A CPU_HEAP_ALIGNMENT of 2 comes close to disabling all the rounding |
---|
687 | * while still ensuring that the least significant bit of the front |
---|
688 | * and back flags can be used as the used bit -- not part of the size. |
---|
689 | */ |
---|
690 | |
---|
691 | #define CPU_HEAP_ALIGNMENT 2 |
---|
692 | |
---|
693 | /* |
---|
694 | * This number corresponds to the byte alignment requirement for memory |
---|
695 | * buffers allocated by the partition manager. This alignment requirement |
---|
696 | * may be stricter than that for the data types alignment specified by |
---|
697 | * CPU_ALIGNMENT. It is common for the partition to follow the same |
---|
698 | * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict |
---|
699 | * enough for the partition, then this should be set to CPU_ALIGNMENT. |
---|
700 | * |
---|
701 | * NOTE: This does not have to be a power of 2. It does have to |
---|
702 | * be greater or equal to than CPU_ALIGNMENT. |
---|
703 | * |
---|
704 | * C4x Specific Information: |
---|
705 | * |
---|
706 | * XXXanswer |
---|
707 | * I think a CPU_PARTITION_ALIGNMENT of 1 will effectively disable all |
---|
708 | * the rounding. |
---|
709 | */ |
---|
710 | |
---|
711 | #define CPU_PARTITION_ALIGNMENT 1 |
---|
712 | |
---|
713 | /* |
---|
714 | * This number corresponds to the byte alignment requirement for the |
---|
715 | * stack. This alignment requirement may be stricter than that for the |
---|
716 | * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT |
---|
717 | * is strict enough for the stack, then this should be set to 0. |
---|
718 | * |
---|
719 | * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. |
---|
720 | * |
---|
721 | * C4x Specific Information: |
---|
722 | * |
---|
723 | * XXXanswer |
---|
724 | */ |
---|
725 | |
---|
726 | #define CPU_STACK_ALIGNMENT 0 |
---|
727 | |
---|
728 | /* |
---|
729 | * ISR handler macros |
---|
730 | * |
---|
731 | * C4x Specific Information: |
---|
732 | * |
---|
733 | * These macros disable interrupts using the GIE (global interrupts enable) |
---|
734 | * bit in the status word. |
---|
735 | */ |
---|
736 | |
---|
737 | /* |
---|
738 | * Support routine to initialize the RTEMS vector table after it is allocated. |
---|
739 | */ |
---|
740 | |
---|
741 | #define _CPU_Initialize_vectors() |
---|
742 | |
---|
743 | /* |
---|
744 | * Disable all interrupts for an RTEMS critical section. The previous |
---|
745 | * level is returned in _isr_cookie. |
---|
746 | */ |
---|
747 | |
---|
748 | #define _CPU_ISR_Disable( _isr_cookie ) \ |
---|
749 | do { \ |
---|
750 | (_isr_cookie) = c4x_global_interrupts_get(); \ |
---|
751 | c4x_global_interrupts_disable(); \ |
---|
752 | } while (0) |
---|
753 | |
---|
754 | /* |
---|
755 | * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). |
---|
756 | * This indicates the end of an RTEMS critical section. The parameter |
---|
757 | * _isr_cookie is not modified. |
---|
758 | */ |
---|
759 | |
---|
760 | #define _CPU_ISR_Enable( _isr_cookie ) \ |
---|
761 | c4x_global_interrupts_restore( _isr_cookie ) |
---|
762 | |
---|
763 | /* |
---|
764 | * This temporarily restores the interrupt to _isr_cookie before immediately |
---|
765 | * disabling them again. This is used to divide long RTEMS critical |
---|
766 | * sections into two or more parts. The parameter _isr_cookie is not |
---|
767 | * modified. |
---|
768 | */ |
---|
769 | |
---|
770 | #define _CPU_ISR_Flash( _isr_cookie ) \ |
---|
771 | c4x_global_interrupts_flash( _isr_cookie ) |
---|
772 | |
---|
773 | /* |
---|
774 | * Map interrupt level in task mode onto the hardware that the CPU |
---|
775 | * actually provides. Currently, interrupt levels which do not |
---|
776 | * map onto the CPU in a generic fashion are undefined. Someday, |
---|
777 | * it would be nice if these were "mapped" by the application |
---|
778 | * via a callout. For example, m68k has 8 levels 0 - 7, levels |
---|
779 | * 8 - 255 would be available for bsp/application specific meaning. |
---|
780 | * This could be used to manage a programmable interrupt controller |
---|
781 | * via the rtems_task_mode directive. |
---|
782 | * |
---|
783 | * The get routine usually must be implemented as a subroutine. |
---|
784 | * |
---|
785 | * C4x Specific Information: |
---|
786 | * |
---|
787 | * The C4x port probably needs to allow the BSP to define |
---|
788 | * a mask table for all values 0-255. For now, 0 is global |
---|
789 | * interrupts enabled and and non-zero is global interrupts |
---|
790 | * disabled. In the future, values 1-254 could be defined as |
---|
791 | * specific combinations of the global interrupt enabled and the IE mask. |
---|
792 | * |
---|
793 | * The logic for setting the mask field is something like this: |
---|
794 | * _ie_value = c4x_get_ie(); |
---|
795 | * _ie_value &= C4X_IE_INTERRUPT_MASK_BITS; |
---|
796 | * _ie_value |= _ie_mask; |
---|
797 | * c4x_set_ie(_ie_value); |
---|
798 | * |
---|
799 | * NOTE: If this is implemented, then the context of each task |
---|
800 | * must be extended to include the IE register. |
---|
801 | */ |
---|
802 | |
---|
803 | #define _CPU_ISR_Set_level( _new_level ) \ |
---|
804 | do { \ |
---|
805 | if ( _new_level == 0 ) c4x_global_interrupts_enable(); \ |
---|
806 | else c4x_global_interrupts_disable(); \ |
---|
807 | } while (0) |
---|
808 | |
---|
809 | /* if GIE = 1, then logical level is 0. */ |
---|
810 | #define _CPU_ISR_Get_level() \ |
---|
811 | (c4x_global_interrupts_get() ? 0 : 1) |
---|
812 | |
---|
813 | |
---|
814 | /* end of ISR handler macros */ |
---|
815 | |
---|
816 | /* Context handler macros */ |
---|
817 | |
---|
818 | /* |
---|
819 | * Initialize the context to a state suitable for starting a |
---|
820 | * task after a context restore operation. Generally, this |
---|
821 | * involves: |
---|
822 | * |
---|
823 | * - setting a starting address |
---|
824 | * - preparing the stack |
---|
825 | * - preparing the stack and frame pointers |
---|
826 | * - setting the proper interrupt level in the context |
---|
827 | * - initializing the floating point context |
---|
828 | * |
---|
829 | * This routine generally does not set any unnecessary register |
---|
830 | * in the context. The state of the "general data" registers is |
---|
831 | * undefined at task start time. |
---|
832 | * |
---|
833 | * NOTE: This is_fp parameter is TRUE if the thread is to be a floating |
---|
834 | * point thread. This is typically only used on CPUs where the |
---|
835 | * FPU may be easily disabled by software such as on the SPARC |
---|
836 | * where the PSR contains an enable FPU bit. |
---|
837 | * |
---|
838 | * C4x Specific Information: |
---|
839 | * |
---|
840 | * XXXanswer |
---|
841 | */ |
---|
842 | |
---|
843 | void _CPU_Context_Initialize( |
---|
844 | Context_Control *_the_context, |
---|
845 | void *_stack_base, |
---|
846 | uint32_t _size, |
---|
847 | uint32_t _isr, |
---|
848 | void (*_entry_point)(void), |
---|
849 | int _is_fp |
---|
850 | ); |
---|
851 | |
---|
852 | /* |
---|
853 | * This routine is responsible for somehow restarting the currently |
---|
854 | * executing task. If you are lucky, then all that is necessary |
---|
855 | * is restoring the context. Otherwise, there will need to be |
---|
856 | * a special assembly routine which does something special in this |
---|
857 | * case. Context_Restore should work most of the time. It will |
---|
858 | * not work if restarting self conflicts with the stack frame |
---|
859 | * assumptions of restoring a context. |
---|
860 | * |
---|
861 | * C4x Specific Information: |
---|
862 | * |
---|
863 | * XXXanswer |
---|
864 | */ |
---|
865 | |
---|
866 | #define _CPU_Context_Restart_self( _the_context ) \ |
---|
867 | _CPU_Context_restore( (_the_context) ); |
---|
868 | |
---|
869 | #if ( C4X_HAS_FPU == 1 ) |
---|
870 | /* |
---|
871 | * The purpose of this macro is to allow the initial pointer into |
---|
872 | * a floating point context area (used to save the floating point |
---|
873 | * context) to be at an arbitrary place in the floating point |
---|
874 | * context area. |
---|
875 | * |
---|
876 | * This is necessary because some FP units are designed to have |
---|
877 | * their context saved as a stack which grows into lower addresses. |
---|
878 | * Other FP units can be saved by simply moving registers into offsets |
---|
879 | * from the base of the context area. Finally some FP units provide |
---|
880 | * a "dump context" instruction which could fill in from high to low |
---|
881 | * or low to high based on the whim of the CPU designers. |
---|
882 | * |
---|
883 | * C4x Specific Information: |
---|
884 | * |
---|
885 | * No Floating Point from RTEMS perspective. |
---|
886 | */ |
---|
887 | |
---|
888 | #define _CPU_Context_Fp_start( _base, _offset ) \ |
---|
889 | ( (void *) _Addresses_Add_offset( (_base), (_offset) ) ) |
---|
890 | #endif |
---|
891 | |
---|
892 | #if ( C4X_HAS_FPU == 1 ) |
---|
893 | /* |
---|
894 | * This routine initializes the FP context area passed to it to. |
---|
895 | * There are a few standard ways in which to initialize the |
---|
896 | * floating point context. The code included for this macro assumes |
---|
897 | * that this is a CPU in which a "initial" FP context was saved into |
---|
898 | * _CPU_Null_fp_context and it simply copies it to the destination |
---|
899 | * context passed to it. |
---|
900 | * |
---|
901 | * Other models include (1) not doing anything, and (2) putting |
---|
902 | * a "null FP status word" in the correct place in the FP context. |
---|
903 | * |
---|
904 | * C4x Specific Information: |
---|
905 | * |
---|
906 | * No Floating Point from RTEMS perspective. |
---|
907 | */ |
---|
908 | |
---|
909 | #define _CPU_Context_Initialize_fp( _destination ) \ |
---|
910 | do { \ |
---|
911 | *(*(_destination)) = _CPU_Null_fp_context; \ |
---|
912 | } while (0) |
---|
913 | #endif |
---|
914 | |
---|
915 | /* end of Context handler macros */ |
---|
916 | |
---|
917 | /* Fatal Error manager macros */ |
---|
918 | |
---|
919 | /* |
---|
920 | * This routine copies _error into a known place -- typically a stack |
---|
921 | * location or a register, optionally disables interrupts, and |
---|
922 | * halts/stops the CPU. |
---|
923 | * |
---|
924 | * C4x Specific Information: |
---|
925 | * |
---|
926 | * XXXanswer |
---|
927 | */ |
---|
928 | |
---|
929 | #define _CPU_Fatal_halt( _error ) \ |
---|
930 | do { \ |
---|
931 | } while (0) |
---|
932 | |
---|
933 | /* end of Fatal Error manager macros */ |
---|
934 | |
---|
935 | /* Bitfield handler macros */ |
---|
936 | |
---|
937 | /* |
---|
938 | * This routine sets _output to the bit number of the first bit |
---|
939 | * set in _value. _value is of CPU dependent type Priority_Bit_map_control. |
---|
940 | * This type may be either 16 or 32 bits wide although only the 16 |
---|
941 | * least significant bits will be used. |
---|
942 | * |
---|
943 | * There are a number of variables in using a "find first bit" type |
---|
944 | * instruction. |
---|
945 | * |
---|
946 | * (1) What happens when run on a value of zero? |
---|
947 | * (2) Bits may be numbered from MSB to LSB or vice-versa. |
---|
948 | * (3) The numbering may be zero or one based. |
---|
949 | * (4) The "find first bit" instruction may search from MSB or LSB. |
---|
950 | * |
---|
951 | * RTEMS guarantees that (1) will never happen so it is not a concern. |
---|
952 | * (2),(3), (4) are handled by the macros _CPU_Priority_mask() and |
---|
953 | * _CPU_Priority_bits_index(). These three form a set of routines |
---|
954 | * which must logically operate together. Bits in the _value are |
---|
955 | * set and cleared based on masks built by _CPU_Priority_mask(). |
---|
956 | * The basic major and minor values calculated by _Priority_Major() |
---|
957 | * and _Priority_Minor() are "massaged" by _CPU_Priority_bits_index() |
---|
958 | * to properly range between the values returned by the "find first bit" |
---|
959 | * instruction. This makes it possible for _Priority_Get_highest() to |
---|
960 | * calculate the major and directly index into the minor table. |
---|
961 | * This mapping is necessary to ensure that 0 (a high priority major/minor) |
---|
962 | * is the first bit found. |
---|
963 | * |
---|
964 | * This entire "find first bit" and mapping process depends heavily |
---|
965 | * on the manner in which a priority is broken into a major and minor |
---|
966 | * components with the major being the 4 MSB of a priority and minor |
---|
967 | * the 4 LSB. Thus (0 << 4) + 0 corresponds to priority 0 -- the highest |
---|
968 | * priority. And (15 << 4) + 14 corresponds to priority 254 -- the next |
---|
969 | * to the lowest priority. |
---|
970 | * |
---|
971 | * If your CPU does not have a "find first bit" instruction, then |
---|
972 | * there are ways to make do without it. Here are a handful of ways |
---|
973 | * to implement this in software: |
---|
974 | * |
---|
975 | * - a series of 16 bit test instructions |
---|
976 | * - a "binary search using if's" |
---|
977 | * - _number = 0 |
---|
978 | * if _value > 0x00ff |
---|
979 | * _value >>=8 |
---|
980 | * _number = 8; |
---|
981 | * |
---|
982 | * if _value > 0x0000f |
---|
983 | * _value >=8 |
---|
984 | * _number += 4 |
---|
985 | * |
---|
986 | * _number += bit_set_table[ _value ] |
---|
987 | * |
---|
988 | * where bit_set_table[ 16 ] has values which indicate the first |
---|
989 | * bit set |
---|
990 | * |
---|
991 | * C4x Specific Information: |
---|
992 | * |
---|
993 | * There does not appear to be a simple way to do this on this |
---|
994 | * processor family that is better than the generic algorithm. |
---|
995 | * Almost certainly, a hand-optimized assembly version of the |
---|
996 | * generic algorithm could be written although it is not |
---|
997 | * worth the development effort at this time. |
---|
998 | */ |
---|
999 | |
---|
1000 | #define CPU_USE_GENERIC_BITFIELD_CODE TRUE |
---|
1001 | #define CPU_USE_GENERIC_BITFIELD_DATA TRUE |
---|
1002 | |
---|
1003 | #if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) |
---|
1004 | |
---|
1005 | #define _CPU_Bitfield_Find_first_bit( _value, _output ) \ |
---|
1006 | do { \ |
---|
1007 | (_output) = 0; /* do something to prevent warnings */ \ |
---|
1008 | } while (0) |
---|
1009 | |
---|
1010 | #endif |
---|
1011 | |
---|
1012 | /* end of Bitfield handler macros */ |
---|
1013 | |
---|
1014 | /* |
---|
1015 | * This routine builds the mask which corresponds to the bit fields |
---|
1016 | * as searched by _CPU_Bitfield_Find_first_bit(). See the discussion |
---|
1017 | * for that routine. |
---|
1018 | * |
---|
1019 | * C4x Specific Information: |
---|
1020 | * |
---|
1021 | * XXXanswer |
---|
1022 | */ |
---|
1023 | |
---|
1024 | #if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) |
---|
1025 | |
---|
1026 | #define _CPU_Priority_Mask( _bit_number ) \ |
---|
1027 | ( 1 << (_bit_number) ) |
---|
1028 | |
---|
1029 | #endif |
---|
1030 | |
---|
1031 | /* |
---|
1032 | * This routine translates the bit numbers returned by |
---|
1033 | * _CPU_Bitfield_Find_first_bit() into something suitable for use as |
---|
1034 | * a major or minor component of a priority. See the discussion |
---|
1035 | * for that routine. |
---|
1036 | * |
---|
1037 | * C4x Specific Information: |
---|
1038 | * |
---|
1039 | * XXXanswer |
---|
1040 | */ |
---|
1041 | |
---|
1042 | #if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) |
---|
1043 | |
---|
1044 | #define _CPU_Priority_bits_index( _priority ) \ |
---|
1045 | (_priority) |
---|
1046 | |
---|
1047 | #endif |
---|
1048 | |
---|
1049 | /* end of Priority handler macros */ |
---|
1050 | |
---|
1051 | /* functions */ |
---|
1052 | |
---|
1053 | /* |
---|
1054 | * _CPU_Initialize |
---|
1055 | * |
---|
1056 | * This routine performs CPU dependent initialization. |
---|
1057 | * |
---|
1058 | * C4x Specific Information: |
---|
1059 | * |
---|
1060 | * XXXanswer |
---|
1061 | */ |
---|
1062 | |
---|
1063 | void _CPU_Initialize(void); |
---|
1064 | |
---|
1065 | /* |
---|
1066 | * _CPU_ISR_install_raw_handler |
---|
1067 | * |
---|
1068 | * This routine installs a "raw" interrupt handler directly into the |
---|
1069 | * processor's vector table. |
---|
1070 | * |
---|
1071 | * C4x Specific Information: |
---|
1072 | * |
---|
1073 | * XXXanswer |
---|
1074 | */ |
---|
1075 | |
---|
1076 | void _CPU_ISR_install_raw_handler( |
---|
1077 | uint32_t vector, |
---|
1078 | proc_ptr new_handler, |
---|
1079 | proc_ptr *old_handler |
---|
1080 | ); |
---|
1081 | |
---|
1082 | /* |
---|
1083 | * _CPU_ISR_install_vector |
---|
1084 | * |
---|
1085 | * This routine installs an interrupt vector. |
---|
1086 | * |
---|
1087 | * C4x Specific Information: |
---|
1088 | * |
---|
1089 | * XXXanswer |
---|
1090 | */ |
---|
1091 | |
---|
1092 | void _CPU_ISR_install_vector( |
---|
1093 | uint32_t vector, |
---|
1094 | proc_ptr new_handler, |
---|
1095 | proc_ptr *old_handler |
---|
1096 | ); |
---|
1097 | |
---|
1098 | /* |
---|
1099 | * _CPU_Thread_Idle_body |
---|
1100 | * |
---|
1101 | * This routine is the CPU dependent IDLE thread body. |
---|
1102 | * |
---|
1103 | * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY |
---|
1104 | * |
---|
1105 | * C4x Specific Information: |
---|
1106 | * |
---|
1107 | * XXXanswer |
---|
1108 | * is TRUE. |
---|
1109 | */ |
---|
1110 | |
---|
1111 | #if (CPU_PROVIDES_IDLE_THREAD_BODY == 1) |
---|
1112 | void *_CPU_Thread_Idle_body( uint32_t ); |
---|
1113 | #endif |
---|
1114 | |
---|
1115 | /* |
---|
1116 | * _CPU_Context_switch |
---|
1117 | * |
---|
1118 | * This routine switches from the run context to the heir context. |
---|
1119 | * |
---|
1120 | * C4x Specific Information: |
---|
1121 | * |
---|
1122 | * XXXanswer |
---|
1123 | */ |
---|
1124 | |
---|
1125 | void _CPU_Context_switch( |
---|
1126 | Context_Control *run, |
---|
1127 | Context_Control *heir |
---|
1128 | ); |
---|
1129 | |
---|
1130 | /* |
---|
1131 | * _CPU_Context_restore |
---|
1132 | * |
---|
1133 | * This routine is generally used only to restart self in an |
---|
1134 | * efficient manner. It may simply be a label in _CPU_Context_switch. |
---|
1135 | * |
---|
1136 | * NOTE: May be unnecessary to reload some registers. |
---|
1137 | * |
---|
1138 | * C4x Specific Information: |
---|
1139 | * |
---|
1140 | * XXXanswer |
---|
1141 | */ |
---|
1142 | |
---|
1143 | void _CPU_Context_restore( |
---|
1144 | Context_Control *new_context |
---|
1145 | ); |
---|
1146 | |
---|
1147 | /* |
---|
1148 | * _CPU_Context_save_fp |
---|
1149 | * |
---|
1150 | * This routine saves the floating point context passed to it. |
---|
1151 | * |
---|
1152 | * C4x Specific Information: |
---|
1153 | * |
---|
1154 | * No Floating Point from RTEMS perspective. |
---|
1155 | */ |
---|
1156 | |
---|
1157 | #if ( C4X_HAS_FPU == 1 ) |
---|
1158 | void _CPU_Context_save_fp( |
---|
1159 | Context_Control_fp **fp_context_ptr |
---|
1160 | ); |
---|
1161 | #endif |
---|
1162 | |
---|
1163 | /* |
---|
1164 | * _CPU_Context_restore_fp |
---|
1165 | * |
---|
1166 | * This routine restores the floating point context passed to it. |
---|
1167 | * |
---|
1168 | * C4x Specific Information: |
---|
1169 | * |
---|
1170 | * No Floating Point from RTEMS perspective. |
---|
1171 | */ |
---|
1172 | |
---|
1173 | #if ( C4X_HAS_FPU == 1 ) |
---|
1174 | void _CPU_Context_restore_fp( |
---|
1175 | Context_Control_fp **fp_context_ptr |
---|
1176 | ); |
---|
1177 | #endif |
---|
1178 | |
---|
1179 | /* The following routine swaps the endian format of an unsigned int. |
---|
1180 | * It must be static because it is referenced indirectly. |
---|
1181 | * |
---|
1182 | * This version will work on any processor, but if there is a better |
---|
1183 | * way for your CPU PLEASE use it. The most common way to do this is to: |
---|
1184 | * |
---|
1185 | * swap least significant two bytes with 16-bit rotate |
---|
1186 | * swap upper and lower 16-bits |
---|
1187 | * swap most significant two bytes with 16-bit rotate |
---|
1188 | * |
---|
1189 | * Some CPUs have special instructions which swap a 32-bit quantity in |
---|
1190 | * a single instruction (e.g. i486). It is probably best to avoid |
---|
1191 | * an "endian swapping control bit" in the CPU. One good reason is |
---|
1192 | * that interrupts would probably have to be disabled to ensure that |
---|
1193 | * an interrupt does not try to access the same "chunk" with the wrong |
---|
1194 | * endian. Another good reason is that on some CPUs, the endian bit |
---|
1195 | * endianness for ALL fetches -- both code and data -- so the code |
---|
1196 | * will be fetched incorrectly. |
---|
1197 | * |
---|
1198 | * C4x Specific Information: |
---|
1199 | * |
---|
1200 | * XXXanswer |
---|
1201 | */ |
---|
1202 | |
---|
1203 | static inline uint32_t CPU_swap_u32( |
---|
1204 | uint32_t value |
---|
1205 | ) |
---|
1206 | { |
---|
1207 | uint32_t byte1, byte2, byte3, byte4, swapped; |
---|
1208 | |
---|
1209 | byte4 = (value >> 24) & 0xff; |
---|
1210 | byte3 = (value >> 16) & 0xff; |
---|
1211 | byte2 = (value >> 8) & 0xff; |
---|
1212 | byte1 = value & 0xff; |
---|
1213 | |
---|
1214 | swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; |
---|
1215 | return( swapped ); |
---|
1216 | } |
---|
1217 | |
---|
1218 | #define CPU_swap_u16( value ) \ |
---|
1219 | (((value&0xff) << 8) | ((value >> 8)&0xff)) |
---|
1220 | |
---|
1221 | #ifdef __cplusplus |
---|
1222 | } |
---|
1223 | #endif |
---|
1224 | |
---|
1225 | #endif |
---|