I have written a small 64-bit kernel with my own custom 2 stages boot loader. I switch to protected mode and then to long mode.
I can boot with my kernel until loading ISRs as well as setting PIT timer and it works fine as designed on all emulation/virtualization environment: Bochs, QEMU/KVM, and Virtual Box.
I tried my OS from a USB boot on a couple of real physical hardware machines such as Lenovo Thinkpads T61P, W500, and W510 and they all worked fine.
When I try to boot with the same USB on Lenovo desktop tower machines (More than one model), the computer keeps on rebooting. I have put some halt statements and kept on incrementing them in the code until I found out that as soon as I enable paging with the following instructions it reboots:
Code: Select all
mov eax, cr0
or eax, 1 << 31
mov cr0, eax
Code: Select all
mov ax, 0x2401
int 0x15
in al, 0x92
test al, 2
jnz after
or al, 2
and al, 0xFE
out 0x92, al
jmp done:
after:
call print_a20_ok
done:
I cannot figure out the reason behind the problem and it is very difficult to debug on real hardware.
Please if anyone is familiar with that or has any clue what my problem can be or even how to tackle it, please let me know.
Thanks
Karim.