Higher half kernel
Posted: Sun Nov 04, 2007 9:03 am
Hi,
I'm currently trying to write a higher half kernel based on this http://www.osdev.org/osfaq2/index.php/HigherHalfWithGdt.
However, everytime when I want so change segment selectors a triple fault occurs.
Here is the code:
nm output:
qemu output:
I'm currently trying to write a higher half kernel based on this http://www.osdev.org/osfaq2/index.php/HigherHalfWithGdt.
However, everytime when I want so change segment selectors a triple fault occurs.
Here is the code:
Code: Select all
.globl start, _start
start:
_start:
lgdt gdtr
movw $0x10, %ax
movw %ax, %ds
hlt
multiboot_entry:
movl $(stack + STACK_SIZE), %esp
pushl $0
popf
pushl %ebx
pushl %eax
call EXT_C(cmain)
loop: hlt
jmp loop
.section .setup
gdtr:
.word gdt_end - gdt - 1
.long gdt
gdt:
.long 0, 0
.byte 0xFF, 0xFF, 0, 0, 0, 0x9A, 0xCF, 0x40
.byte 0xFF, 0xFF, 0, 0, 0, 0x92, 0xCF, 0x40
gdt_end:
Code: Select all
c010002c T _start
00100006 n gdt
0010001e n gdt_end
00100000 n gdtr
...
c010002c T start
qemu: fatal: triple fault
EAX=00000010 EBX=0002daa0 ECX=00000001 EDX=00000001
ESI=00054729 EDI=0005472a EBP=00067eac ESP=00067e8c
EIP=00100039 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00cf9300
CS =0008 00000000 ffffffff 00cf9a00
SS =0010 00000000 ffffffff 00cf9300
DS =0010 00000000 ffffffff 00cf9300
FS =0010 00000000 ffffffff 00cf9300
GS =0010 00000000 ffffffff 00cf9300
LDT=0000 00000000 0000ffff 00008000
TR =0000 00000000 0000ffff 00008000
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=60000011 CR2=00000000 CR3=00000000 CR4=00000000
...