GNU/Linux环境下搭建GeekOS实验环境

我使用的操作系统为Debian GNU/Linux 6,基本系统安装好后GeekOS实验环境需要安装的组件只有bochs和nasm,直接使用源中的软件包即可:

# apt-get install build-essential
# apt-get install bochs bochs-x nasm

下载geekos-0.3软件包,地址为: http://sourceforge.net/projects/geekos/files/

下载得到一个geekos-0.3.0.zip

复制到任意目录,比如~/work,解压缩:
$ unzip geekos-0.3.0.zip 
解压缩后会得到一个geekos-0.3.0目录。

我们首先试试第一个项目:
$ cd ~/work/geekos-0.3.0/src/project0/build$ 
$ make depend
$ make
在make后会提示错误,
cc1: warnings being treated as errors
In file included from ../src/geekos/gdt.c:11:
../include/geekos/segment.h:43: error: ‘packed’ attribute ignored for field of type ‘uchar_t’

这是因为makefile中默认的编译选项过于严格,把警告都当成错误来看待,我们可以修改一下Makefile将这个过于严格的编译选项去掉。
$ vim Makefile
用vim编辑器打开,找到第149行的-Werror:
CC_GENERAL_OPTS := $(GENERAL_OPTS) -Werror 
修改为:
CC_GENERAL_OPTS := $(GENERAL_OPTS)
:wq保存退出
接下来再make,编译就可以通过了。
$ ls -a
.   .bochsrc  common      fd.img  libc   user
..  Makefile  depend.mak  geekos  tools
现在生成了一个包含工程0编译好的软盘镜像fd.img和bochs模拟器的配置文件.bochsrc,运行bochs却提示错误:
$ bochs
========================================================================
                       Bochs x86 Emulator 2.4.5
              Build from CVS snapshot, on April 25, 2010
========================================================================
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
00000000000p[     ] >>PANIC<< .bochsrc:4: vgaromimage directive malformed.
00000000000e[CTRL ] notify called, but no bxevent_callback function is registered
00000000000i[CTRL ] quit_sim called with exit code 1

仔细看看配置文件是针对很古老的版本的bochs(2.0.2?)写的,甚至文件里面的内容和文件路径都完全不正确,那么我们需要修改这个文件,将vgaromimage和romimage的路径修改正确,并且删除提示错误的行,得到如下文件:
# An example .bochsrc file.
# You will need to edit these lines to reflect your system.
vgaromimage: file=/usr/share/vgabios/vgabios.bin
romimage: file=/usr/share/bochs/BIOS-bochs-latest
megs: 8
boot: a
floppya: 1_44=fd.img, status=inserted
#floppya: 1_44=fd_aug.img, status=inserted
log: ./bochs.out
keyboard_serial_delay: 200
vga_update_interval: 300000
mouse: enabled=0
private_colormap: enabled=0
i440fxsupport: enabled=0
# Uncomment this to write all bochs debugging messages to
# bochs.out.  This produces a lot of output, but can be very
# useful for debugging the kernel.
#debug: action=report
再次启动bochs:
$ bochs

得到如下画面:


说明生成的镜像已经启动成功了。

你可能感兴趣的:(OS,技术文档)