Strange Booting Problem
Posted: Wed May 28, 2008 12:19 pm
I have a very strange problem with booting. I've been developing thus far using bochs / vmware, but I decided to try it on a real PC. Unfortunately the only one with a working floppy drive is my laptop. I have a two stage bootloader. The first stage loads a file named loader.bin from the floppy using the FAT12 filesystem. That works fine. Then loader.bin, which is in the low memory area (0x500) loads another file KERNEL.BIN which has some RM code at the beginning for switching video modes, and is followed by the ELF file for the kernel written in C. It sets up PMode just fine, jumps into it, relocates the ELF up into high memory (0x100000) then calls it based off of the entry point in the ELF image.
Interrupts are disabled, the stack is way up high (0x90000) and I even do a push dword 2 popfd to clear all the flags before calling the kernel's entry point. I changed the kernel I've been working on for the last 2 weeks to just one that writes 0x1f20 to the screen at 0xb8000 2000 times.
The above is literally my "kernel" code. Thus far, everything has worked in Bochs and even VMWare, but when I try it on a real PC (or laptop) it actually enters the kernel and fills up most of the screen with blue, hangs, then the PC reboots.
I've tried it on more than one PC by writing a CDROM with a floppy image and an emulator. Exactly the same thing. It must be an interrupt somewhere , but where? What would cause it? Has anyone else experienced this problem?
Interrupts are disabled, the stack is way up high (0x90000) and I even do a push dword 2 popfd to clear all the flags before calling the kernel's entry point. I changed the kernel I've been working on for the last 2 weeks to just one that writes 0x1f20 to the screen at 0xb8000 2000 times.
Code: Select all
void _start()
{
short *vm = (short *)0xb8000;
int i;
/* Clear the screen */
for (i=0; i < 2000; i++) vm[i] = 0x1f20;
while(1);
}
I've tried it on more than one PC by writing a CDROM with a floppy image and an emulator. Exactly the same thing. It must be an interrupt somewhere , but where? What would cause it? Has anyone else experienced this problem?