Loop causes qemu to crash

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
GhostSniper
Posts: 12
Joined: Wed Jul 08, 2009 4:57 pm

Loop causes qemu to crash

Post 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?
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Re: Loop causes qemu to crash

Post 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.
GhostSniper
Posts: 12
Joined: Wed Jul 08, 2009 4:57 pm

Re: Loop causes qemu to crash

Post by GhostSniper »

Works fine now. I just added more code like you suggested :p
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Re: Loop causes qemu to crash

Post by salil_bhagurkar »

GhostSniper wrote:Works fine now. I just added more code like you suggested :p
:shock:

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.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Loop causes qemu to crash

Post 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
tharkun
Member
Member
Posts: 51
Joined: Sat Mar 21, 2009 1:29 pm
Location: Ireland

Re: Loop causes qemu to crash

Post 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.
User avatar
-m32
Member
Member
Posts: 120
Joined: Thu Feb 21, 2008 5:59 am
Location: Ottawa, Canada

Re: Loop causes qemu to crash

Post 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...
tharkun
Member
Member
Posts: 51
Joined: Sat Mar 21, 2009 1:29 pm
Location: Ireland

Re: Loop causes qemu to crash

Post 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.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Loop causes qemu to crash

Post 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*
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
manonthemoon
Member
Member
Posts: 65
Joined: Sat Jul 04, 2009 9:39 pm

Re: Loop causes qemu to crash

Post 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.
tharkun
Member
Member
Posts: 51
Joined: Sat Mar 21, 2009 1:29 pm
Location: Ireland

Re: Loop causes qemu to crash

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