Bochs Software Company

http://world.std.com/~bochs.

Bochs x86 PC Emulation Software



Getting current source code

Source code for Bochs, is available via FTP at ftp://ftp.std.com/pub/bochs/. Release names are of the format bochs-YYMMDD.tar.gz.

Compiling source code

All releases are gzip'd tar files. That means the whole Bochs source code directory has been consolidated into one file using the Unix command 'tar', then compressed to save space with GNU 'gzip'. To extract the source code, you'll need both 'tar' and 'gzip/gunzip'. All files are contained within one subdirectory named 'bochs-YYMMDD'.
    cd /path/parent-directory
    gzip -dc bochs-YYMMDD.tar.gz | tar -xvf -
    cd bochs-YYMMDD
Before compiling, you'll need to run the configure script, which will configure source code to run on your system, and with your chosen options. There are many options to 'configure', and some depend upon which OS you plan to run within Bochs. To see a complete list:
    unix-> ./configure --help
Options to 'configure':
    --enable-inlines                 use inlines for instruction funcs
    --enable-debugger                compile in support for Bochs internal debugger
    --enable-8086                    target emulation is 8086
    --enable-80286                   target emulation is 80286
    --enable-80386                   target emulation is 80386
    --enable-native-floppy           allow use of native floppy device
    --enable-dma-floppy-io           allow use of DMA/floppy IO xfers
    --enable-v8086-mode              allow use of virtual 8086 mode
    --enable-paging                  allow use of paging
    --enable-tasking                 allow use of tasking
    --enable-vga                     use VGA emulation
    --enable-memory=Nmegs            configure emulator with Nmegs RAM
    --enable-hga-dumps=Nmicroseconds copy memory to HGA video buffer every N useconds
    --enable-external-device-models  use external hardware device models
    --enable-external-cpu-memory     use external CPU+memory simulation environment
    --enable-bochs-bios-hooks        compile in native Bochs BIOS hooks
    --enable-processor-ips=IPS       processor speed in instructions/sec
    --enable-tlb                     use a TLB for faster paging
    --enable-smf                     use static member functions for speed
Set your CC & CFLAGS environment flags for your compiler and optimization flags. For example, on a SuperSparc with GCC: (CSH)
    unix-> setenv CC gcc
    unix-> setenv CFLAGS "-Wall -O3 -mv8 -msupersparc -mno-epilogue"
...or on an x86 with Linux and GCC: (CSH)
    unix-> setenv CC gcc
    unix-> setenv CFLAGS "-Wall -O3 -m486 -fomit-frame-pointer -pipe"
Now run the configure script with necessary options. For example, for Win'95 I use the following. Note that the 'megs:' directive in your '.bochsrc' file will override the '--enable-memory=' option if you supply one, but you might as well compile in a reasonable default.
    # for Win '95
    unix-> ./configure --enable-memory=16 \
                       --enable-bochs-bios-hooks \
                       --enable-processor-ips=400000

    # for Minix, you need DMA/Floppy IO emulation
    unix-> ./configure --enable-memory=16 \
                       --enable-bochs-bios-hooks \
                       --enable-processor-ips=400000 \
                       --enable-dma-floppy-io
If the configure script bombs, check 'config.log'. Specifically, look for errors returned by the compiler. You may have options incompatible with your compiler. See the section on setting the CC & CFLAGS above.

Assuming at this point all went well with the configure command, you may compile the source.

    unix-> make

Setting up environment before running

In text mode, Bochs requires your X server to have access to the VGA font. If you don't already have it, you must install it from one of the font files in bochs-yymmdd/font.

There are two options; you may install the VGA font in a global place, or in a local directory. You may need to install it locally if you don't have root access.

Option 1: installing VGA font in global font directory


   # NOTE1: Make sure your DISPLAY variable points to local machine.
   # NOTE2: These steps require root privileges.
   # NOTE3: Your X11 fonts path will vary on different systems. For example:
   #        Solaris 2.x /usr/openwin/lib/X11/fonts
   #        Linux       /usr/lib/X11/fonts/
   root-> cp font/vga.pcf font-path-here/misc
   root-> compress font-path-here/vga.pcf
   root-> mkfontdir font-path-here/misc
   root-> xset fp rehash
