diff options
Diffstat (limited to 'src/gdt.asm')
-rw-r--r-- | src/gdt.asm | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/gdt.asm b/src/gdt.asm new file mode 100644 index 0000000..15fe924 --- /dev/null +++ b/src/gdt.asm @@ -0,0 +1,43 @@ +; GDT global descriptor table + +gdt_start: + +; mandatory null entry +gdt_null: + dd 0x0 + dd 0x0 + +; code segment +; base=0x0, limit=0xfffff +; flags: present (not paged), ring 0, executable, direction bit +; conforming, writable, not accessed +; granularity: 4kb pages, 32-bit mode, no 64-bit segment, AVL would +; be for our own extensions +gdt_code: + dw 0xffff + dw 0x0 + db 0x0 + db 10011010b + db 11001111b + db 0x0 + +; flat model, same as code segment, but flags are +; flags: ring 0, +gdt_data: + dw 0xffff + dw 0x0 + db 0x0 + db 10010010b + db 11001111b + db 0x0 + +gdt_end: + +gdt_descriptor: + dw gdt_end -gdt_start - 1 ; size + dd gdt_start ; start address of the GDT + +; constants representing the segment bases +CODE_SEGMENT equ gdt_code - gdt_start +DATA_SEGMENT equ gdt_data - gdt_start + |