File indexing completed on 2025-05-11 08:23:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <rtems/asm.h>
0017 #include <bspopts.h>
0018 #include <rtems/score/cpu.h>
0019 #include <rtems/score/percpu.h>
0020
0021 #include <bsp.h> /* to establish dependency on prototype */
0022
0023 #ifndef CPU_STACK_ALIGNMENT
0024 #error "Missing header? CPU_STACK_ALIGNMENT is not defined here"
0025 #endif
0026
0027
0028 #define ARG_OFF 0
0029 #define EBX_OFF 4
0030 #define EBP_OFF 8
0031 #define ESP_OFF 12
0032 #ifdef __SSE__
0033 #ifdef RTEMS_SMP
0034 #error SMP with SSE support has not been tested. Use at your own risk.
0035 #endif
0036
0037 #define FRM_SIZ (20+12+512)
0038 #define SSE_OFF 32
0039 #else
0040 #define FRM_SIZ 16
0041 #endif
0042
0043 BEGIN_CODE
0044
0045 SYM (_ISR_Handler):
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 movl esp, eax
0082 subl $FRM_SIZ, esp
0083 movl eax, ESP_OFF(esp)
0084 movl ebp, EBP_OFF(esp)
0085 movl ebx, EBX_OFF(esp)
0086
0087
0088
0089
0090
0091
0092 cld
0093
0094 #ifdef __SSE__
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107 fxsave SSE_OFF(esp)
0108 fninit
0109 movl $0x1f80, ARG_OFF(esp)
0110 ldmxcsr ARG_OFF(esp)
0111 #endif
0112
0113
0114
0115
0116
0117 PUBLIC (ISR_STOP)
0118 ISR_STOP:
0119 .check_stack_switch:
0120 movl esp, ebp
0121 andl $ - CPU_STACK_ALIGNMENT, esp
0122
0123 GET_SELF_CPU_CONTROL ebx
0124
0125
0126 cmpl $0, PER_CPU_ISR_NEST_LEVEL(ebx)
0127 jne nested
0128 movl PER_CPU_INTERRUPT_STACK_HIGH(ebx), esp
0129
0130
0131
0132
0133
0134
0135
0136 nested:
0137 incl PER_CPU_ISR_NEST_LEVEL(ebx)
0138 incl PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL(ebx)
0139
0140
0141
0142
0143
0144
0145
0146
0147 movl ecx, ARG_OFF(esp)
0148 call BSP_dispatch_isr
0149
0150 movl ARG_OFF(esp), ecx
0151
0152
0153
0154
0155
0156 movl ebp, esp
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166 movl PER_CPU_DISPATCH_NEEDED(ebx), eax
0167 xorl PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL(ebx), eax
0168 decl PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL(ebx)
0169 orl PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL(ebx), eax
0170 orl PER_CPU_ISR_DISPATCH_DISABLE(ebx), eax
0171 decl PER_CPU_ISR_NEST_LEVEL(ebx)
0172
0173 cmpl $0, eax
0174 jne .Lthread_dispatch_done
0175
0176 .Ldo_thread_dispatch:
0177
0178 movl $1, PER_CPU_ISR_DISPATCH_DISABLE(ebx)
0179 movl $1, PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL(ebx)
0180
0181 push $EFLAGS_INTR_ENABLE
0182 push ebx
0183 call _Thread_Do_dispatch
0184
0185
0186 cli
0187 addl $8, esp
0188
0189 GET_SELF_CPU_CONTROL ebx
0190 cmpb $0, PER_CPU_DISPATCH_NEEDED(ebx)
0191 jne .Ldo_thread_dispatch
0192
0193
0194 movl $0, PER_CPU_ISR_DISPATCH_DISABLE(ebx)
0195
0196
0197
0198
0199 .Lthread_dispatch_done:
0200
0201 #ifdef __SSE__
0202 fwait
0203 fxrstor SSE_OFF(esp)
0204 #endif
0205
0206
0207 addl $EBX_OFF, esp
0208 popl ebx
0209 popl ebp
0210 popl esp
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225 popl edx
0226 popl ecx
0227 popl eax
0228 iret
0229
0230 #define DISTINCT_INTERRUPT_ENTRY(_vector) \
0231 .p2align 4 ; \
0232 PUBLIC (rtems_irq_prologue_ ## _vector ) ; \
0233 SYM (rtems_irq_prologue_ ## _vector ): \
0234 pushl eax ; \
0235 pushl ecx ; \
0236 pushl edx ; \
0237 movl $ _vector, ecx ; \
0238 jmp SYM (_ISR_Handler) ;
0239
0240 DISTINCT_INTERRUPT_ENTRY(0)
0241 DISTINCT_INTERRUPT_ENTRY(1)
0242 DISTINCT_INTERRUPT_ENTRY(2)
0243 DISTINCT_INTERRUPT_ENTRY(3)
0244 DISTINCT_INTERRUPT_ENTRY(4)
0245 DISTINCT_INTERRUPT_ENTRY(5)
0246 DISTINCT_INTERRUPT_ENTRY(6)
0247 DISTINCT_INTERRUPT_ENTRY(7)
0248 DISTINCT_INTERRUPT_ENTRY(8)
0249 DISTINCT_INTERRUPT_ENTRY(9)
0250 DISTINCT_INTERRUPT_ENTRY(10)
0251 DISTINCT_INTERRUPT_ENTRY(11)
0252 DISTINCT_INTERRUPT_ENTRY(12)
0253 DISTINCT_INTERRUPT_ENTRY(13)
0254 DISTINCT_INTERRUPT_ENTRY(14)
0255 DISTINCT_INTERRUPT_ENTRY(15)
0256 DISTINCT_INTERRUPT_ENTRY(16)
0257
0258
0259
0260
0261
0262 PUBLIC (default_raw_idt_handler)
0263 PUBLIC (raw_idt_notify)
0264
0265 SYM (default_raw_idt_handler):
0266 pusha
0267 cld
0268 mov esp, ebp
0269 andl $ - CPU_STACK_ALIGNMENT, esp
0270 call raw_idt_notify
0271 mov ebp, esp
0272 popa
0273 iret
0274
0275 END_CODE
0276
0277 END