fix: gdt add stack

This commit is contained in:
starnakin 2024-09-10 16:37:30 +02:00
parent 07ff7f6087
commit cc9aca2595

View File

@ -50,9 +50,11 @@ void initGdt()
.base = 0, .limit = 0xFFFFF, .access_byte = 0x92, .flags = 0xC}; .base = 0, .limit = 0xFFFFF, .access_byte = 0x92, .flags = 0xC};
encodeGdtEntry(gdt_entries[2], gdt_entry_kernel_mode_data_segment); encodeGdtEntry(gdt_entries[2], gdt_entry_kernel_mode_data_segment);
struct gdt_entry gdt_entry_kernel_mode_stack_segment = { struct gdt_entry gdt_entry_kernel_mode_stack_segment = { .base = 0x0,
.base = 0x0, .limit = 0x0, .access_byte = 0x97, .flags = 0x0D}; .limit = 0x0,
encodeGdtEntry(gdt_entries[3], gdt_entry_kernel_mode_data_segment); .access_byte = 0x97,
.flags = 0x0D };
encodeGdtEntry(gdt_entries[3], gdt_entry_kernel_mode_stack_segment);
struct gdt_entry gdt_entry_user_mode_code_segment = { struct gdt_entry gdt_entry_user_mode_code_segment = {
.base = 0, .limit = 0xFFFFF, .access_byte = 0xFA, .flags = 0xC}; .base = 0, .limit = 0xFFFFF, .access_byte = 0xFA, .flags = 0xC};
@ -62,9 +64,11 @@ void initGdt()
.base = 0, .limit = 0xFFFFF, .access_byte = 0xF2, .flags = 0xC}; .base = 0, .limit = 0xFFFFF, .access_byte = 0xF2, .flags = 0xC};
encodeGdtEntry(gdt_entries[5], gdt_entry_user_mode_data_segment); encodeGdtEntry(gdt_entries[5], gdt_entry_user_mode_data_segment);
struct gdt_entry gdt_entry_user_mode_stack_segment = { struct gdt_entry gdt_entry_user_mode_stack_segment = { .base = 0x0,
.base = 0x0, .limit = 0x0, .access_byte = 0xF7, .flags = 0x0D}; .limit = 0x0,
encodeGdtEntry(gdt_entries[6], gdt_entry_user_mode_data_segment); .access_byte = 0xF7,
.flags = 0x0D };
encodeGdtEntry(gdt_entries[6], gdt_entry_user_mode_stack_segment);
memcpy((void *)gdtr.base, (void *)gdt_entries, (size_t)GDT_SIZE); memcpy((void *)gdtr.base, (void *)gdt_entries, (size_t)GDT_SIZE);