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.