fix (kernel): made GDT selctors an enum
This commit is contained in:
parent
bbf798c644
commit
45f18251a9
|
@ -18,6 +18,15 @@
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
#include "utils/stdtypes.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GDT_SELECTOR_NULL = 0x00,
|
||||||
|
GDT_SELECTOR_KERNEL_CODE = 0x08,
|
||||||
|
GDT_SELECTOR_KERNEL_DATA = 0x10,
|
||||||
|
GDT_SELECTOR_USER_NULL = 0x18,
|
||||||
|
GDT_SELECTOR_USER_CODE = 0x20,
|
||||||
|
GDT_SELECTOR_USER_DATA = 0x28
|
||||||
|
} gdt_selector_E;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t size;
|
uint16_t size;
|
||||||
uint64_t offset;
|
uint64_t offset;
|
||||||
|
|
|
@ -37,6 +37,8 @@ typedef struct {
|
||||||
uint32_t ignore;
|
uint32_t ignore;
|
||||||
} idt_descriptor_entry_T;
|
} idt_descriptor_entry_T;
|
||||||
|
|
||||||
|
extern idt_register_T g_idt_register;
|
||||||
|
|
||||||
void idt_init();
|
void idt_init();
|
||||||
|
|
||||||
#endif //NOX_INTERRUPTS_H
|
#endif //NOX_INTERRUPTS_H
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "platform/interrupts.h"
|
#include "platform/interrupts.h"
|
||||||
#include "platform/cpu.h"
|
#include "platform/cpu.h"
|
||||||
|
#include "platform/gdt.h"
|
||||||
#include "platform/exceptions.h"
|
#include "platform/exceptions.h"
|
||||||
#include "mm/page_frame.h"
|
#include "mm/page_frame.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
@ -81,38 +82,38 @@ void idt_init() {
|
||||||
g_idt_register.offset = (uint64_t)pframe_request();
|
g_idt_register.offset = (uint64_t)pframe_request();
|
||||||
|
|
||||||
|
|
||||||
idt_set_gate((void*)interrupt_stub_0x00, 0x00, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x00, 0x00, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x01, 0x01, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x01, 0x01, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x02, 0x02, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x02, 0x02, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x03, 0x03, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x03, 0x03, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x04, 0x04, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x04, 0x04, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x05, 0x05, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x05, 0x05, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x06, 0x06, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x06, 0x06, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x07, 0x07, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x07, 0x07, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x08, 0x08, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x08, 0x08, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x09, 0x09, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x09, 0x09, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x0A, 0x0A, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x0A, 0x0A, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x0B, 0x0B, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x0B, 0x0B, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x0C, 0x0C, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x0C, 0x0C, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x0D, 0x0D, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x0D, 0x0D, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x0E, 0x0E, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x0E, 0x0E, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x0F, 0x0F, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x0F, 0x0F, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x10, 0x10, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x10, 0x10, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x11, 0x11, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x11, 0x11, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x12, 0x12, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x12, 0x12, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x13, 0x13, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x13, 0x13, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x14, 0x14, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x14, 0x14, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x15, 0x15, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x15, 0x15, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x16, 0x16, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x16, 0x16, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x17, 0x17, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x17, 0x17, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x18, 0x18, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x18, 0x18, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x19, 0x19, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x19, 0x19, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x1A, 0x1A, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x1A, 0x1A, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x1B, 0x1B, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x1B, 0x1B, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x1C, 0x1C, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x1C, 0x1C, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x1D, 0x1D, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x1D, 0x1D, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x1E, 0x1E, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x1E, 0x1E, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
idt_set_gate((void*)interrupt_stub_0x1F, 0x1F, IDT_ENTRY_INTR_GATE, 0x08);
|
idt_set_gate((void*)interrupt_stub_0x1F, 0x1F, IDT_ENTRY_INTR_GATE, GDT_SELECTOR_KERNEL_CODE);
|
||||||
|
|
||||||
idt_load(&g_idt_register);
|
idt_load(&g_idt_register);
|
||||||
log(LOG_INFO, "Interrupts initialized");
|
log(LOG_INFO, "Interrupts initialized");
|
||||||
|
@ -123,7 +124,6 @@ cpu_state_T* interrupts_handle(cpu_state_T* state) {
|
||||||
return exception_handle(state);
|
return exception_handle(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
log(LOG_WARNING, "Non exception interrupt detected");
|
log(LOG_WARNING, "Non exception interrupt detected");
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
|
|
Loading…
Reference in New Issue