pmode is driving me crazy
Posted: Mon Mar 08, 2004 12:21 pm
I am trying to enter pmode and execute some C-code i have linked to my bootsector program.
I have been disabling interrupts like crazy as you can see in my code.
[BITS 16]
[global start]
[extern load_kernel]
start:
jmp start_load
nop
resb 0x3E
start_load:
cli
cld
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov fs, ax
mov gs, ax
mov sp, 0x7bfe
cli
seta20.1:
in al, 0x64
test al, 2
jnz seta20.1
mov al, 0xD1
out 0x64, al
seta20.2:
in al, 0x64
and ax, byte 2
jnz seta20.2
mov al, 0xDF
out 0x60, al
cli
lgdt [gdt_ptr]
mov eax,cr0
inc eax
mov cr0,eax
cli
jmp 8:pmode
[BITS 32]
pmode:
mov ax, 0x10
mov ds, ax
mov es, ax
mov ss, ax
mov fs, ax
mov gs, ax
call load_kernel
the load_kernel() is just a while(1); as of now
i compile it with
nasm -f aout bootsector.asm
and the c-code with
gcc -c kernel_loader.c
then i link them together with
ld -T link.ld bootsector.o kernel_loader.o -o boot
and then i write the boot file to a floppy image (skipping the BPB though)
I use this link-script (link.ld)
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x7c00 : {
code = .; _code = .; __code = .;
*(.text)
}
.data : {
data = .; _data = .; __data = .;
*(.data)
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
}
end = .; _end = .; __end = .;
}
When run, Bochs just keep resetting indefinately with the following error.
(0) [0x00007c78] 0000:00007c78 (unk. ctxt): jmp 0008:7c7d ; ea7d7c0800
<bochs:30>
00000694946e[CPU ] jump_protected: gate type 0 unsupported
00000694946e[CPU ] exception(): 3rd (13) exception with no resolution, shutdown
status is 00h, resetting
Error: (0) print_guard_results: guard_found ? (stop reason 0)
Next at t=694946
(0) [0x00007c78] 0000:7c78 (unk. ctxt): jmp 0008:7c7d ; ea7d7c0800
It's the jmp 8:pmode-instruction that fails.. why?
If i remove it i can enter C.. but nothing seems to work properly.
Can anyone help me?
I have been disabling interrupts like crazy as you can see in my code.
[BITS 16]
[global start]
[extern load_kernel]
start:
jmp start_load
nop
resb 0x3E
start_load:
cli
cld
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov fs, ax
mov gs, ax
mov sp, 0x7bfe
cli
seta20.1:
in al, 0x64
test al, 2
jnz seta20.1
mov al, 0xD1
out 0x64, al
seta20.2:
in al, 0x64
and ax, byte 2
jnz seta20.2
mov al, 0xDF
out 0x60, al
cli
lgdt [gdt_ptr]
mov eax,cr0
inc eax
mov cr0,eax
cli
jmp 8:pmode
[BITS 32]
pmode:
mov ax, 0x10
mov ds, ax
mov es, ax
mov ss, ax
mov fs, ax
mov gs, ax
call load_kernel
the load_kernel() is just a while(1); as of now
i compile it with
nasm -f aout bootsector.asm
and the c-code with
gcc -c kernel_loader.c
then i link them together with
ld -T link.ld bootsector.o kernel_loader.o -o boot
and then i write the boot file to a floppy image (skipping the BPB though)
I use this link-script (link.ld)
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x7c00 : {
code = .; _code = .; __code = .;
*(.text)
}
.data : {
data = .; _data = .; __data = .;
*(.data)
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
}
end = .; _end = .; __end = .;
}
When run, Bochs just keep resetting indefinately with the following error.
(0) [0x00007c78] 0000:00007c78 (unk. ctxt): jmp 0008:7c7d ; ea7d7c0800
<bochs:30>
00000694946e[CPU ] jump_protected: gate type 0 unsupported
00000694946e[CPU ] exception(): 3rd (13) exception with no resolution, shutdown
status is 00h, resetting
Error: (0) print_guard_results: guard_found ? (stop reason 0)
Next at t=694946
(0) [0x00007c78] 0000:7c78 (unk. ctxt): jmp 0008:7c7d ; ea7d7c0800
It's the jmp 8:pmode-instruction that fails.. why?
If i remove it i can enter C.. but nothing seems to work properly.
Can anyone help me?