aboutsummaryrefslogtreecommitdiff
path: root/src/idt/stubs.S
blob: 568b0dc6f494a67e0f8e695e9b1a6d0e2939624a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
.set IRQ_BASE, 0x20

.section .text
.extern handle_interrupt
.extern handle_exception

.macro interrupt num
.global interrupt\num
interrupt\num:
    push $0
    push $\num + IRQ_BASE
    jmp interrupt_common
.endm

.macro exception num
.global exception\num
exception\num:
    push $0
    push $\num
    jmp exception_common
.endm

.macro exception_ec num
.global exception\num
exception\num:
    push $\num
    jmp exception_common
.endm

/* exceptions */
exception 0x00
exception 0x01
exception 0x02
exception 0x03
exception 0x04
exception 0x05
exception 0x06
exception 0x07
exception_ec 0x08
exception 0x09
exception_ec 0x0a
exception_ec 0x0b
exception_ec 0x0c
exception_ec 0x0d
exception_ec 0x0e
exception 0x0f
exception 0x10
exception_ec 0x11
exception 0x12
exception 0x13

/* interrupts - master pic */
interrupt 0x00  # system timer
interrupt 0x01  # keyboard controller
interrupt 0x02  # slave pic
interrupt 0x03  # serial port 2 and 4
interrupt 0x04  # serial port 1 and 3
interrupt 0x05  # parallel port 2 and 3, sound card
interrupt 0x06  # floppy controller
interrupt 0x07  # parallel port 1
/* interrupts - slave pic */
interrupt 0x08  # real-time clock
interrupt 0x09  # acpi
interrupt 0x0a  #
interrupt 0x0b  #
interrupt 0x0c  # mouse on ps/2
interrupt 0x0d  # fpu
interrupt 0x0e  # primary ATA
interrupt 0x0f  # secondary ATA

exception_common:
    pusha

    push %esp
    call handle_exception
    add $4, %esp

    popa
    /* remove error code and irq from stack */
    add $8, %esp

    iret

interrupt_common:
    pushal

    push %esp
    call handle_interrupt
    #add $4, %esp
    mov %eax, %esp

    popal
    /* remove error code and irq from stack */
    add $8, %esp

    iret