Option 2: installing VGA font in local font directory
   # NOTE1: Make sure your DISPLAY variable points to local machine.
   # NOTE2: The "xset" command needs to be run for each X session.
   user-> mkfontdir bochs-YYMMDD/font
   user-> xset fp+ [full-path]/bochs-YYMMDD/font
Hard Drive Image File: Bochs emulates a hard drive by using a large Unix file, which you must create. The size of the hard drive is dependent upon the number of cylinders, heads, and sectors-per-track that you would like to emulate. Here are some examples of possible drive geometries:

Size Cylinders Heads Sectors/Track Sectors Total
10MB 306 4 17 20808
20MB 615 4 17 41820
30MB 615 6 17 62730
46MB 940 6 17 95880
62MB 940 8 17 127840
112MB 900 15 17 229500
483MB 1024 15 63 967680

Pick the size of the hard drive you want to emulate, and create a blank file according to the parameters in the table. If you have the 'dd' command, you can use it to create the file. Keeping in mind that there are 512 bytes in a sector, just use the number of "Sectors Total" from the table as the 'count=' option to dd, and tell dd to use a block size ('bs=') the same as a disk sector size (512). For example, for a 112MB drive, there are 229500 (900*15*17) sectors.
    unix-> dd if=/dev/zero of=112M bs=512 count=229500
Floppy Disk Image File: Bochs emulates a floppy drive/disk using either a Unix file, or a real floppy drive Unix device. To use either, you will need an entry in your '.bochsrc' file pointing to the regular or device file. Use the 'floppya:' and 'floppyb:' directives. If you are starting out, you will need to make a copy of an existing bootable floppy. Otherwise, you may create a blank image file, if you intend on formatting it using the OS you boot within Bochs.

Size Cylinders Heads Sectors/Track Sectors Total
0.720MB 80 2 9 1440
1.2MB 80 2 15 2400
1.44MB 80 2 18 2880
1.680MB 80 2 21 3360


To create a blank floppy image file, you can use the same concept as above for creating blank hard disk image files. For example, to create a blank 1.44MB floppy image file:
    unix-> dd if=/dev/zero of=1.44M bs=512 count=2880
To create a copy of an existing floppy disk, granted you have a floppy disk drive on your workstation, you can use one of the following commands, where '/dev/fd0' would be the path to your floppy drive device name.

NOTE: If your system uses a form of volume management to automount your floppy drive, you may have to tell it you popped in a new floppy, and use an alternative device name to access it.

    # Linux, direct use of floppy drive using 'dd'
    unix-> dd if=/dev/fd0 ibs=512 of=1.44M

        --or--

    # Linux, direct use of floppy drive using 'cp'
    unix-> cp /dev/fd0 1.44M

        --or--

    # With Volume Management handling floppy drive
    Solaris 2.x-> volcheck
    Solaris 2.x-> dd if=/vol/dev/aliases/floppy0 ibs=512 of=1.44M

Installing an OS (DOS/Win'95/Minix/Linux) within Bochs

The goal of Bochs is to emulate the components of a basic PC (CPU, BIOS, disk drive, floppy, keyboard, VGA, and other chipsets) well enough to allow for multiple Operating Systems to run within the emulator. So far, Bochs has been successful in running several OS's at one time or the other. Follow the link of your choice to learn how to install the OS of your interest.

Bochs source code developers email mailing list

  To subscribe:
    email to: bochs-developers-request@world.std.com
    subject:  (leave blank)
    body:     subscribe

  To send to mailing list
    email to: bochs-developers@world.std.com

X11 Keyboard Hacks

  NOTE: your backspace key may not work properly.  You may have to
        source the file 'xmods' in the main distribution directory.
        I need to look at this problem a little more.
        Using Ctrl-h always seems to work for me.