I have been holding back to ask this question for about a week trying to figure out what is going on by my self, but, no luck.
I am following the JamesM tutorial on kernels and have gotten stuck at flushing the old GDT loaded by grub out and replacing it with my new one.
This is not working however and I do not know why.
Code: Select all
gdt_flush2:
lgdt [gdt_ptr_struct] //get the structure from C
mov ax, 0x10 //offset to data
mov ds, ax //load segment selector
mov es, ax //load segment selector
mov fs, ax //load segment selector
mov gs, ax //load segment selector
mov ss, ax //load segment selector
jmp 0x08:flush2 //will cause cs to be loaded as well
flush2:
ret //back to C
Any help would be appreciated.
Here is a bochs dump:
Code: Select all
00209657525i[CPU0 ] CS.d_b = 16 bit
00209657525i[CPU0 ] SS.d_b = 16 bit
00209657525i[CPU0 ] EFER = 0x00000000
00209657525i[CPU0 ] | RAX=0000000000000000 RBX=0000000000000000
00209657525i[CPU0 ] | RCX=000000000009e080 RDX=0000000000000014
00209657525i[CPU0 ] | RSP=000000000000ff98 RBP=000000000000ffb0
00209657525i[CPU0 ] | RSI=00000000000e472c RDI=000000000000ffac
00209657525i[CPU0 ] | R8=0000000000000000 R9=0000000000000000
00209657525i[CPU0 ] | R10=0000000000000000 R11=0000000000000000
00209657525i[CPU0 ] | R12=0000000000000000 R13=0000000000000000
00209657525i[CPU0 ] | R14=0000000000000000 R15=0000000000000000
00209657525i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df IF tf SF zf AF PF CF
00209657525i[CPU0 ] | SEG selector base limit G D
00209657525i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00209657525i[CPU0 ] | CS:f000( 0004| 0| 0) 000f0000 0000ffff 0 0
00209657525i[CPU0 ] | DS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00209657525i[CPU0 ] | SS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00209657525i[CPU0 ] | ES:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00209657525i[CPU0 ] | FS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00209657525i[CPU0 ] | GS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00209657525i[CPU0 ] | MSR_FS_BASE:0000000000000000
00209657525i[CPU0 ] | MSR_GS_BASE:0000000000000000
00209657525i[CPU0 ] | RIP=000000000000fea6 (000000000000fea6)
00209657525i[CPU0 ] | CR0=0x60000010 CR2=0x0000000000000000
00209657525i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00209657525i[CPU0 ] 0x000000000000fea6>> push eax : 6650