Page 1 of 1

Bare Bones only works after running "info registers" in QEMU

Posted: Sat Dec 18, 2010 4:08 pm
by Wallacoloo
I couldn't get the Bare Bones working in Qemu. Everything compiled and linked with no errors, but simply didn't do anything when I ran it in qemu.

So I decided to try and see where things were going wrong. I ran Qemu from the terminal (btw, I'm using Linux) like so:

Code: Select all

qemu -monitor stdio -kernel kernel.bin
That makes it so I can enter commands into the terminal window while my OS is running.
So at the (Qemu) prompt, I type:

Code: Select all

info registers
To, obviously, dump the registers.
The instant I hit enter, the upper left character is replaced with an A, which is exactly what the program was supposed to do.

I repeated that process a few times to make sure it was reproducible, and it is (on my system).
All OSes that I've tried which don't switch into protected mode seem to work fine on Qemu, and the 2 tutorials for protected mode that I've followed only work after doing the above process (1 was the bare bones, the other can be found here: http://www.osdever.net/tutorials/view/t ... ected-mode). So I figure it's got something to do with switching to protected mode.

Code: Select all

qemu -version
shows
QEMU PC emulator version 0.12.5 (qemu-kvm-0.12.5), Copyright (c) 2003-2008 Fabrice Bellard

What can I do to avoid having to do this every time?

Re: Bare Bones only works after running "info registers" in

Posted: Sat Dec 18, 2010 4:37 pm
by gerryg400
Make sure interrupts are ENABLED when you execute the hlt instruction. Like this

Code: Select all

   sti
hang:
   hlt                                ; halt machine should kernel return
   jmp   hang

Re: Bare Bones only works after running "info registers" in

Posted: Sun Dec 19, 2010 12:03 am
by Wallacoloo
Thanks for the tip. That was precisely the problem!