core: use define for gdt offset
This commit is contained in:
parent
64a3f6ee0d
commit
a3bbffcfd9
@ -30,3 +30,12 @@ void init_gdt();
|
||||
#define GDT_ACCESS_RW_READABLE_FOR_CODE_WRITABLE_FOR_DATA 0b00000010
|
||||
#define GDT_ACCESS_A_ACCESSED 0b00000001
|
||||
#define GDT_ACCESS_A_NOT_ACCESSED 0b00000000
|
||||
|
||||
extern uint8_t gdt_entries[GDT_SIZE * 8];
|
||||
|
||||
#define GDT_OFFSET_KERNEL_CODE 0x08
|
||||
#define GDT_OFFSET_KERNEL_DATA 0x10
|
||||
#define GDT_OFFSET_KERNEL_STACK 0x18
|
||||
#define GDT_OFFSET_USER_CODE 0x20
|
||||
#define GDT_OFFSET_USER_DATA 0x28
|
||||
#define GDT_OFFSET_USER_STACK 0x30
|
||||
|
@ -42,7 +42,7 @@ void init_gdt(void)
|
||||
set_gdt_entry_value(gdt_entries + 0x00, 0, 0, 0, 0); // Null segment
|
||||
|
||||
set_gdt_entry_value(
|
||||
gdt_entries + 0x08, 0, 0xFFFFF,
|
||||
gdt_entries + GDT_OFFSET_KERNEL_CODE, 0, 0xFFFFF,
|
||||
GDT_ACCESS_P_VALID | GDT_ACCESS_DPL_KERNEL_MODE |
|
||||
GDT_ACCESS_S_CODE_OR_DATA | GDT_ACCESS_E_EXECUTABLE |
|
||||
GDT_ACCESS_DC_NOT_CONFORM |
|
||||
@ -50,7 +50,7 @@ void init_gdt(void)
|
||||
GDT_ACCESS_A_ACCESSED,
|
||||
GDT_FLAG_32BIT_MODE | GDT_FLAG_PAGE_MODE); // Kernel code
|
||||
set_gdt_entry_value(
|
||||
gdt_entries + 0x10, 0, 0xFFFFF,
|
||||
gdt_entries + GDT_OFFSET_KERNEL_DATA, 0, 0xFFFFF,
|
||||
GDT_ACCESS_P_VALID | GDT_ACCESS_DPL_KERNEL_MODE |
|
||||
GDT_ACCESS_S_CODE_OR_DATA | GDT_ACCESS_E_NOT_EXECUTABLE |
|
||||
GDT_ACCESS_DC_NOT_CONFORM |
|
||||
@ -58,7 +58,7 @@ void init_gdt(void)
|
||||
GDT_ACCESS_A_ACCESSED,
|
||||
GDT_FLAG_32BIT_MODE | GDT_FLAG_PAGE_MODE); // Kernel data
|
||||
set_gdt_entry_value(
|
||||
gdt_entries + 0x18, 0, 0xFFFFF,
|
||||
gdt_entries + GDT_OFFSET_KERNEL_STACK, 0, 0xFFFFF,
|
||||
GDT_ACCESS_P_VALID | GDT_ACCESS_DPL_KERNEL_MODE |
|
||||
GDT_ACCESS_S_CODE_OR_DATA | GDT_ACCESS_E_NOT_EXECUTABLE |
|
||||
GDT_ACCESS_DC_CONFORM |
|
||||
@ -67,7 +67,7 @@ void init_gdt(void)
|
||||
GDT_FLAG_32BIT_MODE | GDT_FLAG_PAGE_MODE); // Kernel stack
|
||||
|
||||
set_gdt_entry_value(
|
||||
gdt_entries + 0x20, 0, 0xFFFFF,
|
||||
gdt_entries + GDT_OFFSET_USER_CODE, 0, 0xFFFFF,
|
||||
GDT_ACCESS_P_VALID | GDT_ACCESS_DPL_USER_MODE |
|
||||
GDT_ACCESS_S_CODE_OR_DATA | GDT_ACCESS_E_EXECUTABLE |
|
||||
GDT_ACCESS_DC_CONFORM |
|
||||
@ -75,7 +75,7 @@ void init_gdt(void)
|
||||
GDT_ACCESS_A_ACCESSED,
|
||||
GDT_FLAG_32BIT_MODE | GDT_FLAG_PAGE_MODE); // User code
|
||||
set_gdt_entry_value(
|
||||
gdt_entries + 0x28, 0, 0xFFFFF,
|
||||
gdt_entries + GDT_OFFSET_USER_DATA, 0, 0xFFFFF,
|
||||
GDT_ACCESS_P_VALID | GDT_ACCESS_DPL_USER_MODE |
|
||||
GDT_ACCESS_S_CODE_OR_DATA | GDT_ACCESS_E_NOT_EXECUTABLE |
|
||||
GDT_ACCESS_DC_NOT_CONFORM |
|
||||
@ -83,7 +83,7 @@ void init_gdt(void)
|
||||
GDT_ACCESS_A_ACCESSED,
|
||||
GDT_FLAG_32BIT_MODE | GDT_FLAG_PAGE_MODE); // User data
|
||||
set_gdt_entry_value(
|
||||
gdt_entries + 0x30, 0, 0xFFFFF,
|
||||
gdt_entries + GDT_OFFSET_USER_STACK, 0, 0xFFFFF,
|
||||
GDT_ACCESS_P_VALID | GDT_ACCESS_DPL_USER_MODE |
|
||||
GDT_ACCESS_S_CODE_OR_DATA | GDT_ACCESS_E_NOT_EXECUTABLE |
|
||||
GDT_ACCESS_DC_CONFORM |
|
||||
|
Loading…
Reference in New Issue
Block a user