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

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

start moving the APIC code into the PIC driver

File size: 4.1 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  hal_com1_intr
39        .globl  hal_keyboard_intr
40        .type   hal_exception_entry, @function
41        .type   hal_timer_intr, @function
42        .type   hal_com1_intr, @function
43        .type   hal_keyboard_intr, @function
44
45        /*
46         * General exceptions.
47         */
48ASM_ENTRY(x86_trap00)
49        ZTRAPENTRY(T_DIVIDE)
50
51ASM_ENTRY(x86_trap01)
52        ZTRAPENTRY(T_TRCTRAP)
53
54ASM_ENTRY(x86_trap02)
55        ZTRAPENTRY(T_NMI)
56
57ASM_ENTRY(x86_trap03)
58        ZTRAPENTRY(T_BPTFLT)
59
60ASM_ENTRY(x86_trap04)
61        ZTRAPENTRY(T_OFLOW)
62
63ASM_ENTRY(x86_trap05)
64        ZTRAPENTRY(T_BOUND)
65
66ASM_ENTRY(x86_trap06)
67        ZTRAPENTRY(T_PRIVINFLT)
68
69ASM_ENTRY(x86_trap07)
70        ZTRAPENTRY(T_DNA)
71
72ASM_ENTRY(x86_trap08)
73        TRAPENTRY(T_DOUBLEFLT)
74
75ASM_ENTRY(x86_trap09)
76        ZTRAPENTRY(T_FPOPFLT)
77
78ASM_ENTRY(x86_trap0a)
79        TRAPENTRY(T_TSSFLT)
80
81ASM_ENTRY(x86_trap0b)
82        TRAPENTRY(T_SEGNPFLT)
83
84ASM_ENTRY(x86_trap0c)
85        TRAPENTRY(T_STKFLT)
86
87ASM_ENTRY(x86_trap0d)
88        TRAPENTRY(T_PROTFLT)
89
90ASM_ENTRY(x86_trap0e)
91        TRAPENTRY(T_PAGEFLT)
92
93ASM_ENTRY(x86_trap0f)
94        ZTRAPENTRY(T_ASTFLT)
95
96ASM_ENTRY(x86_trap10)
97        ZTRAPENTRY(T_ARITHTRAP)
98
99ASM_ENTRY(x86_trap11)
100        TRAPENTRY(T_ALIGNFLT)
101
102ASM_ENTRY(x86_trap12)
103        ZTRAPENTRY(T_MCA)
104
105ASM_ENTRY(x86_trap13)
106        ZTRAPENTRY(T_XMM)
107
108ASM_ENTRY(x86_trap14)
109ASM_ENTRY(x86_trap15)
110ASM_ENTRY(x86_trap16)
111ASM_ENTRY(x86_trap17)
112ASM_ENTRY(x86_trap18)
113ASM_ENTRY(x86_trap19)
114ASM_ENTRY(x86_trap1a)
115ASM_ENTRY(x86_trap1b)
116ASM_ENTRY(x86_trap1c)
117ASM_ENTRY(x86_trap1d)
118ASM_ENTRY(x86_trap1e)
119ASM_ENTRY(x86_trap1f)
120ASM_ENTRY(x86_rsvd)
121        /* 20 - 31 reserved for future exp */
122        ZTRAPENTRY(T_RESERVED)
123
124        /*
125         * APIC interrupts.
126         */
127ASM_ENTRY(x86_lapic_spurious)
128        ZTRAPENTRY(T_ASTFLT)
129
130ASM_ENTRY(x86_lapic_timer)
131        pushq   $0
132        pushq   $T_ASTFLT
133        INTR_SAVE_REGS
134
135        movq    %rsp,%rdi
136        call    hal_timer_intr
137
138        movq    lapic_va(%rip),%rax
139        movl    $0,LAPIC_EOI(%rax)
140
141        INTR_RESTORE_REGS
142        addq    $16,%rsp
143        iretq
144
145ASM_ENTRY(x86_ioapic_com1)
146        pushq   $0
147        pushq   $T_ASTFLT
148        INTR_SAVE_REGS
149
150        movq    %rsp,%rdi
151        call    hal_com1_intr
152
153        movq    lapic_va(%rip),%rax
154        movl    $0,LAPIC_EOI(%rax)
155
156        INTR_RESTORE_REGS
157        addq    $16,%rsp
158        iretq
159
160ASM_ENTRY(x86_ioapic_keyboard)
161        pushq   $0
162        pushq   $T_ASTFLT
163        INTR_SAVE_REGS
164
165        movq    %rsp,%rdi
166        call    hal_keyboard_intr
167
168        movq    lapic_va(%rip),%rax
169        movl    $0,LAPIC_EOI(%rax)
170
171        INTR_RESTORE_REGS
172        addq    $16,%rsp
173        iretq
174
175/*
176 * Arguments pushed on the stack:
177 *  tf_trapno
178 *  tf_err: Dummy inserted if not defined
179 *  tf_rip
180 *  tf_cs
181 *  tf_rflags
182 *  tf_rsp
183 *  tf_ss
184 */
185alltraps:
186        movq    %rsp,%rdi
187        call    hal_exception_entry
188        /* NOTREACHED */
189
190        .data
191        .globl  x86_traps
192        .globl  x86_intrs
193        .type   x86_traps, @object
194        .type   x86_intrs, @object
195
196        .align  64
197x86_traps:
198        .quad   x86_trap00, x86_trap01
199        .quad   x86_trap02, x86_trap03
200        .quad   x86_trap04, x86_trap05
201        .quad   x86_trap06, x86_trap07
202        .quad   x86_trap08, x86_trap09
203        .quad   x86_trap0a, x86_trap0b
204        .quad   x86_trap0c, x86_trap0d
205        .quad   x86_trap0e, x86_trap0f
206        .quad   x86_trap10, x86_trap11
207        .quad   x86_trap12, x86_trap13
208        .quad   x86_trap14, x86_trap15
209        .quad   x86_trap16, x86_trap17
210        .quad   x86_trap18, x86_trap19
211        .quad   x86_trap1a, x86_trap1b
212        .quad   x86_trap1c, x86_trap1d
213        .quad   x86_trap1e, x86_trap1f
214
215x86_intrs:
216        .quad   x86_lapic_spurious
217        .quad   x86_lapic_timer
218        .quad   x86_ioapic_com1
219        .quad   x86_ioapic_keyboard
220
Note: See TracBrowser for help on using the repository browser.