Page 1 of 1

Function Call halts execution - Screwed up code? O_o

Posted: Sun Feb 20, 2011 1:45 pm
by vargadanis
Hello everyone!

I am facing an interesting problem. In short: I have function A and B. When Calling B from inside A my code stops the execution and nothing happens from that point on. A is called from kmain() function (yes I am saving the world and writing yet another OS :) ) I have no idea why that happens.

The line that 'breaks' my code is at line 44 here
https://github.com/fenistil/ToyToyOS/bl ... nel/scrn.c

If I comment it out like it is now on the git website, bochs has no trouble running it. Seems to be working the way I want it to work. I compile the c file with these options:
-c -g3 -Wall -Wextra -Werror -nostdlib -nostartfiles -nodefaultlibs -I./include
Any help would be appreciated

Re: Function Call halts execution - Screwed up code? O_o

Posted: Sun Feb 20, 2011 2:01 pm
by Tosi
Try setting up a GDT with a flat address space, the multiboot specification recommends that the kernel set up its own GDT as soon as possible.

Re: Function Call halts execution - Screwed up code? O_o

Posted: Sun Feb 20, 2011 2:03 pm
by Combuster
Assuming you tried rebuilding everything, the obvious thing to check is the stack: can you tell exactly what part of memory it is supposed to use, and then what the actual value of ESP and EBP is?

Re: Function Call halts execution - Screwed up code? O_o

Posted: Sun Feb 20, 2011 2:20 pm
by vargadanis
A solution is to move the function definitions above the line of the calling function. Even tho I have included a header file that contains the declarations the function call halts. I suppose it could be cause of faulty stack or not set up GDT. I'll get back to this problem once I have facilities to check the stack's value and as well the contents of the registers.