[Resolved] Somewhat Easy Question (Bochs)

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.
Bobalandi
Member
Member
Posts: 107
Joined: Mon Dec 03, 2007 7:26 am
Location: Near Boston, MA
Contact:

[Resolved] Somewhat Easy Question (Bochs)

Post 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]
Last edited by Bobalandi on Mon Dec 03, 2007 5:27 pm, edited 1 time in total.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
Bobalandi
Member
Member
Posts: 107
Joined: Mon Dec 03, 2007 7:26 am
Location: Near Boston, MA
Contact:

Yupp

Post 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? :?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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]
Bobalandi
Member
Member
Posts: 107
Joined: Mon Dec 03, 2007 7:26 am
Location: Near Boston, MA
Contact:

Post 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:
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
Bobalandi
Member
Member
Posts: 107
Joined: Mon Dec 03, 2007 7:26 am
Location: Near Boston, MA
Contact:

Post 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
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

You're trying to boot a kernel without a bootloader.... did you expect it to work? :roll:
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Bobalandi
Member
Member
Posts: 107
Joined: Mon Dec 03, 2007 7:26 am
Location: Near Boston, MA
Contact:

Well,

Post by Bobalandi »

I tried with a grub boot loader and it didn't work, it just stopped after saying.

Code: Select all

GRUB _
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Have you (a) installed grub properly and (b) written a menu.lst file?
Bobalandi
Member
Member
Posts: 107
Joined: Mon Dec 03, 2007 7:26 am
Location: Near Boston, MA
Contact:

Post by Bobalandi »

I'm not sure about either... How do you properly install grub? Sorry for asking all this stuff...
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
Bobalandi
Member
Member
Posts: 107
Joined: Mon Dec 03, 2007 7:26 am
Location: Near Boston, MA
Contact:

Post by Bobalandi »

That's the tutorial that I used to make my kernel...? :?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

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