From ba7e57138c9e41cf944afb91c146fea23713c1d1 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Mon, 5 Apr 2021 14:46:31 +0200 Subject: Reload GDT --- src/boot/boot.S | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/boot') diff --git a/src/boot/boot.S b/src/boot/boot.S index 746f858..e3830eb 100644 --- a/src/boot/boot.S +++ b/src/boot/boot.S @@ -1,4 +1,5 @@ .extern bringelle +.extern gdt_memcpy .globl _start .text @@ -23,5 +24,28 @@ mb_header: .long MB_ENTRY_ADDR _start: - call bringelle + +# Copy GDT into memory then load its register +call gdt_memcpy +lgdtl (GDTR) + +# Update all segments register +# with the new GDT offset +movw $0x10, %ax +movw %ax, %ds +movw %ax, %es +movw %ax, %fs +movw %ax, %gs + +# Update code segment +ljmp $0x08, $cs_new +cs_new: + +# Update stack segment +movw $0x18, %ax +movw %ax, %ss +movl $0x20000,%esp + +# Start kernel main function +call bringelle -- cgit v1.2.3