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

Last change on this file since 226 was 220, checked in by max@…, 7 years ago

use the asm entry point to save the context

File size: 4.3 KB
RevLine 
[25]1/*
[145]2 * hal_kentry.S - Entry points into the kernel (exceptions/interrupts/syscalls)
3 *
[29]4 * Copyright (c) 2017 Maxime Villard
[145]5 *
[25]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
[29]18 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
[25]19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
[29]22#define x86_ASM
23#include <hal_boot.h>
24#include <hal_kentry.h>
[86]25#include <hal_apic.h>
[25]26
[29]27#define TRAPENTRY(a)    \
[86]28        pushq   $(a);   \
29        jmp     alltraps;
[25]30
[29]31#define ZTRAPENTRY(a) \
[86]32        pushq   $0; \
[29]33        TRAPENTRY(a)
[25]34
[29]35        .text
[142]36        .globl  hal_exception_entry
[86]37        .globl  hal_timer_intr
[220]38        .globl  ioc_ata_isr
[152]39        .globl  hal_com1_intr
[89]40        .globl  hal_keyboard_intr
[142]41        .type   hal_exception_entry, @function
[86]42        .type   hal_timer_intr, @function
[220]43        .type   ioc_ata_isr, @function
[152]44        .type   hal_com1_intr, @function
[89]45        .type   hal_keyboard_intr, @function
[25]46
[45]47        /*
48         * General exceptions.
49         */
[29]50ASM_ENTRY(x86_trap00)
51        ZTRAPENTRY(T_DIVIDE)
[25]52
[29]53ASM_ENTRY(x86_trap01)
54        ZTRAPENTRY(T_TRCTRAP)
[25]55
[29]56ASM_ENTRY(x86_trap02)
57        ZTRAPENTRY(T_NMI)
[25]58
[29]59ASM_ENTRY(x86_trap03)
60        ZTRAPENTRY(T_BPTFLT)
[25]61
[29]62ASM_ENTRY(x86_trap04)
63        ZTRAPENTRY(T_OFLOW)
[25]64
[29]65ASM_ENTRY(x86_trap05)
66        ZTRAPENTRY(T_BOUND)
[25]67
[29]68ASM_ENTRY(x86_trap06)
69        ZTRAPENTRY(T_PRIVINFLT)
[25]70
[29]71ASM_ENTRY(x86_trap07)
72        ZTRAPENTRY(T_DNA)
[25]73
[29]74ASM_ENTRY(x86_trap08)
75        TRAPENTRY(T_DOUBLEFLT)
[25]76
[29]77ASM_ENTRY(x86_trap09)
78        ZTRAPENTRY(T_FPOPFLT)
[25]79
[29]80ASM_ENTRY(x86_trap0a)
81        TRAPENTRY(T_TSSFLT)
[25]82
[29]83ASM_ENTRY(x86_trap0b)
[82]84        TRAPENTRY(T_SEGNPFLT)
[25]85
[29]86ASM_ENTRY(x86_trap0c)
[82]87        TRAPENTRY(T_STKFLT)
[25]88
[29]89ASM_ENTRY(x86_trap0d)
[82]90        TRAPENTRY(T_PROTFLT)
[25]91
[29]92ASM_ENTRY(x86_trap0e)
93        TRAPENTRY(T_PAGEFLT)
[25]94
[29]95ASM_ENTRY(x86_trap0f)
96        ZTRAPENTRY(T_ASTFLT)
[25]97
[29]98ASM_ENTRY(x86_trap10)
99        ZTRAPENTRY(T_ARITHTRAP)
[25]100
[29]101ASM_ENTRY(x86_trap11)
102        TRAPENTRY(T_ALIGNFLT)
[25]103
[29]104ASM_ENTRY(x86_trap12)
105        ZTRAPENTRY(T_MCA)
[25]106
[29]107ASM_ENTRY(x86_trap13)
108        ZTRAPENTRY(T_XMM)
[25]109
[29]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)
[80]122ASM_ENTRY(x86_rsvd)
[29]123        /* 20 - 31 reserved for future exp */
124        ZTRAPENTRY(T_RESERVED)
[25]125
[45]126        /*
[89]127         * APIC interrupts.
[45]128         */
[86]129ASM_ENTRY(x86_lapic_spurious)
[45]130        ZTRAPENTRY(T_ASTFLT)
131
[86]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
[220]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
[152]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
[89]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
[29]192/*
193 * Arguments pushed on the stack:
194 *  tf_trapno
195 *  tf_err: Dummy inserted if not defined
196 *  tf_rip
197 *  tf_cs
198 *  tf_rflags
199 *  tf_rsp
200 *  tf_ss
201 */
202alltraps:
203        movq    %rsp,%rdi
[142]204        call    hal_exception_entry
[29]205        /* NOTREACHED */
[25]206
[29]207        .data
208        .globl  x86_traps
[45]209        .globl  x86_intrs
[29]210        .type   x86_traps, @object
[45]211        .type   x86_intrs, @object
[25]212
[29]213        .align  64
214x86_traps:
215        .quad   x86_trap00, x86_trap01
216        .quad   x86_trap02, x86_trap03
217        .quad   x86_trap04, x86_trap05
218        .quad   x86_trap06, x86_trap07
219        .quad   x86_trap08, x86_trap09
220        .quad   x86_trap0a, x86_trap0b
221        .quad   x86_trap0c, x86_trap0d
222        .quad   x86_trap0e, x86_trap0f
223        .quad   x86_trap10, x86_trap11
224        .quad   x86_trap12, x86_trap13
225        .quad   x86_trap14, x86_trap15
226        .quad   x86_trap16, x86_trap17
227        .quad   x86_trap18, x86_trap19
228        .quad   x86_trap1a, x86_trap1b
229        .quad   x86_trap1c, x86_trap1d
230        .quad   x86_trap1e, x86_trap1f
231
[45]232x86_intrs:
[86]233        .quad   x86_lapic_spurious
234        .quad   x86_lapic_timer
[152]235        .quad   x86_ioapic_com1
[89]236        .quad   x86_ioapic_keyboard
[45]237
Note: See TracBrowser for help on using the repository browser.