feat(gdt): add macros for generic kernel segment descriptors

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
Julien CLEMENT 2021-07-16 02:47:12 +02:00
parent ed803673c4
commit 02811acc2c
2 changed files with 5 additions and 8 deletions

10
k/gdt.c

@ -78,10 +78,7 @@ static void load_gdt(void)
static void load_ds(void) static void load_ds(void)
{ {
struct segment_selector selector; struct segment_selector selector = KERNEL_DS_SEGMENT_SELECTOR;
selector.index = KERNEL_DS_INDEX;
selector.table_indicator = 0;
selector.rpl = 0;
asm volatile("movw %0, %%ax\n" asm volatile("movw %0, %%ax\n"
"movw %%ax, %%ds\n" "movw %%ax, %%ds\n"
@ -95,10 +92,7 @@ static void load_ds(void)
static void load_cs(void) static void load_cs(void)
{ {
struct segment_selector selector; struct segment_selector selector = KERNEL_CS_SEGMENT_SELECTOR;
selector.index = KERNEL_CS_INDEX;
selector.table_indicator = 0;
selector.rpl = 0;
asm volatile("pushl %0\n" asm volatile("pushl %0\n"
"pushl $1f\n" "pushl $1f\n"

@ -9,6 +9,9 @@
#define KERNEL_CS_INDEX 1 #define KERNEL_CS_INDEX 1
#define KERNEL_DS_INDEX 2 #define KERNEL_DS_INDEX 2
#define KERNEL_CS_SEGMENT_SELECTOR {0, 0, KERNEL_CS_INDEX}
#define KERNEL_DS_SEGMENT_SELECTOR {0, 0, KERNEL_DS_INDEX}
struct gdt_entry struct gdt_entry
{ {
uint16_t limit_1 : 16; // 16 lsbs of the segment limit uint16_t limit_1 : 16; // 16 lsbs of the segment limit