summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/hal/idt_entries.s
blob: 204fa935e4d083f38b20fe8de654a008f41e4d1e (plain) (blame)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
.section .text
.macro push_state
    pushq %rax
    pushq %rbx
    pushq %rcx
    pushq %rdx
    pushq %rsi
    pushq %rdi
    pushq %rbp
    pushq %r8
    pushq %r9
    pushq %r10
    pushq %r11
    pushq %r12
    pushq %r13
    pushq %r14
    pushq %r15
.endm

.macro pop_state
    popq %r15
    popq %r14
    popq %r13
    popq %r12
    popq %r11
    popq %r10
    popq %r9
    popq %r8
    popq %rbp
    popq %rdi
    popq %rsi
    popq %rdx
    popq %rcx
    popq %rbx
    popq %rax
.endm

.macro swapgs_if_necessary
    cmpq $0x08, 0x8(%rsp)
    je 1f
    swapgs
1:
.endm

.extern __int_handles
.type __isr_header @function
__isr_header:
    push_state
    cld

    movq %rsp, %rdi

isr_break:
    movq 0x78(%rdi), %rax
    movq __int_handles(,%rax,8), %rbx
    call %rbx

    pop_state
    addq $16, %rsp
    swapgs_if_necessary
    iretq
.size __isr_header, . - __isr_header

.macro defn_isr_err num:req
.type __isr\num @function
__isr\num:
    swapgs_if_necessary
    pushq $\num
    jmp __isr_header
.size __isr\num, . - __isr\num
.endm

.macro defn_isr num:req
.type __isr\num @function
__isr\num:
    swapgs_if_necessary
    pushq $0
    pushq $\num
    jmp __isr_header
.size __isr\num, . - __isr\num
.endm

.macro decl_isr num:req
.quad __isr\num
.endm

defn_isr 0
defn_isr 1
defn_isr 2
defn_isr 3
defn_isr 4
defn_isr 5
defn_isr 6
defn_isr 7
defn_isr_err 8
defn_isr 9
defn_isr_err 10
defn_isr_err 11
defn_isr_err 12
defn_isr_err 13
defn_isr_err 14
defn_isr 15
defn_isr 16
defn_isr_err 17
defn_isr 18
defn_isr 19
defn_isr 20
defn_isr_err 21

.altmacro
.set i, 22
.rept 48-22
    defn_isr %i
    .set i, i+1
.endr

.section .data

.global __isrs
.type __isrs @object
__isrs:
    .set i, 0
    .rept 48
        decl_isr %i
        .set i, i+1
    .endr
.size __isrs, . - __isrs