Page 1 of 2

[Resolved] Somewhat Easy Question (Bochs)

Posted: Mon Dec 03, 2007 7:41 am
by Bobalandi
Alright, I'm kind of a noob at this, so I need your help. I've compiled a very, very, basic kernel of my own, but I want to be able to test it with bochs, or qemu, or some other emulator (Preferably bochs.). I have really no idea how to do this. Does anyone have suggestions? Thanks in advance. :?

[P.S. I'm running on Windows XP]

Posted: Mon Dec 03, 2007 7:56 am
by AJ
Hi,

I would have a look at the Bochs Guide which takes you through how to install and run bochs (I'm using it on XP too). It really is just a matter of writing a config file (theres a sample one in the Bochs install dir, or get the bochs configuration tool to do it for you when you start Bochs) and running it.

You probably want to use a floppy image - have a look at VFD for that.

Cheers,
Adam

Yupp

Posted: Mon Dec 03, 2007 8:07 am
by Bobalandi
Yah, I have it installed and all, but what I meant to ask (sorry...) was how would I put my kernel binary into the image? :?

Posted: Mon Dec 03, 2007 8:10 am
by AJ
With VFD (link above), you create a complete virtual floppy disk. You simply copy over your kernel with Windows. Then edit menu.cfg in \boot and you're away!

Cheers,
Adam

[edit]If you have an existing image, just open it with VFD and tell it to become, for example, drive b:. This all assumes you have GRUB on the image (or some other boot loader). [/edit]

Posted: Mon Dec 03, 2007 8:19 am
by Bobalandi
I'm really sorry, but I still don't understand. I'm using VFD, and I have the image generated by bximage and my kernel is kernel.bin. Sorry, but I am really confused... :oops:

Posted: Mon Dec 03, 2007 8:29 am
by AJ
Ok,

Firstly, is it really a kernel, or is it a boot loader? If it's a boot loader (and therefore needs to be on the first disk sector), see http://www.osdever.net/tutorials/usingpcopy.php.

If you have a boot loader, and you simply want to put kernel.bin on that floppy disk (FAT12), just copy the file, as usual, in Windows using explorer. If you are using GRUB, you will need to navigate to [fddletter]:\boot\menu.cfg and edit a new entry for your kernel.

Now, for Bochs, create a new file called bochsrc.bxrc in notepad (not with a .txt extension). Add the following lines to the file:

Code: Select all

#	Memory and BIOS
megs: 32
romimage: file="C:\Program Files\Bochs-2.3.5\BIOS-bochs-latest"
vgaromimage: file="C:\Program Files\Bochs-2.3.5\VGABIOS-lgpl-latest"
log: bochsout.txt
log: -

#	Boot Source
boot: floppy
floppy_bootsig_check: disabled=0
floppya: 1_44="b:", status=inserted
You will, of course, need to exchange the letter 'b:' with whatever the letter of your disk drive is. If you are just developping a boot sector, you can replace:

Code: Select all

floppya: 1_44="b:", status=inserted
with

Code: Select all

floppya: 1_44=[path to kernel.bin], status=inserted
Save the file and double-click on it. Bochs should start and try to run your floppy image. If not, let me know the error message you get and we will try to sort it out.

Cheers,
Adam

Posted: Mon Dec 03, 2007 8:49 am
by Bobalandi
I used this in my bochsrc:

Code: Select all

floppya: 1_44=kernel.bin, status=inserted
and I got that there was no bootable device. If it helps at all, I used this tutorial for most of my kernel.

http://osdever.net/bkerndev/Docs/intro.htm

Posted: Mon Dec 03, 2007 8:51 am
by Brynet-Inc
You're trying to boot a kernel without a bootloader.... did you expect it to work? :roll:

Well,

Posted: Mon Dec 03, 2007 8:55 am
by Bobalandi
I tried with a grub boot loader and it didn't work, it just stopped after saying.

Code: Select all

GRUB _

Posted: Mon Dec 03, 2007 9:15 am
by JamesM
Have you (a) installed grub properly and (b) written a menu.lst file?

Posted: Mon Dec 03, 2007 9:20 am
by Bobalandi
I'm not sure about either... How do you properly install grub? Sorry for asking all this stuff...

Posted: Mon Dec 03, 2007 9:33 am
by AJ
Ah - I see why I wasn't answering your question properly now!

A boot sector must be exactly 512b long and must end with 0x55AA. Have a look at the articles at this link http://www.osdever.net/tutorials.php?cat=2&sort=1.

Also, if you don't want to use your own boot loader, see http://www.osdever.net/bkerndev/index.php, which gives you an idea of what you need to do to get a multiboot kernel up and running.

Cheers,
Adam

Posted: Mon Dec 03, 2007 9:46 am
by Bobalandi
That's the tutorial that I used to make my kernel...? :?

Posted: Mon Dec 03, 2007 9:59 am
by JamesM
That tutorial doesn't actually tell you *how* to set up a grub image. Use the wiki or

http://www.jamesmolloy.co.uk/tutorial_h ... setup.html

See the link under "compiling": There is a fully made GRUB boot image ready for your kernel.bin file.

Try that, and report what errors/what happens.

Posted: Mon Dec 03, 2007 10:04 am
by AJ
OK - have a look at this floppy image - that should get you started - I'll leave the link active for a few days: www.ajsoft.co.uk/files/grub.zip

Cheers,
Adam