pmode problems

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Guest

pmode problems

Post by Guest »

Hi,
I have a very serious problem with booting with my own bootstrap.
On the bochs-PC-emu it runs perfectly. It also runs on two other
computers, but on my computer (Athlon 1.4GHz) it reboots
when loading into protected mode.
Here my bootstrap-code:
.code16
.global _start
.text
_start:
mov $0x1000, %ax
mov %ax, %es
mov $0x01, %al
mov $0x02, %ah
mov $0x0000, %bx
mov $0, %dl
mov $0, %dh
mov $0, %ch
mov $2, %cl
int $0x13
call enableA20
call waitA20
cli
mov $_pmode, %eax
movl %eax, (pmoff)
mov $seg0, %eax
mov %eax, (gdt+0x02)
lgdt gdt
lidt idt
lmsw 0x01
.byte 0x66, 0xea # Here it resets
pmoff: .long 0x10000
.word 0x0008
.code32
_pmode:
mov $0x00000002, %eax
shl $3, %eax
mov %eax, %ss
mov $0x00000003, %eax
shl $3, %eax
mov %eax, %ds
mov $0x00000001, %eax
shl $3, %eax
mov %eax, %es
mov $0x10000, %eax
jmp *%eax

enableA20:
push %ax
push %bx
mov $0xd0, %al
out %al, $0x64
_wait: in $0x64, %al
test $0x01, %al
jz _wait
in $0x60, %al
or $0x02, %al
mov %al, %bl
mov $0xd1, %al
out %al, $0x64
mov %bl, %al
out %al, $0x60
pop %bx
pop %ax
ret

waitA20:
push %es
push %fs
push %ax
_testA20:
mov $0x0000, %ax
mov %ax, %es
mov $0xffff, %ax
mov %ax, %fs
mov $0xfff0, %ax
mov %ax, %es:(0x200)
cmp %fs:(0x210), %ax
je _testA20
pop %ax
pop %fs
pop %es
ret

gdt: .word 0x0020
.word 0x7c6f
.word 0x0000
idt: .word 0x0000
.word 0x0000
.word 0x0000
seg0: .word 0x0000
.word 0x0000
.byte 0x00
.byte 0b10011111
.byte 0b01001000
.byte 0x00
cseg: .word 0x0000
.word 0x0000
.byte 0x00
.byte 0b10011110
.byte 0b01001000
.byte 0x00
stack: .word 0xffff
.word 0x0000
.byte 0x00
.byte 0b10010010
.byte 0b01001111
.byte 0x00
data: .word 0xffff
.word 0x0000
.byte 0x00
.byte 0b10010010
.byte 0b01001111
.byte 0x00
Post Reply