aboutsummaryrefslogtreecommitdiff
path: root/src/boot/boot.S
diff options
context:
space:
mode:
Diffstat (limited to 'src/boot/boot.S')
-rw-r--r--src/boot/boot.S26
1 files changed, 25 insertions, 1 deletions
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