我的操作系统是ubuntu8.10。这就是搭建bochs的环境,搭建bochs更操作系统关系不大,我认为重点是在bochs的配置上。配置bochs就需要对bochsrc.bxrc文档的编辑。
在安装bochs之前,需要做的是安装编译环境:
code:
sudo apt-get install build-essential
闲话少说,先从安装开始:
我是用ubuntu的软件包工具apt安装的bochs,当然了也可以直接编译bochs的源代码。源代码在下载即可。在这里我就不介绍怎么编译源代码了。
code:
sudo apt-get install bochs vgabios bochs-x bochsbios bochs-doc
好了,bochs安装完成。
一般网上的资料都会提示你安装好后会有如下工具:
/usr/bin/bochs Bochs启动程序
/usr/bin/bximage Bochs带的制作磁盘镜像文件的工具
/usr/bin/bxcommit 把redolog放进flat磁盘镜像文件中去的交互工具
/usr/share/doc/bochs/bochsrc-sample.txt Bochs配置文件的例子
/usr/share/bochs/BIOS-bochs-* ROM BIOS镜像文件
/usr/share/bochs/VGABIOS-* 与VGA BIOS镜像文件相关的文件
/usr/bin/bochs-dlx 启动Bochs中DLX linux的程序
/usr/share/bochs/dlxlinux/ DLX Linux的目录,包含它的磁盘镜像文件和配置文件
/usr/share/bochs/keymaps/*.map X11和SDL的keymap列表
我这里没有DLX。所以在有一个sls-1.0.zip包,把它下载下来。这个包就有我所需要的。
将这个压缩包解压,解压就不需要叙述了吧~在解压后的目录中,我们可以试一下,看看这个精简的linux能不能在bochs下跑起来,估计够呛:
code:
bochs -q -f 'bochsrc.bxrc'
果然,出现如下错误:
========================================================================
Bochs x86 Emulator 2.3.7
Build from CVS snapshot, on June 3, 2008
========================================================================
00000000000i[ ] LTDL_LIBRARY_PATH not set. using compile time default '/usr/lib/bochs/plugins'
00000000000i[ ] BXSHARE not set. using compile time default '/usr/share/bochs'
00000000000i[ ] reading configuration from bochsrc.bxrc
00000000000e[ ] bochsrc.bxrc:190: unknown parameter for parport1 ignored.
00000000000p[ ] >>PANIC<< bochsrc.bxrc:281: directive 'floppy_command_delay' not understood
00000000000e[CTRL ] notify called, but no bxevent_callback function is registered
00000000000i[CTRL ] quit_sim called with exit code 1
这个文档毕竟是别人的,别人根据自己的机器调试的。所以这个只是指引我们前进的路灯而已,接下来就是开始改了。普通的bochsrc:
romimage: file=$BXSHARE/BIOS-bochs-latest, address=0xf0000
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
但是在Ubuntu下压根就没有VGABIOS-lgpl-latest
例如:
/usr/share/bochs$ ls
BIOS-bochs-latest BIOS-bochs-legacy BIOS-qemu-latest keymaps
后来我才发现,从终端下安装bochs时它把VGA专门作为了一个程序安装在了/usr/share/vgabios/中了。 /usr/share/bochs$ ls /usr/share/vgabios/
vgabios.bin vgabios.cirrus.bin vgabios.cirrus.debug.bin vgabios.debug.bin
根据出错信息
BXSHARE not set. using compile time default '/usr/share/bochs',这是我的出发点,文件中有这么一行:
romimage: file=$BXSHARE\BIOS-bochs-latest, address=0xf0000
不知大家发现什么问题没有,这是个细节:$BXSHARE后跟的是“\”,我的环境是ubuntu,linux环境中需要的是“/” 所以替换为:
romimage: file=/usr/share/bochs/BIOS-bochs-latest, address=0xf0000
同理,将文档中还有一处“$BXSHARE”:
vgaromimage: file=$BXSHARE\vgabios/VGABIOS-elpin-2.40 将这行替换为:
vgaromimage: file=/usr/share/vgabios/vgabios.bin
其中一行出错信息为:00000000000p[ ] >>PANIC<< bochsrc.bxrc:281: directive 'floppy_command_delay' not understood
,当然了google是强大的。在bochsrc.bxrc文档中,将这行注释掉,再试试。得,又出错了:
========================================================================
Event type: PANIC
Device: [MEM0 ]
Message: ROM: System BIOS must end at 0xfffff
A PANIC has occurred. Do you want to:
cont - continue execution
alwayscont - continue execution, and don't ask again.
This affects only PANIC events from device [MEM0 ]
die - stop execution now
abort - dump core
debug - hand control to gdb
Choose one of the actions above: [die]
其中一行出错信息为:
Message: ROM: System BIOS must end at 0xfffff
这又是一个出发点,查google:
因为不同的版本会有不同的值
bochsrc_sample.txt说明如下:
#=======================================================================
# ROMIMAGE:
# The ROM BIOS controls what the PC does when it first powers on.
# Normally, you can use a precompiled BIOS in the source or binary
# distribution called BIOS-bochs-latest. The ROM BIOS is usually loaded
# starting at address 0xf0000, and it is exactly 64k long. Another option
# is 128k BIOS which is loaded at address 0xe0000.
# You can also use the environment variable $BXSHARE to specify the
# location of the BIOS.
# The usage of external large BIOS images (up to 512k) at memory top is
# now supported, but we still recommend to use the BIOS distributed with
# Bochs. Now the start address can be calculated from image size.
#=======================================================================
romimage: file=/usr/local/share/bochs/BIOS-bochs-latest
所以最省心的方法是去掉address=0xf0000
OK,环境搭建完成。
阅读(8180) | 评论(0) | 转发(0) |