Bochs for Windows

Bochs for Windows

by K.J.

What is Bochs?

Bochs is a very complete x86 PC emulator(with almost complete support for x86-64). It allows you to actually run two or more operating systems at the same time on the same computer. It runs on Windows(9x/2k/XP), Linux, BeOS, Mac OSX, Sharp Zaurus and more. All that and Bochs is 100% free and opensource!

How do I setup Bochs?

First, you need to get Bochs. You can download it either from the Bochs homepage or from our downloads page. Then, simply unzip Bochs to the desired directory. Now you need to create a configuration file for Bochs.

Setting Up a Bochs Configuration File for a Simple OS

Okay, let's set up bochs to boot from an OS that is on a floppy disk.

First, we need a new directory that's inside the Bochs' directory. In my case, I'm going to create a new directory called OS dev inside the Bochs' directory. Second, we need to make a configuration file called bochsrc.txt in the directory that we just created. The configuration file is important because it tells Bochs where our floppy disk image is, that we want to boot from it, and where the BIOS rom and VGA rom are. This is a sample configuration file that will work fine for what we are doing:

# how much memory the emulated machine will have
# if you have less than 64MB of memory in your actuall computer, set this lower(16 is good)
megs: 32

# filename of ROM images
# note that if before a filename we put "../" then the file is looked
# for in the directory above that the current directory(the one the configuration
# file is in).
romimage: file=../BIOS-bochs-latest, address=0xf0000
vgaromimage: ../VGABIOS-elpin-2.40

# we want a floppy drive(called a), the disk image that we are using is called "1.44"
floppya: 1_44=1.44, status=inserted

# choose the boot disk.
boot: a

# where do we send log/error messages?
log: bochsout.txt

# disable the mouse unless your OS uses it
mouse: enabled=0

Every line starting with a # is a comment. I'm not going to go over the configuration file in-depth, as the comments explain it fairly well. If you have a question about a certain line, check out Bochs' documentation.

Now it's time to make a floppy disk image!

Making a Floppy Disk Image

First, start by copying your bootsector and kernel to a real 1.44MB floppy(this tutorial assumes that the floppy is FAT12 formatted). Once that's done, we need to make an image of it. An image is simply every single bit and byte of a disk put into a file. There are several ways to do this.

The first is to go get WinImage(sharware, 30-day trial, costs $30(US) for standard or $60(US) for professional). The second is to use PartCopy(freeware). The third is to use RawWrite(freeware).

Using PartCopy

Using PartCopy is pretty easy. Just insert your floppy into the first floppy drive and run PartCopy with like this:

partcopy -f0 0 168000 1.44

This instructs PartCopy to copy the entire floppy and to put the data in a file called 1.44(which you will find in the same directory as PartCopy once you do the above). Copy 1.44 to the directory where the Bochs configuration file is.

Using WinImage

Install WinImage and run it. Then, insert your floppy into the first floppy drive and select Disk -> Read Disk. Once it is finished you need to save the floppy image. Be sure to select All files when you save the image and don't password protect the image or it will be written in the wrong format:

Just save it to the directory that you made earlier and rename the file if necessary.

Using RawWrite

RawWrite is pretty much self explanitory. Just run it, select Read, specify a file name and where you want it, and click the Read button.

Running Bochs

Now, make a file called bochs.bat in the same directory that your Boch's configuration file is in. Then put the following lines into the bochs.bat:

..\bochs

Now, just double click on the file you just made to run Bochs! Bochs will ask you some questions before starting the emulation. Generally, you can just hit enter to accept the defaults. If Bochs complains about no configuration file, then just specify it:

Using The Images From the Downloads Section

The images in the downloads section already have a bootsector in them but they don't have a kernel. If the image is FAT12 formatted, you can use WinImage and inject a kernel into the image.

Putting an Image Back Onto a Floppy

Putting an image onto a floppy is easy. Just use RawWrite.

Notes

-Under Win2k/XP, Bochs can directly access the computer's physical floppy drive if you set the 1_44 to the letter of the drive on your computer.
-Though Bochs provides very accurate emulation, I highly recommend that you occasionally test your OS on a real PC, as occasionally something will work in Bochs, but not on a real PC.
-You can compile Bochs yourself under Windows with Visual C++ 6 or Cygwin.
-The CVS version of Bochs generally has more features that the official version, and often has some speedups too. The downside is it's not bug free.
-The VGABIOS-lgpl-latest VGA ROM has VBE 3.0 support, though it's colors aren't as accurate as VGABIOS-elpin-2.40 .
-As of Bochs 2.0, Bochs can be compiled as one executable, or as one executable with several plugins. If your version of Bochs has been compiled to use plugins, you need to have the plugins in the same directoy as your configuration file.
-Another way to make disk images is with dd, on Windows, the command is: dd if=floppy.img of=a: and in *nix dd if=floppy.img of=/dev/fd0

Related

Report issues via Bona Fide feedback.

2001 - 2017 © Bona Fide OS Development | The Goal | Contributors | How To Help |