Page 1 of 1

Functions cause HLT (Or simular lockup)

Posted: Fri Mar 27, 2009 6:44 am
by ThymeCypher
As stated in a previous post, I'm trying to write a very basic x86_64 kernel. In this kernel, I tried making a function to write text out to the buffer. Problem is: Calling any functions, from inside that file, from an external file, in any way at all, causes the kernel to lock up. Does anyone have any suggestions?

Re: Functions cause HLT (Or simular lockup)

Posted: Fri Mar 27, 2009 7:04 am
by Solar
Did you set up a stack?

Re: Functions cause HLT (Or simular lockup)

Posted: Fri Mar 27, 2009 7:47 am
by ThymeCypher
My luck with premade x86_64 code has been.... well, there's a lack of any luck. I reworked some x86 code and whatnot and got things working. Maybe I was wrong about the lack of example code being a bad thing when it only works sometimes after all ;)

Re: Functions cause HLT (Or simular lockup)

Posted: Fri Mar 27, 2009 11:07 am
by 01000101
It would go a long way to provide the end of a bochs debugging run.
It's very vague to say "locked up".

It could be your stack, your ELF not being properly/fully loaded (or to the right place), interrupts being enabled without any real IDT setup, or any other fault with the emulator not set to reboot/exit. =)

Re: Functions cause HLT (Or simular lockup)

Posted: Sat Mar 28, 2009 6:07 am
by djsilence
How can you know that it is exactly HLT instruction? Can it be loop without exit point? I am asking you, because there is no instructions except HLT which causes such effect. If it is really loop without exit point then just check you code (maybe you lost something little :D ).

PS: It will be much better to most of repliers to see the code themself.

Daniel.

Re: Functions cause HLT (Or simular lockup)

Posted: Sat Mar 28, 2009 9:02 am
by Combuster
Any form of infinite loop will appear like a lockup to the end user.

so, you can HLT, while(1);, or get into an exception loop. If your HLTs are prefixed with a CLI, bochs will complain whenever a halt state is entered.

If bochs doesn't complain, 9 out of 10 chance an unintended lockup is an exception loop.

Re: Functions cause HLT (Or simular lockup)

Posted: Sun Mar 29, 2009 9:37 am
by ThymeCypher
I still haven't figured out the problem, but the issue has SOMETHING to do with it being compiled as 64-bit. I rewrote the code- basically, I can select 2 targets now, x86 and x86_64, and the x86_64 version has the same code, plus an aout kludge. Of course I'm not expecting this to fully work, and it still gives me crashes (Even crashes big enough to take Windows down too), but it compiles. I plan to target just x86_64 in the future, but it couldn't hurt to work in x86 until someone can make a x86_64 bare bones that works (I really like the ZOmB project, but the code does not work, atleast for my tools. It tosses errors about there not being enough memory so it cuts out some of the ASM, which of course, leads to a bad file) I'm just looking for a simple x86_64 barebones, nothing as fancy as ZOmB anyway, just something that boots then loads long mode using as little code as possible.

Oh, and also, I use VirtualBox, not Bochs. It doesn't offer debugging, but it seems to be a very stable VM.