[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 | /* |
---|
| 48 | * General exceptions. |
---|
| 49 | */ |
---|
[29] | 50 | ASM_ENTRY(x86_trap00) |
---|
| 51 | ZTRAPENTRY(T_DIVIDE) |
---|
[25] | 52 | |
---|
[29] | 53 | ASM_ENTRY(x86_trap01) |
---|
| 54 | ZTRAPENTRY(T_TRCTRAP) |
---|
[25] | 55 | |
---|
[29] | 56 | ASM_ENTRY(x86_trap02) |
---|
| 57 | ZTRAPENTRY(T_NMI) |
---|
[25] | 58 | |
---|
[29] | 59 | ASM_ENTRY(x86_trap03) |
---|
| 60 | ZTRAPENTRY(T_BPTFLT) |
---|
[25] | 61 | |
---|
[29] | 62 | ASM_ENTRY(x86_trap04) |
---|
| 63 | ZTRAPENTRY(T_OFLOW) |
---|
[25] | 64 | |
---|
[29] | 65 | ASM_ENTRY(x86_trap05) |
---|
| 66 | ZTRAPENTRY(T_BOUND) |
---|
[25] | 67 | |
---|
[29] | 68 | ASM_ENTRY(x86_trap06) |
---|
| 69 | ZTRAPENTRY(T_PRIVINFLT) |
---|
[25] | 70 | |
---|
[29] | 71 | ASM_ENTRY(x86_trap07) |
---|
| 72 | ZTRAPENTRY(T_DNA) |
---|
[25] | 73 | |
---|
[29] | 74 | ASM_ENTRY(x86_trap08) |
---|
| 75 | TRAPENTRY(T_DOUBLEFLT) |
---|
[25] | 76 | |
---|
[29] | 77 | ASM_ENTRY(x86_trap09) |
---|
| 78 | ZTRAPENTRY(T_FPOPFLT) |
---|
[25] | 79 | |
---|
[29] | 80 | ASM_ENTRY(x86_trap0a) |
---|
| 81 | TRAPENTRY(T_TSSFLT) |
---|
[25] | 82 | |
---|
[29] | 83 | ASM_ENTRY(x86_trap0b) |
---|
[82] | 84 | TRAPENTRY(T_SEGNPFLT) |
---|
[25] | 85 | |
---|
[29] | 86 | ASM_ENTRY(x86_trap0c) |
---|
[82] | 87 | TRAPENTRY(T_STKFLT) |
---|
[25] | 88 | |
---|
[29] | 89 | ASM_ENTRY(x86_trap0d) |
---|
[82] | 90 | TRAPENTRY(T_PROTFLT) |
---|
[25] | 91 | |
---|
[29] | 92 | ASM_ENTRY(x86_trap0e) |
---|
| 93 | TRAPENTRY(T_PAGEFLT) |
---|
[25] | 94 | |
---|
[29] | 95 | ASM_ENTRY(x86_trap0f) |
---|
| 96 | ZTRAPENTRY(T_ASTFLT) |
---|
[25] | 97 | |
---|
[29] | 98 | ASM_ENTRY(x86_trap10) |
---|
| 99 | ZTRAPENTRY(T_ARITHTRAP) |
---|
[25] | 100 | |
---|
[29] | 101 | ASM_ENTRY(x86_trap11) |
---|
| 102 | TRAPENTRY(T_ALIGNFLT) |
---|
[25] | 103 | |
---|
[29] | 104 | ASM_ENTRY(x86_trap12) |
---|
| 105 | ZTRAPENTRY(T_MCA) |
---|
[25] | 106 | |
---|
[29] | 107 | ASM_ENTRY(x86_trap13) |
---|
| 108 | ZTRAPENTRY(T_XMM) |
---|
[25] | 109 | |
---|
[29] | 110 | ASM_ENTRY(x86_trap14) |
---|
| 111 | ASM_ENTRY(x86_trap15) |
---|
| 112 | ASM_ENTRY(x86_trap16) |
---|
| 113 | ASM_ENTRY(x86_trap17) |
---|
| 114 | ASM_ENTRY(x86_trap18) |
---|
| 115 | ASM_ENTRY(x86_trap19) |
---|
| 116 | ASM_ENTRY(x86_trap1a) |
---|
| 117 | ASM_ENTRY(x86_trap1b) |
---|
| 118 | ASM_ENTRY(x86_trap1c) |
---|
| 119 | ASM_ENTRY(x86_trap1d) |
---|
| 120 | ASM_ENTRY(x86_trap1e) |
---|
| 121 | ASM_ENTRY(x86_trap1f) |
---|
[80] | 122 | ASM_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] | 129 | ASM_ENTRY(x86_lapic_spurious) |
---|
[45] | 130 | ZTRAPENTRY(T_ASTFLT) |
---|
| 131 | |
---|
[86] | 132 | ASM_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] | 147 | ASM_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] | 162 | ASM_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] | 177 | ASM_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 | /* |
---|
[233] | 193 | * Common entry point for exceptions. |
---|
[29] | 194 | */ |
---|
| 195 | alltraps: |
---|
[233] | 196 | INTR_SAVE_REGS |
---|
| 197 | |
---|
[29] | 198 | movq %rsp,%rdi |
---|
[142] | 199 | call hal_exception_entry |
---|
[29] | 200 | /* NOTREACHED */ |
---|
[25] | 201 | |
---|
[29] | 202 | .data |
---|
| 203 | .globl x86_traps |
---|
[45] | 204 | .globl x86_intrs |
---|
[29] | 205 | .type x86_traps, @object |
---|
[45] | 206 | .type x86_intrs, @object |
---|
[25] | 207 | |
---|
[29] | 208 | .align 64 |
---|
| 209 | x86_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 | |
---|
[45] | 227 | x86_intrs: |
---|
[86] | 228 | .quad x86_lapic_spurious |
---|
| 229 | .quad x86_lapic_timer |
---|
[152] | 230 | .quad x86_ioapic_com1 |
---|
[89] | 231 | .quad x86_ioapic_keyboard |
---|
[45] | 232 | |
---|