From 975a9ec96e282e437ccc1bdf1e660dcbf4542791 Mon Sep 17 00:00:00 2001 From: EmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com> Date: Fri, 10 May 2024 01:44:59 -0400 Subject: Added GDT and basic IDT as well as a bitmap drawing function --- kernel/arch/x86_64/gdt.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 kernel/arch/x86_64/gdt.h (limited to 'kernel/arch/x86_64/gdt.h') diff --git a/kernel/arch/x86_64/gdt.h b/kernel/arch/x86_64/gdt.h new file mode 100644 index 0000000..4f68977 --- /dev/null +++ b/kernel/arch/x86_64/gdt.h @@ -0,0 +1,38 @@ +#ifndef GDT_H +#define GDT_H + +#include + +struct GDTR { + uint16_t size; + uint64_t offset; +}__attribute__((packed)); + +struct SegDesc { + uint16_t limit_low; + uint16_t base_low; + uint8_t base_mid; + uint8_t access; + uint8_t flag_limit_high; + uint8_t base_high; +}__attribute__((packed)); + +// tss segment descriptor is larger than the normal ones +struct TssSegDesc { + uint16_t limit_low; + uint16_t base1; // lowest base + uint8_t base2; + uint8_t access; + uint8_t flag_limit_high; // both in the same 8 bits + uint8_t base3; + uint32_t base4; // highest base + uint32_t reserved; +}__attribute__((packed)); + +void gdt_entry(SegDesc* seg, uint32_t base, uint32_t limit, uint8_t access, uint8_t flags); +void gdt_tss_entry(TssSegDesc* seg, uint64_t base, uint32_t limit, uint8_t access, uint8_t flags); + +extern "C" void load_gdt(GDTR*); +extern "C" void reload_segments(); + +#endif \ No newline at end of file -- cgit v1.2.3-70-g09d2