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

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

Add a basic syscall entry.

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