No more double faults B-)

This commit is contained in:
2024-08-07 13:38:21 +02:00
parent cf7a7303e3
commit 1e385af53c
16 changed files with 496 additions and 155 deletions

View File

@@ -1,11 +1,13 @@
#pragma once
#include <stdint.h>
#include "types.h"
struct __attribute__((packed)) idt_gate_descriptor {
uint16_t offset_0;
uint16_t segment_selector;
uint8_t ist;
uint8_t ist; // unused in 32-bit
/* `flags`
=======
@@ -20,22 +22,26 @@ struct __attribute__((packed)) idt_gate_descriptor {
uint16_t offset_1;
};
_Static_assert(sizeof(struct idt_gate_descriptor) == 8);
enum idt_flags : uint8_t {
IDT_GATE_TYPE_TASK_GATE = 0x5,
IDT_GATE_TYPE_INTERUPT_GATE_16 = 0x6,
IDT_GATE_TYPE_TRAP_GATE_16 = 0x7,
IDT_GATE_TYPE_INTERUPT_GATE_32 = 0xE,
IDT_GATE_TYPE_TRAP_GATE_32 = 0xF,
IDT_GATE_TYPE_TASK = 0x5,
IDT_GATE_TYPE_INTERRUPT16 = 0x6,
IDT_GATE_TYPE_TRAP16 = 0x7,
IDT_GATE_TYPE_INTERRUPT32 = 0xE,
IDT_GATE_TYPE_TRAP32 = 0xF,
IDT_PRESENT = 1 << 7,
};
enum idt_dpl : uint8_t {
IDT_DPL_0 = 0 << 5,
IDT_DPL_1 = 1 << 5,
IDT_DPL_2 = 2 << 5,
IDT_DPL_3 = 3 << 5,
IDT_PRESENT = 1 << 7,
};
struct idt_gate_descriptor idt_encode_descriptor(uint32_t offset, uint16_t segment_selector, uint8_t ist, enum idt_flags type);
struct idt_gate_descriptor idt_encode_descriptor(void* func, segment_t segment_selector, enum idt_dpl dpl, enum idt_flags type);
void idt_load(struct idt_gate_descriptor table[], uint16_t size);