Page 1 of 1

OS just keeps restarting over and over again

Posted: Sun Jan 30, 2005 3:52 am
by e_d
Okay I am new to the entire OS development thing, enough said. anyways I was reading through Xosdev's tutorials and I compiled the kernel, assembled the boot loader, attached them both with cat boot.bin kernel.o > kernel.img and then used "dd" to put it on a floppy. I am coding in linux. So after 8 hours of trying to get just a "hello world" to print on the screen I finally think I got it. So I stick the floppy in expecting to see it and what happens made me laugh so hard I almost threw up. The computer just kept restarting over and over again. Does anyone have ANY idea what this could be caused by?

I know i know I can easily get a hello world to work by using the bios stuff and coding the asm for it, but I want to have a mixture of C and ASM since I dont plan on coding the entire OS in ASM. Any help would be appreciated. Thanks.

Re:OS just keeps restarting over and over again

Posted: Sun Jan 30, 2005 4:56 am
by IRBMe
Probably a tripple protection fault occurs each time, thus causing the PC to reboot. A tripple protection fault could be caused by absolutely ANYTHING!

What I would suggest is that you install an emulator such as bochs. Run the debug version and see what happens. You'll get some kind of feed back in bochsout hopefully. You can then use that information to set break points, then examine memory, or step through each instruction one at a time to see which is the one causing the thing to blow up.

By the way, best to learn how to do this sooner rather than later. Trust me - you will be getting LOTS of tripple protection faults in the beginning. It happens to us all. :)

Re:OS just keeps restarting over and over again

Posted: Sun Jan 30, 2005 11:23 am
by mystran
Actually on IA-32 it's called just "tripple fault" and it happens when an exception happens when trying to call the double-fault handler. Double-fault handler is called when an exception occurs when trying to access another exception handler (except when there are special rules).

In other words, when an exception results when calling an exception handler, a double-fault is generated to prevent an infinite exception loop. If calling double-fault handler also results in exception, then calling the double-fault handler again would result in such a loop, and instead a tripple-fault is raised, resetting the processor.

Until you've implemented valid exception handlers, pretty much any exception can result in a double-fault, and if you don't have a valid double-fault handler either, then you'll get a tripple-fault.

For testing your kernel, I'd suggest using Bochs (preferably a recent version) since it can show you the exceptions, so you can see what was the original exception that caused the tripple-fault. This helps debugging quite a bit. It can also give you other interesting information, and even has a debugger if you compile that in.