Page 1 of 1
Loop causes qemu to crash
Posted: Wed Jul 08, 2009 11:48 pm
by GhostSniper
Im using a loop to check and see if shift is pressed.
Code: Select all
inb (unsigned short port)
{
unsigned char value;
asm volatile ("inb %w1, %0" : "=a" (value) : "Nd" (port));
return value;
}
void CheckChar()
{
for(;;)
{
if(inb(0x60) ==54)
{
clear_screen(0,0x02);
WriteText("Shift Was Pressed",0x02);
}
}
}
The problem is that the for(;;) loop causes qemu to crash. Whydoes that occur?
Re: Loop causes qemu to crash
Posted: Wed Jul 08, 2009 11:51 pm
by salil_bhagurkar
You probably need to provide more code. This code seems all correct (or rather logically correct). Go for Bochs and find out the exact reason why your os is crashing. There might be several reasons.
Re: Loop causes qemu to crash
Posted: Thu Jul 09, 2009 12:21 am
by GhostSniper
Works fine now. I just added more code like you suggested :p
Re: Loop causes qemu to crash
Posted: Thu Jul 09, 2009 2:03 am
by salil_bhagurkar
GhostSniper wrote:Works fine now. I just added more code like you suggested :p
I meant you should provide us more code to look at. If you just add more code for no reason, you are just covering a nasty bug temporarily that *will* surface later.
Re: Loop causes qemu to crash
Posted: Thu Jul 09, 2009 4:19 am
by jal
GhostSniper wrote:The problem is that the for(;;) loop causes qemu to crash. Whydoes that occur?
Is dat occuring before or after you press shift? Please learn to provide all relevant details.
JAL
Re: Loop causes qemu to crash
Posted: Fri Jul 17, 2009 10:47 am
by tharkun
Have you actually set up a gdt/idt/isrs/irqs?
Because from the last few topics you've started you have been asking very basic questions.
Try this tutorial first:
http://www.jamesmolloy.co.uk/tutorial_html/index.html
Come back after you've finished with it.
And if you have any questions read the wiki, try google, or whatever. But use this forum as a last resort.
BTW Ignore this post if you have a have gotten as far as the irqs.
Re: Loop causes qemu to crash
Posted: Fri Jul 17, 2009 11:02 am
by -m32
What makes you think it's the for loop that causes the crash? It's more likely something wrong with your clear_screen or WriteText functions... and I have to assume that since your naming conventions for each function are different, that there's copy & pasting going on...
Re: Loop causes qemu to crash
Posted: Fri Jul 17, 2009 11:29 am
by tharkun
-m32 wrote:What makes you think it's the for loop that causes the crash? It's more likely something wrong with your clear_screen or WriteText functions... and I have to assume that since your naming conventions for each function are different, that there's copy & pasting going on...
I believe you are probably correct. I just hope he isn't cotton509 all over again...
Then again, this guy knows (supposedly) how to use a compiler.
Re: Loop causes qemu to crash
Posted: Fri Jul 17, 2009 11:54 am
by Troy Martin
I'm getting a little tired of these noobs that come in here, think they can do OS development, copy and paste some code, then complain to us that it doesn't work when they probably don't even know what it does.
OP: You should be checking port 0x64 to see if there's a scancode in the buffer. I've never heard of the lack of that causing a fault, but it's possible.
pinged wrote:I just hope he isn't cotton509 all over again...
The cotton legacy lives on...
*wonders how someone that joined 5 months after the cotton fiasco knows about him*
Re: Loop causes qemu to crash
Posted: Fri Jul 17, 2009 12:21 pm
by manonthemoon
Troy Martin wrote:The cotton legacy lives on... *wonders how someone that joined 5 months after the cotton fiasco knows about him*
Haha, I know all about the cotton fiasco!
To the original poster: QEMU is nice, but for debugging purposes you should probably try Bochs. Run your original code with Bochs and see what happens. It will leave behind a log (whether it crashes or not) which you can inspect for any error conditions.
Re: Loop causes qemu to crash
Posted: Fri Jul 17, 2009 12:28 pm
by tharkun
Troy Martin wrote:
*wonders how someone that joined 5 months after the cotton fiasco knows about him*
I've only joined the forum a few months ago, but I had been reading it for about six months beforehand.
It gave me a good laugh when I read it though.