Functions cause HLT (Or simular lockup)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ThymeCypher
Posts: 21
Joined: Tue Mar 24, 2009 10:59 am

Functions cause HLT (Or simular lockup)

Post 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?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Functions cause HLT (Or simular lockup)

Post by Solar »

Did you set up a stack?
Every good solution is obvious once you've found it.
ThymeCypher
Posts: 21
Joined: Tue Mar 24, 2009 10:59 am

Re: Functions cause HLT (Or simular lockup)

Post 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 ;)
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Re: Functions cause HLT (Or simular lockup)

Post 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. =)
User avatar
djsilence
Member
Member
Posts: 70
Joined: Wed Oct 01, 2008 11:18 am
Location: Ukraine, Kiev
Contact:

Re: Functions cause HLT (Or simular lockup)

Post 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.
Don't think a ****, but in ukrainian schools English is TOO BAD!
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Functions cause HLT (Or simular lockup)

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
ThymeCypher
Posts: 21
Joined: Tue Mar 24, 2009 10:59 am

Re: Functions cause HLT (Or simular lockup)

Post 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.
Post Reply