Commit Diff


commit - 74abebcec4b1333d222c56edcad978061b82c4d2
commit + 5cd42ecdae41f3fa8dcabb0b4c33fc01dfc78db7
blob - 2e164902d3ff80a682fa604b5ffe8eb16e8fc449
blob + be79d53efc80383547d6a0a19297bceba9872599
--- sys/kernel.asm
+++ sys/kernel.asm
@@ -162,6 +162,10 @@ _entry:
 	; load TSS into TR
 	lea ax, [gdt.tss - gdt]
 	ltr ax
+
+	; load LDT
+	lea ax, [gdt.ldt - gdt]
+	lldt ax
 
 	; enter userspace, TODO: enter ring 3
 	lea ax, [gdt.data - gdt]
@@ -393,8 +397,37 @@ gdt:
 	db 0x81
 	dw 0x0000
 
+.ldt:	; 0x28 - LDT
+	dw (ldt.end - ldt)
+	dw ldt
+	db 0x01
+	db 0x82
+	dw 0x0000
 .end:
 
+ldt:
+.text:	; 0x07 - user code
+	dw 0xffff
+	dw 0x0000
+	db 0x02
+	db 0xfa
+	dw 0x0000
+
+.data:	; 0x0f - user data
+	dw 0xffff
+	dw 0x0000
+	db 0x02
+	db 0xf2
+	dw 0x0000
+
+.stack:	; 0x17 - user stack
+	dw 0xffff
+	dw 0x0000
+	db 0x03
+	db 0xf2
+	dw 0x0000
+.end:
+
 section .bss
 posx:
 	resw 1