refactor: add architecture
This commit is contained in:
+4
-38
@@ -1,5 +1,4 @@
|
||||
#include "gdt.hpp"
|
||||
#include "task.hpp"
|
||||
#include "arch/arch.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
static volatile u16* const s_vga = reinterpret_cast<volatile u16*>(0xB8000);
|
||||
@@ -17,46 +16,13 @@ static inline void puts(const char* str, u8 row, u8 col) {
|
||||
s_vga[col + off + (VGA_COLS * row)] = 0x0700 | str[off];
|
||||
}
|
||||
|
||||
static constexpr tss s_tss{};
|
||||
|
||||
static gdt_entry s_gdt[] = {
|
||||
// Null Descriptor
|
||||
gdt_entry{ 0, 0, 0, 0 },
|
||||
// Kernel Mode Code Segment
|
||||
gdt_entry{ 0,
|
||||
0xFFFFF,
|
||||
gdt_entry::ACCESS_P | gdt_entry::ACCESS_DPL0 | gdt_entry::ACCESS_S | gdt_entry::ACCESS_E | gdt_entry::ACCESS_RW,
|
||||
gdt_entry::FLAG_G | gdt_entry::FLAG_L },
|
||||
// Kernel Mode Data Segment
|
||||
gdt_entry{ 0,
|
||||
0xFFFFF,
|
||||
gdt_entry::ACCESS_P | gdt_entry::ACCESS_DPL0 | gdt_entry::ACCESS_S | gdt_entry::ACCESS_RW,
|
||||
gdt_entry::FLAG_G | gdt_entry::FLAG_DB },
|
||||
// User Mode Data Segment
|
||||
gdt_entry{ 0,
|
||||
0xFFFFF,
|
||||
gdt_entry::ACCESS_P | gdt_entry::ACCESS_DPL3 | gdt_entry::ACCESS_S | gdt_entry::ACCESS_RW,
|
||||
gdt_entry::FLAG_G | gdt_entry::FLAG_DB },
|
||||
// User Mode Code Segment
|
||||
gdt_entry{ 0,
|
||||
0xFFFFF,
|
||||
gdt_entry::ACCESS_P | gdt_entry::ACCESS_DPL3 | gdt_entry::ACCESS_S | gdt_entry::ACCESS_E | gdt_entry::ACCESS_RW,
|
||||
gdt_entry::FLAG_G | gdt_entry::FLAG_L },
|
||||
// Task State Segment
|
||||
gdt_entry{ static_cast<u32>(reinterpret_cast<u64>(&s_tss) & 0xFFFFFFFF),
|
||||
sizeof(s_tss) - 1,
|
||||
gdt_entry::ACCESS_P | gdt_entry::ACCESS_E | gdt_entry::ACCESS_A,
|
||||
0 },
|
||||
gdt_entry{ static_cast<u32>(reinterpret_cast<u64>(&s_tss) >> 32) }
|
||||
};
|
||||
|
||||
extern "C" void kmain(void) {
|
||||
clrsc();
|
||||
|
||||
load_gdt(s_gdt, sizeof(s_gdt));
|
||||
reload_segments(0x8, 0x10);
|
||||
arch* arch = arch::get();
|
||||
arch->init();
|
||||
|
||||
puts("Loaded GDT!", 0, 0);
|
||||
puts("TowOS initialized!", 0, 0);
|
||||
puts("Zdravstvuyte, tovarisch!", 1, 0);
|
||||
|
||||
for (;;)
|
||||
|
||||
Reference in New Issue
Block a user