Chinaunix首页 | 论坛 | 博客
  • 博客访问: 113050
  • 博文数量: 23
  • 博客积分: 2092
  • 博客等级: 大尉
  • 技术积分: 305
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-10 19:40
文章分类
文章存档

2011年(3)

2010年(17)

2009年(3)

我的朋友

分类:

2010-08-22 13:20:07

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

 

环境 win7 +VMware+Fedora 9

使用工具:

bochs-2.4.5.tar.gz

nasm-2.09rc6.tar.gz

1,、安装bochs

$tar zxvf bochs-2.4.5.tar.gz

$cd bochs-2.4.5

$./configure --enable-debugger --enable-disasm

$make

#make install

 

注意:因为要运用到线程而configure生成的makefile并没将线程的库连接进来,连接的时候会出错,可以在Makefile中添加链接-lpthread库就可以解决这个问题了。

如下:

LIBS =  -lm -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0  -lpthread

 

安装完之后就可以运行bochs

不过由于使用的是默认的配置文件,不太正确会提示找不到XXX,这里我先先不管它,之后再用我们自己的配置文件。

2.、安装nasm

$tar zxvf nasm-2.09rc6.tar.gz

$ cd nasm-2.09rc6

$ ./configure

$ make

#make install

 

3.、编译boot..ASM

nasm  -o boot.bin boot.asm

只用用bximage生成a.img,然后将引导扇区写进a.img

$ dd if=boot.bin of=a.img bs=512 count=1 conv=notrunc

 

编写我们的配置文件如下:

 

###############################################################

# mybochrc

###############################################################

 

# how much memory the emulated machine will have

megs: 32

 

# filename of ROM images

romimage: file=$BXSHARE/BIOS-bochs-latest

vgaromimage: file=$BXSHARE/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=$BXSHARE/keymaps/x11-pc-us.map

 

使用bochs -f mybochrc 就可以运行hello world

其中 a.img mybochrc 在同一目录下,floppya: 1_44=a.img, status=inserted

这个路径一定要写对,$BXSHARE /usr/local/share/bochs

其运行结果如下图所示:

阅读(1576) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~