您的位置:首页 > 其它

学习笔记:一个操作系统的实现--搭建你的工作环境

2012-03-15 22:31 791 查看
         由于这本书的例子是以Linux为主的,因此我采用的操作系统是Ubuntu 11.10,Bochs的版本是2.5.1。安装Ubuntu和下载Bochs的事情这里就不罗嗦了,直入主题,我们讨论Bochs的安装。

简单的安装方法

        在Terminal输入 sudo apt-get install vgabios bochs bochs-x bximage,按下回车键,输入密码就等着完事就行了。但是默认安装的Bochs很可能没有调试功能,而我们最好要求有调试功能。所以我们还是老老实实的选择麻烦的方法:从源代码安装。

从源代码安装

        下载好bochs之后,安装过程并不是很顺,会出现以下错误:

1  configure: error: C++ preprocessor "/lib/cpp" fails sanity check

解决方法:sudo apt-get install build-essential

2  X windows gui was selected, but X windows libraries were not found.

解决方法:sudo apt-get install xorg-dev

3  ERROR: pkg-config was not found, or unable to access the gtk+-2.0 package.

Install pkg-config and the gtk+ development package,

or disable the gui debugger, or the wxWidgets display library (whichever is being used).

解决方法:sudo sudo aptitude install libgtk2.0-dev

这之前,configure的事情就算搞定了,但是在sudo make install时出现了一个诡异的错误。

4  /bin/sh: flex: not found

make[1]: *** [lexer.c] Error 127

make[1]: Leaving directory `/home/well/Desktop/oranges/bochs/bx_debug'

make: *** [bx_debug/libdebug.a] Error 2

这个错误比较诡异,我纠结了很久,没明白为什么,然后去`/home/well/Desktop/oranges/bochs/bx_debug'目录找lexer.c文件,发现是个空文件,然后我又把压缩包解压了一遍,里面的lexer.c文件并不是空文件,然后我重新把lexer.c文件拷进去,再次执行sudo make  install 执行成功。(或许这是bochs开发大师哪里出了点错误吧。)

运行的时候的错误

       如果你照着书上编写bochsrc文件的话,你应该发现了这并不能运行成功,刚到一半就要你退出了。嗯,对的,新版本的bochs对一些文件的位置进行了调整。
       书上提供的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

 
        新版本的bochs修改了BOIS-bochs-latest、x11-pc-us.map的位置,同时用VGABOIS-lgpl-latest替换了vgabios.bin。
        新版本的bochsrc需要对以上三项修该,修改如下:

romimage: file=/usr/local/share/bochs/BIOS-bochs-latest

vgaromimage: file=/usr/local/share/vgabios/VGABOIS-lgpl-latest

map=/usr/local/share/bochs/keymaps/x11-pc-us.map

        如果你和我用的是一样的环境,我相信,修改了以上的错误,你一定就完成了bochs的安装,体会到了看到第一章程序“jmp  -2”
时候的兴奋。

       嗯,第二章就到这里,相信你只要认真按照书上的做,就不会有什么问题了。


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息