Global descriptor table
Posted: Mon May 18, 2015 4:54 pm
Hello, I recently started to play with OS-Development. As tutorials suggested I am using GRUB multiboot to get booted kernel witch A20 line on and protected mode set on. Although I want to set my own GDT (for training). I read on wiki that extended memory starts at 0x01000000 address, and I set qemu to run with 3Gb of RAM (-m 3G switch). After GDT flush I want to use only upper memory and use only 1Gb of it (for code and data only for now). Here is my code for GDT flush (GAS synatx):
Please don't mind PLACE_HOLD1 and PLACE_HOLD2, as name says it is just place holder for something ( probably TSS).
Problem with this code is that as soon as jump is performed CPU triple faults. I get that this is caused by trying to access invalid memory, but I do not get why RAM described in selectors is invalid. I will really appreciate your help in this matter.
Code: Select all
.equ NULL_DESCRIPTOR, 0x0000000000000000
.equ CODE, 0x01C09A0000000000
.equ DATA, 0x01C0930000000000
.equ PLACE_HOLD1, 0x01C0930000000000
.equ PLACE_HOLD2, 0x01C09A0000000000
.section .data
GDT:
.quad NULL_DESCRIPTOR
.quad CODE
.quad DATA
.quad PLACE_HOLD1
.quad PLACE_HOLD2
_GDT:
.word 24
.long GDT
.section .text
.global flushGDT
.type flushGDT, @function
flushGDT:
lgdt _GDT
xor %eax, %eax
mov $0x10, %ax
mov %ax, %ss
mov %ax, %ds
mov %ax, %gs
mov %ax, %fs
mov %ax, %es
jmp $0x08 ,$leaveToKernel
leaveToKernel:
ret
Problem with this code is that as soon as jump is performed CPU triple faults. I get that this is caused by trying to access invalid memory, but I do not get why RAM described in selectors is invalid. I will really appreciate your help in this matter.