From 27191b17ce7b74ebe252bdbdd54a2461e1d18afa Mon Sep 17 00:00:00 2001 From: Reto Buerki Date: Wed, 11 Feb 2015 16:29:06 +0100 Subject: [PATCH] hw_x86_64: Declare Global Descriptor Table (GDT) in .data The table specifies a 64-bit code segment descriptor at index 1, a 64-bit data segment descriptor at index 2 and a task segment descriptor at index 3. --- .../src/core/spec/x86_64/kernel/crt0.s | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/repos/base-hw/src/core/spec/x86_64/kernel/crt0.s b/repos/base-hw/src/core/spec/x86_64/kernel/crt0.s index 25e4cebe0..8481cb9f8 100644 --- a/repos/base-hw/src/core/spec/x86_64/kernel/crt0.s +++ b/repos/base-hw/src/core/spec/x86_64/kernel/crt0.s @@ -117,3 +117,35 @@ .quad 0 .quad 0x20018f .fill 510, 8, 0x0 + + /******************************************* + ** Global Descriptor Table ** + ** See Intel SDM Vol. 3A, section 3.5.1. ** + *******************************************/ + + .align 4 + .space 2 + + _gdt_ptr: + .word _gdt_end - _gdt_start - 1 /* limit */ + .long _gdt_start /* base address */ + + .align 8 + _gdt_start: + /* Null descriptor */ + .quad 0 + /* 64-bit code segment descriptor */ + .long 0 + /* GDTE_LONG | GDTE_PRESENT | GDTE_CODE | GDTE_NON_SYSTEM */ + .long 0x209800 + /* 64-bit data segment descriptor */ + .long 0 + /* GDTE_LONG | GDTE_PRESENT | GDTE_TYPE_DATA_A | GDTE_TYPE_DATA_W | GDTE_NON_SYSTEM */ + .long 0x209300 + /* Task segment descriptor */ + .long 0 + /* GDTE_PRESENT | GDTE_SYS_TSS */ + .long 0x8900 + .long 0 + .long 0 + _gdt_end: