1 | /* |
---|
2 | * C4x CPU Dependent Source |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1999. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.com/license/LICENSE. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #include <rtems/system.h> |
---|
16 | #include <rtems/score/isr.h> |
---|
17 | #include <rtems/score/wkspace.h> |
---|
18 | |
---|
19 | |
---|
20 | /* _CPU_Initialize |
---|
21 | * |
---|
22 | * This routine performs processor dependent initialization. |
---|
23 | * |
---|
24 | * INPUT PARAMETERS: |
---|
25 | * thread_dispatch - address of disptaching routine |
---|
26 | * |
---|
27 | * C4x Specific Information: |
---|
28 | * |
---|
29 | */ |
---|
30 | |
---|
31 | void _CPU_Initialize( |
---|
32 | void (*thread_dispatch) /* ignored on this CPU */ |
---|
33 | ) |
---|
34 | { |
---|
35 | #if 0 |
---|
36 | /* |
---|
37 | * The thread_dispatch argument is the address of the entry point |
---|
38 | * for the routine called at the end of an ISR once it has been |
---|
39 | * decided a context switch is necessary. On some compilation |
---|
40 | * systems it is difficult to call a high-level language routine |
---|
41 | * from assembly. This allows us to trick these systems. |
---|
42 | * |
---|
43 | * If you encounter this problem save the entry point in a CPU |
---|
44 | * dependent variable. |
---|
45 | */ |
---|
46 | |
---|
47 | _CPU_Thread_dispatch_pointer = thread_dispatch; |
---|
48 | #endif |
---|
49 | |
---|
50 | #if (CPU_HARDWARE_FP == TRUE) |
---|
51 | /* |
---|
52 | * If there is not an easy way to initialize the FP context |
---|
53 | * during Context_Initialize, then it is usually easier to |
---|
54 | * save an "uninitialized" FP context here and copy it to |
---|
55 | * the task's during Context_Initialize. |
---|
56 | */ |
---|
57 | |
---|
58 | /* FP context initialization support goes here */ |
---|
59 | #endif |
---|
60 | } |
---|
61 | |
---|
62 | /*PAGE |
---|
63 | * |
---|
64 | * _CPU_ISR_install_raw_handler |
---|
65 | * |
---|
66 | * C4x Specific Information: |
---|
67 | * |
---|
68 | */ |
---|
69 | |
---|
70 | void _CPU_ISR_install_raw_handler( |
---|
71 | uint32_t vector, |
---|
72 | proc_ptr new_handler, |
---|
73 | proc_ptr *old_handler |
---|
74 | ) |
---|
75 | { |
---|
76 | void **ittp; |
---|
77 | |
---|
78 | /* |
---|
79 | * This is where we install the interrupt handler into the "raw" interrupt |
---|
80 | * table used by the CPU to dispatch interrupt handlers. |
---|
81 | */ |
---|
82 | |
---|
83 | ittp = c4x_get_ittp(); |
---|
84 | *old_handler = ittp[ vector ]; |
---|
85 | ittp[ vector ] = new_handler; |
---|
86 | } |
---|
87 | |
---|
88 | /*XXX */ |
---|
89 | |
---|
90 | #define C4X_CACHE 1 |
---|
91 | #define C4X_BASE_ST (C4X_CACHE==1) ? 0x4800 : 0x4000 |
---|
92 | |
---|
93 | void _CPU_Context_Initialize( |
---|
94 | Context_Control *_the_context, |
---|
95 | void *_stack_base, |
---|
96 | uint32_t _size, |
---|
97 | uint32_t _isr, |
---|
98 | void (*_entry_point)(void), |
---|
99 | int _is_fp |
---|
100 | ) |
---|
101 | { |
---|
102 | unsigned int *_stack; |
---|
103 | _stack = (unsigned int *)_stack_base; |
---|
104 | |
---|
105 | *_stack = (unsigned int) _entry_point; |
---|
106 | _the_context->sp = (unsigned int) _stack; |
---|
107 | _the_context->st = C4X_BASE_ST; |
---|
108 | if ( _isr == 0 ) |
---|
109 | _the_context->st |= C4X_ST_GIE; |
---|
110 | } |
---|
111 | |
---|
112 | /*PAGE |
---|
113 | * |
---|
114 | * _CPU_ISR_install_vector |
---|
115 | * |
---|
116 | * This kernel routine installs the RTEMS handler for the |
---|
117 | * specified vector. |
---|
118 | * |
---|
119 | * Input parameters: |
---|
120 | * vector - interrupt vector number |
---|
121 | * old_handler - former ISR for this vector number |
---|
122 | * new_handler - replacement ISR for this vector number |
---|
123 | * |
---|
124 | * Output parameters: NONE |
---|
125 | * |
---|
126 | * |
---|
127 | * C4x Specific Information: |
---|
128 | * |
---|
129 | */ |
---|
130 | |
---|
131 | void _CPU_ISR_install_vector( |
---|
132 | uint32_t vector, |
---|
133 | proc_ptr new_handler, |
---|
134 | proc_ptr *old_handler |
---|
135 | ) |
---|
136 | { |
---|
137 | proc_ptr ignored; |
---|
138 | extern void rtems_irq_prologue_0(void); |
---|
139 | extern void rtems_irq_prologue_1(void); |
---|
140 | void *entry; |
---|
141 | |
---|
142 | *old_handler = _ISR_Vector_table[ vector ]; |
---|
143 | |
---|
144 | /* |
---|
145 | * If the interrupt vector table is a table of pointer to isr entry |
---|
146 | * points, then we need to install the appropriate RTEMS interrupt |
---|
147 | * handler for this vector number. |
---|
148 | */ |
---|
149 | |
---|
150 | entry = (void *)rtems_irq_prologue_0 + |
---|
151 | ((rtems_irq_prologue_1 - rtems_irq_prologue_0) * vector); |
---|
152 | _CPU_ISR_install_raw_handler( vector, entry, &ignored ); |
---|
153 | |
---|
154 | /* |
---|
155 | * We put the actual user ISR address in '_ISR_vector_table'. This will |
---|
156 | * be used by the _ISR_Handler so the user gets control. |
---|
157 | */ |
---|
158 | |
---|
159 | _ISR_Vector_table[ vector ] = new_handler; |
---|
160 | } |
---|
161 | |
---|
162 | /*PAGE |
---|
163 | * |
---|
164 | * _CPU_Thread_Idle_body |
---|
165 | * |
---|
166 | * NOTES: |
---|
167 | * |
---|
168 | * 1. This is the same as the regular CPU independent algorithm. |
---|
169 | * |
---|
170 | * 2. If you implement this using a "halt", "idle", or "shutdown" |
---|
171 | * instruction, then don't forget to put it in an infinite loop. |
---|
172 | * |
---|
173 | * 3. Be warned. Some processors with onboard DMA have been known |
---|
174 | * to stop the DMA if the CPU were put in IDLE mode. This might |
---|
175 | * also be a problem with other on-chip peripherals. So use this |
---|
176 | * hook with caution. |
---|
177 | * |
---|
178 | * C4x Specific Information: |
---|
179 | * |
---|
180 | * |
---|
181 | */ |
---|
182 | |
---|
183 | #if (CPU_PROVIDES_IDLE_THREAD_BODY == 1) |
---|
184 | void *_CPU_Thread_Idle_body( uint32_t ignored ) |
---|
185 | { |
---|
186 | |
---|
187 | for( ; ; ) { |
---|
188 | __asm__( "idle" ); |
---|
189 | __asm__( "nop" ); |
---|
190 | __asm__( "nop" ); |
---|
191 | __asm__( "nop" ); |
---|
192 | /* insert your "halt" instruction here */ ; |
---|
193 | } |
---|
194 | } |
---|
195 | #endif |
---|