| 1 | /* |
|---|
| 2 | * hal_kentry.S - Entry points into the kernel (traps, 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 | |
|---|
| 26 | #define TRAPENTRY(a) \ |
|---|
| 27 | pushq $(a); \ |
|---|
| 28 | jmp alltraps; |
|---|
| 29 | |
|---|
| 30 | #define ZTRAPENTRY(a) \ |
|---|
| 31 | pushq $0; \ |
|---|
| 32 | TRAPENTRY(a) |
|---|
| 33 | |
|---|
| 34 | .text |
|---|
| 35 | .globl hal_trap_entry |
|---|
| 36 | .type hal_trap_entry, @function |
|---|
| 37 | |
|---|
| 38 | ASM_ENTRY(x86_trap00) |
|---|
| 39 | ZTRAPENTRY(T_DIVIDE) |
|---|
| 40 | |
|---|
| 41 | ASM_ENTRY(x86_trap01) |
|---|
| 42 | ZTRAPENTRY(T_TRCTRAP) |
|---|
| 43 | |
|---|
| 44 | ASM_ENTRY(x86_trap02) |
|---|
| 45 | ZTRAPENTRY(T_NMI) |
|---|
| 46 | |
|---|
| 47 | ASM_ENTRY(x86_trap03) |
|---|
| 48 | ZTRAPENTRY(T_BPTFLT) |
|---|
| 49 | |
|---|
| 50 | ASM_ENTRY(x86_trap04) |
|---|
| 51 | ZTRAPENTRY(T_OFLOW) |
|---|
| 52 | |
|---|
| 53 | ASM_ENTRY(x86_trap05) |
|---|
| 54 | ZTRAPENTRY(T_BOUND) |
|---|
| 55 | |
|---|
| 56 | ASM_ENTRY(x86_trap06) |
|---|
| 57 | ZTRAPENTRY(T_PRIVINFLT) |
|---|
| 58 | |
|---|
| 59 | ASM_ENTRY(x86_trap07) |
|---|
| 60 | ZTRAPENTRY(T_DNA) |
|---|
| 61 | |
|---|
| 62 | ASM_ENTRY(x86_trap08) |
|---|
| 63 | TRAPENTRY(T_DOUBLEFLT) |
|---|
| 64 | |
|---|
| 65 | ASM_ENTRY(x86_trap09) |
|---|
| 66 | ZTRAPENTRY(T_FPOPFLT) |
|---|
| 67 | |
|---|
| 68 | ASM_ENTRY(x86_trap0a) |
|---|
| 69 | TRAPENTRY(T_TSSFLT) |
|---|
| 70 | |
|---|
| 71 | ASM_ENTRY(x86_trap0b) |
|---|
| 72 | ZTRAPENTRY(T_SEGNPFLT) |
|---|
| 73 | |
|---|
| 74 | ASM_ENTRY(x86_trap0c) |
|---|
| 75 | ZTRAPENTRY(T_STKFLT) |
|---|
| 76 | |
|---|
| 77 | ASM_ENTRY(x86_trap0d) |
|---|
| 78 | ZTRAPENTRY(T_PROTFLT) |
|---|
| 79 | |
|---|
| 80 | ASM_ENTRY(x86_trap0e) |
|---|
| 81 | TRAPENTRY(T_PAGEFLT) |
|---|
| 82 | |
|---|
| 83 | ASM_ENTRY(x86_trap0f) |
|---|
| 84 | ZTRAPENTRY(T_ASTFLT) |
|---|
| 85 | |
|---|
| 86 | ASM_ENTRY(x86_trap10) |
|---|
| 87 | ZTRAPENTRY(T_ARITHTRAP) |
|---|
| 88 | |
|---|
| 89 | ASM_ENTRY(x86_trap11) |
|---|
| 90 | TRAPENTRY(T_ALIGNFLT) |
|---|
| 91 | |
|---|
| 92 | ASM_ENTRY(x86_trap12) |
|---|
| 93 | ZTRAPENTRY(T_MCA) |
|---|
| 94 | |
|---|
| 95 | ASM_ENTRY(x86_trap13) |
|---|
| 96 | ZTRAPENTRY(T_XMM) |
|---|
| 97 | |
|---|
| 98 | ASM_ENTRY(x86_trap14) |
|---|
| 99 | ASM_ENTRY(x86_trap15) |
|---|
| 100 | ASM_ENTRY(x86_trap16) |
|---|
| 101 | ASM_ENTRY(x86_trap17) |
|---|
| 102 | ASM_ENTRY(x86_trap18) |
|---|
| 103 | ASM_ENTRY(x86_trap19) |
|---|
| 104 | ASM_ENTRY(x86_trap1a) |
|---|
| 105 | ASM_ENTRY(x86_trap1b) |
|---|
| 106 | ASM_ENTRY(x86_trap1c) |
|---|
| 107 | ASM_ENTRY(x86_trap1d) |
|---|
| 108 | ASM_ENTRY(x86_trap1e) |
|---|
| 109 | ASM_ENTRY(x86_trap1f) |
|---|
| 110 | /* 20 - 31 reserved for future exp */ |
|---|
| 111 | ZTRAPENTRY(T_RESERVED) |
|---|
| 112 | |
|---|
| 113 | /* |
|---|
| 114 | * Arguments pushed on the stack: |
|---|
| 115 | * tf_trapno |
|---|
| 116 | * tf_err: Dummy inserted if not defined |
|---|
| 117 | * tf_rip |
|---|
| 118 | * tf_cs |
|---|
| 119 | * tf_rflags |
|---|
| 120 | * tf_rsp |
|---|
| 121 | * tf_ss |
|---|
| 122 | */ |
|---|
| 123 | alltraps: |
|---|
| 124 | movq %rsp,%rdi |
|---|
| 125 | call hal_trap_entry |
|---|
| 126 | /* NOTREACHED */ |
|---|
| 127 | |
|---|
| 128 | .data |
|---|
| 129 | .globl x86_traps |
|---|
| 130 | .type x86_traps, @object |
|---|
| 131 | |
|---|
| 132 | .align 64 |
|---|
| 133 | x86_traps: |
|---|
| 134 | .quad x86_trap00, x86_trap01 |
|---|
| 135 | .quad x86_trap02, x86_trap03 |
|---|
| 136 | .quad x86_trap04, x86_trap05 |
|---|
| 137 | .quad x86_trap06, x86_trap07 |
|---|
| 138 | .quad x86_trap08, x86_trap09 |
|---|
| 139 | .quad x86_trap0a, x86_trap0b |
|---|
| 140 | .quad x86_trap0c, x86_trap0d |
|---|
| 141 | .quad x86_trap0e, x86_trap0f |
|---|
| 142 | .quad x86_trap10, x86_trap11 |
|---|
| 143 | .quad x86_trap12, x86_trap13 |
|---|
| 144 | .quad x86_trap14, x86_trap15 |
|---|
| 145 | .quad x86_trap16, x86_trap17 |
|---|
| 146 | .quad x86_trap18, x86_trap19 |
|---|
| 147 | .quad x86_trap1a, x86_trap1b |
|---|
| 148 | .quad x86_trap1c, x86_trap1d |
|---|
| 149 | .quad x86_trap1e, x86_trap1f |
|---|
| 150 | |
|---|