source: trunk/hal/x86_64/core/hal_kentry.S @ 233

Last change on this file since 233 was 233, checked in by max@…, 5 years ago

Push the context entirely for an exception.

File size: 4.2 KB
Line 
1/*
2 * hal_kentry.S - Entry points into the kernel (exceptions/interrupts/syscalls)
3 *
4 * Copyright (c) 2017 Maxime Villard
5 *
6 * This file is part of ALMOS-MKH.
7 *
8 * ALMOS-MKH is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.0 of the License.
11 *
12 * ALMOS-MKH is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#define x86_ASM
23#include <hal_boot.h>
24#include <hal_kentry.h>
25#include <hal_apic.h>
26
27#define TRAPENTRY(a)    \
28        pushq   $(a);   \
29        jmp     alltraps;
30
31#define ZTRAPENTRY(a) \
32        pushq   $0; \
33        TRAPENTRY(a)
34
35        .text
36        .globl  hal_exception_entry
37        .globl  hal_timer_intr
38        .globl  ioc_ata_isr
39        .globl  hal_com1_intr
40        .globl  hal_keyboard_intr
41        .type   hal_exception_entry, @function
42        .type   hal_timer_intr, @function
43        .type   ioc_ata_isr, @function
44        .type   hal_com1_intr, @function
45        .type   hal_keyboard_intr, @function
46
47        /*
48         * General exceptions.
49         */
50ASM_ENTRY(x86_trap00)
51        ZTRAPENTRY(T_DIVIDE)
52
53ASM_ENTRY(x86_trap01)
54        ZTRAPENTRY(T_TRCTRAP)
55
56ASM_ENTRY(x86_trap02)
57        ZTRAPENTRY(T_NMI)
58
59ASM_ENTRY(x86_trap03)
60        ZTRAPENTRY(T_BPTFLT)
61
62ASM_ENTRY(x86_trap04)
63        ZTRAPENTRY(T_OFLOW)
64
65ASM_ENTRY(x86_trap05)
66        ZTRAPENTRY(T_BOUND)
67
68ASM_ENTRY(x86_trap06)
69        ZTRAPENTRY(T_PRIVINFLT)
70
71ASM_ENTRY(x86_trap07)
72        ZTRAPENTRY(T_DNA)
73
74ASM_ENTRY(x86_trap08)
75        TRAPENTRY(T_DOUBLEFLT)
76
77ASM_ENTRY(x86_trap09)
78        ZTRAPENTRY(T_FPOPFLT)
79
80ASM_ENTRY(x86_trap0a)
81        TRAPENTRY(T_TSSFLT)
82
83ASM_ENTRY(x86_trap0b)
84        TRAPENTRY(T_SEGNPFLT)
85
86ASM_ENTRY(x86_trap0c)
87        TRAPENTRY(T_STKFLT)
88
89ASM_ENTRY(x86_trap0d)
90        TRAPENTRY(T_PROTFLT)
91
92ASM_ENTRY(x86_trap0e)
93        TRAPENTRY(T_PAGEFLT)
94
95ASM_ENTRY(x86_trap0f)
96        ZTRAPENTRY(T_ASTFLT)
97
98ASM_ENTRY(x86_trap10)
99        ZTRAPENTRY(T_ARITHTRAP)
100
101ASM_ENTRY(x86_trap11)
102        TRAPENTRY(T_ALIGNFLT)
103
104ASM_ENTRY(x86_trap12)
105        ZTRAPENTRY(T_MCA)
106
107ASM_ENTRY(x86_trap13)
108        ZTRAPENTRY(T_XMM)
109
110ASM_ENTRY(x86_trap14)
111ASM_ENTRY(x86_trap15)
112ASM_ENTRY(x86_trap16)
113ASM_ENTRY(x86_trap17)
114ASM_ENTRY(x86_trap18)
115ASM_ENTRY(x86_trap19)
116ASM_ENTRY(x86_trap1a)
117ASM_ENTRY(x86_trap1b)
118ASM_ENTRY(x86_trap1c)
119ASM_ENTRY(x86_trap1d)
120ASM_ENTRY(x86_trap1e)
121ASM_ENTRY(x86_trap1f)
122ASM_ENTRY(x86_rsvd)
123        /* 20 - 31 reserved for future exp */
124        ZTRAPENTRY(T_RESERVED)
125
126        /*
127         * APIC interrupts.
128         */
129ASM_ENTRY(x86_lapic_spurious)
130        ZTRAPENTRY(T_ASTFLT)
131
132ASM_ENTRY(x86_lapic_timer)
133        pushq   $0
134        pushq   $T_ASTFLT
135        INTR_SAVE_REGS
136
137        movq    %rsp,%rdi
138        call    hal_timer_intr
139
140        movq    lapic_va(%rip),%rax
141        movl    $0,LAPIC_EOI(%rax)
142
143        INTR_RESTORE_REGS
144        addq    $16,%rsp
145        iretq
146
147ASM_ENTRY(x86_ioapic_ata0)
148        pushq   $0
149        pushq   $T_ASTFLT
150        INTR_SAVE_REGS
151
152        movq    %rsp,%rdi
153        call    ioc_ata_isr
154
155        movq    lapic_va(%rip),%rax
156        movl    $0,LAPIC_EOI(%rax)
157
158        INTR_RESTORE_REGS
159        addq    $16,%rsp
160        iretq
161
162ASM_ENTRY(x86_ioapic_com1)
163        pushq   $0
164        pushq   $T_ASTFLT
165        INTR_SAVE_REGS
166
167        movq    %rsp,%rdi
168        call    hal_com1_intr
169
170        movq    lapic_va(%rip),%rax
171        movl    $0,LAPIC_EOI(%rax)
172
173        INTR_RESTORE_REGS
174        addq    $16,%rsp
175        iretq
176
177ASM_ENTRY(x86_ioapic_keyboard)
178        pushq   $0
179        pushq   $T_ASTFLT
180        INTR_SAVE_REGS
181
182        movq    %rsp,%rdi
183        call    hal_keyboard_intr
184
185        movq    lapic_va(%rip),%rax
186        movl    $0,LAPIC_EOI(%rax)
187
188        INTR_RESTORE_REGS
189        addq    $16,%rsp
190        iretq
191
192/*
193 * Common entry point for exceptions.
194 */
195alltraps:
196        INTR_SAVE_REGS
197
198        movq    %rsp,%rdi
199        call    hal_exception_entry
200        /* NOTREACHED */
201
202        .data
203        .globl  x86_traps
204        .globl  x86_intrs
205        .type   x86_traps, @object
206        .type   x86_intrs, @object
207
208        .align  64
209x86_traps:
210        .quad   x86_trap00, x86_trap01
211        .quad   x86_trap02, x86_trap03
212        .quad   x86_trap04, x86_trap05
213        .quad   x86_trap06, x86_trap07
214        .quad   x86_trap08, x86_trap09
215        .quad   x86_trap0a, x86_trap0b
216        .quad   x86_trap0c, x86_trap0d
217        .quad   x86_trap0e, x86_trap0f
218        .quad   x86_trap10, x86_trap11
219        .quad   x86_trap12, x86_trap13
220        .quad   x86_trap14, x86_trap15
221        .quad   x86_trap16, x86_trap17
222        .quad   x86_trap18, x86_trap19
223        .quad   x86_trap1a, x86_trap1b
224        .quad   x86_trap1c, x86_trap1d
225        .quad   x86_trap1e, x86_trap1f
226
227x86_intrs:
228        .quad   x86_lapic_spurious
229        .quad   x86_lapic_timer
230        .quad   x86_ioapic_com1
231        .quad   x86_ioapic_keyboard
232
Note: See TracBrowser for help on using the repository browser.