/* 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
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
/* 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);