实验环境:ubuntu16.04LTS,bochs2.6.11
实验环境搭建可参考链接: 《Orange’s 一个操作系统的实现》第一、二章(搭建工作环境ubuntu16.04LTS+bochs2.6.11).
1.编译配书源码
nasm c08_mbr.asm -o c08_mbr.bin
nasm c08.asm -o c08.asm
2.创建硬盘映像
bximage
========================================================================
bximage
Disk Image Creation / Conversion / Resize and Commit Tool for Bochs
$Id: bximage.cc 13481 2018-03-30 21:04:04Z vruppert $
========================================================================
1. Create new floppy or hard disk image
2. Convert hard disk image to other format (mode)
3. Resize hard disk image
4. Commit 'undoable' redolog to base image
5. Disk image info
0. Quit
Please choose one [0] 1
Create image
Do you want to create a floppy disk image or a hard disk image?
Please type hd or fd. [hd]
What kind of image should I create?
Please type flat, sparse, growing, vpc or vmware4. [flat]
Choose the size of hard disk sectors.
Please type 512, 1024 or 4096. [512]
Enter the hard disk size in megabytes, between 10 and 8257535
[10]
What should be the name of the image?
[c.img]
Creating hard disk image 'c.img' with CHS=20/16/63 (sector size = 512)
The following line should appear in your bochsrc:
ata0-master: type=disk, path="c.img", mode=flat
3.使用dd写硬盘
dd if=c08_mbr.bin of=c.img bs=512 conv=notrunc
dd if=c08.bin of=c.img bs=512 seek=100 conv=notrunc
4.修改bochs配置文件
############################
# Configurate filefor Bochs#
############################
# how much memorythe emulated machine will have
megs: 32
# filename of ROMimages
romimage:file=/usr/local/share/bochs/BIOS-bochs-latest
vgaromimage:file=/usr/local/share/bochs/VGABIOS-lgpl-latest
# what disk imageswill be used
#floppya:1_44=a.img, status=inserted
# choose the bootdisk.
boot: disk
# where do we sendlog messages?
log: bochsout.txt
# disable themouse
mouse: enabled=0
# enable keymapping, using Us layout as default
keyboard:keymap=/usr/local/share/bochs/keymaps/x11-pc-us.map
ata0-master: type=disk, path="c.img", mode=flat
5.执行
bochs -f bochsrc