stdlibc: \!perror()
[meinos.git] / kernel2 / isr.asm
blob9a6804eedbbdf34dba511cd26d07fcecd721b69d
1 ; meinOS - A unix-like x86 microkernel operating system
2 ; Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
4 ; This program is free software: you can redistribute it and/or modify
5 ; it under the terms of the GNU General Public License as published by
6 ; the Free Software Foundation, either version 3 of the License, or
7 ; (at your option) any later version.
9 ; This program is distributed in the hope that it will be useful,
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ; GNU General Public License for more details.
14 ; You should have received a copy of the GNU General Public License
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
17 global isr00,isr01,isr02,isr03,isr04,isr05,isr06,isr07,isr08,isr09,isr0A,isr0B,isr0C,isr0D,isr0E,isr0F
18 global isr10,isr11,isr12,isr13,isr14,isr15,isr16,isr17,isr18,isr19,isr1A,isr1B,isr1C,isr1D,isr1E,isr1F
19 global isr20,isr21,isr22,isr23,isr24,isr25,isr26,isr27,isr28,isr29,isr2A,isr2B,isr2C,isr2D,isr2E,isr2F
20 global isr30,isr31,isr32,isr33,isr34,isr35,isr36,isr37
22 global isr_uselapic
23 global isr
25 extern syscall_handler
26 extern interrupt_handler
27 extern lapic_timer_calibrate
29 align 4
31 reg_eax dd 0
32 reg_eip dd 0
33 reg_esp dd 0
34 reg_efl dd 0
35 reg_cs dw 0
36 reg_ds dw 0
37 reg_ss dw 0
38 reg_kernelesp dd 0
39 isr_uselapic dd 0
41 ; Pointer to ISRs as array
42 isr dd isr_table
43 isr_table dd isr00,isr01,isr02,isr03,isr04,isr05,isr06,isr07,isr08,isr09,isr0A,isr0B,isr0C,isr0D,isr0E,isr0F, \
44 isr10,isr11,isr12,isr13,isr14,isr15,isr16,isr17,isr18,isr19,isr1A,isr1B,isr1C,isr1D,isr1E,isr1F, \
45 isr20,isr21,isr22,isr23,isr24,isr25,isr26,isr27,isr28,isr29,isr2A,isr2B,isr2C,isr2D,isr2E,isr2F, \
46 isr30,isr31,isr32,isr33,isr34,isr35,isr36,isr37
48 %macro pushsr 0
49 push DWORD ds
50 push DWORD es
51 push DWORD fs
52 push DWORD gs
53 %endmacro
55 %macro popsr 0
56 pop DWORD ds
57 pop DWORD es
58 pop DWORD fs
59 pop DWORD gs
60 %endmacro
62 ; Interrupt Service Routines
63 isr00:
64 push DWORD 0 ; dummy error code
65 pushsr
66 pushad
67 push esp
68 push DWORD 0x00
69 call interrupt_handler
70 add esp,8
71 popad
72 popsr
73 add esp,4
74 iret
75 isr01:
76 push DWORD 0 ; dummy error code
77 pushsr
78 pushad
79 push esp
80 push DWORD 0x01
81 call interrupt_handler
82 add esp,8
83 popad
84 popsr
85 add esp,4
86 iret
87 isr02:
88 push DWORD 0 ; dummy error code
89 pushsr
90 pushad
91 push esp
92 push DWORD 0x02
93 call interrupt_handler
94 add esp,8
95 popad
96 popsr
97 add esp,4
98 iret
99 isr03:
100 push DWORD 0 ; dummy error code
101 pushsr
102 pushad
103 push esp
104 push DWORD 0x03
105 call interrupt_handler
106 add esp,8
107 popad
108 popsr
109 add esp,4
110 iret
111 isr04:
112 push DWORD 0 ; dummy error code
113 pushsr
114 pushad
115 push esp
116 push DWORD 0x04
117 call interrupt_handler
118 add esp,8
119 popad
120 popsr
121 add esp,4
122 iret
123 isr05:
124 push DWORD 0 ; dummy error code
125 pushsr
126 pushad
127 push esp
128 push DWORD 0x05
129 call interrupt_handler
130 add esp,8
131 popad
132 popsr
133 add esp,4
134 iret
135 isr06:
136 push DWORD 0 ; dummy error code
137 pushsr
138 pushad
139 push esp
140 push DWORD 0x06
141 call interrupt_handler
142 add esp,8
143 popad
144 popsr
145 add esp,4
146 iret
147 isr07:
148 push DWORD 0 ; dummy error code
149 pushsr
150 pushad
151 push esp
152 push DWORD 0x07
153 call interrupt_handler
154 add esp,8
155 popad
156 popsr
157 add esp,4
158 iret
159 isr08:
160 pushsr
161 pushad
162 push esp
163 push DWORD 0x08
164 call interrupt_handler
165 add esp,8
166 popad
167 popsr
168 add esp,4
169 iret
170 isr09:
171 push DWORD 0 ; dummy error code
172 pushsr
173 pushad
174 push esp
175 push DWORD 0x09
176 call interrupt_handler
177 add esp,8
178 popad
179 popsr
180 add esp,4
181 iret
182 isr0A:
183 pushsr
184 pushad
185 push esp
186 push DWORD 0x0A
187 call interrupt_handler
188 add esp,8
189 popad
190 popsr
191 add esp,4
192 iret
193 isr0B:
194 pushsr
195 pushad
196 push esp
197 push DWORD 0x0B
198 call interrupt_handler
199 add esp,8
200 popad
201 popsr
202 add esp,4
203 iret
204 isr0C:
205 pushsr
206 pushad
207 push esp
208 push DWORD 0x0C
209 call interrupt_handler
210 add esp,8
211 popad
212 popsr
213 add esp,4
214 iret
215 isr0D:
216 pushsr
217 pushad
218 push esp
219 push DWORD 0x0D
220 call interrupt_handler
221 add esp,8
222 popad
223 popsr
224 add esp,4
225 iret
226 isr0E:
227 pushsr
228 pushad
229 push esp
230 push DWORD 0x0E
231 call interrupt_handler
232 add esp,8
233 popad
234 popsr
235 add esp,4
236 iret
237 isr0F: ; Spurious
238 push DWORD 0 ; dummy error code
239 pushsr
240 pushad
241 push esp
242 push DWORD 0x0F
243 call interrupt_handler
244 add esp,8
245 popad
246 popsr
247 add esp,4
248 iret
249 isr10:
250 push DWORD 0 ; dummy error code
251 pushsr
252 pushad
253 push esp
254 push DWORD 0x10
255 call interrupt_handler
256 add esp,8
257 popad
258 popsr
259 add esp,4
260 iret
261 isr11:
262 push DWORD 0 ; dummy error code
263 pushsr
264 pushad
265 push esp
266 push DWORD 0x11
267 call interrupt_handler
268 add esp,8
269 popad
270 popsr
271 add esp,4
272 iret
273 isr12:
274 push DWORD 0 ; dummy error code
275 pushsr
276 pushad
277 push esp
278 push DWORD 0x12
279 call interrupt_handler
280 add esp,8
281 popad
282 popsr
283 add esp,4
284 iret
285 isr13:
286 push DWORD 0 ; dummy error code
287 pushsr
288 pushad
289 push esp
290 push DWORD 0x13
291 call interrupt_handler
292 add esp,8
293 popad
294 popsr
295 add esp,4
296 iret
297 isr14:
298 push DWORD 0 ; dummy error code
299 pushsr
300 pushad
301 push esp
302 push DWORD 0x14
303 call interrupt_handler
304 add esp,8
305 popad
306 popsr
307 add esp,4
308 iret
309 isr15:
310 push DWORD 0 ; dummy error code
311 pushsr
312 pushad
313 push esp
314 push DWORD 0x15
315 call interrupt_handler
316 add esp,8
317 popad
318 popsr
319 add esp,4
320 iret
321 isr16:
322 push DWORD 0 ; dummy error code
323 pushsr
324 pushad
325 push esp
326 push DWORD 0x16
327 call interrupt_handler
328 add esp,8
329 popad
330 popsr
331 add esp,4
332 iret
333 isr17:
334 push DWORD 0 ; dummy error code
335 pushsr
336 pushad
337 push esp
338 push DWORD 0x17
339 call interrupt_handler
340 add esp,8
341 popad
342 popsr
343 add esp,4
344 iret
345 isr18:
346 push DWORD 0 ; dummy error code
347 pushsr
348 pushad
349 push esp
350 push DWORD 0x18
351 call interrupt_handler
352 add esp,8
353 popad
354 popsr
355 add esp,4
356 iret
357 isr19:
358 push DWORD 0 ; dummy error code
359 pushsr
360 pushad
361 push esp
362 push DWORD 0x19
363 call interrupt_handler
364 add esp,8
365 popad
366 popsr
367 add esp,4
368 iret
369 isr1A:
370 push DWORD 0 ; dummy error code
371 pushsr
372 pushad
373 push esp
374 push DWORD 0x1A
375 call interrupt_handler
376 add esp,8
377 popad
378 popsr
379 add esp,4
380 iret
381 isr1B:
382 push DWORD 0 ; dummy error code
383 pushsr
384 pushad
385 push esp
386 push DWORD 0x1B
387 call interrupt_handler
388 add esp,8
389 popad
390 popsr
391 add esp,4
392 iret
393 isr1C:
394 push DWORD 0 ; dummy error code
395 pushsr
396 pushad
397 push esp
398 push DWORD 0x1C
399 call interrupt_handler
400 add esp,8
401 popad
402 popsr
403 add esp,4
404 iret
405 isr1D:
406 push DWORD 0 ; dummy error code
407 pushsr
408 pushad
409 push esp
410 push DWORD 0x1D
411 call interrupt_handler
412 add esp,8
413 popad
414 popsr
415 add esp,4
416 iret
417 isr1E:
418 push DWORD 0 ; dummy error code
419 pushsr
420 pushad
421 push esp
422 push DWORD 0x1E
423 call interrupt_handler
424 add esp,8
425 popad
426 popsr
427 add esp,4
428 iret
429 isr1F:
430 push DWORD 0 ; dummy error code
431 pushsr
432 pushad
433 push esp
434 push DWORD 0x1F
435 call interrupt_handler
436 add esp,8
437 popad
438 popsr
439 add esp,4
440 iret
441 isr20: ; PIT timer interrupt (for calibration of APIC timer)
442 pushad
443 mov eax,[isr_uselapic]
444 test eax,eax
445 jz .usepic
446 call lapic_timer_calibrate
447 popad
448 iret
449 .usepic:
450 popad
451 jmp isr30
452 isr21:
453 push DWORD 0 ; dummy error code
454 pushsr
455 pushad
456 push esp
457 push DWORD 0x21
458 call interrupt_handler
459 add esp,8
460 popad
461 popsr
462 add esp,4
463 iret
464 isr22:
465 push DWORD 0 ; dummy error code
466 pushsr
467 pushad
468 push esp
469 push DWORD 0x22
470 call interrupt_handler
471 add esp,8
472 popad
473 popsr
474 add esp,4
475 iret
476 isr23:
477 push DWORD 0 ; dummy error code
478 pushsr
479 pushad
480 push esp
481 push DWORD 0x23
482 call interrupt_handler
483 add esp,8
484 popad
485 popsr
486 add esp,4
487 iret
488 isr24:
489 push DWORD 0 ; dummy error code
490 pushsr
491 pushad
492 push esp
493 push DWORD 0x24
494 call interrupt_handler
495 add esp,8
496 popad
497 popsr
498 add esp,4
499 iret
500 isr25:
501 push DWORD 0 ; dummy error code
502 pushsr
503 pushad
504 push esp
505 push DWORD 0x25
506 call interrupt_handler
507 add esp,8
508 popad
509 popsr
510 add esp,4
511 iret
512 isr26:
513 push DWORD 0 ; dummy error code
514 pushsr
515 pushad
516 push esp
517 push DWORD 0x26
518 call interrupt_handler
519 add esp,8
520 popad
521 popsr
522 add esp,4
523 iret
524 isr27:
525 push DWORD 0 ; dummy error code
526 pushsr
527 pushad
528 push esp
529 push DWORD 0x27
530 call interrupt_handler
531 add esp,8
532 popad
533 popsr
534 add esp,4
535 iret
536 isr28:
537 push DWORD 0 ; dummy error code
538 pushsr
539 pushad
540 push esp
541 push DWORD 0x28
542 call interrupt_handler
543 add esp,8
544 popad
545 popsr
546 add esp,4
547 iret
548 isr29:
549 push DWORD 0 ; dummy error code
550 pushsr
551 pushad
552 push esp
553 push DWORD 0x29
554 call interrupt_handler
555 add esp,8
556 popad
557 popsr
558 add esp,4
559 iret
560 isr2A:
561 push DWORD 0 ; dummy error code
562 pushsr
563 pushad
564 push esp
565 push DWORD 0x2A
566 call interrupt_handler
567 add esp,8
568 popad
569 popsr
570 add esp,4
571 iret
572 isr2B:
573 push DWORD 0 ; dummy error code
574 pushsr
575 pushad
576 push esp
577 push DWORD 0x2B
578 call interrupt_handler
579 add esp,8
580 popad
581 popsr
582 add esp,4
583 iret
584 isr2C:
585 push DWORD 0 ; dummy error code
586 pushsr
587 pushad
588 push esp
589 push DWORD 0x2C
590 call interrupt_handler
591 add esp,8
592 popad
593 popsr
594 add esp,4
595 iret
596 isr2D:
597 push DWORD 0 ; dummy error code
598 pushsr
599 pushad
600 push esp
601 push DWORD 0x2D
602 call interrupt_handler
603 add esp,8
604 popad
605 popsr
606 add esp,4
607 iret
608 isr2E:
609 push DWORD 0 ; dummy error code
610 pushsr
611 pushad
612 push esp
613 push DWORD 0x2E
614 call interrupt_handler
615 add esp,8
616 popad
617 popsr
618 add esp,4
619 iret
620 isr2F:
621 push DWORD 0 ; dummy error code
622 pushsr
623 pushad
624 push esp
625 push DWORD 0x2F
626 call interrupt_handler
627 add esp,8
628 popad
629 popsr
630 add esp,4
631 iret
632 isr30: ; LAPIC Timer
633 push DWORD 0 ; dummy error code
634 pushsr
635 pushad
636 push esp
637 push DWORD 0x30
638 call interrupt_handler
639 add esp,8
640 popad
641 popsr
642 add esp,4
643 iret
644 isr31: ; Thermal
645 push DWORD 0 ; dummy error code
646 pushsr
647 pushad
648 push esp
649 push DWORD 0x31
650 call interrupt_handler
651 add esp,8
652 popad
653 popsr
654 add esp,4
655 iret
656 isr32: ; Performance monitor
657 push DWORD 0 ; dummy error code
658 pushsr
659 pushad
660 push esp
661 push DWORD 0x32
662 call interrupt_handler
663 add esp,8
664 popad
665 popsr
666 add esp,4
667 iret
668 isr33: ; LINT0
669 push DWORD 0 ; dummy error code
670 pushsr
671 pushad
672 push esp
673 push DWORD 0x33
674 call interrupt_handler
675 add esp,8
676 popad
677 popsr
678 add esp,4
679 iret
680 isr34: ; LINT1
681 push DWORD 0 ; dummy error code
682 pushsr
683 pushad
684 push esp
685 push DWORD 0x34
686 call interrupt_handler
687 add esp,8
688 popad
689 popsr
690 add esp,4
691 iret
692 isr35: ; Error
693 push DWORD 0 ; dummy error code
694 pushsr
695 pushad
696 push esp
697 push DWORD 0x35
698 call interrupt_handler
699 add esp,8
700 popad
701 popsr
702 add esp,4
703 iret
704 isr36: ; IPCI
705 push DWORD 0 ; dummy error code
706 pushsr
707 pushad
708 push esp
709 push DWORD 0x36
710 call interrupt_handler
711 add esp,8
712 popad
713 popsr
714 add esp,4
715 iret
716 isr37: ; Syscall interrupt
717 push DWORD 0 ; dummy error code
718 pushsr
719 pushad
720 mov ax,ds
721 push ax
722 mov ax,ss
723 mov ds,ax
724 pop ax
725 mov [reg_ds],ax
727 ; call syscallhandler
728 push esp
729 call syscall_handler
730 add esp,4 ; pop esp
732 popad
733 popsr
734 add esp,4 ; pop error code
736 ; restore ds
737 mov dx,[reg_ds]
738 mov ds,dx
739 iret