| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- /* arch/x86/kernel/arch_int.c
- *
- * This file is part of evx.
- *
- * evx is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * evx is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with evx. If not, see <https://www.gnu.org/licenses/>
- */
- #include <kernel/init.h>
- #include <kernel/module.h>
- #include <kernel/mm.h>
- #include <kernel/kernel.h>
- #include <kernel/kmlog.h>
- #include <arch/archinfo.h>
- #include <arch/mm.h>
- #include <arch/int.h>
- #include <arch/string.h>
- #include <sys/types.h>
- #include <config.h>
- /* head$(BITS).S */
- /* extern struct idt_entry *idt; things interesting.
- * a struct idt_entry *idt, and that is a pointer. idt, is
- * the address.
- *
- * a struct idt_entry idt[], and that is an array. */
- extern struct idt_entry idt[256];
- static int set_gate(struct idt_entry *, void (*) (void), int attr);
- /* set the handlers for traps, 0 - 31 */
- int __init arch_traps_init(void) {
- set_gate(idt + 0x80, NULL, 0x8e);
- return 0;
- }
- static int set_gate(struct idt_entry *entry, void (* handler) (void), int attr) {
- /* no ist support in long-mode, well, that's not so useful */
- __archptr_t p = (__archptr_t) handler;
- entry->off_0 = p & 0xffffu;
- entry->seg = 8;
- #if CONFIG_64BIT
- entry->ist =
- #else
- entry->resv =
- #endif
- 0;
- entry->attr = attr;
- entry->off_1 = (p >> 16u) & 0xffffu;
- #if CONFIG_64BIT
- entry->off_2 = p >> 32u;
- entry->zero = 0;
- #endif
- return 0;
- }
- arch_init(arch_traps_init);
|