I've been pretty quiet on the board for many months. Over the period of my absence, I've been putting a bit of time into playing with my skeleton OS. I'm able to boot it and get it to display a simple, "Hi I'm alive!" message. Thanks to so many of you that helped be get over the GDT hurdle.
I've been poking around with my exception handling and noticed one problem. I've got an #ifdef block written that will allow me to subjectively work on this code through my DEBUG variable in the Makefile. In trying to work out this odd triple fault I've commented out that whole block.
Below, I've included the snips of relevant (hopefully) code. You can see where, in loader.asm, I jump to my main and follow it up with a jmp $. Presumably this will put the processor in a localized loop should main() return for some cornball reason.
In my kernel.c, you'll see where I print some stuff out to screen, and return to the asm stub. Note that I've disabled my DEBUG ifdef. When I run this, the "Testing" message is displayed, followed by my "I GOT HERE" sanity check. Then immediately triple-fault the processor.
My question is why? Shouldn't the jmp $ returned to from main() loop me? I think it might do with stack handling from main back to asm code, but I'm not certain.
Here's something even odder... if I uncomment the for( ; ; ) loop in the C code, it still triple-faults! No endless loop in either case. What is going on here?
Thanks (again) for your help!
-Sean
From my loader.asm file:
Code: Select all
start:
mov esp, _sys_stack ; points stack to new stack area
call main ; jumps to c kernel
jmp $ ; just in case kernel returns
Code: Select all
{snip}
cls();
settextcolor(WHITE,BLUE);
puts("Test Kernel 0.1\n");
puts("---------------\n");
/* exception handling testing */
/* #ifdef DEBUG */
/* int test; */
/* test = 1 / 0; */
/* puts(test); */
/* #endif */
/* loop forever - do not return to start.asm jmp $ */
/* commented for testing purposes */
/* for (;;) ; */
puts("I GET THIS FAR!\n");
return -1;