注:本文为笔者的学习笔记,并非教学文章。旨在记录笔者本人的学习过程,摸索中遇到的困难以及积累经验,若能为有相同难题的朋友提供一定的前车之鉴则再好不过。希望各位辩证性阅读,讨论。
前提:相关软硬件版本
VMware® Workstation 17 Pro 版本17.5.1 build-23298084
搭建Ubuntu系统,版本ubuntu-16.04.6-desktop-i386
bochs2.7。
问题一:bochsrc配置文件在哪里?
bochsrc文件需要自己建立,
在翻遍了整个虚拟机也没有找到这个文件后我得出以上结论。
问题二:运行报错
尤其是在经历了一系列困难,最终搭建好bochs环境,跟着教科书写下第一段代码和bochsrc配置文件后,并没有想象中的顺利运行,而是接二连三的报错:
根据网上的不可靠消息表示,这种情况多半是配置文件(bochsrc)出了问题;
原配置文件:
###############################################################
# Configuration file for Bochs
###############################################################
# how much memory the emulated machine will have
megs: 32
# filename of ROM images
romimage: file=/usr/share/bochs/BIOS-bochs-latest
vgaromimage: file=/usr/share/vgabios/vgabios.bin
# what disk images will be used
floppya: 1_44=a.img, status=inserted
# choose the boot disk.
boot: floppy
# where do we send log messages?
# log: bochsout.txt
# disable the mouse
mouse: enabled=0
# enable key mapping, using US layout as default.
keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map
配置文件并不算长,但也当然不能直接照搬,需要根据自己机器的实际情况进行修改。
修改项:
romimage: file=/usr/share/bochs/BIOS-bochs-latest
vgaromimage: file=/usr/share/vgabios/vgabios.bin
这里的romimage和vgaromimage指定的文件对应着真实机器的BIOS和VGABIOS,所以需要根据实际情况进行修改。
修改后:
romimage: file=/home/user-9009715/labor/bochs-2.7/bios/BIOS-bochs-latest
vgaromimage: file=/home/user-9009715/labor/bochs-2.7/bios/VGABIOS-lgpl-latest
此外,根据老师给的PPT,还需要
1、注释掉keyboard_mapping一行或者作出修改,笔者能力有限选择直接注释掉。
2、增加一行:display_library: sdl
onfiguration file for Bochs
###############################################################
# how much memory the emulated machine will have
megs: 32
# filename of ROM images
romimage: file=/home/user-9009715/labor/bochs-2.7/bios/BIOS-bochs-latest
vgaromimage: file=/home/user-9009715/labor/bochs-2.7/bios/VGABIOS-lgpl-latest
# what disk images will be used
floppya: 1_44=a.img, status=inserted
# choose the boot disk.
boot: floppy
# where do we send log messages?
# log: bochsout.txt
# disable the mouse
mouse: enabled=0
# enable key mapping, using US layout as default.
# keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map
display_library: sdl
《Orange-_S一个操作系统的实现》中告诉我们:
如果你在Windows下的话romimage和vgaromimage两项指定的文件应该是安装目录下的BIOS-bochs-latest和VGABIOS-lgpl-latest。当然最保险的方法是参考安装程序自带的DLX linux 的配置文件将其稍作修改即可。
但笔者的Linux环境下的bochs并没有找到vgabios.bin文件,反而找到了VGABIOS-lgpl-latest?(搞不懂为什么
搞懂了
文件找错了,怪不得搞不懂。
笔者找到的文件:
实际上的BIOS和vgabios文件:
所以正确的文件路径应该为:
romimage: file=/usr/local/share/bochs/BIOS-bochs-latest
vgaromimage: file=/usr/share/vgabios/vgabios.bin
configuration file for Bochs
###############################################################
# how much memory the emulated machine will have
megs: 32
# filename of ROM images
romimage: file=/usr/local/share/bochs/BIOS-bochs-latest
vgaromimage: file=/usr/share/vgabios/vgabios.bin
# what disk images will be used
floppya: 1_44=a.img, status=inserted
# choose the boot disk.
boot: floppy
# where do we send log messages?
# log: bochsout.txt
# disable the mouse
mouse: enabled=0
# enable key mapping, using US layout as default.
# keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map
display_library: sdl
(代码里有个小问题你能找到吗?)
你以为这就结束了吗?
修改代码,运行,报错一气呵成
还是报错,心态没崩,应该是麻了。
这就不得不提到上文中的小问题了:第一行是没有用的,需要注释掉。
附上正确的配置文件 bochsrc
#configuration file for Bochs
###############################################################
# how much memory the emulated machine will have
megs: 32
# filename of ROM images
romimage: file=/usr/local/share/bochs/BIOS-bochs-latest
vgaromimage: file=/usr/share/vgabios/vgabios.bin
# what disk images will be used
floppya: 1_44=a.img, status=inserted
# choose the boot disk.
boot: floppy
# where do we send log messages?
# log: bochsout.txt
# disable the mouse
mouse: enabled=0
# enable key mapping, using US layout as default.
# keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map
display_library: sdl
以及运行截图:
这里输入6,开始模拟
泪目了