-
RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/i386/shared/irq/irq.c,v
retrieving revision 1.22
diff -u -r1.22 irq.c
|
|
|
249 | 249 | irq_count[vector]++; |
250 | 250 | bsp_interrupt_handler_dispatch(vector); |
251 | 251 | } |
252 | | |
253 | | void _ThreadProcessSignalsFromIrq (void) |
254 | | { |
255 | | /* |
256 | | * Process pending signals that have not already been |
257 | | * processed by _Thread_Displatch. This happens quite |
258 | | * unfrequently : the ISR must have posted an action |
259 | | * to the current running thread. |
260 | | */ |
261 | | if ( _Thread_Do_post_task_switch_extension || |
262 | | _Thread_Executing->do_post_task_switch_extension ) { |
263 | | _Thread_Executing->do_post_task_switch_extension = false; |
264 | | _API_extensions_Run_postswitch(); |
265 | | } |
266 | | /* |
267 | | * I plan to process other thread related events here. |
268 | | * This will include DEBUG session requested from keyboard... |
269 | | */ |
270 | | } |
-
RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/i386/shared/irq/irq_asm.S,v
retrieving revision 1.17
diff -u -r1.17 irq_asm.S
|
|
|
8 | 8 | * found in found in the file LICENSE in this distribution or at |
9 | 9 | * http://www.rtems.com/license/LICENSE. |
10 | 10 | * |
11 | | * $Id: irq_asm.S,v 1.17 2010/06/15 16:36:19 joel Exp $ |
| 11 | * $Id: irq_asm.S,v 1.16 2009/11/30 03:47:10 ralf Exp $ |
12 | 12 | */ |
13 | 13 | |
14 | 14 | #include <rtems/asm.h> |
| 15 | #include <bspopts.h> |
15 | 16 | #include <bsp/irq_asm.h> |
16 | 17 | #include <rtems/score/cpu.h> |
| 18 | #include <rtems/score/percpu.h> |
17 | 19 | |
18 | 20 | #ifndef CPU_STACK_ALIGNMENT |
19 | 21 | #error "Missing header? CPU_STACK_ALIGNMENT is not defined here" |
… |
… |
|
22 | 24 | /* Stack frame we use for intermediate storage */ |
23 | 25 | #define ARG_OFF 0 |
24 | 26 | #define MSK_OFF 4 |
25 | | #define EBP_OFF 8 /* code restoring ebp/esp relies on */ |
26 | | #define ESP_OFF 12 /* esp being on top of ebp! */ |
| 27 | #define EBX_OFF 8 /* ebx */ |
| 28 | #define EBP_OFF 12 /* code restoring ebp/esp relies on */ |
| 29 | #define ESP_OFF 16 /* esp being on top of ebp! */ |
27 | 30 | #ifdef __SSE__ |
28 | | #define FRM_SIZ (16+512) |
29 | | #define SSE_OFF 16 |
| 31 | #define FRM_SIZ (20+512) |
| 32 | #define SSE_OFF 20 |
30 | 33 | #else |
31 | | #define FRM_SIZ 16 |
| 34 | #define FRM_SIZ 20 |
32 | 35 | #endif |
33 | 36 | |
34 | 37 | BEGIN_CODE |
… |
… |
|
64 | 67 | |
65 | 68 | /* |
66 | 69 | * Establish an aligned stack frame |
67 | | * original-sp |
68 | | * saved-bp |
69 | | * saved-irq-mask |
70 | | * vector-arg-to-C_dispatch_isr <- aligned SP |
| 70 | * original sp |
| 71 | * saved ebx |
| 72 | * saved ebp |
| 73 | * saved irq mask |
| 74 | * vector arg to C_dispatch_isr <- aligned SP |
71 | 75 | */ |
72 | 76 | movl esp, eax |
73 | 77 | subl $FRM_SIZ, esp |
74 | 78 | andl $ - CPU_STACK_ALIGNMENT, esp |
| 79 | movl ebx, EBX_OFF(esp) |
75 | 80 | movl eax, ESP_OFF(esp) |
76 | 81 | movl ebp, EBP_OFF(esp) |
77 | 82 | |
… |
… |
|
82 | 87 | */ |
83 | 88 | |
84 | 89 | /* We save SSE here (on the task stack) because we possibly |
85 | | * call other C-code (besides the ISR, namely _Thread_Dispatch() |
86 | | * or _ThreadProcessSignalsFromIrq()). |
| 90 | * call other C-code (besides the ISR, namely _Thread_Dispatch()) |
87 | 91 | */ |
88 | 92 | /* don't wait here; a possible exception condition will eventually be |
89 | 93 | * detected when the task resumes control and executes a FP instruction |
… |
… |
|
95 | 99 | ldmxcsr ARG_OFF(esp) /* clean-slate MXCSR */ |
96 | 100 | #endif |
97 | 101 | |
| 102 | /* Do not disable any 8259 interrupts if this isn't from one */ |
| 103 | cmp ecx, 16 /* is this a PIC IRQ? */ |
| 104 | jge .check_stack_switch |
98 | 105 | |
99 | 106 | /* |
100 | 107 | * acknowledge the interrupt |
101 | | * |
102 | 108 | */ |
103 | | movw SYM (i8259s_cache), ax /* move current i8259 interrupt mask in ax */ |
| 109 | movw SYM (i8259s_cache), ax /* save current i8259 interrupt mask */ |
104 | 110 | movl eax, MSK_OFF(esp) /* save in stack frame */ |
| 111 | |
105 | 112 | /* |
106 | 113 | * compute the new PIC mask: |
107 | 114 | * |
… |
… |
|
129 | 136 | * Now switch stacks if necessary |
130 | 137 | */ |
131 | 138 | |
| 139 | PUBLIC (ISR_STOP) |
| 140 | ISR_STOP: |
132 | 141 | .check_stack_switch: |
133 | 142 | movl esp, ebp /* ebp = previous stack pointer */ |
134 | | cmpl $0, SYM (_ISR_Nest_level) /* is this the outermost interrupt? */ |
| 143 | |
| 144 | movl $SYM(rtems_per_cpu_info), ebx |
| 145 | |
| 146 | /* is this the outermost interrupt? */ |
| 147 | cmpl $0, PER_CPU_ISR_NEST_LEVEL(ebx) |
135 | 148 | jne nested /* No, then continue */ |
136 | | movl SYM (_CPU_Interrupt_stack_high), esp |
| 149 | movl PER_CPU_INTERRUPT_STACK_HIGH(ebx), esp |
137 | 150 | |
138 | 151 | /* |
139 | 152 | * We want to insure that the old stack pointer is in ebp |
… |
… |
|
142 | 155 | */ |
143 | 156 | |
144 | 157 | nested: |
145 | | incl SYM (_ISR_Nest_level) /* one nest level deeper */ |
| 158 | incl PER_CPU_ISR_NEST_LEVEL(ebx) /* one nest level deeper */ |
146 | 159 | incl SYM (_Thread_Dispatch_disable_level) /* disable multitasking */ |
147 | 160 | |
148 | 161 | /* |
… |
… |
|
151 | 164 | */ |
152 | 165 | sti |
153 | 166 | |
154 | | /* |
| 167 | /* |
155 | 168 | * ECX is preloaded with the vector number; store as arg |
156 | 169 | * on top of stack. Note that _CPU_Interrupt_stack_high |
157 | 170 | * was adjusted in _CPU_Interrupt_stack_setup() (score/rtems/cpu.h) |
… |
… |
|
166 | 179 | */ |
167 | 180 | cli |
168 | 181 | |
| 182 | movl ARG_OFF(esp), ecx /* grab vector arg from stack */ |
| 183 | |
169 | 184 | /* |
170 | 185 | * Restore stack. This moves back to the task stack |
171 | 186 | * when all interrupts are unnested. |
… |
… |
|
175 | 190 | /* |
176 | 191 | * restore the original i8259 masks |
177 | 192 | */ |
| 193 | /* Do not touch 8259 interrupts if this isn't from one */ |
| 194 | cmp ecx, 16 /* is this a PIC IRQ? */ |
| 195 | jge .dont_restore_i8259 |
| 196 | |
178 | 197 | movl MSK_OFF(esp), eax |
179 | 198 | movw ax, SYM (i8259s_cache) |
180 | 199 | outb $PIC_MASTER_IMR_IO_PORT |
181 | 200 | movb ah, al |
182 | 201 | outb $PIC_SLAVE_IMR_IO_PORT |
183 | 202 | |
184 | | decl SYM (_ISR_Nest_level) /* one less ISR nest level */ |
| 203 | .dont_restore_i8259: |
| 204 | decl PER_CPU_ISR_NEST_LEVEL(ebx) /* one less ISR nest level */ |
185 | 205 | /* If interrupts are nested, */ |
186 | 206 | /* then dispatching is disabled */ |
187 | 207 | |
… |
… |
|
190 | 210 | /* Is dispatch disabled */ |
191 | 211 | jne .exit /* Yes, then exit */ |
192 | 212 | |
193 | | cmpb $0, SYM (_Context_Switch_necessary) |
| 213 | cmpb $0, PER_CPU_DISPATCH_NEEDED(ebx) |
194 | 214 | /* Is task switch necessary? */ |
195 | 215 | jne .schedule /* Yes, then call the scheduler */ |
196 | | |
197 | | cmpb $0, SYM (_ISR_Signals_to_thread_executing) |
198 | | /* signals sent to Run_thread */ |
199 | | /* while in interrupt handler? */ |
200 | | je .exit /* No, exit */ |
201 | | |
202 | | .bframe: |
203 | | movb $0, SYM (_ISR_Signals_to_thread_executing) |
204 | | /* |
205 | | * This code is the less critical path. In order to have a single |
206 | | * Thread Context, we take the same frame than the one pushed on |
207 | | * exceptions. This makes sense because Signal is a software |
208 | | * exception. |
209 | | */ |
210 | | call _ThreadProcessSignalsFromIrq |
211 | | |
212 | | jmp .exit |
| 216 | jmp .exit /* No, exit */ |
213 | 217 | |
214 | 218 | .schedule: |
215 | 219 | /* |
… |
… |
|
229 | 233 | fxrstor SSE_OFF(esp) |
230 | 234 | #endif |
231 | 235 | |
232 | | /* restore ebp and original esp */ |
233 | | addl $EBP_OFF, esp |
| 236 | /* restore ebx, ebp and original esp */ |
| 237 | addl $EBX_OFF, esp |
| 238 | popl ebx |
234 | 239 | popl ebp |
235 | 240 | popl esp |
| 241 | |
236 | 242 | /* |
237 | 243 | * BEGINNING OF DE-ESTABLISH SEGMENTS |
238 | 244 | * |
… |
… |
|
277 | 283 | DISTINCT_INTERRUPT_ENTRY(13) |
278 | 284 | DISTINCT_INTERRUPT_ENTRY(14) |
279 | 285 | DISTINCT_INTERRUPT_ENTRY(15) |
| 286 | DISTINCT_INTERRUPT_ENTRY(16) |
280 | 287 | |
281 | 288 | /* |
282 | 289 | * routine used to initialize the IDT by default |
-
RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/mips/shared/irq/exception.S,v
retrieving revision 1.2
diff -u -r1.2 exception.S
|
|
|
35 | 35 | |
36 | 36 | #include <bspopts.h> |
37 | 37 | #include <rtems/asm.h> |
| 38 | #include <rtems/score/percpu.h> |
38 | 39 | #include <rtems/mips/iregdef.h> |
39 | 40 | #include <rtems/mips/idtcpu.h> |
40 | 41 | #if BSP_HAS_USC320 |
… |
… |
|
88 | 89 | #endif |
89 | 90 | |
90 | 91 | |
91 | | EXTERN(_ISR_Nest_level, 4) |
92 | 92 | EXTERN(_Thread_Dispatch_disable_level,4) |
93 | | EXTERN(_Context_Switch_necessary,1) |
94 | 93 | EXTERN(_ISR_Signals_to_thread_executing,1) |
95 | 94 | .extern _Thread_Dispatch |
96 | 95 | .extern _ISR_Vector_table |
… |
… |
|
236 | 235 | /* |
237 | 236 | * _ISR_Nest_level++; |
238 | 237 | */ |
239 | | lw t0,_ISR_Nest_level |
| 238 | lw t0,ISR_NEST_LEVEL |
240 | 239 | NOP |
241 | 240 | add t0,t0,1 |
242 | | sw t0,_ISR_Nest_level |
| 241 | sw t0,ISR_NEST_LEVEL |
243 | 242 | /* |
244 | 243 | * _Thread_Dispatch_disable_level++; |
245 | 244 | */ |
… |
… |
|
299 | 298 | /* |
300 | 299 | * --_ISR_Nest_level; |
301 | 300 | */ |
302 | | lw t2,_ISR_Nest_level |
| 301 | lw t2,ISR_NEST_LEVEL |
303 | 302 | NOP |
304 | 303 | add t2,t2,-1 |
305 | | sw t2,_ISR_Nest_level |
| 304 | sw t2,ISR_NEST_LEVEL |
306 | 305 | /* |
307 | 306 | * --_Thread_Dispatch_disable_level; |
308 | 307 | */ |
… |
… |
|
324 | 323 | * restore stack |
325 | 324 | * #endif |
326 | 325 | * |
327 | | * if ( !_Context_Switch_necessary && !_ISR_Signals_to_thread_executing ) |
| 326 | * if ( !_Context_Switch_necessary ) |
328 | 327 | * goto the label "exit interrupt (simple case)" |
329 | 328 | */ |
330 | | lb t0,_Context_Switch_necessary |
331 | | lb t1,_ISR_Signals_to_thread_executing |
| 329 | lb t0,DISPATCH_NEEDED |
332 | 330 | NOP |
333 | | or t0,t0,t1 |
| 331 | or t0,t0,t0 |
334 | 332 | beq t0,zero,_ISR_Handler_exit |
335 | 333 | NOP |
336 | 334 | |
-
RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/powerpc/score603e/irq/irq.c,v
retrieving revision 1.13
diff -u -r1.13 irq.c
|
|
|
472 | 472 | return 0; |
473 | 473 | } |
474 | 474 | |
475 | | void _ThreadProcessSignalsFromIrq (BSP_Exception_frame* ctx) |
476 | | { |
477 | | printk(" _ThreadProcessSignalsFromIrq \n"); |
478 | | /* |
479 | | * Process pending signals that have not already been |
480 | | * processed by _Thread_Displatch. This happens quite |
481 | | * unfrequently : the ISR must have posted an action |
482 | | * to the current running thread. |
483 | | */ |
484 | | if ( _Thread_Do_post_task_switch_extension || |
485 | | _Thread_Executing->do_post_task_switch_extension ) { |
486 | | _Thread_Executing->do_post_task_switch_extension = false; |
487 | | _API_extensions_Run_postswitch(); |
488 | | } |
489 | | /* |
490 | | * I plan to process other thread related events here. |
491 | | * This will include DEBUG session requested from keyboard... |
492 | | */ |
493 | | } |
494 | | |
495 | 475 | rtems_status_code bsp_interrupt_facility_initialize(void) |
496 | 476 | { |
497 | 477 | /* Install exception handler */ |
-
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/powerpc/mpc5xx/irq/irq.c,v
retrieving revision 1.8
diff -u -r1.8 irq.c
|
|
|
482 | 482 | usiu.simask = ppc_cached_irq_mask; |
483 | 483 | } |
484 | 484 | } |
485 | | |
486 | | void _ThreadProcessSignalsFromIrq (CPU_Exception_frame* ctx) |
487 | | { |
488 | | /* |
489 | | * Process pending signals that have not already been |
490 | | * processed by _Thread_Displatch. This happens quite |
491 | | * unfrequently : the ISR must have posted an action |
492 | | * to the current running thread. |
493 | | */ |
494 | | if ( _Thread_Do_post_task_switch_extension || |
495 | | _Thread_Executing->do_post_task_switch_extension ) { |
496 | | _Thread_Executing->do_post_task_switch_extension = false; |
497 | | _API_extensions_Run_postswitch(); |
498 | | } |
499 | | /* |
500 | | * I plan to process other thread related events here. |
501 | | * This will include DEBUG session requested from keyboard... |
502 | | */ |
503 | | } |
-
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/powerpc/mpc5xx/irq/irq_asm.S,v
retrieving revision 1.5
diff -u -r1.5 irq_asm.S
|
|
|
26 | 26 | |
27 | 27 | #include <rtems/asm.h> |
28 | 28 | #include <rtems/score/cpu.h> |
| 29 | #include <rtems/score/percpu.h> |
29 | 30 | #include <libcpu/vectors.h> |
30 | 31 | #include <libcpu/raw_exception.h> |
31 | 32 | |
… |
… |
|
118 | 119 | /* |
119 | 120 | * Retrieve current nesting level from _ISR_Nest_level |
120 | 121 | */ |
121 | | lis r7, _ISR_Nest_level@ha |
122 | | lwz r3, _ISR_Nest_level@l(r7) |
| 122 | lis r7, ISR_NEST_LEVEL@ha |
| 123 | lwz r3, ISR_NEST_LEVEL@l(r7) |
123 | 124 | |
124 | 125 | /* |
125 | 126 | * Check if stack switch is necessary |
… |
… |
|
141 | 142 | lwz r6, _Thread_Dispatch_disable_level@l(r15) |
142 | 143 | |
143 | 144 | /* store new nesting level in _ISR_Nest_level */ |
144 | | stw r3, _ISR_Nest_level@l(r7) |
| 145 | stw r3, ISR_NEST_LEVEL@l(r7) |
145 | 146 | |
146 | 147 | addi r6, r6, 1 |
147 | 148 | |
… |
… |
|
170 | 171 | * value as an easy exit condition because if interrupt nesting level > 1 |
171 | 172 | * then _Thread_Dispatch_disable_level > 1 |
172 | 173 | */ |
173 | | lis r7, _ISR_Nest_level@ha |
174 | | lwz r4, _ISR_Nest_level@l(r7) |
| 174 | lis r7, ISR_NEST_LEVEL@ha |
| 175 | lwz r4, ISR_NEST_LEVEL@l(r7) |
175 | 176 | |
176 | 177 | /* |
177 | 178 | * start decrementing _Thread_Dispatch_disable_level |
… |
… |
|
181 | 182 | addi r4, r4, -1 /* Continue decrementing nesting level */ |
182 | 183 | addi r3, r3, -1 /* Continue decrementing _Thread_Dispatch_disable_level */ |
183 | 184 | |
184 | | stw r4, _ISR_Nest_level@l(r7) /* End decrementing nesting level */ |
| 185 | stw r4, ISR_NEST_LEVEL@l(r7) /* End decrementing nesting level */ |
185 | 186 | stw r3,_Thread_Dispatch_disable_level@l(r15) /* End decrementing _Thread_Dispatch_disable_level */ |
186 | 187 | |
187 | 188 | cmpwi r3, 0 |
… |
… |
|
199 | 200 | * Interrupt are still disabled. Time to check if scheduler request to |
200 | 201 | * do something with the current thread... |
201 | 202 | */ |
202 | | addis r4, 0, _Context_Switch_necessary@ha |
203 | | lbz r5, _Context_Switch_necessary@l(r4) |
| 203 | addis r4, 0, DISPATCH_NEEDED@ha |
| 204 | lbz r5, DISPATCH_NEEDED@l(r4) |
204 | 205 | cmpwi r5, 0 |
205 | | bne switch |
206 | | |
207 | | addis r6, 0, _ISR_Signals_to_thread_executing@ha |
208 | | lbz r7, _ISR_Signals_to_thread_executing@l(r6) |
209 | | cmpwi r7, 0 |
210 | | li r8, 0 |
211 | 206 | beq easy_exit |
212 | 207 | |
213 | | stb r8, _ISR_Signals_to_thread_executing@l(r6) |
214 | | |
215 | 208 | /* |
216 | | * going to call _ThreadProcessSignalsFromIrq |
| 209 | * going to call _Thread_Dispatch |
217 | 210 | * Push a complete exception like frame... |
218 | 211 | */ |
219 | 212 | stmw r16, GPR16_OFFSET(r1) |
… |
… |
|
232 | 225 | /* |
233 | 226 | * Call High Level signal handling code |
234 | 227 | */ |
235 | | bl _ThreadProcessSignalsFromIrq |
| 228 | bl _Thread_Dispatch |
236 | 229 | |
237 | 230 | /* |
238 | 231 | * start restoring exception like frame |
… |
… |
|
272 | 265 | rfi |
273 | 266 | |
274 | 267 | |
275 | | switch: |
276 | | bl SYM (_Thread_Dispatch) |
277 | | |
278 | 268 | easy_exit: |
279 | 269 | /* |
280 | 270 | * start restoring interrupt frame |
-
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc.S,v
retrieving revision 1.5
diff -u -r1.5 ppc_exc.S
|
|
|
13 | 13 | */ |
14 | 14 | |
15 | 15 | /* Load macro definitions */ |
| 16 | #include <rtems/asm.h> |
| 17 | #include <rtems/system.h> |
| 18 | #include <rtems/score/percpu.h> |
| 19 | |
16 | 20 | #include "ppc_exc_asm_macros.h" |
17 | 21 | |
18 | 22 | /******************************************************/ |
-
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_asm_macros.h,v
retrieving revision 1.10
diff -u -r1.10 ppc_exc_asm_macros.h
|
|
|
422 | 422 | */ |
423 | 423 | |
424 | 424 | /* Increment ISR nest level and thread dispatch disable level */ |
425 | | lwz SCRATCH_REGISTER_0, _ISR_Nest_level@sdarel(r13) |
| 425 | lis SCRATCH_REGISTER_2, ISR_NEST_LEVEL@ha |
| 426 | lwz SCRATCH_REGISTER_0, ISR_NEST_LEVEL@l(SCRATCH_REGISTER_2) |
426 | 427 | lwz SCRATCH_REGISTER_1, _Thread_Dispatch_disable_level@sdarel(r13) |
427 | 428 | addi SCRATCH_REGISTER_0, SCRATCH_REGISTER_0, 1 |
428 | 429 | addi SCRATCH_REGISTER_1, SCRATCH_REGISTER_1, 1 |
429 | | stw SCRATCH_REGISTER_0, _ISR_Nest_level@sdarel(r13) |
| 430 | stw SCRATCH_REGISTER_0, ISR_NEST_LEVEL@l(SCRATCH_REGISTER_2) |
430 | 431 | stw SCRATCH_REGISTER_1, _Thread_Dispatch_disable_level@sdarel(r13) |
431 | 432 | |
432 | 433 | /* |
… |
… |
|
612 | 613 | */ |
613 | 614 | |
614 | 615 | /* Decrement ISR nest level and thread dispatch disable level */ |
615 | | lwz SCRATCH_REGISTER_0, _ISR_Nest_level@sdarel(r13) |
| 616 | lis SCRATCH_REGISTER_2, ISR_NEST_LEVEL@ha |
| 617 | lwz SCRATCH_REGISTER_0, ISR_NEST_LEVEL@l(SCRATCH_REGISTER_2) |
616 | 618 | lwz SCRATCH_REGISTER_1, _Thread_Dispatch_disable_level@sdarel(r13) |
617 | 619 | subi SCRATCH_REGISTER_0, SCRATCH_REGISTER_0, 1 |
618 | 620 | subic. SCRATCH_REGISTER_1, SCRATCH_REGISTER_1, 1 |
619 | | stw SCRATCH_REGISTER_0, _ISR_Nest_level@sdarel(r13) |
| 621 | stw SCRATCH_REGISTER_0, ISR_NEST_LEVEL@l(SCRATCH_REGISTER_2) |
620 | 622 | stw SCRATCH_REGISTER_1, _Thread_Dispatch_disable_level@sdarel(r13) |
621 | 623 | |
622 | 624 | /* Branch to skip thread dispatching */ |
-
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_hdl.c,v
retrieving revision 1.8
diff -u -r1.8 ppc_exc_hdl.c
|
|
|
86 | 86 | * interrupts around the execution of _Thread_Dispatch(); |
87 | 87 | */ |
88 | 88 | _Thread_Dispatch(); |
89 | | } else if ( _ISR_Signals_to_thread_executing ) { |
90 | | _ISR_Signals_to_thread_executing = 0; |
91 | | /* |
92 | | * Process pending signals that have not already been |
93 | | * processed by _Thread_Dispatch. This happens quite |
94 | | * unfrequently : the ISR must have posted an action |
95 | | * to the current running thread. |
96 | | */ |
97 | | if ( _Thread_Do_post_task_switch_extension || |
98 | | _Thread_Executing->do_post_task_switch_extension ) { |
99 | | _Thread_Executing->do_post_task_switch_extension = false; |
100 | | _API_extensions_Run_postswitch(); |
101 | | } |
102 | 89 | } |
103 | 90 | } |
-
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/sh/sh7032/score/cpu_asm.c,v
retrieving revision 1.15
diff -u -r1.15 cpu_asm.c
|
|
|
173 | 173 | return; |
174 | 174 | |
175 | 175 | if ( _Thread_Dispatch_disable_level ) { |
176 | | _ISR_Signals_to_thread_executing = FALSE; |
177 | 176 | return; |
178 | 177 | } |
179 | 178 | |
180 | | if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) { |
181 | | _ISR_Signals_to_thread_executing = FALSE; |
| 179 | if ( _Context_Switch_necessary ) { |
182 | 180 | _Thread_Dispatch(); |
183 | 181 | } |
184 | 182 | } |
-
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/sh/sh7045/score/cpu_asm.c,v
retrieving revision 1.17
diff -u -r1.17 cpu_asm.c
|
|
|
175 | 175 | return; |
176 | 176 | |
177 | 177 | if ( _Thread_Dispatch_disable_level ) { |
178 | | _ISR_Signals_to_thread_executing = FALSE; |
179 | 178 | return; |
180 | 179 | } |
181 | 180 | |
182 | | if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) { |
183 | | _ISR_Signals_to_thread_executing = FALSE; |
| 181 | if ( _Context_Switch_necessary ) { |
184 | 182 | _Thread_Dispatch(); |
185 | 183 | } |
186 | 184 | } |
-
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/sh/sh7750/score/cpu_asm.c,v
retrieving revision 1.13
diff -u -r1.13 cpu_asm.c
|
|
|
98 | 98 | return; |
99 | 99 | |
100 | 100 | if ( _Thread_Dispatch_disable_level ) { |
101 | | _ISR_Signals_to_thread_executing = FALSE; |
102 | 101 | return; |
103 | 102 | } |
104 | 103 | |
105 | | if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) { |
106 | | _ISR_Signals_to_thread_executing = FALSE; |
| 104 | if ( _Context_Switch_necessary ) { |
107 | 105 | _Thread_Dispatch(); |
108 | 106 | } |
109 | 107 | } |
-
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/sh/shgdb/score/cpu_asm.c,v
retrieving revision 1.2
diff -u -r1.2 cpu_asm.c
|
|
|
72 | 72 | return; |
73 | 73 | |
74 | 74 | if ( _Thread_Dispatch_disable_level ) { |
75 | | _ISR_Signals_to_thread_executing = FALSE; |
76 | 75 | return; |
77 | 76 | } |
78 | 77 | |
79 | | if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) { |
80 | | _ISR_Signals_to_thread_executing = FALSE; |
| 78 | if ( _Context_Switch_necessary ) { |
81 | 79 | _Thread_Dispatch(); |
82 | 80 | } |
83 | 81 | } |
-
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/sparc64/shared/score/interrupt.S,v
retrieving revision 1.1
diff -u -r1.1 interrupt.S
|
|
|
26 | 26 | */ |
27 | 27 | |
28 | 28 | #include <rtems/asm.h> |
| 29 | #include <rtems/score/percpu.h> |
29 | 30 | |
30 | 31 | |
31 | 32 | /* |
… |
… |
|
178 | 179 | |
179 | 180 | setx SYM(_Thread_Dispatch_disable_level), %o5, %g3 |
180 | 181 | lduw [%g3], %g5 |
181 | | setx SYM(_ISR_Nest_level), %o5, %g6 |
| 182 | setx ISR_NEST_LEVEL, %o5, %g6 |
182 | 183 | lduw [%g6], %g4 |
183 | 184 | |
184 | 185 | add %g5, 1, %g5 |
… |
… |
|
345 | 346 | bnz simple_return ! Yes, then do a "simple" exit |
346 | 347 | nop |
347 | 348 | |
348 | | setx SYM(_Context_Switch_necessary), %o5, %g7 |
| 349 | setx DISPATCH_NEEDED, %o5, %g7 |
349 | 350 | |
350 | 351 | |
351 | 352 | /* |
… |
… |
|
360 | 361 | nop |
361 | 362 | |
362 | 363 | /* |
363 | | * Finally, check to see if signals were sent to the currently |
364 | | * executing task. If so, we need to invoke the interrupt dispatcher. |
365 | | */ |
366 | | setx SYM(_ISR_Signals_to_thread_executing), %o5, %g5 |
367 | | ldub [%g5], %o5 |
368 | | |
369 | | orcc %o5, %g0, %g0 ! Were signals sent to the currently |
370 | | ! executing thread? |
371 | | bz simple_return ! yes, then invoke the dispatcher |
372 | | ! use the delay slot to clear the signals |
373 | | ! to the currently executing task flag |
374 | | stb %g0, [%g5] |
375 | | |
376 | | |
377 | | /* |
378 | 364 | * Invoke interrupt dispatcher. |
379 | 365 | */ |
380 | 366 | PUBLIC(_ISR_Dispatch) |
… |
… |
|
408 | 394 | * _Thread_Dispatch before leaving this ISR Dispatch context. |
409 | 395 | */ |
410 | 396 | |
411 | | setx SYM(_Context_Switch_necessary), %o5, %o1 |
| 397 | setx DISPATCH_NEEDED, %o5, %o1 |
412 | 398 | ldub [%o1], %o2 |
413 | 399 | |
414 | | ! NOTE: Use some of delay slot to start loading this |
415 | | setx SYM(_ISR_Signals_to_thread_executing), %o5, %o1 |
416 | | ldub [%o1], %o3 |
417 | | |
418 | 400 | orcc %o2, %g0, %g0 ! Is thread switch necessary? |
419 | | bnz dispatchAgain ! yes, then invoke the dispatcher AGAIN |
420 | | ! NOTE: Use the delay slot to catch the orcc below |
421 | | |
422 | | /* |
423 | | * Finally, check to see if signals were sent to the currently |
424 | | * executing task. If so, we need to invoke the interrupt dispatcher. |
425 | | */ |
426 | | |
427 | | ! NOTE: Delay slots above were used to perform the load AND |
428 | | ! this orcc falls into the delay slot for bnz above |
429 | | orcc %o3, %g0, %g0 ! Were signals sent to the currently |
430 | | ! executing thread? |
431 | 401 | bz allow_nest_again ! No, then clear out and return |
432 | 402 | nop |
433 | 403 | |
434 | 404 | ! Yes, then invoke the dispatcher |
435 | | dispatchAgain: |
| 405 | dispatchAgain: |
436 | 406 | mov 3, %g4 ! syscall (enable interrupts) |
437 | 407 | ta 0 ! syscall (enable interrupts) |
438 | 408 | ba isr_dispatch |
-
RCS file: /usr1/CVS/rtems/cpukit/configure.ac,v
retrieving revision 1.187
diff -u -r1.187 configure.ac
|
|
|
251 | 251 | ## Check if libc provides BSD's strlcpy/strlcat |
252 | 252 | AC_CHECK_FUNCS(strlcpy strlcat) |
253 | 253 | |
| 254 | ## This is needed to generate the field offsets of the per CPU |
| 255 | ## data structure so they can be accessed from assembly code. |
| 256 | AC_CHECK_SIZEOF([void *]) |
254 | 257 | |
255 | 258 | # ... far too many conditionals ... |
256 | 259 | AM_CONDITIONAL(LIBRPC,[test x"$rtems_cv_HAS_NETWORKING" = x"yes"]) |
-
RCS file: /usr1/CVS/rtems/cpukit/posix/src/killinfo.c,v
retrieving revision 1.24
diff -u -r1.24 killinfo.c
|
|
|
314 | 314 | */ |
315 | 315 | process_it: |
316 | 316 | |
317 | | the_thread->do_post_task_switch_extension = true; |
318 | | |
319 | 317 | /* |
320 | 318 | * Returns true if the signal was synchronously given to a thread |
321 | 319 | * blocked waiting for the signal. |
-
RCS file: /usr1/CVS/rtems/cpukit/posix/src/psignalclearprocesssignals.c,v
retrieving revision 1.6
diff -u -r1.6 psignalclearprocesssignals.c
|
|
|
53 | 53 | } |
54 | 54 | if ( clear_signal ) { |
55 | 55 | _POSIX_signals_Pending &= ~mask; |
56 | | if ( !_POSIX_signals_Pending ) |
57 | | _Thread_Do_post_task_switch_extension--; |
58 | 56 | } |
59 | 57 | _ISR_Enable( level ); |
60 | 58 | } |
-
RCS file: /usr1/CVS/rtems/cpukit/posix/src/psignalsetprocesssignals.c,v
retrieving revision 1.6
diff -u -r1.6 psignalsetprocesssignals.c
|
|
|
41 | 41 | ISR_Level level; |
42 | 42 | |
43 | 43 | _ISR_Disable( level ); |
44 | | if ( !_POSIX_signals_Pending ) |
45 | | _Thread_Do_post_task_switch_extension++; |
46 | 44 | _POSIX_signals_Pending |= mask; |
47 | 45 | _ISR_Enable( level ); |
48 | 46 | } |
-
RCS file: /usr1/CVS/rtems/cpukit/posix/src/psignalunblockthread.c,v
retrieving revision 1.10
diff -u -r1.10 psignalunblockthread.c
|
|
|
98 | 98 | * + Any other combination, do nothing. |
99 | 99 | */ |
100 | 100 | |
101 | | the_thread->do_post_task_switch_extension = true; |
102 | | |
103 | 101 | if ( the_thread->current_state & STATES_INTERRUPTIBLE_BY_SIGNAL ) { |
104 | 102 | the_thread->Wait.return_code = EINTR; |
105 | 103 | /* |
… |
… |
|
120 | 118 | } |
121 | 119 | } else if ( the_thread->current_state == STATES_READY ) { |
122 | 120 | if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) ) |
123 | | _ISR_Signals_to_thread_executing = true; |
| 121 | _Context_Switch_necessary = true; |
124 | 122 | } |
125 | 123 | } |
126 | 124 | return false; |
-
RCS file: /usr1/CVS/rtems/cpukit/posix/src/pthreadcreate.c,v
retrieving revision 1.20
diff -u -r1.20 pthreadcreate.c
|
|
|
191 | 191 | api->schedparam = schedparam; |
192 | 192 | |
193 | 193 | /* |
194 | | * This insures we evaluate the process-wide signals pending when we |
195 | | * first run. |
196 | | * |
197 | | * NOTE: Since the thread starts with all unblocked, this is necessary. |
198 | | */ |
199 | | the_thread->do_post_task_switch_extension = true; |
200 | | |
201 | | /* |
202 | 194 | * POSIX threads are allocated and started in one operation. |
203 | 195 | */ |
204 | 196 | status = _Thread_Start( |
-
RCS file: /usr1/CVS/rtems/cpukit/posix/src/pthreadkill.c,v
retrieving revision 1.15
diff -u -r1.15 pthreadkill.c
|
|
|
63 | 63 | |
64 | 64 | (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL ); |
65 | 65 | |
66 | | the_thread->do_post_task_switch_extension = true; |
67 | | |
68 | 66 | if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) ) |
69 | | _ISR_Signals_to_thread_executing = true; |
| 67 | _Context_Switch_necessary = true; |
70 | 68 | } |
71 | 69 | _Thread_Enable_dispatch(); |
72 | 70 | return 0; |
-
RCS file: /usr1/CVS/rtems/cpukit/posix/src/pthreadsigmask.c,v
retrieving revision 1.8
diff -u -r1.8 pthreadsigmask.c
|
|
|
65 | 65 | |
66 | 66 | if ( ~api->signals_blocked & |
67 | 67 | (api->signals_pending | _POSIX_signals_Pending) ) { |
68 | | _Thread_Executing->do_post_task_switch_extension = true; |
69 | 68 | _Thread_Dispatch(); |
70 | 69 | } |
71 | 70 | |
-
RCS file: /usr1/CVS/rtems/cpukit/rtems/src/signalsend.c,v
retrieving revision 1.10
diff -u -r1.10 signalsend.c
|
|
|
64 | 64 | if ( asr->is_enabled ) { |
65 | 65 | _ASR_Post_signals( signal_set, &asr->signals_posted ); |
66 | 66 | |
67 | | the_thread->do_post_task_switch_extension = true; |
68 | | |
69 | 67 | if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) ) |
70 | | _ISR_Signals_to_thread_executing = true; |
| 68 | _Context_Switch_necessary = true; |
71 | 69 | } else { |
72 | 70 | _ASR_Post_signals( signal_set, &asr->signals_pending ); |
73 | 71 | } |
-
RCS file: /usr1/CVS/rtems/cpukit/rtems/src/taskmode.c,v
retrieving revision 1.11
diff -u -r1.11 taskmode.c
|
|
|
117 | 117 | _ASR_Swap_signals( asr ); |
118 | 118 | if ( _ASR_Are_signals_pending( asr ) ) { |
119 | 119 | needs_asr_dispatching = true; |
120 | | executing->do_post_task_switch_extension = true; |
121 | 120 | } |
122 | 121 | } |
123 | 122 | } |
-
RCS file: /usr1/CVS/rtems/cpukit/score/Makefile.am,v
retrieving revision 1.81
diff -u -r1.81 Makefile.am
|
|
|
24 | 24 | include/rtems/score/coremutex.h include/rtems/score/coresem.h \ |
25 | 25 | include/rtems/score/heap.h include/rtems/score/protectedheap.h \ |
26 | 26 | include/rtems/score/interr.h include/rtems/score/isr.h \ |
27 | | include/rtems/score/object.h include/rtems/score/priority.h \ |
28 | | include/rtems/score/stack.h include/rtems/score/states.h \ |
29 | | include/rtems/score/sysstate.h include/rtems/score/thread.h \ |
30 | | include/rtems/score/threadq.h include/rtems/score/threadsync.h \ |
31 | | include/rtems/score/timespec.h include/rtems/score/timestamp.h \ |
32 | | include/rtems/score/timestamp64.h include/rtems/score/tod.h \ |
33 | | include/rtems/score/tqdata.h include/rtems/score/userext.h \ |
34 | | include/rtems/score/watchdog.h include/rtems/score/wkspace.h \ |
35 | | include/rtems/score/cpuopts.h |
| 27 | include/rtems/score/object.h include/rtems/score/percpu.h \ |
| 28 | include/rtems/score/priority.h include/rtems/score/stack.h \ |
| 29 | include/rtems/score/states.h include/rtems/score/sysstate.h \ |
| 30 | include/rtems/score/thread.h include/rtems/score/threadq.h \ |
| 31 | include/rtems/score/threadsync.h include/rtems/score/timespec.h \ |
| 32 | include/rtems/score/timestamp.h include/rtems/score/timestamp64.h \ |
| 33 | include/rtems/score/tod.h include/rtems/score/tqdata.h \ |
| 34 | include/rtems/score/userext.h include/rtems/score/watchdog.h \ |
| 35 | include/rtems/score/wkspace.h include/rtems/score/cpuopts.h |
36 | 36 | |
37 | 37 | if HAS_PTHREADS |
38 | 38 | include_rtems_score_HEADERS += include/rtems/score/corespinlock.h \ |
… |
… |
|
101 | 101 | src/coremutexseize.c src/coremutexsurrender.c \ |
102 | 102 | src/coremutexseizeintr.c |
103 | 103 | |
| 104 | ## CORE_PERCPU_C_FILES |
| 105 | libscore_a_SOURCES += src/percpu.c |
| 106 | |
104 | 107 | ## CORE_RWLOCK_C_FILES |
105 | 108 | if HAS_PTHREADS |
106 | 109 | libscore_a_SOURCES += src/corerwlock.c src/corerwlockobtainread.c \ |
-
RCS file: /usr1/CVS/rtems/cpukit/score/preinstall.am,v
retrieving revision 1.21
diff -u -r1.21 preinstall.am
|
|
|
99 | 99 | $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/object.h |
100 | 100 | PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/object.h |
101 | 101 | |
| 102 | $(PROJECT_INCLUDE)/rtems/score/percpu.h: include/rtems/score/percpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) |
| 103 | $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/percpu.h |
| 104 | PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/percpu.h |
| 105 | |
102 | 106 | $(PROJECT_INCLUDE)/rtems/score/priority.h: include/rtems/score/priority.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) |
103 | 107 | $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/priority.h |
104 | 108 | PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/priority.h |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/arm/arm_exc_interrupt.S,v
retrieving revision 1.5
diff -u -r1.5 arm_exc_interrupt.S
|
|
|
30 | 30 | #endif |
31 | 31 | |
32 | 32 | #include <rtems/asm.h> |
| 33 | #include <rtems/score/percpu.h> |
33 | 34 | |
34 | 35 | #define EXCHANGE_LR r4 |
35 | 36 | #define EXCHANGE_SPSR r5 |
… |
… |
|
42 | 43 | #define CONTEXT_LIST {r0, r1, r2, r3, EXCHANGE_LR, EXCHANGE_SPSR, r12} |
43 | 44 | #define CONTEXT_SIZE 28 |
44 | 45 | |
45 | | .extern _ISR_Nest_level |
46 | | .extern _ISR_Signals_to_thread_executing |
47 | | .extern _ISR_Thread_dispatch |
48 | 46 | .extern _Thread_Dispatch_disable_level |
49 | 47 | |
50 | 48 | .extern bsp_interrupt_dispatch |
… |
… |
|
81 | 79 | ldmia r1, EXCHANGE_LIST |
82 | 80 | |
83 | 81 | /* Get interrupt nest level */ |
84 | | ldr r0, =_ISR_Nest_level |
| 82 | ldr r0, =ISR_NEST_LEVEL |
85 | 83 | ldr r2, [r0] |
86 | 84 | |
87 | 85 | /* Switch stack if necessary and save original stack pointer */ |
… |
… |
|
105 | 103 | bl bsp_interrupt_dispatch |
106 | 104 | |
107 | 105 | /* Decrement interrupt nest and thread dispatch disable level */ |
108 | | ldr r0, =_ISR_Nest_level |
| 106 | ldr r0, =ISR_NEST_LEVEL |
109 | 107 | ldr r1, =_Thread_Dispatch_disable_level |
110 | 108 | ldr r2, [r0] |
111 | 109 | ldr r3, [r1] |
… |
… |
|
124 | 122 | bne thread_dispatch_done |
125 | 123 | |
126 | 124 | /* Check context switch necessary */ |
127 | | ldr r0, =_Context_Switch_necessary |
128 | | ldrb r1, [r0] |
129 | | ldr r0, =_ISR_Signals_to_thread_executing |
130 | | cmp r1, #0 |
131 | | bne do_thread_dispatch |
132 | | |
133 | | /* Check ISR signals to thread executing */ |
| 125 | ldr r0, =DISPATCH_NEEDED |
134 | 126 | ldrb r1, [r0] |
135 | 127 | cmp r1, #0 |
136 | 128 | beq thread_dispatch_done |
… |
… |
|
142 | 134 | |
143 | 135 | do_thread_dispatch: |
144 | 136 | |
145 | | /* Clear ISR signals to thread executing */ |
146 | | strb r3, [r0] |
147 | | |
148 | 137 | /* Thread dispatch */ |
149 | 138 | bl _Thread_Dispatch |
150 | 139 | |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/avr/cpu_asm.S,v
retrieving revision 1.9
diff -u -r1.9 cpu_asm.S
|
|
|
28 | 28 | |
29 | 29 | #include <rtems/asm.h> |
30 | 30 | #include <avr/sfr_defs.h> |
| 31 | #include <rtems/score/percpu.h> |
31 | 32 | |
32 | 33 | |
33 | 34 | #define jmpb_hi r25 |
… |
… |
|
438 | 439 | * goto the label "exit interrupt (simple case)" |
439 | 440 | * |
440 | 441 | * if ( _Thread_Dispatch_disable_level ) |
441 | | * _ISR_Signals_to_thread_executing = FALSE; |
442 | 442 | * goto the label "exit interrupt (simple case)" |
443 | 443 | * |
444 | | * if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) { |
445 | | * _ISR_Signals_to_thread_executing = FALSE; |
| 444 | * if ( _Context_Switch_necessary ) { |
446 | 445 | * call _Thread_Dispatch() or prepare to return to _ISR_Dispatch |
447 | 446 | * prepare to get out of interrupt |
448 | 447 | * return from interrupt (maybe to _ISR_Dispatch) |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/avr/rtems/score/cpu.h,v
retrieving revision 1.25
diff -u -r1.25 cpu.h
|
|
|
456 | 456 | SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context; |
457 | 457 | |
458 | 458 | /* |
459 | | * On some CPUs, RTEMS supports a software managed interrupt stack. |
460 | | * This stack is allocated by the Interrupt Manager and the switch |
461 | | * is performed in _ISR_Handler. These variables contain pointers |
462 | | * to the lowest and highest addresses in the chunk of memory allocated |
463 | | * for the interrupt stack. Since it is unknown whether the stack |
464 | | * grows up or down (in general), this give the CPU dependent |
465 | | * code the option of picking the version it wants to use. |
466 | | * |
467 | | * NOTE: These two variables are required if the macro |
468 | | * CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. |
469 | | * |
470 | | * AVR Specific Information: |
471 | | * |
472 | | * XXX document implementation including references if appropriate |
473 | | */ |
474 | | |
475 | | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
476 | | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
477 | | |
478 | | /* |
479 | 459 | * Nothing prevents the porter from declaring more CPU specific variables. |
480 | 460 | * |
481 | 461 | * AVR Specific Information: |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/bfin/cpu_asm.S,v
retrieving revision 1.10
diff -u -r1.10 cpu_asm.S
|
|
|
28 | 28 | #include <rtems/score/cpu_asm.h> |
29 | 29 | #include <rtems/score/bfin.h> |
30 | 30 | #include <rtems/bfin/bfin.h> |
| 31 | #include <rtems/score/percpu.h> |
31 | 32 | |
32 | 33 | #define LO(con32) ((con32) & 0xFFFF) |
33 | 34 | #define HI(con32) (((con32) >> 16) & 0xFFFF) |
… |
… |
|
313 | 314 | |
314 | 315 | |
315 | 316 | .globl SYM(_ISR_Handler) |
316 | | .extern SYM(_CPU_Interrupt_stack_high) |
317 | | .extern SYM(_ISR_Nest_level) |
318 | | .extern SYM(_Thread_Dispatch_disable_level) |
319 | | .extern SYM(_Context_Switch_necessary) |
320 | | .extern SYM(_ISR_Signals_to_thread_executing) |
321 | 317 | SYM(_ISR_Handler): |
| 318 | .extern SYM(_Thread_Dispatch_disable_level) |
322 | 319 | /* all interrupts are disabled at this point */ |
323 | 320 | /* the following few items are pushed onto the task stack for at |
324 | 321 | most one interrupt; nested interrupts will be using the interrupt |
… |
… |
|
328 | 325 | [--sp] = p0; |
329 | 326 | [--sp] = r1; |
330 | 327 | [--sp] = r0; |
331 | | p0.h = SYM(_ISR_Nest_level); |
332 | | p0.l = SYM(_ISR_Nest_level); |
| 328 | p0.h = ISR_NEST_LEVEL; |
| 329 | p0.l = ISR_NEST_LEVEL; |
333 | 330 | r0 = [p0]; |
334 | 331 | r0 += 1; |
335 | 332 | [p0] = r0; |
… |
… |
|
337 | 334 | if !cc jump noStackSwitch; |
338 | 335 | /* setup interrupt stack */ |
339 | 336 | r0 = sp; |
340 | | p0.h = SYM(_CPU_Interrupt_stack_high); |
341 | | p0.l = SYM(_CPU_Interrupt_stack_high); |
| 337 | p0.h = INTERRUPT_STACK_HIGH; |
| 338 | p0.l = INTERRUPT_STACK_HIGH; |
342 | 339 | sp = [p0]; |
343 | 340 | [--sp] = r0; |
344 | 341 | noStackSwitch: |
… |
… |
|
452 | 449 | /* this disables interrupts again */ |
453 | 450 | reti = [sp++]; |
454 | 451 | |
455 | | p0.h = SYM(_ISR_Nest_level); |
456 | | p0.l = SYM(_ISR_Nest_level); |
| 452 | p0.h = ISR_NEST_LEVEL; |
| 453 | p0.l = ISR_NEST_LEVEL; |
457 | 454 | r0 = [p0]; |
458 | 455 | r0 += -1; |
459 | 456 | [p0] = r0; |
… |
… |
|
473 | 470 | if !cc jump noDispatch |
474 | 471 | |
475 | 472 | /* do thread dispatch if necessary */ |
476 | | p0.h = SYM(_Context_Switch_necessary); |
477 | | p0.l = SYM(_Context_Switch_necessary); |
478 | | r0 = B[p0] (Z); |
479 | | cc = r0 == 0; |
480 | | p0.h = SYM(_ISR_Signals_to_thread_executing); |
481 | | p0.l = SYM(_ISR_Signals_to_thread_executing); |
482 | | if !cc jump doDispatch |
| 473 | p0.h = DISPATCH_NEEDED; |
| 474 | p0.l = DISPATCH_NEEDED; |
483 | 475 | r0 = B[p0] (Z); |
484 | 476 | cc = r0 == 0; |
485 | 477 | if cc jump noDispatch |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/bfin/rtems/score/cpu.h,v
retrieving revision 1.19
diff -u -r1.19 cpu.h
|
|
|
544 | 544 | * XXX document implementation including references if appropriate |
545 | 545 | */ |
546 | 546 | |
547 | | /** |
548 | | * @ingroup CPUInterrupt |
549 | | * This variable points to the lowest physical address of the interrupt |
550 | | * stack. |
551 | | */ |
552 | | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
553 | | |
554 | | /** |
555 | | * @ingroup CPUInterrupt |
556 | | * This variable points to the lowest physical address of the interrupt |
557 | | * stack. |
558 | | */ |
559 | | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
560 | | |
561 | 547 | /* |
562 | 548 | * Nothing prevents the porter from declaring more CPU specific variables. |
563 | 549 | * |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/h8300/cpu_asm.S,v
retrieving revision 1.11
diff -u -r1.11 cpu_asm.S
|
|
|
18 | 18 | #include "config.h" |
19 | 19 | #endif |
20 | 20 | |
| 21 | #include <rtems/asm.h> |
| 22 | #include <rtems/score/percpu.h> |
21 | 23 | |
22 | 24 | ;.equ RUNCONTEXT_ARG, er0 |
23 | 25 | ;.equ HEIRCONTEXT_ARG, er1 |
… |
… |
|
51 | 53 | |
52 | 54 | .align 2 |
53 | 55 | |
54 | | .global __CPU_Context_switch |
| 56 | .global SYM(_CPU_Context_switch) |
55 | 57 | |
56 | | __CPU_Context_switch: |
| 58 | SYM(_CPU_Context_switch): |
57 | 59 | /* Save Context */ |
58 | 60 | #if defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) |
59 | 61 | stc.w ccr,@(0:16,er0) |
… |
… |
|
80 | 82 | |
81 | 83 | .align 2 |
82 | 84 | |
83 | | .global __CPU_Context_restore |
| 85 | .global SYM(_CPU_Context_restore) |
84 | 86 | |
85 | | __CPU_Context_restore: |
| 87 | SYM(_CPU_Context_restore): |
86 | 88 | |
87 | 89 | #if defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) |
88 | 90 | mov.l er0,er1 |
… |
… |
|
100 | 102 | |
101 | 103 | */ |
102 | 104 | .align 2 |
103 | | .global __ISR_Handler |
104 | | .extern __ISR_Nest_level |
105 | | .extern __Vector_table |
106 | | .extern __Context_switch_necessary |
| 105 | .global SYM(_ISR_Handler) |
| 106 | .extern SYM(_Vector_table) |
107 | 107 | |
108 | 108 | |
109 | | __ISR_Handler: |
| 109 | SYM(_ISR_Handler): |
110 | 110 | #if defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) |
111 | 111 | mov.l er1,@-er7 |
112 | 112 | mov.l er2,@-er7 |
… |
… |
|
118 | 118 | /* Set IRQ Stack */ |
119 | 119 | orc #0xc0,ccr |
120 | 120 | mov.l er7,er6 ; save stack pointer |
121 | | mov.l @__ISR_Nest_level,er1 |
| 121 | mov.l @ISR_NEST_LEVEL,er1 |
122 | 122 | bne nested |
123 | | mov.l @__CPU_Interrupt_stack_high,er7 |
| 123 | mov.l @INTERRUPT_STACK_HIGH,er7 |
124 | 124 | |
125 | 125 | nested: |
126 | 126 | mov.l er6,@-er7 ; save sp so pop regardless of nest level |
127 | 127 | |
128 | 128 | ;; Inc system counters |
129 | | mov.l @__ISR_Nest_level,er1 |
| 129 | mov.l @ISR_NEST_LEVEL,er1 |
130 | 130 | inc.l #1,er1 |
131 | | mov.l er1,@__ISR_Nest_level |
132 | | mov.l @__Thread_Dispatch_disable_level,er1 |
| 131 | mov.l er1,@ISR_NEST_LEVEL |
| 132 | mov.l @SYM(_Thread_Dispatch_disable_level),er1 |
133 | 133 | inc.l #1,er1 |
134 | | mov.l er1,@__Thread_Dispatch_disable_level |
| 134 | mov.l er1,@SYM(_Thread_Dispatch_disable_level) |
135 | 135 | |
136 | 136 | /* Vector to ISR */ |
137 | 137 | |
138 | | mov.l @__ISR_Vector_table,er1 |
| 138 | mov.l @SYM(_ISR_Vector_table),er1 |
139 | 139 | mov er0,er2 ; copy vector |
140 | 140 | shll.l er2 |
141 | 141 | shll.l er2 ; vector = vector * 4 (sizeof(int)) |
… |
… |
|
144 | 144 | jsr @er1 ; er0 = arg1 =vector |
145 | 145 | |
146 | 146 | orc #0xc0,ccr |
147 | | mov.l @__ISR_Nest_level,er1 |
| 147 | mov.l @ISR_NEST_LEVEL,er1 |
148 | 148 | dec.l #1,er1 |
149 | | mov.l er1,@__ISR_Nest_level |
150 | | mov.l @__Thread_Dispatch_disable_level,er1 |
| 149 | mov.l er1,@ISR_NEST_LEVEL |
| 150 | mov.l @SYM(_Thread_Dispatch_disable_level),er1 |
151 | 151 | dec.l #1,er1 |
152 | | mov.l er1,@__Thread_Dispatch_disable_level |
153 | | bne exit |
| 152 | mov.l er1,@SYM(_Thread_Dispatch_disable_level) |
| 153 | bne exit |
154 | 154 | |
155 | | mov.b @__Context_Switch_necessary,er1 |
156 | | bne bframe ; If yes then dispatch next task |
157 | | |
158 | | mov.b @__ISR_Signals_to_thread_executing,er1 |
159 | | beq exit ; If no signals waiting |
| 155 | mov.b @DISPATCH_NEEDED,er1 |
| 156 | beq exit ; If no then exit |
160 | 157 | |
161 | 158 | /* Context switch here through ISR_Dispatch */ |
162 | | |
163 | 159 | bframe: |
164 | | orc #0xc0,ccr |
| 160 | orc #0xc0,ccr |
165 | 161 | /* Pop Stack */ |
166 | | mov @er7+,er6 |
167 | | mov er6,er7 |
168 | | mov.l #0,er2 |
169 | | mov.l er2,@__ISR_Signals_to_thread_executing |
| 162 | mov @er7+,er6 |
| 163 | mov er6,er7 |
170 | 164 | |
171 | 165 | /* Set up IRQ stack frame and dispatch to _ISR_Dispatch */ |
172 | 166 | |
173 | 167 | mov.l #0xc0000000,er2 /* Disable IRQ */ |
174 | | or.l #_ISR_Dispatch,er2 |
| 168 | or.l #SYM(_ISR_Dispatch),er2 |
175 | 169 | mov.l er2,@-er7 |
176 | 170 | rte |
177 | 171 | |
… |
… |
|
200 | 194 | */ |
201 | 195 | |
202 | 196 | .align 2 |
203 | | .global _ISR_Dispatch |
| 197 | .global SYM(_ISR_Dispatch) |
204 | 198 | |
205 | | _ISR_Dispatch: |
| 199 | SYM(_ISR_Dispatch): |
206 | 200 | |
207 | 201 | #if defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) |
208 | | jsr @__Thread_Dispatch |
| 202 | jsr @SYM(_Thread_Dispatch) |
209 | 203 | mov @er7+,er6 |
210 | 204 | mov @er7+,er5 |
211 | 205 | mov @er7+,er4 |
… |
… |
|
218 | 212 | |
219 | 213 | |
220 | 214 | .align 2 |
221 | | .global __CPU_Context_save_fp |
| 215 | .global SYM(_CPU_Context_save_fp) |
222 | 216 | |
223 | | __CPU_Context_save_fp: |
| 217 | SYM(_CPU_Context_save_fp): |
224 | 218 | rts |
225 | 219 | |
226 | 220 | |
227 | 221 | .align 2 |
228 | | .global __CPU_Context_restore_fp |
| 222 | .global SYM(_CPU_Context_restore_fp) |
229 | 223 | |
230 | | __CPU_Context_restore_fp: |
| 224 | SYM(_CPU_Context_restore_fp): |
231 | 225 | rts |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/h8300/rtems/asm.h,v
retrieving revision 1.8
diff -u -r1.8 asm.h
|
|
|
37 | 37 | * Indicate we are in an assembly file and get the basic CPU definitions. |
38 | 38 | */ |
39 | 39 | |
40 | | #define ASM |
41 | 40 | #include <rtems/score/h8300.h> |
42 | 41 | |
43 | 42 | /* |
… |
… |
|
116 | 115 | #define EXTERN(sym) .globl SYM (sym) |
117 | 116 | |
118 | 117 | #endif |
119 | | |
120 | | asm( \".h8300h\" ); |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/h8300/rtems/score/cpu.h,v
retrieving revision 1.39
diff -u -r1.39 cpu.h
|
|
|
432 | 432 | SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context; |
433 | 433 | |
434 | 434 | /* |
435 | | * On some CPUs, RTEMS supports a software managed interrupt stack. |
436 | | * This stack is allocated by the Interrupt Manager and the switch |
437 | | * is performed in _ISR_Handler. These variables contain pointers |
438 | | * to the lowest and highest addresses in the chunk of memory allocated |
439 | | * for the interrupt stack. Since it is unknown whether the stack |
440 | | * grows up or down (in general), this give the CPU dependent |
441 | | * code the option of picking the version it wants to use. |
442 | | * |
443 | | * NOTE: These two variables are required if the macro |
444 | | * CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. |
445 | | * |
446 | | * H8300 Specific Information: |
447 | | * |
448 | | * XXX |
449 | | */ |
450 | | |
451 | | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
452 | | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
453 | | |
454 | | /* |
455 | 435 | * Nothing prevents the porter from declaring more CPU specific variables. |
456 | 436 | * |
457 | 437 | * H8300 Specific Information: |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/lm32/irq.c,v
retrieving revision 1.4
diff -u -r1.4 irq.c
|
|
|
19 | 19 | |
20 | 20 | #include <rtems/system.h> |
21 | 21 | #include <rtems/score/cpu.h> |
22 | | #include <rtems/score/isr.h> |
23 | 22 | #include <rtems/score/thread.h> |
| 23 | #include <rtems/score/isr.h> |
| 24 | #include <rtems/score/percpu.h> |
24 | 25 | |
25 | 26 | /* |
26 | 27 | * This routine provides the RTEMS interrupt management. |
… |
… |
|
77 | 78 | if ( _ISR_Nest_level ) |
78 | 79 | return; |
79 | 80 | |
80 | | if ( _Thread_Dispatch_disable_level ) { |
81 | | _ISR_Signals_to_thread_executing = FALSE; |
82 | | return; |
83 | | } |
84 | | |
85 | | if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) { |
86 | | _ISR_Signals_to_thread_executing = FALSE; |
| 81 | if ( _Context_Switch_necessary ) { |
87 | 82 | |
88 | 83 | /* save off our stack frame so the context switcher can get to it */ |
89 | 84 | _exception_stack_frame = ifr; |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/lm32/rtems/score/cpu.h,v
retrieving revision 1.8
diff -u -r1.8 cpu.h
|
|
|
560 | 560 | * XXX document implementation including references if appropriate |
561 | 561 | */ |
562 | 562 | |
563 | | /** |
564 | | * @ingroup CPUInterrupt |
565 | | * This variable points to the lowest physical address of the interrupt |
566 | | * stack. |
567 | | */ |
568 | | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
569 | | |
570 | | /** |
571 | | * @ingroup CPUInterrupt |
572 | | * This variable points to the lowest physical address of the interrupt |
573 | | * stack. |
574 | | */ |
575 | | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
576 | | |
577 | 563 | /* |
578 | 564 | * Nothing prevents the porter from declaring more CPU specific variables. |
579 | 565 | * |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/m32c/cpu_asm.c,v
retrieving revision 1.5
diff -u -r1.5 cpu_asm.c
|
|
|
87 | 87 | * goto the label "exit interrupt (simple case)" |
88 | 88 | * |
89 | 89 | * if ( _Thread_Dispatch_disable_level ) |
90 | | * _ISR_Signals_to_thread_executing = FALSE; |
91 | 90 | * goto the label "exit interrupt (simple case)" |
92 | 91 | * |
93 | | * if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) { |
94 | | * _ISR_Signals_to_thread_executing = FALSE; |
| 92 | * if ( _Context_Switch_necessary ) { |
95 | 93 | * call _Thread_Dispatch() or prepare to return to _ISR_Dispatch |
96 | 94 | * prepare to get out of interrupt |
97 | 95 | * return from interrupt (maybe to _ISR_Dispatch) |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/m32c/rtems/score/cpu.h,v
retrieving revision 1.7
diff -u -r1.7 cpu.h
|
|
|
522 | 522 | * XXX document implementation including references if appropriate |
523 | 523 | */ |
524 | 524 | |
525 | | /** |
526 | | * @ingroup CPUInterrupt |
527 | | * This variable points to the lowest physical address of the interrupt |
528 | | * stack. |
529 | | */ |
530 | | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
531 | | |
532 | | /** |
533 | | * @ingroup CPUInterrupt |
534 | | * This variable points to the lowest physical address of the interrupt |
535 | | * stack. |
536 | | */ |
537 | | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
538 | | |
539 | 525 | /* |
540 | 526 | * Nothing prevents the porter from declaring more CPU specific variables. |
541 | 527 | * |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/m32r/cpu_asm.c,v
retrieving revision 1.3
diff -u -r1.3 cpu_asm.c
|
|
|
77 | 77 | * goto the label "exit interrupt (simple case)" |
78 | 78 | * |
79 | 79 | * if ( _Thread_Dispatch_disable_level ) |
80 | | * _ISR_Signals_to_thread_executing = FALSE; |
81 | 80 | * goto the label "exit interrupt (simple case)" |
82 | 81 | * |
83 | | * if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) { |
84 | | * _ISR_Signals_to_thread_executing = FALSE; |
| 82 | * if ( _Context_Switch_necessary ) { |
85 | 83 | * call _Thread_Dispatch() or prepare to return to _ISR_Dispatch |
86 | 84 | * prepare to get out of interrupt |
87 | 85 | * return from interrupt (maybe to _ISR_Dispatch) |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/m32r/rtems/score/cpu.h,v
retrieving revision 1.4
diff -u -r1.4 cpu.h
|
|
|
555 | 555 | * XXX document implementation including references if appropriate |
556 | 556 | */ |
557 | 557 | |
558 | | /** |
559 | | * @ingroup CPUInterrupt |
560 | | * This variable points to the lowest physical address of the interrupt |
561 | | * stack. |
562 | | */ |
563 | | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
564 | | |
565 | | /** |
566 | | * @ingroup CPUInterrupt |
567 | | * This variable points to the lowest physical address of the interrupt |
568 | | * stack. |
569 | | */ |
570 | | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
571 | | |
572 | 558 | /* |
573 | 559 | * Nothing prevents the porter from declaring more CPU specific variables. |
574 | 560 | * |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/m68k/cpu_asm.S,v
retrieving revision 1.18
diff -u -r1.18 cpu_asm.S
|
|
|
19 | 19 | #endif |
20 | 20 | |
21 | 21 | #include <rtems/asm.h> |
| 22 | #include <rtems/score/percpu.h> |
22 | 23 | |
23 | 24 | /* void _CPU_Context_switch( run_context, heir_context ) |
24 | 25 | * |
… |
… |
|
263 | 264 | |
264 | 265 | #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == 1 ) |
265 | 266 | | Make a0 point just above interrupt stack |
266 | | movel _CPU_Interrupt_stack_high,a0 |
267 | | cmpl _CPU_Interrupt_stack_low,a7 | stack below interrupt stack? |
| 267 | movel INTERRUPT_STACK_HIGH,a0 |
| 268 | cmpl INTERRUPT_STACK_LOW,a7 | stack below interrupt stack? |
268 | 269 | bcs.b 1f | yes, switch to interrupt stack |
269 | 270 | cmpl a0,a7 | stack above interrupt stack? |
270 | 271 | bcs.b 2f | no, do not switch stacks |
… |
… |
|
276 | 277 | 2: |
277 | 278 | #endif /* CPU_HAS_SOFTWARE_INTERRUPT_STACK == 1 */ |
278 | 279 | |
279 | | addql #1,SYM(_ISR_Nest_level) | one nest level deeper |
| 280 | addql #1,ISR_NEST_LEVEL | one nest level deeper |
280 | 281 | |
281 | 282 | movel SYM (_ISR_Vector_table),a0 | a0= base of RTEMS table |
282 | 283 | #if ( M68K_HAS_PREINDEXING == 1 ) |
… |
… |
|
290 | 291 | movel d0,a7@- | push vector number |
291 | 292 | jbsr a0@ | invoke the user ISR |
292 | 293 | addql #4,a7 | remove vector number |
293 | | subql #1,SYM(_ISR_Nest_level) | Reduce interrupt-nesting count |
| 294 | subql #1,ISR_NEST_LEVEL | Reduce interrupt-nesting count |
294 | 295 | |
295 | 296 | #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == 1 ) |
296 | | movel _CPU_Interrupt_stack_high,a0 |
| 297 | movel INTERRUPT_STACK_HIGH,a0 |
297 | 298 | subql #4,a0 |
298 | 299 | cmpl a0,a7 | At top of interrupt stack? |
299 | 300 | bne.b 1f | No, do not restore task stack pointer |
… |
… |
|
322 | 323 | beq.b exit |
323 | 324 | #endif |
324 | 325 | #endif |
325 | | tstb SYM (_Context_Switch_necessary) |
| 326 | tstb DISPATCH_NEEDED |
326 | 327 | | Is thread switch necessary? |
327 | | bne.b bframe | Yes, invoke dispatcher |
328 | | |
329 | | tstb SYM (_ISR_Signals_to_thread_executing) |
330 | | | signals sent to Run_thread |
331 | | | while in interrupt handler? |
332 | 328 | beq.b exit | No, then exit |
333 | 329 | |
334 | | bframe: clrb SYM (_ISR_Signals_to_thread_executing) |
| 330 | bframe: |
335 | 331 | | If sent, will be processed |
336 | 332 | #if ( M68K_HAS_SEPARATE_STACKS == 1 ) |
337 | 333 | movec msp,a0 | a0 = master stack pointer |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/m68k/rtems/score/cpu.h,v
retrieving revision 1.42
diff -u -r1.42 cpu.h
|
|
|
308 | 308 | |
309 | 309 | /* variables */ |
310 | 310 | |
311 | | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
312 | | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
313 | | |
314 | 311 | extern void* _VBR; |
315 | 312 | |
316 | 313 | #if ( M68K_HAS_VBR == 0 ) |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/mips/cpu_asm.S,v
retrieving revision 1.41
diff -u -r1.41 cpu_asm.S
|
|
|
57 | 57 | #include <rtems/asm.h> |
58 | 58 | #include <rtems/mips/iregdef.h> |
59 | 59 | #include <rtems/mips/idtcpu.h> |
| 60 | #include <rtems/score/percpu.h> |
60 | 61 | |
61 | 62 | #define ASSEMBLY_ONLY |
62 | 63 | #include <rtems/score/cpu.h> |
… |
… |
|
201 | 202 | |
202 | 203 | ASM_EXTERN(__exceptionStackFrame, SZ_INT) |
203 | 204 | |
204 | | |
205 | | |
206 | 205 | /* |
207 | 206 | * _CPU_Context_save_fp_context |
208 | 207 | * |
… |
… |
|
585 | 584 | |
586 | 585 | ENDFRAME(_CPU_Context_restore) |
587 | 586 | |
588 | | |
589 | | ASM_EXTERN(_ISR_Nest_level,4) |
590 | 587 | ASM_EXTERN(_Thread_Dispatch_disable_level,4) |
591 | | ASM_EXTERN(_Context_Switch_necessary,1) |
592 | | ASM_EXTERN(_ISR_Signals_to_thread_executing,1) |
593 | 588 | ASM_EXTERN(_Thread_Executing,4) |
594 | 589 | |
595 | 590 | .extern _Thread_Dispatch |
596 | 591 | .extern _ISR_Vector_table |
597 | 592 | |
598 | | |
599 | | |
600 | | |
601 | | |
602 | 593 | /* void _DBG_Handler() |
603 | 594 | * |
604 | 595 | * This routine services the (at least) MIPS1 debug vector, |
… |
… |
|
606 | 597 | * while optional, is best located here because its intrinsically |
607 | 598 | * associated with exceptions in general & thus tied pretty |
608 | 599 | * closely to _ISR_Handler. |
609 | | * |
610 | 600 | */ |
611 | | |
612 | | |
613 | 601 | FRAME(_DBG_Handler,sp,0,ra) |
614 | 602 | .set noreorder |
615 | 603 | la k0,_ISR_Handler |
… |
… |
|
618 | 606 | .set reorder |
619 | 607 | ENDFRAME(_DBG_Handler) |
620 | 608 | |
621 | | |
622 | | |
623 | | |
624 | | |
625 | 609 | /* void __ISR_Handler() |
626 | 610 | * |
627 | 611 | * This routine provides the RTEMS interrupt management. |
… |
… |
|
693 | 677 | |
694 | 678 | |
695 | 679 | #ifdef INSTRUMENT_EXECUTING_THREAD |
696 | | lw t2, _Thread_Executing |
| 680 | lw t2, THREAD_EXECUTING |
697 | 681 | NOP |
698 | 682 | sw t2, 0x8001FFF0 |
699 | 683 | #endif |
… |
… |
|
904 | 888 | /* |
905 | 889 | * _ISR_Nest_level++; |
906 | 890 | */ |
907 | | lw t0,_ISR_Nest_level |
| 891 | lw t0,ISR_NEST_LEVEL |
908 | 892 | NOP |
909 | 893 | add t0,t0,1 |
910 | | sw t0,_ISR_Nest_level |
| 894 | sw t0,ISR_NEST_LEVEL |
911 | 895 | /* |
912 | 896 | * _Thread_Dispatch_disable_level++; |
913 | 897 | */ |
… |
… |
|
940 | 924 | /* |
941 | 925 | * --_ISR_Nest_level; |
942 | 926 | */ |
943 | | lw t2,_ISR_Nest_level |
| 927 | lw t2,ISR_NEST_LEVEL |
944 | 928 | NOP |
945 | 929 | add t2,t2,-1 |
946 | | sw t2,_ISR_Nest_level |
| 930 | sw t2,ISR_NEST_LEVEL |
947 | 931 | /* |
948 | 932 | * --_Thread_Dispatch_disable_level; |
949 | 933 | */ |
… |
… |
|
965 | 949 | * restore stack |
966 | 950 | * #endif |
967 | 951 | * |
968 | | * if ( !_Context_Switch_necessary && !_ISR_Signals_to_thread_executing ) |
| 952 | * if !_Context_Switch_necessary |
969 | 953 | * goto the label "exit interrupt (simple case)" |
970 | 954 | */ |
971 | | lbu t0,_Context_Switch_necessary |
972 | | lbu t1,_ISR_Signals_to_thread_executing |
| 955 | lbu t0,DISPATCH_NEEDED |
973 | 956 | NOP |
974 | | or t0,t0,t1 |
| 957 | or t0,t0,t0 |
975 | 958 | beq t0,zero,_ISR_Handler_exit |
976 | 959 | NOP |
977 | 960 | |
978 | 961 | |
979 | 962 | |
980 | 963 | #ifdef INSTRUMENT_EXECUTING_THREAD |
981 | | lw t0,_Thread_Executing |
| 964 | lw t0,THREAD_EXECUTING |
982 | 965 | NOP |
983 | 966 | sw t0,0x8001FFF4 |
984 | 967 | #endif |
… |
… |
|
1068 | 1051 | |
1069 | 1052 | |
1070 | 1053 | #ifdef INSTRUMENT_EXECUTING_THREAD |
1071 | | lw t0,_Thread_Executing |
| 1054 | lw t0,THREAD_EXECUTING |
1072 | 1055 | NOP |
1073 | 1056 | sw t0,0x8001FFF8 |
1074 | 1057 | #endif |
… |
… |
|
1093 | 1076 | /* restore context from stack */ |
1094 | 1077 | |
1095 | 1078 | #ifdef INSTRUMENT_EXECUTING_THREAD |
1096 | | lw t0,_Thread_Executing |
| 1079 | lw t0,THREAD_EXECUTING |
1097 | 1080 | NOP |
1098 | 1081 | sw t0, 0x8001FFFC |
1099 | 1082 | #endif |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/mips/rtems/score/cpu.h,v
retrieving revision 1.56
diff -u -r1.56 cpu.h
|
|
|
617 | 617 | SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context; |
618 | 618 | |
619 | 619 | /* |
620 | | * On some CPUs, RTEMS supports a software managed interrupt stack. |
621 | | * This stack is allocated by the Interrupt Manager and the switch |
622 | | * is performed in _ISR_Handler. These variables contain pointers |
623 | | * to the lowest and highest addresses in the chunk of memory allocated |
624 | | * for the interrupt stack. Since it is unknown whether the stack |
625 | | * grows up or down (in general), this give the CPU dependent |
626 | | * code the option of picking the version it wants to use. |
627 | | * |
628 | | * NOTE: These two variables are required if the macro |
629 | | * CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. |
630 | | */ |
631 | | |
632 | | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
633 | | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
634 | | |
635 | | /* |
636 | 620 | * Nothing prevents the porter from declaring more CPU specific variables. |
637 | 621 | */ |
638 | 622 | |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/nios2/irq.c,v
retrieving revision 1.5
diff -u -r1.5 irq.c
|
|
|
64 | 64 | |
65 | 65 | _ISR_Nest_level--; |
66 | 66 | |
67 | | if( _ISR_Nest_level == 0) |
68 | | { |
| 67 | if( _ISR_Nest_level == 0) { |
69 | 68 | #if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) |
70 | 69 | stack_ptr = _old_stack_ptr; |
71 | 70 | #endif |
72 | 71 | |
73 | 72 | if( _Thread_Dispatch_disable_level == 0 ) |
74 | 73 | { |
75 | | if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) |
76 | | { |
77 | | _ISR_Signals_to_thread_executing = FALSE; |
| 74 | if ( _Context_Switch_necessary ) { |
78 | 75 | _CPU_ISR_Enable( level ); |
79 | 76 | _Thread_Dispatch(); |
80 | 77 | /* may have switched to another task and not return here immed. */ |
81 | 78 | _CPU_ISR_Disable( level ); /* Keep _pairs_ of Enable/Disable */ |
82 | 79 | } |
83 | 80 | } |
84 | | else |
85 | | { |
86 | | _ISR_Signals_to_thread_executing = FALSE; |
87 | | }; |
88 | | }; |
| 81 | } |
89 | 82 | |
90 | 83 | _CPU_ISR_Enable( level ); |
91 | 84 | } |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/nios2/rtems/score/cpu.h,v
retrieving revision 1.13
diff -u -r1.13 cpu.h
|
|
|
590 | 590 | * XXX document implementation including references if appropriate |
591 | 591 | */ |
592 | 592 | |
593 | | /** |
594 | | * @ingroup CPUInterrupt |
595 | | * This variable points to the lowest physical address of the interrupt |
596 | | * stack. |
597 | | */ |
598 | | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
599 | | |
600 | | /** |
601 | | * @ingroup CPUInterrupt |
602 | | * This variable points to the lowest physical address of the interrupt |
603 | | * stack. |
604 | | */ |
605 | | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
606 | | |
607 | 593 | /* |
608 | 594 | * Nothing prevents the porter from declaring more CPU specific variables. |
609 | 595 | * |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/no_cpu/cpu_asm.c,v
retrieving revision 1.18
diff -u -r1.18 cpu_asm.c
|
|
|
166 | 166 | * goto the label "exit interrupt (simple case)" |
167 | 167 | * |
168 | 168 | * if ( _Thread_Dispatch_disable_level ) |
169 | | * _ISR_Signals_to_thread_executing = FALSE; |
170 | 169 | * goto the label "exit interrupt (simple case)" |
171 | 170 | * |
172 | | * if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) { |
173 | | * _ISR_Signals_to_thread_executing = FALSE; |
| 171 | * if ( _Context_Switch_necessary ) { |
174 | 172 | * call _Thread_Dispatch() or prepare to return to _ISR_Dispatch |
175 | 173 | * prepare to get out of interrupt |
176 | 174 | * return from interrupt (maybe to _ISR_Dispatch) |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/no_cpu/rtems/score/cpu.h,v
retrieving revision 1.31
diff -u -r1.31 cpu.h
|
|
|
548 | 548 | * XXX document implementation including references if appropriate |
549 | 549 | */ |
550 | 550 | |
551 | | /** |
552 | | * @ingroup CPUInterrupt |
553 | | * This variable points to the lowest physical address of the interrupt |
554 | | * stack. |
555 | | */ |
556 | | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
557 | | |
558 | | /** |
559 | | * @ingroup CPUInterrupt |
560 | | * This variable points to the lowest physical address of the interrupt |
561 | | * stack. |
562 | | */ |
563 | | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
564 | | |
565 | 551 | /* |
566 | 552 | * Nothing prevents the porter from declaring more CPU specific variables. |
567 | 553 | * |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/powerpc/rtems/new-exceptions/cpu.h,v
retrieving revision 1.38
diff -u -r1.38 cpu.h
|
|
|
163 | 163 | |
164 | 164 | /* EXTERN Context_Control_fp _CPU_Null_fp_context; */ |
165 | 165 | |
166 | | /* |
167 | | * On some CPUs, RTEMS supports a software managed interrupt stack. |
168 | | * This stack is allocated by the Interrupt Manager and the switch |
169 | | * is performed in _ISR_Handler. These variables contain pointers |
170 | | * to the lowest and highest addresses in the chunk of memory allocated |
171 | | * for the interrupt stack. Since it is unknown whether the stack |
172 | | * grows up or down (in general), this give the CPU dependent |
173 | | * code the option of picking the version it wants to use. |
174 | | * |
175 | | * NOTE: These two variables are required if the macro |
176 | | * CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. |
177 | | */ |
178 | | |
179 | | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
180 | | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
181 | | |
182 | 166 | #endif /* ndef ASM */ |
183 | 167 | |
184 | 168 | /* |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/sh/rtems/score/cpu.h,v
retrieving revision 1.31
diff -u -r1.31 cpu.h
|
|
|
413 | 413 | #endif |
414 | 414 | |
415 | 415 | /* |
416 | | * On some CPUs, RTEMS supports a software managed interrupt stack. |
417 | | * This stack is allocated by the Interrupt Manager and the switch |
418 | | * is performed in _ISR_Handler. These variables contain pointers |
419 | | * to the lowest and highest addresses in the chunk of memory allocated |
420 | | * for the interrupt stack. Since it is unknown whether the stack |
421 | | * grows up or down (in general), this give the CPU dependent |
422 | | * code the option of picking the version it wants to use. |
423 | | * |
424 | | * NOTE: These two variables are required if the macro |
425 | | * CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. |
426 | | */ |
427 | | |
428 | | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
429 | | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
430 | | |
431 | | /* |
432 | 416 | * Nothing prevents the porter from declaring more CPU specific variables. |
433 | 417 | */ |
434 | 418 | |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/sparc/cpu_asm.S,v
retrieving revision 1.17
diff -u -r1.17 cpu_asm.S
|
|
|
4 | 4 | * in an specific CPU port of RTEMS. These algorithms must be implemented |
5 | 5 | * in assembly language. |
6 | 6 | * |
7 | | * COPYRIGHT (c) 1989-2007. |
| 7 | * COPYRIGHT (c) 1989-2010. |
8 | 8 | * On-Line Applications Research Corporation (OAR). |
9 | 9 | * |
10 | 10 | * The license and distribution terms for this file may be |
… |
… |
|
26 | 26 | #endif |
27 | 27 | |
28 | 28 | #include <rtems/asm.h> |
| 29 | #include <rtems/system.h> |
29 | 30 | |
30 | 31 | #if (SPARC_HAS_FPU == 1) |
31 | 32 | |
… |
… |
|
471 | 472 | * Register usage for this section: |
472 | 473 | * |
473 | 474 | * l4 = _Thread_Dispatch_disable_level pointer |
474 | | * l5 = _ISR_Nest_level pointer |
| 475 | * l5 = per cpu info pointer |
475 | 476 | * l6 = _Thread_Dispatch_disable_level value |
476 | 477 | * l7 = _ISR_Nest_level value |
477 | 478 | * |
… |
… |
|
481 | 482 | |
482 | 483 | sethi %hi(SYM(_Thread_Dispatch_disable_level)), %l4 |
483 | 484 | ld [%l4 + %lo(SYM(_Thread_Dispatch_disable_level))], %l6 |
484 | | sethi %hi(SYM(_ISR_Nest_level)), %l5 |
485 | | ld [%l5 + %lo(SYM(_ISR_Nest_level))], %l7 |
| 485 | |
| 486 | sethi %hi(_Per_CPU_Information), %l5 |
| 487 | add %l5, %lo(_Per_CPU_Information), %l5 |
| 488 | |
| 489 | ld [%l5 + PER_CPU_ISR_NEST_LEVEL], %l7 |
486 | 490 | |
487 | 491 | add %l6, 1, %l6 |
488 | 492 | st %l6, [%l4 + %lo(SYM(_Thread_Dispatch_disable_level))] |
489 | 493 | |
490 | 494 | add %l7, 1, %l7 |
491 | | st %l7, [%l5 + %lo(SYM(_ISR_Nest_level))] |
| 495 | st %l7, [%l5 + PER_CPU_ISR_NEST_LEVEL] |
492 | 496 | |
493 | 497 | /* |
494 | 498 | * If ISR nest level was zero (now 1), then switch stack. |
… |
… |
|
498 | 502 | subcc %l7, 1, %l7 ! outermost interrupt handler? |
499 | 503 | bnz dont_switch_stacks ! No, then do not switch stacks |
500 | 504 | |
501 | | sethi %hi(SYM(_CPU_Interrupt_stack_high)), %g4 |
502 | | ld [%g4 + %lo(SYM(_CPU_Interrupt_stack_high))], %sp |
| 505 | nop |
| 506 | ld [%l5 + PER_CPU_INTERRUPT_STACK_HIGH], %sp |
503 | 507 | |
504 | 508 | dont_switch_stacks: |
505 | 509 | /* |
… |
… |
|
644 | 648 | sub %l6, 1, %l6 |
645 | 649 | st %l6, [%l4 + %lo(SYM(_Thread_Dispatch_disable_level))] |
646 | 650 | |
647 | | st %l7, [%l5 + %lo(SYM(_ISR_Nest_level))] |
| 651 | st %l7, [%l5 + PER_CPU_ISR_NEST_LEVEL] |
648 | 652 | |
649 | 653 | /* |
650 | 654 | * If dispatching is disabled (includes nested interrupt case), |
… |
… |
|
660 | 664 | ld [%l6 + %lo(SYM(_CPU_ISR_Dispatch_disable))], %l7 |
661 | 665 | orcc %l7, %g0, %g0 ! Is this thread already doing an ISR? |
662 | 666 | bnz simple_return ! Yes, then do a "simple" exit |
663 | | ! NOTE: Use the delay slot |
664 | | sethi %hi(SYM(_Context_Switch_necessary)), %l4 |
| 667 | nop |
665 | 668 | |
666 | 669 | |
667 | 670 | /* |
… |
… |
|
669 | 672 | * return to the interrupt dispatcher. |
670 | 673 | */ |
671 | 674 | |
672 | | ldub [%l4 + %lo(SYM(_Context_Switch_necessary))], %l5 |
| 675 | ldub [%l5 + PER_CPU_DISPATCH_NEEDED], %l5 |
673 | 676 | |
674 | 677 | orcc %l5, %g0, %g0 ! Is thread switch necessary? |
675 | | bnz SYM(_ISR_Dispatch) ! yes, then invoke the dispatcher |
676 | | ! NOTE: Use the delay slot |
677 | | sethi %hi(SYM(_ISR_Signals_to_thread_executing)), %l6 |
678 | | |
679 | | /* |
680 | | * Finally, check to see if signals were sent to the currently |
681 | | * executing task. If so, we need to invoke the interrupt dispatcher. |
682 | | */ |
683 | | |
684 | | ldub [%l6 + %lo(SYM(_ISR_Signals_to_thread_executing))], %l7 |
685 | | |
686 | | orcc %l7, %g0, %g0 ! Were signals sent to the currently |
687 | | ! executing thread? |
688 | | bz simple_return ! yes, then invoke the dispatcher |
689 | | ! use the delay slot to clear the signals |
690 | | ! to the currently executing task flag |
691 | | st %g0, [%l6 + %lo(SYM(_ISR_Signals_to_thread_executing))] |
692 | | |
| 678 | bz simple_return ! no, then do a simple return |
| 679 | nop |
693 | 680 | |
694 | 681 | /* |
695 | 682 | * Invoke interrupt dispatcher. |
… |
… |
|
737 | 724 | * _Thread_Dispatch before leaving this ISR Dispatch context. |
738 | 725 | */ |
739 | 726 | |
740 | | sethi %hi(SYM(_Context_Switch_necessary)), %l4 |
741 | | ldub [%l4 + %lo(SYM(_Context_Switch_necessary))], %l5 |
742 | | |
743 | | ! NOTE: Use some of delay slot to start loading this |
744 | | sethi %hi(SYM(_ISR_Signals_to_thread_executing)), %l6 |
745 | | ldub [%l6 + %lo(SYM(_ISR_Signals_to_thread_executing))], %l7 |
| 727 | sethi %hi(_Per_CPU_Information), %l5 |
| 728 | add %l5, %lo(_Per_CPU_Information), %l5 |
746 | 729 | |
747 | | orcc %l5, %g0, %g0 ! Is thread switch necessary? |
748 | | bnz dispatchAgain ! yes, then invoke the dispatcher AGAIN |
749 | | ! NOTE: Use the delay slot to catch the orcc below |
| 730 | ldub [%l5 + PER_CPU_DISPATCH_NEEDED], %l7 |
750 | 731 | |
751 | | /* |
752 | | * Finally, check to see if signals were sent to the currently |
753 | | * executing task. If so, we need to invoke the interrupt dispatcher. |
754 | | */ |
755 | | |
756 | | ! NOTE: Delay slots above were used to perform the load AND |
757 | | ! this orcc falls into the delay slot for bnz above |
758 | | orcc %l7, %g0, %g0 ! Were signals sent to the currently |
759 | | ! executing thread? |
| 732 | orcc %l7, %g0, %g0 ! Is thread switch necesary? |
760 | 733 | bz allow_nest_again ! No, then clear out and return |
761 | | ! NOTE: use the delay slot from the bz to load 3 into %g1 |
| 734 | nop |
762 | 735 | |
763 | 736 | ! Yes, then invoke the dispatcher |
764 | 737 | dispatchAgain: |
-
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/sparc/rtems/score/cpu.h,v
retrieving revision 1.35
diff -u -r1.35 cpu.h
|
|
|
523 | 523 | SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context CPU_STRUCTURE_ALIGNMENT; |
524 | 524 | |
525 | 525 | /* |
526 | | * This stack is allocated by the Interrupt Manager and the switch |
527 | | * is performed in _ISR_Handler. These variables contain pointers |
528 | | * to the lowest and highest addresses in the chunk of memory allocated |
529 | | * for the interrupt stack. Since it is unknown whether the stack |
530 | | * grows up or down (in general), this give the CPU dependent |
531 | | * code the option of picking the version it wants to use. Thus |
532 | | * both must be present if either is. |
533 | | * |
534 | | * The SPARC supports a software based interrupt stack and these |
535 | | * are required. |
536 | | */ |
537 | | |
538 | | SCORE_EXTERN void *_CPU_Interrupt_stack_low; |
539 | | SCORE_EXTERN void *_CPU_Interrupt_stack_high; |
540 | | |
541 | | /* |
542 | 526 | * This flag is context switched with each thread. It indicates |
543 | 527 | * that THIS thread has an _ISR_Dispatch stack frame on its stack. |
544 | 528 | * By using this flag, we can avoid nesting more interrupt dispatching |
… |
… |
|
965 | 949 | Context_Control_fp **fp_context_ptr |
966 | 950 | ); |
967 | 951 | |
| 952 | |
968 | 953 | /* |
969 | 954 | * CPU_swap_u32 |
970 | 955 | * |
-
RCS file: /usr1/CVS/rtems/cpukit/score/include/rtems/system.h,v
retrieving revision 1.64
diff -u -r1.64 system.h
|
|
|
169 | 169 | #include <stdint.h> |
170 | 170 | #endif |
171 | 171 | #include <rtems/score/cpu.h> /* processor specific information */ |
| 172 | #include <rtems/score/percpu.h> |
172 | 173 | |
173 | 174 | #ifndef ASM |
174 | 175 | /** |
-
RCS file: /usr1/CVS/rtems/cpukit/score/include/rtems/score/context.h,v
retrieving revision 1.21
diff -u -r1.21 context.h
|
|
|
23 | 23 | * |
24 | 24 | * This handler encapsulates functionality which abstracts thread context |
25 | 25 | * management in a portable manner. |
| 26 | * |
| 27 | * The context switch needed variable is contained in the per cpu |
| 28 | * data structure. |
26 | 29 | */ |
27 | 30 | /**@{*/ |
28 | 31 | |
… |
… |
|
41 | 44 | #define CONTEXT_FP_SIZE CPU_CONTEXT_FP_SIZE |
42 | 45 | |
43 | 46 | /** |
44 | | * @brief Is Context Switch Needed? |
45 | | * |
46 | | * This variable is set to true when a reschedule operation |
47 | | * has determined that the processor should be taken away from the |
48 | | * currently executing thread and given to the heir thread. |
49 | | */ |
50 | | |
51 | | SCORE_EXTERN volatile bool _Context_Switch_necessary; |
52 | | |
53 | | /** |
54 | 47 | * @brief Initialize Context Area |
55 | 48 | * This routine initializes @a _the_context such that the stack |
56 | 49 | * pointer, interrupt level, and entry point are correct for the |
-
RCS file: /usr1/CVS/rtems/cpukit/score/include/rtems/score/isr.h,v
retrieving revision 1.31
diff -u -r1.31 isr.h
|
|
|
21 | 21 | #ifndef _RTEMS_SCORE_ISR_H |
22 | 22 | #define _RTEMS_SCORE_ISR_H |
23 | 23 | |
| 24 | #include <rtems/score/percpu.h> |
| 25 | |
24 | 26 | /** |
25 | 27 | * @defgroup ScoreISR ISR Handler |
26 | 28 | * |
27 | 29 | * This handler encapsulates functionality which provides the foundation |
28 | 30 | * ISR services used in all of the APIs supported by RTEMS. |
| 31 | * |
| 32 | * The ISR Nest level counter variable is maintained as part of the |
| 33 | * per cpu data structure. |
29 | 34 | */ |
30 | 35 | /**@{*/ |
31 | 36 | |
… |
… |
|
75 | 80 | */ |
76 | 81 | #define ISR_INTERRUPT_MAXIMUM_VECTOR_NUMBER CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER |
77 | 82 | |
78 | | /** |
79 | | * The following is true if signals have been sent to the currently |
80 | | * executing thread by an ISR handler. |
81 | | */ |
82 | | SCORE_EXTERN bool _ISR_Signals_to_thread_executing; |
83 | | |
84 | | /** |
85 | | * The following contains the interrupt service routine nest level. |
86 | | * When this variable is zero, a thread is executing. |
87 | | */ |
88 | | SCORE_EXTERN volatile uint32_t _ISR_Nest_level; |
89 | | |
90 | 83 | #if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE) |
91 | 84 | /** |
92 | 85 | * The following declares the Vector Table. Application |
-
RCS file: cpukit/score/include/rtems/score/percpu.h
diff -N cpukit/score/include/rtems/score/percpu.h
-
|
+
|
|
| 1 | /** |
| 2 | * @file rtems/score/percpu.h |
| 3 | * |
| 4 | * This include file defines the per CPU information required |
| 5 | * by RTEMS. |
| 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * COPYRIGHT (c) 1989-2010. |
| 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: percpu.h,v 1.1 2010/05/12 15:09:32 joel Exp $ |
| 17 | */ |
| 18 | |
| 19 | #ifndef _RTEMS_PERCPU_H |
| 20 | #define _RTEMS_PERCPU_H |
| 21 | |
| 22 | #ifdef ASM |
| 23 | #include <rtems/asm.h> |
| 24 | #endif |
| 25 | |
| 26 | /** |
| 27 | * @defgroup PerCPU RTEMS Per CPU Information |
| 28 | * |
| 29 | * This defines the per CPU state information required by RTEMS |
| 30 | * and the BSP. In an SMP configuration, there will be multiple |
| 31 | * instances of this data structure -- one per CPU -- and the |
| 32 | * current CPU number will be used as the index. |
| 33 | */ |
| 34 | |
| 35 | /**@{*/ |
| 36 | |
| 37 | #ifdef __cplusplus |
| 38 | extern "C" { |
| 39 | #endif |
| 40 | |
| 41 | #ifndef ASM |
| 42 | |
| 43 | /** |
| 44 | * This forward defines the Thread Control Block structure. |
| 45 | */ |
| 46 | typedef struct Thread_Control_struct Thread_Control; |
| 47 | |
| 48 | /** |
| 49 | * @brief Per CPU Core Structure |
| 50 | * |
| 51 | * This structure is used to hold per core state information. |
| 52 | */ |
| 53 | typedef struct { |
| 54 | #if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE) || \ |
| 55 | (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) |
| 56 | /** |
| 57 | * This contains a pointer to the lower range of the interrupt stack for |
| 58 | * this CPU. This is the address allocated and freed. |
| 59 | */ |
| 60 | void *interrupt_stack_low; |
| 61 | |
| 62 | /** |
| 63 | * This contains a pointer to the interrupt stack pointer for this CPU. |
| 64 | * It will be loaded at the beginning on an ISR. |
| 65 | */ |
| 66 | void *interrupt_stack_high; |
| 67 | #endif |
| 68 | |
| 69 | /** |
| 70 | * |
| 71 | * This contains the current interrupt nesting level on this |
| 72 | * CPU. |
| 73 | */ |
| 74 | uint32_t isr_nest_level; |
| 75 | |
| 76 | /** This is the thread executing on this CPU. */ |
| 77 | Thread_Control *executing; |
| 78 | |
| 79 | /** This is the heir thread for this this CPU. */ |
| 80 | Thread_Control *heir; |
| 81 | |
| 82 | /** This is the idle thread for this CPU. */ |
| 83 | Thread_Control *idle; |
| 84 | |
| 85 | /** This is set to true when this CPU needs to run the dispatcher. */ |
| 86 | volatile bool dispatch_needed; |
| 87 | |
| 88 | } Per_CPU_Control; |
| 89 | #endif |
| 90 | |
| 91 | #ifdef ASM |
| 92 | |
| 93 | #if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE) || \ |
| 94 | (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) |
| 95 | /* |
| 96 | * If this CPU target lets RTEMS allocates the interrupt stack, then |
| 97 | * we need to have places in the per cpu table to hold them. |
| 98 | */ |
| 99 | #define PER_CPU_INTERRUPT_STACK_LOW 0 |
| 100 | #define PER_CPU_INTERRUPT_STACK_HIGH (1 * SIZEOF_VOID_P) |
| 101 | #define PER_CPU_END_STACK (2 * SIZEOF_VOID_P) |
| 102 | #else |
| 103 | /* |
| 104 | * Otherwise, there are no interrupt stack addresses in the per CPU table. |
| 105 | */ |
| 106 | #define PER_CPU_END_STACK 0 |
| 107 | #endif |
| 108 | |
| 109 | /* |
| 110 | * These are the offsets of the required elements in the per CPU table. |
| 111 | */ |
| 112 | #define PER_CPU_ISR_NEST_LEVEL PER_CPU_END_STACK + 0 |
| 113 | #define PER_CPU_EXECUTING PER_CPU_END_STACK + (1 * SIZEOF_VOID_P) |
| 114 | #define PER_CPU_HEIR PER_CPU_END_STACK + (2 * SIZEOF_VOID_P) |
| 115 | #define PER_CPU_IDLE PER_CPU_END_STACK + (3 * SIZEOF_VOID_P) |
| 116 | #define PER_CPU_DISPATCH_NEEDED PER_CPU_END_STACK + (4 * SIZEOF_VOID_P) |
| 117 | #define ISR_NEST_LEVEL \ |
| 118 | (SYM(_Per_CPU_Information) + PER_CPU_ISR_NEST_LEVEL) |
| 119 | #define DISPATCH_NEEDED \ |
| 120 | (SYM(_Per_CPU_Information) + PER_CPU_DISPATCH_NEEDED) |
| 121 | |
| 122 | /* |
| 123 | * Do not define these offsets if they are not in the table. |
| 124 | */ |
| 125 | #if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE) || \ |
| 126 | (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) |
| 127 | #define INTERRUPT_STACK_LOW \ |
| 128 | (SYM(_Per_CPU_Information) + PER_CPU_INTERRUPT_STACK_LOW) |
| 129 | #define INTERRUPT_STACK_HIGH \ |
| 130 | (SYM(_Per_CPU_Information) + PER_CPU_INTERRUPT_STACK_HIGH) |
| 131 | #endif |
| 132 | |
| 133 | #endif |
| 134 | |
| 135 | #ifndef ASM |
| 136 | |
| 137 | /** |
| 138 | * @brief Set of Per CPU Core Information |
| 139 | * |
| 140 | * This is an array of per CPU core information. |
| 141 | */ |
| 142 | extern Per_CPU_Control _Per_CPU_Information; |
| 143 | |
| 144 | /* |
| 145 | * On an SMP system, these macros dereference the CPU core number. |
| 146 | * But on a non-SMP system, these macros are simple references. |
| 147 | * Thus when built for non-SMP, there should be no performance penalty. |
| 148 | */ |
| 149 | #define _Thread_Heir _Per_CPU_Information.heir |
| 150 | #define _Thread_Executing _Per_CPU_Information.executing |
| 151 | #define _Thread_Idle _Per_CPU_Information.idle |
| 152 | #define _ISR_Nest_level _Per_CPU_Information.isr_nest_level |
| 153 | #define _CPU_Interrupt_stack_low _Per_CPU_Information.interrupt_stack_low |
| 154 | #define _CPU_Interrupt_stack_high _Per_CPU_Information.interrupt_stack_high |
| 155 | #define _Context_Switch_necessary _Per_CPU_Information.dispatch_needed |
| 156 | |
| 157 | #endif /* ASM */ |
| 158 | |
| 159 | #ifdef __cplusplus |
| 160 | } |
| 161 | #endif |
| 162 | |
| 163 | /**@}*/ |
| 164 | |
| 165 | #endif |
| 166 | /* end of include file */ |
-
RCS file: /usr1/CVS/rtems/cpukit/score/include/rtems/score/thread.h,v
retrieving revision 1.93
diff -u -r1.93 thread.h
|
|
|
24 | 24 | * |
25 | 25 | * This handler encapsulates functionality related to the management of |
26 | 26 | * threads. This includes the creation, deletion, and scheduling of threads. |
| 27 | * |
| 28 | * The following variables are maintained as part of the per cpu data |
| 29 | * structure. |
| 30 | * |
| 31 | * + Idle thread pointer |
| 32 | * + Executing thread pointer |
| 33 | * + Heir thread pointer |
27 | 34 | */ |
28 | 35 | /**@{*/ |
29 | 36 | |
… |
… |
|
55 | 62 | typedef uint32_t Thread_CPU_usage_t; |
56 | 63 | #endif |
57 | 64 | |
| 65 | #include <rtems/score/percpu.h> |
58 | 66 | #include <rtems/score/context.h> |
59 | 67 | #include <rtems/score/cpu.h> |
60 | 68 | #if defined(RTEMS_MULTIPROCESSING) |
… |
… |
|
147 | 155 | #endif |
148 | 156 | } Thread_CPU_budget_algorithms; |
149 | 157 | |
150 | | /** This type defines the Thread Control Block structure. |
151 | | */ |
152 | | typedef struct Thread_Control_struct Thread_Control; |
153 | | |
154 | 158 | /** This defines thes the entry point for the thread specific timeslice |
155 | 159 | * budget management algorithm. |
156 | 160 | */ |
… |
… |
|
363 | 367 | /** This field is true if the thread is offered globally */ |
364 | 368 | bool is_global; |
365 | 369 | #endif |
366 | | /** This field is is true if the post task context switch should be |
367 | | * executed for this thread at the next context switch. |
368 | | */ |
369 | | bool do_post_task_switch_extension; |
370 | 370 | /** This field is true if the thread is preemptible. */ |
371 | 371 | bool is_preemptible; |
372 | 372 | #if __RTEMS_ADA__ |
… |
… |
|
427 | 427 | SCORE_EXTERN Objects_Information _Thread_Internal_information; |
428 | 428 | |
429 | 429 | /** |
430 | | * The following define the thread control pointers used to access |
431 | | * and manipulate the idle thread. |
432 | | */ |
433 | | SCORE_EXTERN Thread_Control *_Thread_Idle; |
434 | | |
435 | | /** |
436 | 430 | * The following context area contains the context of the "thread" |
437 | 431 | * which invoked the start multitasking routine. This context is |
438 | 432 | * restored as the last action of the stop multitasking routine. Thus |
… |
… |
|
449 | 443 | SCORE_EXTERN volatile uint32_t _Thread_Dispatch_disable_level; |
450 | 444 | |
451 | 445 | /** |
452 | | * If this is non-zero, then the post-task switch extension |
453 | | * is run regardless of the state of the per thread flag. |
454 | | */ |
455 | | SCORE_EXTERN uint32_t _Thread_Do_post_task_switch_extension; |
456 | | |
457 | | /** |
458 | 446 | * The following holds how many user extensions are in the system. This |
459 | 447 | * is used to determine how many user extension data areas to allocate |
460 | 448 | * per thread. |
… |
… |
|
473 | 461 | SCORE_EXTERN Chain_Control *_Thread_Ready_chain; |
474 | 462 | |
475 | 463 | /** |
476 | | * The following points to the thread which is currently executing. |
477 | | * This thread is implicitly manipulated by numerous directives. |
478 | | */ |
479 | | SCORE_EXTERN Thread_Control *_Thread_Executing; |
480 | | |
481 | | /** |
482 | | * The following points to the highest priority ready thread |
483 | | * in the system. Unless the current thread is not preemptibl, |
484 | | * then this thread will be context switched to when the next |
485 | | * dispatch occurs. |
486 | | */ |
487 | | SCORE_EXTERN Thread_Control *_Thread_Heir; |
488 | | |
489 | | /** |
490 | 464 | * The following points to the thread whose floating point |
491 | 465 | * context is currently loaded. |
492 | 466 | */ |
-
RCS file: /usr1/CVS/rtems/cpukit/score/src/isr.c,v
retrieving revision 1.18
diff -u -r1.18 isr.c
|
|
|
34 | 34 | |
35 | 35 | void _ISR_Handler_initialization( void ) |
36 | 36 | { |
37 | | _ISR_Signals_to_thread_executing = false; |
38 | | |
39 | 37 | _ISR_Nest_level = 0; |
40 | 38 | |
41 | 39 | #if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE) |
… |
… |
|
64 | 62 | Configuration.interrupt_stack_size |
65 | 63 | ); |
66 | 64 | |
| 65 | _CPU_Interrupt_stack_high = (void *) |
| 66 | ((uintptr_t) _CPU_Interrupt_stack_high & ~CPU_STACK_ALIGNMENT); |
| 67 | |
67 | 68 | /* Interrupt stack might have to be aligned and/or setup |
68 | 69 | * in a specific way. |
69 | 70 | */ |
-
RCS file: /usr1/CVS/rtems/cpukit/score/src/isrthreaddispatch.c,v
retrieving revision 1.3
diff -u -r1.3 isrthreaddispatch.c
|
|
|
33 | 33 | { |
34 | 34 | if ( _Context_Switch_necessary ) { |
35 | 35 | _Thread_Dispatch(); |
36 | | } else if ( _ISR_Signals_to_thread_executing ) { |
37 | | _ISR_Signals_to_thread_executing = false; |
38 | | if ( |
39 | | _Thread_Do_post_task_switch_extension |
40 | | || _Thread_Executing->do_post_task_switch_extension |
41 | | ) { |
42 | | _Thread_Executing->do_post_task_switch_extension = false; |
43 | | _API_extensions_Run_postswitch(); |
44 | | } |
45 | 36 | } |
46 | 37 | } |
47 | 38 | |
-
RCS file: cpukit/score/src/percpu.c
diff -N cpukit/score/src/percpu.c
-
|
+
|
|
| 1 | /* |
| 2 | * COPYRIGHT (c) 1989-2010. |
| 3 | * On-Line Applications Research Corporation (OAR). |
| 4 | * |
| 5 | * The license and distribution terms for this file may be |
| 6 | * found in the file LICENSE in this distribution or at |
| 7 | * http://www.rtems.com/license/LICENSE. |
| 8 | * |
| 9 | * $Id: chain.c,v 1.18 2007/05/09 18:27:26 joel Exp $ |
| 10 | */ |
| 11 | |
| 12 | #if HAVE_CONFIG_H |
| 13 | #include "config.h" |
| 14 | #endif |
| 15 | |
| 16 | #include <rtems/system.h> |
| 17 | #include <rtems/score/thread.h> |
| 18 | #include <rtems/score/percpu.h> |
| 19 | #include <rtems/score/wkspace.h> |
| 20 | #include <rtems/score/wkspace.h> |
| 21 | #include <rtems/config.h> |
| 22 | #include <string.h> |
| 23 | |
| 24 | /* |
| 25 | * On single core systems, we can efficiently directly access a single |
| 26 | * statically allocated per cpu structure. And the fields are initialized |
| 27 | * as individual elements just like it has always been done. |
| 28 | */ |
| 29 | Per_CPU_Control _Per_CPU_Information; |
-
RCS file: /usr1/CVS/rtems/cpukit/score/src/thread.c,v
retrieving revision 1.62
diff -u -r1.62 thread.c
|
|
|
76 | 76 | _Thread_Allocated_fp = NULL; |
77 | 77 | #endif |
78 | 78 | |
79 | | _Thread_Do_post_task_switch_extension = 0; |
80 | | |
81 | 79 | _Thread_Maximum_extensions = maximum_extensions; |
82 | 80 | |
83 | 81 | _Thread_Ticks_per_timeslice = ticks_per_timeslice; |
-
RCS file: /usr1/CVS/rtems/cpukit/score/src/threaddispatch.c,v
retrieving revision 1.20
diff -u -r1.20 threaddispatch.c
|
|
|
94 | 94 | _Thread_Dispatch_disable_level = 1; |
95 | 95 | _Context_Switch_necessary = false; |
96 | 96 | _Thread_Executing = heir; |
| 97 | |
| 98 | /* |
| 99 | * When the heir and executing are the same, then we are being |
| 100 | * requested to do the post switch dispatching. This is normally |
| 101 | * done to dispatch signals. |
| 102 | */ |
| 103 | if ( heir == executing ) |
| 104 | goto post_switch; |
| 105 | |
| 106 | /* |
| 107 | * Since heir and executing are not the same, we need to do a real |
| 108 | * context switch. |
| 109 | */ |
97 | 110 | #if __RTEMS_ADA__ |
98 | 111 | executing->rtems_ada_self = rtems_ada_self; |
99 | 112 | rtems_ada_self = heir->rtems_ada_self; |
100 | 113 | #endif |
101 | 114 | if ( heir->budget_algorithm == THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE ) |
102 | 115 | heir->cpu_time_budget = _Thread_Ticks_per_timeslice; |
| 116 | |
103 | 117 | _ISR_Enable( level ); |
104 | 118 | |
105 | 119 | #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ |
… |
… |
|
170 | 184 | _ISR_Disable( level ); |
171 | 185 | } |
172 | 186 | |
| 187 | post_switch: |
173 | 188 | _Thread_Dispatch_disable_level = 0; |
174 | 189 | |
175 | 190 | _ISR_Enable( level ); |
176 | 191 | |
177 | | if ( _Thread_Do_post_task_switch_extension || |
178 | | executing->do_post_task_switch_extension ) { |
179 | | executing->do_post_task_switch_extension = false; |
180 | | _API_extensions_Run_postswitch(); |
181 | | } |
182 | | |
| 192 | _API_extensions_Run_postswitch(); |
183 | 193 | } |
-
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadloadenv.c,v
retrieving revision 1.7
diff -u -r1.7 threadloadenv.c
|
|
|
58 | 58 | #endif |
59 | 59 | is_fp = false; |
60 | 60 | |
61 | | |
62 | | the_thread->do_post_task_switch_extension = false; |
63 | 61 | the_thread->is_preemptible = the_thread->Start.is_preemptible; |
64 | 62 | the_thread->budget_algorithm = the_thread->Start.budget_algorithm; |
65 | 63 | the_thread->budget_callout = the_thread->Start.budget_callout; |
-
RCS file: /usr1/CVS/rtems/doc/porting/interrupts.t,v
retrieving revision 1.9
diff -u -r1.9 interrupts.t
|
|
|
366 | 366 | #endif |
367 | 367 | |
368 | 368 | if ( _Thread_Dispatch_disable_level ) |
369 | | _ISR_Signals_to_thread_executing = FALSE; |
370 | 369 | goto the label "exit interrupt (simple case)" |
371 | 370 | |
372 | | if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) |
373 | | _ISR_Signals_to_thread_executing = FALSE; |
| 371 | if ( _Context_Switch_necessary ) |
374 | 372 | call _Thread_Dispatch() or prepare to return to _ISR_Dispatch |
375 | 373 | prepare to get out of interrupt |
376 | 374 | return from interrupt (maybe to _ISR_Dispatch) |