Pmode + Kernel
Posted: Sun Jun 06, 2004 4:35 pm
Is it wrong to enter Pmode in the kernel rather than the bootsector? As my bootsector is getting rather full. Thanks.
Code: Select all
eax:0x60000011
ebx:0x2
ecx:0x90010
edx:0x0
ebp:0x0
esi:0x7e03
edi:0x7e00
esp:0xfffe
eflags:0x2
eip:0x7d3c
cs:s=0x0, dl=0xffff, dh=0x9b00, valid=1
ss:s=0x0, dl=0xffff, dh=0x9300, valid=7
ds:s=0x0, dl=0xffff, dh=0x9300, valid=7
es:s=0x1000, dl=0xffff, dh=0x9301, valid=1
fs:s=0x0, dl=0xffff, dh=0x9300, valid=1
gs:s=0x0, dl=0xffff, dh=0x9300, valid=1
ldtr:s=0x0, dl=0x0, dh=0x0, valid=0
tr:s=0x0, dl=0x0, dh=0x0, valid=0
gdtr:base=0x7d, limit=0x9118
idtr:base=0x0, limit=0x3ff
dr0:0x0
dr1:0x0
dr2:0x0
dr3:0x0
dr6:0xffff0ff0
dr7:0x400
tr3:0x0
tr4:0x0
tr5:0x0
tr6:0x0
tr7:0x0
cr0:0x60000010
cr1:0x0
cr2:0x0
cr3:0x0
cr4:0x0
inhibit_mask:0
Code: Select all
gdt: ; Very start of our GDT
gdt_null: ; Null Segment -> 4 Null Words
dw 0 ; Null Word
dw 0 ; Null Word
dw 0 ; Null Word
dw 0 ; Null Word
gdtCode: ; Code Segment
dw 0xFFFF ; Limit -> 4GB
dw 0x0000 ; Base Address -> 0 (Start of memory)
db 0x00 ; Continue base address
; Access flag -> 0, Readable Segment -> 1, Conforming -> 0
; Code Segment -> 1, Code/Data Segment -> 1, Privelage level -> 00
; Present -> 1
db 10011010b ; Above flags
; Last bits of segment limit -> 1111, Ignored -> 0, Reserved -> 0,
; 32-bit code -> 1, Granularity -> 1,
db 11001111b ; Above flags
db 0x00 ; Remaining base address
gdtData: ; Our data segment
dw 0xFFFF ; Limit -> 4GB
dw 0x0000 ; Base Address -> 0 (Start of memory)
db 0x00 ; Continue base address
; Accessed -> 0, Writeable Segment -> 1, Expand -> 0 (down),
; Code Segment -> 0 (data), Code/Data Segment -> 1, Privelage -> 00
; Present -> 1
db 10010010b ; Above flags
; Last bits of segment limit -> 1111, Ignored -> 0, Reserved -> 0,
; 32-bit code -> 1, Granularity -> 1
db 11001111b ; Above Flags
db 0x00 ; Remaining base address
gdtEnd ; End of our GDT
gdtDesc: ; GDT Descriptor
db gdtEnd - gdt ; Size of GDT in bytes
dw gdt ; GDT's memory address
Code: Select all
cli
lgdt [gdtDesc]
mov eax, cr0
or eax, 1
mov cr0, eax ; hangs here
Do you see a mismatch? The limit is 16-bit, the base 32-bit, base must be 8-byte aligned, and the dump shows it didn't load correctly. What's the offset of the GDT itself in your memory image?Pulser wrote:This is my GDT (over commented as you can see ):Code: Select all
gdtr:base=0x7d, limit=0x9118
Code: Select all
gdt: ; Very start of our GDT <snip> gdtDesc: ; GDT Descriptor db gdtEnd - gdt ; Size of GDT in bytes dw gdt ; GDT's memory address
Your ORG is good I suppose (ORG 0x7C00 would work). Make the base a dd, and the limit a dw, then it should work.Pulser wrote: I went for the 0x0000:7c00 approach, and my GDTR.base is set to gdt... any other ideas? Thanks