3.1.7 branch.
[minix.git] / kernel / arch / i386 / apic_asm.S
blobb678a5a4f08375e2c9ea581013b533a8d311b4c8
1 #include "archconst.h"
2 #include "apic.h"
3 #include "sconst.h"
4 #include "apic_asm.h"
6 .globl  _apic_hwint00   /*  handlers for hardware interrupts */
7 .globl  _apic_hwint01
8 .globl  _apic_hwint02
9 .globl  _apic_hwint03
10 .globl  _apic_hwint04
11 .globl  _apic_hwint05
12 .globl  _apic_hwint06
13 .globl  _apic_hwint07
14 .globl  _apic_hwint08
15 .globl  _apic_hwint09
16 .globl  _apic_hwint10
17 .globl  _apic_hwint11
18 .globl  _apic_hwint12
19 .globl  _apic_hwint13
20 .globl  _apic_hwint14
21 .globl  _apic_hwint15
23 .text
24 #define APIC_IRQ_HANDLER(irq)   \
25         push    $irq                                                            ;\
26         call    _irq_handle             /* intr_handle(irq_handlers[irq]) */    ;\
27         add     $4, %esp                                                        ;\
28         mov     _lapic_eoi_addr, %eax                                           ;\
29         movl    $0, (%eax)                                                      ;\
31 /*===========================================================================*/
32 /*                              interrupt handlers                           */
33 /*              interrupt handlers for 386 32-bit protected mode             */
34 /*              APIC interrupt handlers for 386 32-bit protected mode        */
35 /*===========================================================================*/
36 #define apic_hwint(irq) \
37         TEST_INT_IN_KERNEL(4, 0f)                                       ;\
38                                                                         \
39         SAVE_PROCESS_CTX(0)                                             ;\
40         push    %ebp                                                    ;\
41         call    _context_stop                                           ;\
42         add     $4, %esp                                                ;\
43         movl    $0, %ebp        /* for stack trace */                   ;\
44         APIC_IRQ_HANDLER(irq)                                           ;\
45         jmp     _switch_to_user                                         ;\
46                                                                         \
47 0:                                                                      \
48         pusha                                                           ;\
49         call    _context_stop_idle                                      ;\
50         APIC_IRQ_HANDLER(irq)                                           ;\
51         CLEAR_IF(10*4(%esp))                                            ;\
52         popa                                                            ;\
53         iret                                                            ;
55 /*  Each of these entry points is an expansion of the hwint_master macro */
56 .balign 16
57 _apic_hwint00:
58 /*  Interrupt routine for irq 0 (the clock). */
59         apic_hwint(0)
61 .balign 16
62 _apic_hwint01:
63 /*  Interrupt routine for irq 1 (keyboard) */
64         apic_hwint(1)
66 .balign 16
67 _apic_hwint02:
68 /*  Interrupt routine for irq 2 (cascade!) */
69         apic_hwint(2)
71 .balign 16
72 _apic_hwint03:
73 /*  Interrupt routine for irq 3 (second serial) */
74         apic_hwint(3)
76 .balign 16
77 _apic_hwint04:
78 /*  Interrupt routine for irq 4 (first serial) */
79         apic_hwint(4)
81 .balign 16
82 _apic_hwint05:
83 /*  Interrupt routine for irq 5 (XT winchester) */
84         apic_hwint(5)
86 .balign 16
87 _apic_hwint06:
88 /*  Interrupt routine for irq 6 (floppy) */
89         apic_hwint(6)
91 .balign 16
92 _apic_hwint07:
93 /*  Interrupt routine for irq 7 (printer) */
94         apic_hwint(7)
96 .balign 16
97 _apic_hwint08:
98 /*  Interrupt routine for irq 8 (realtime clock) */
99         apic_hwint(8)
101 .balign 16
102 _apic_hwint09:
103 /*  Interrupt routine for irq 9 (irq 2 redirected) */
104         apic_hwint(9)
106 .balign 16
107 _apic_hwint10:
108 /*  Interrupt routine for irq 10 */
109         apic_hwint(10)
111 .balign 16
112 _apic_hwint11:
113 /*  Interrupt routine for irq 11 */
114         apic_hwint(11)
116 .balign 16
117 _apic_hwint12:
118 /*  Interrupt routine for irq 12 */
119         apic_hwint(12)
121 .balign 16
122 _apic_hwint13:
123 /*  Interrupt routine for irq 13 (FPU exception) */
124         apic_hwint(13)
126 .balign 16
127 _apic_hwint14:
128 /*  Interrupt routine for irq 14 (AT winchester) */
129         apic_hwint(14)
131 .balign 16
132 _apic_hwint15:
133 /*  Interrupt routine for irq 15 */
134         apic_hwint(15)
137 #define LAPIC_INTR_HANDLER(func)        \
138         movl    $func, %eax                                             ;\
139         call    *%eax           /* call the actual handler */           ;\
140         mov     _lapic_eoi_addr, %eax   /* the end of handler*/         ;\
141         movl    $0, (%eax)                                              ;
143 /*===========================================================================*/
144 /*                      handler of the local APIC interrupts                 */
145 /*===========================================================================*/
147 #define lapic_intr(func) \
148         TEST_INT_IN_KERNEL(4, 0f)                                       ;\
149                                                                         \
150         SAVE_PROCESS_CTX(0)                                             ;\
151         push    %ebp                                                    ;\
152         call    _context_stop                                           ;\
153         add     $4, %esp                                                ;\
154         movl    $0, %ebp                /* for stack trace */           ;\
155         LAPIC_INTR_HANDLER(func)                                        ;\
156         jmp     _switch_to_user                                         ;\
157         \
158 0:      \
159         pusha                                                           ;\
160         call    _context_stop_idle                                      ;\
161         LAPIC_INTR_HANDLER(func)                                        ;\
162         CLEAR_IF(10*4(%esp))                                            ;\
163         popa                                                            ;\
164         iret                                                            ;
166 /* apic timer tick handlers */
167 .globl _lapic_bsp_timer_int_handler
168 _lapic_bsp_timer_int_handler:
169         lapic_intr(_bsp_timer_int_handler)
171 .globl _lapic_ap_timer_int_handler
172 _lapic_ap_timer_int_handler:
173         lapic_intr(_ap_timer_int_handler)
175 #ifdef CONFIG_APIC_DEBUG
177 .data
178 lapic_intr_dummy_handler_msg:
179 .ascii "UNHABLED APIC interrupt vector %d\n"
181 .text
183 #define lapic_intr_dummy_handler(vect)                  \
184         pushl   $vect;                                  \
185         push    $lapic_intr_dummy_handler_msg;          \
186         call    _printf;                                \
187 1:      jmp     1b; /* never return */
189 #define LAPIC_INTR_DUMMY_HANDLER(vect)                  \
190         .balign LAPIC_INTR_DUMMY_HANDLER_SIZE;          \
191         lapic_intr_dummy_handler_##vect: lapic_intr_dummy_handler(vect)
193 .globl _lapic_intr_dummy_handles_start
194 _lapic_intr_dummy_handles_start:
196 LAPIC_INTR_DUMMY_HANDLER(0)
197 LAPIC_INTR_DUMMY_HANDLER(1)
198 LAPIC_INTR_DUMMY_HANDLER(2)
199 LAPIC_INTR_DUMMY_HANDLER(3)
200 LAPIC_INTR_DUMMY_HANDLER(4)
201 LAPIC_INTR_DUMMY_HANDLER(5)
202 LAPIC_INTR_DUMMY_HANDLER(6)
203 LAPIC_INTR_DUMMY_HANDLER(7)
204 LAPIC_INTR_DUMMY_HANDLER(8)
205 LAPIC_INTR_DUMMY_HANDLER(9)
206 LAPIC_INTR_DUMMY_HANDLER(10)
207 LAPIC_INTR_DUMMY_HANDLER(11)
208 LAPIC_INTR_DUMMY_HANDLER(12)
209 LAPIC_INTR_DUMMY_HANDLER(13)
210 LAPIC_INTR_DUMMY_HANDLER(14)
211 LAPIC_INTR_DUMMY_HANDLER(15)
212 LAPIC_INTR_DUMMY_HANDLER(16)
213 LAPIC_INTR_DUMMY_HANDLER(17)
214 LAPIC_INTR_DUMMY_HANDLER(18)
215 LAPIC_INTR_DUMMY_HANDLER(19)
216 LAPIC_INTR_DUMMY_HANDLER(20)
217 LAPIC_INTR_DUMMY_HANDLER(21)
218 LAPIC_INTR_DUMMY_HANDLER(22)
219 LAPIC_INTR_DUMMY_HANDLER(23)
220 LAPIC_INTR_DUMMY_HANDLER(24)
221 LAPIC_INTR_DUMMY_HANDLER(25)
222 LAPIC_INTR_DUMMY_HANDLER(26)
223 LAPIC_INTR_DUMMY_HANDLER(27)
224 LAPIC_INTR_DUMMY_HANDLER(28)
225 LAPIC_INTR_DUMMY_HANDLER(29)
226 LAPIC_INTR_DUMMY_HANDLER(30)
227 LAPIC_INTR_DUMMY_HANDLER(31)
228 LAPIC_INTR_DUMMY_HANDLER(32)
229 LAPIC_INTR_DUMMY_HANDLER(33)
230 LAPIC_INTR_DUMMY_HANDLER(34)
231 LAPIC_INTR_DUMMY_HANDLER(35)
232 LAPIC_INTR_DUMMY_HANDLER(36)
233 LAPIC_INTR_DUMMY_HANDLER(37)
234 LAPIC_INTR_DUMMY_HANDLER(38)
235 LAPIC_INTR_DUMMY_HANDLER(39)
236 LAPIC_INTR_DUMMY_HANDLER(40)
237 LAPIC_INTR_DUMMY_HANDLER(41)
238 LAPIC_INTR_DUMMY_HANDLER(42)
239 LAPIC_INTR_DUMMY_HANDLER(43)
240 LAPIC_INTR_DUMMY_HANDLER(44)
241 LAPIC_INTR_DUMMY_HANDLER(45)
242 LAPIC_INTR_DUMMY_HANDLER(46)
243 LAPIC_INTR_DUMMY_HANDLER(47)
244 LAPIC_INTR_DUMMY_HANDLER(48)
245 LAPIC_INTR_DUMMY_HANDLER(49)
246 LAPIC_INTR_DUMMY_HANDLER(50)
247 LAPIC_INTR_DUMMY_HANDLER(51)
248 LAPIC_INTR_DUMMY_HANDLER(52)
249 LAPIC_INTR_DUMMY_HANDLER(53)
250 LAPIC_INTR_DUMMY_HANDLER(54)
251 LAPIC_INTR_DUMMY_HANDLER(55)
252 LAPIC_INTR_DUMMY_HANDLER(56)
253 LAPIC_INTR_DUMMY_HANDLER(57)
254 LAPIC_INTR_DUMMY_HANDLER(58)
255 LAPIC_INTR_DUMMY_HANDLER(59)
256 LAPIC_INTR_DUMMY_HANDLER(60)
257 LAPIC_INTR_DUMMY_HANDLER(61)
258 LAPIC_INTR_DUMMY_HANDLER(62)
259 LAPIC_INTR_DUMMY_HANDLER(63)
260 LAPIC_INTR_DUMMY_HANDLER(64)
261 LAPIC_INTR_DUMMY_HANDLER(65)
262 LAPIC_INTR_DUMMY_HANDLER(66)
263 LAPIC_INTR_DUMMY_HANDLER(67)
264 LAPIC_INTR_DUMMY_HANDLER(68)
265 LAPIC_INTR_DUMMY_HANDLER(69)
266 LAPIC_INTR_DUMMY_HANDLER(70)
267 LAPIC_INTR_DUMMY_HANDLER(71)
268 LAPIC_INTR_DUMMY_HANDLER(72)
269 LAPIC_INTR_DUMMY_HANDLER(73)
270 LAPIC_INTR_DUMMY_HANDLER(74)
271 LAPIC_INTR_DUMMY_HANDLER(75)
272 LAPIC_INTR_DUMMY_HANDLER(76)
273 LAPIC_INTR_DUMMY_HANDLER(77)
274 LAPIC_INTR_DUMMY_HANDLER(78)
275 LAPIC_INTR_DUMMY_HANDLER(79)
276 LAPIC_INTR_DUMMY_HANDLER(80)
277 LAPIC_INTR_DUMMY_HANDLER(81)
278 LAPIC_INTR_DUMMY_HANDLER(82)
279 LAPIC_INTR_DUMMY_HANDLER(83)
280 LAPIC_INTR_DUMMY_HANDLER(84)
281 LAPIC_INTR_DUMMY_HANDLER(85)
282 LAPIC_INTR_DUMMY_HANDLER(86)
283 LAPIC_INTR_DUMMY_HANDLER(87)
284 LAPIC_INTR_DUMMY_HANDLER(88)
285 LAPIC_INTR_DUMMY_HANDLER(89)
286 LAPIC_INTR_DUMMY_HANDLER(90)
287 LAPIC_INTR_DUMMY_HANDLER(91)
288 LAPIC_INTR_DUMMY_HANDLER(92)
289 LAPIC_INTR_DUMMY_HANDLER(93)
290 LAPIC_INTR_DUMMY_HANDLER(94)
291 LAPIC_INTR_DUMMY_HANDLER(95)
292 LAPIC_INTR_DUMMY_HANDLER(96)
293 LAPIC_INTR_DUMMY_HANDLER(97)
294 LAPIC_INTR_DUMMY_HANDLER(98)
295 LAPIC_INTR_DUMMY_HANDLER(99)
296 LAPIC_INTR_DUMMY_HANDLER(100)
297 LAPIC_INTR_DUMMY_HANDLER(101)
298 LAPIC_INTR_DUMMY_HANDLER(102)
299 LAPIC_INTR_DUMMY_HANDLER(103)
300 LAPIC_INTR_DUMMY_HANDLER(104)
301 LAPIC_INTR_DUMMY_HANDLER(105)
302 LAPIC_INTR_DUMMY_HANDLER(106)
303 LAPIC_INTR_DUMMY_HANDLER(107)
304 LAPIC_INTR_DUMMY_HANDLER(108)
305 LAPIC_INTR_DUMMY_HANDLER(109)
306 LAPIC_INTR_DUMMY_HANDLER(110)
307 LAPIC_INTR_DUMMY_HANDLER(111)
308 LAPIC_INTR_DUMMY_HANDLER(112)
309 LAPIC_INTR_DUMMY_HANDLER(113)
310 LAPIC_INTR_DUMMY_HANDLER(114)
311 LAPIC_INTR_DUMMY_HANDLER(115)
312 LAPIC_INTR_DUMMY_HANDLER(116)
313 LAPIC_INTR_DUMMY_HANDLER(117)
314 LAPIC_INTR_DUMMY_HANDLER(118)
315 LAPIC_INTR_DUMMY_HANDLER(119)
316 LAPIC_INTR_DUMMY_HANDLER(120)
317 LAPIC_INTR_DUMMY_HANDLER(121)
318 LAPIC_INTR_DUMMY_HANDLER(122)
319 LAPIC_INTR_DUMMY_HANDLER(123)
320 LAPIC_INTR_DUMMY_HANDLER(124)
321 LAPIC_INTR_DUMMY_HANDLER(125)
322 LAPIC_INTR_DUMMY_HANDLER(126)
323 LAPIC_INTR_DUMMY_HANDLER(127)
324 LAPIC_INTR_DUMMY_HANDLER(128)
325 LAPIC_INTR_DUMMY_HANDLER(129)
326 LAPIC_INTR_DUMMY_HANDLER(130)
327 LAPIC_INTR_DUMMY_HANDLER(131)
328 LAPIC_INTR_DUMMY_HANDLER(132)
329 LAPIC_INTR_DUMMY_HANDLER(133)
330 LAPIC_INTR_DUMMY_HANDLER(134)
331 LAPIC_INTR_DUMMY_HANDLER(135)
332 LAPIC_INTR_DUMMY_HANDLER(136)
333 LAPIC_INTR_DUMMY_HANDLER(137)
334 LAPIC_INTR_DUMMY_HANDLER(138)
335 LAPIC_INTR_DUMMY_HANDLER(139)
336 LAPIC_INTR_DUMMY_HANDLER(140)
337 LAPIC_INTR_DUMMY_HANDLER(141)
338 LAPIC_INTR_DUMMY_HANDLER(142)
339 LAPIC_INTR_DUMMY_HANDLER(143)
340 LAPIC_INTR_DUMMY_HANDLER(144)
341 LAPIC_INTR_DUMMY_HANDLER(145)
342 LAPIC_INTR_DUMMY_HANDLER(146)
343 LAPIC_INTR_DUMMY_HANDLER(147)
344 LAPIC_INTR_DUMMY_HANDLER(148)
345 LAPIC_INTR_DUMMY_HANDLER(149)
346 LAPIC_INTR_DUMMY_HANDLER(150)
347 LAPIC_INTR_DUMMY_HANDLER(151)
348 LAPIC_INTR_DUMMY_HANDLER(152)
349 LAPIC_INTR_DUMMY_HANDLER(153)
350 LAPIC_INTR_DUMMY_HANDLER(154)
351 LAPIC_INTR_DUMMY_HANDLER(155)
352 LAPIC_INTR_DUMMY_HANDLER(156)
353 LAPIC_INTR_DUMMY_HANDLER(157)
354 LAPIC_INTR_DUMMY_HANDLER(158)
355 LAPIC_INTR_DUMMY_HANDLER(159)
356 LAPIC_INTR_DUMMY_HANDLER(160)
357 LAPIC_INTR_DUMMY_HANDLER(161)
358 LAPIC_INTR_DUMMY_HANDLER(162)
359 LAPIC_INTR_DUMMY_HANDLER(163)
360 LAPIC_INTR_DUMMY_HANDLER(164)
361 LAPIC_INTR_DUMMY_HANDLER(165)
362 LAPIC_INTR_DUMMY_HANDLER(166)
363 LAPIC_INTR_DUMMY_HANDLER(167)
364 LAPIC_INTR_DUMMY_HANDLER(168)
365 LAPIC_INTR_DUMMY_HANDLER(169)
366 LAPIC_INTR_DUMMY_HANDLER(170)
367 LAPIC_INTR_DUMMY_HANDLER(171)
368 LAPIC_INTR_DUMMY_HANDLER(172)
369 LAPIC_INTR_DUMMY_HANDLER(173)
370 LAPIC_INTR_DUMMY_HANDLER(174)
371 LAPIC_INTR_DUMMY_HANDLER(175)
372 LAPIC_INTR_DUMMY_HANDLER(176)
373 LAPIC_INTR_DUMMY_HANDLER(177)
374 LAPIC_INTR_DUMMY_HANDLER(178)
375 LAPIC_INTR_DUMMY_HANDLER(179)
376 LAPIC_INTR_DUMMY_HANDLER(180)
377 LAPIC_INTR_DUMMY_HANDLER(181)
378 LAPIC_INTR_DUMMY_HANDLER(182)
379 LAPIC_INTR_DUMMY_HANDLER(183)
380 LAPIC_INTR_DUMMY_HANDLER(184)
381 LAPIC_INTR_DUMMY_HANDLER(185)
382 LAPIC_INTR_DUMMY_HANDLER(186)
383 LAPIC_INTR_DUMMY_HANDLER(187)
384 LAPIC_INTR_DUMMY_HANDLER(188)
385 LAPIC_INTR_DUMMY_HANDLER(189)
386 LAPIC_INTR_DUMMY_HANDLER(190)
387 LAPIC_INTR_DUMMY_HANDLER(191)
388 LAPIC_INTR_DUMMY_HANDLER(192)
389 LAPIC_INTR_DUMMY_HANDLER(193)
390 LAPIC_INTR_DUMMY_HANDLER(194)
391 LAPIC_INTR_DUMMY_HANDLER(195)
392 LAPIC_INTR_DUMMY_HANDLER(196)
393 LAPIC_INTR_DUMMY_HANDLER(197)
394 LAPIC_INTR_DUMMY_HANDLER(198)
395 LAPIC_INTR_DUMMY_HANDLER(199)
396 LAPIC_INTR_DUMMY_HANDLER(200)
397 LAPIC_INTR_DUMMY_HANDLER(201)
398 LAPIC_INTR_DUMMY_HANDLER(202)
399 LAPIC_INTR_DUMMY_HANDLER(203)
400 LAPIC_INTR_DUMMY_HANDLER(204)
401 LAPIC_INTR_DUMMY_HANDLER(205)
402 LAPIC_INTR_DUMMY_HANDLER(206)
403 LAPIC_INTR_DUMMY_HANDLER(207)
404 LAPIC_INTR_DUMMY_HANDLER(208)
405 LAPIC_INTR_DUMMY_HANDLER(209)
406 LAPIC_INTR_DUMMY_HANDLER(210)
407 LAPIC_INTR_DUMMY_HANDLER(211)
408 LAPIC_INTR_DUMMY_HANDLER(212)
409 LAPIC_INTR_DUMMY_HANDLER(213)
410 LAPIC_INTR_DUMMY_HANDLER(214)
411 LAPIC_INTR_DUMMY_HANDLER(215)
412 LAPIC_INTR_DUMMY_HANDLER(216)
413 LAPIC_INTR_DUMMY_HANDLER(217)
414 LAPIC_INTR_DUMMY_HANDLER(218)
415 LAPIC_INTR_DUMMY_HANDLER(219)
416 LAPIC_INTR_DUMMY_HANDLER(220)
417 LAPIC_INTR_DUMMY_HANDLER(221)
418 LAPIC_INTR_DUMMY_HANDLER(222)
419 LAPIC_INTR_DUMMY_HANDLER(223)
420 LAPIC_INTR_DUMMY_HANDLER(224)
421 LAPIC_INTR_DUMMY_HANDLER(225)
422 LAPIC_INTR_DUMMY_HANDLER(226)
423 LAPIC_INTR_DUMMY_HANDLER(227)
424 LAPIC_INTR_DUMMY_HANDLER(228)
425 LAPIC_INTR_DUMMY_HANDLER(229)
426 LAPIC_INTR_DUMMY_HANDLER(230)
427 LAPIC_INTR_DUMMY_HANDLER(231)
428 LAPIC_INTR_DUMMY_HANDLER(232)
429 LAPIC_INTR_DUMMY_HANDLER(233)
430 LAPIC_INTR_DUMMY_HANDLER(234)
431 LAPIC_INTR_DUMMY_HANDLER(235)
432 LAPIC_INTR_DUMMY_HANDLER(236)
433 LAPIC_INTR_DUMMY_HANDLER(237)
434 LAPIC_INTR_DUMMY_HANDLER(238)
435 LAPIC_INTR_DUMMY_HANDLER(239)
436 LAPIC_INTR_DUMMY_HANDLER(240)
437 LAPIC_INTR_DUMMY_HANDLER(241)
438 LAPIC_INTR_DUMMY_HANDLER(242)
439 LAPIC_INTR_DUMMY_HANDLER(243)
440 LAPIC_INTR_DUMMY_HANDLER(244)
441 LAPIC_INTR_DUMMY_HANDLER(245)
442 LAPIC_INTR_DUMMY_HANDLER(246)
443 LAPIC_INTR_DUMMY_HANDLER(247)
444 LAPIC_INTR_DUMMY_HANDLER(248)
445 LAPIC_INTR_DUMMY_HANDLER(249)
446 LAPIC_INTR_DUMMY_HANDLER(250)
447 LAPIC_INTR_DUMMY_HANDLER(251)
448 LAPIC_INTR_DUMMY_HANDLER(252)
449 LAPIC_INTR_DUMMY_HANDLER(253)
450 LAPIC_INTR_DUMMY_HANDLER(254)
451 LAPIC_INTR_DUMMY_HANDLER(255)
453 .globl _lapic_intr_dummy_handles_end
454 _lapic_intr_dummy_handles_end:
457 #endif /* CONFIG_APIC_DEBUG */