在ubuntu 下用 bochs安装编译linux 0.11 并运行

安装 bochs之前做一些准备工作
sudo apt-get install build-essential
sudo apt-get install xorg-dev
sudo apt-get install bison
一.安装bochs
1. 解包
        tar xvfz bochs-20100502.tar.gz
2.进入bochs-20100502目录
        cd bochs-20100502
3. 配置
        编译两份不同的配置的版本
        第一个的版本为使用bochs自带的内部调试器
        ./configure --prefix=/opt/bochs/debug --enable-plugins --enable-debugger --enable-        disasm
        注释:
              * --prefix=/opt/bochs/debug 软件将被安装到哪个目录下
              * --enable-plugins 是必须要的
              * --enable-debugger 是打开bochs的自带调试器
              * --enbale-disasm 允许反汇编


------------------------------------------
如果configure过程中出现这个问题:
checking for gtk+-2.0 >= 2.0.0... Package gtk+-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `gtk+-2.0.pc' to the PKG_CONFIG_PATH environment variable No package 'gtk+-2.0' found
configure: error: Library requirements (gtk+-2.0 >= 2.0.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.


解决办法为:安装 libgtk2.0-dev
sudo apt-get install  libgtk2.0-dev
------------------------------------------


4. 编译
        make
5. 安装
        sudo make install
6.加一个符号连接
        sudo ln -s /opt/bochs/debug/
bin /bochs /usr/bin/bochsdbg


第二个版本为使用
gdb -stub的版本

1. 清理
    在配置第二个版本之前,需要把刚才编译的东西清理掉,输入以下
命令
    make clean
2. 配置
    然后配置,配置命令为
    ./configure --prefix=/opt/bochs/gdbstub --enable-plugins --enable-disasm --enable-           gdb-stub
    配置注释:
        * --enable-gdb-stub 打开gdb stub支持
        * 其他选项同上,注意这个不同版本会安装到不同的目录下。
3. 编译
    make
4. 安装
    sudo make install
这样bochs使用外部调试器gdb的版本就编译好了。
5.建一个符号链接
    sudo ln -s /opt/bochs/gdbstub/bin/bochs  /usr/bin/bochs


二. 编译linux 0.11 
内核
linux 0.11源码文件在linux-0.11-081030.tar.gz中,进入目录解压后的目录linux-0.11中
1. 
ubuntu  8.04 gcc 版本为4.2.4,但是GCC4.x 默认检查stack安全,会导致出现__stack_chk_fail错误,所以在编译之前应先修改Makefile:
    linux-0.11/Makefile
    linux-0.11/
kernel /Makefile
    linux-0.11/kernel/chr_dev/Makefile
    linux-0.11/kernel/blk_dev/Makefile
    linux-0.11/fs/Makefile
    在 CFLAGS参数中加入-fno-stack-protector

2. 安装 as86 ld86
    sudo apt-get install bin86 

3.编译 make  
    (编译不成功记得在下次编译前 make clean 一下),如果编译成功则在linux-0.11目录下生成          Image

三. 配置bochs
这是bochs-2.3.5的配置文件
                
                
                romimage: file=$BXSHARE/BIOS-bochs-latest   
megs: 16 
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
vga: extension=vbe 
floppya: 1_44="Image", status=inserted 
floppyb: 1_44=diska.img, status=inserted 
ata0-master: type=disk, path="hdc-0.11-new.img", mode=flat,cylinders=410, heads=16, spt=38 
boot: a 
log: bochsout.txt
parport1: enable=0 
vga_update_interval: 300000 
keyboard_serial_delay: 200 
floppy_command_delay: 50000 
ips: 4000000 
mouse: enabled=0 
private_colormap: enabled=0 
fullscreen: enabled=0
screenmode: name="sample"
(注:如果编译内核不成功且只是想启动bochs,看一下linux 0.11 界面的话,可以直接把上述配置的boot:a,改为boot:c)

运行bochs
bochs -f bochsrc.bxrc
注:用gdb 调试时出现“system bios must end at 0xffff”,可把*.bxrc romimage 一行中的address=0f0000 去掉

#romimage: file=$BXSHARE/BIOS-bochs-latest, address=0xf0000
romimage: file=$BXSHARE/BIOS-bochs-latest


附:linux 0.11   http://dipplum.com/linux-0.11-lab/linux-0.11-060618-gcc4.tar.gz
     关于在unbuntu下安装0.11般linux 的参考
                 http://oldlinux.org/oldlinux/viewthread.php?tid=3850&extra=page%3D1
                 http://www.seebit.org/2007/12/compile-linux011-in-ubuntu/

遇到的问题:把#elif 该为#else

你可能感兴趣的:(linux)