Bochs 最新版安装(debian) 及调试 hello world OS 详解
2015-07-15 11:04
766 查看
1.首先下载Bochs源码 下载后解压。
最新版源码包下载地址:
http://bochs.sourceforge.net/getcurrent.html (官方网站)
http://download.csdn.net/detail/wangyezi19930928/7412551 (本地上传)
2. 为了安装Bochs,还要安装一些必要的东西,执行一下命令 如下:
1)、依赖包安装:
所以最后执行的命令如下:
3)、编译
3.安装成功后输入命令bochs 就可以看到启动画面了:
4. 安装 nasm
5. BOCHS运行需要.bochsrc文件,在LINUX下以.开头的文件都是隐藏文件
1) : 可查看这些文件。
2 :如果要运行 image 文件需要先编写bochs配置文件,先看一下其中的几项比较重要的参数:
1)、选择虚拟机的内存
2)、 ROMIMAGE:
3)、
4)、
创建自己的 hello.bxrc:
6、创建 hello world OS
1)、编写 hello.asm
2)、编译hello.asm
3)、
创建 hello.img : 进入到Bochs的目录下,执行如下操作
4)、
把 hello 写入 hello.img 中
输出了 0+1 个块
================================================================================
8.
运行 hello world OS
================================================================================
================================================================================
bochs安装一系列问题:
错误一:
00000000000p[ ] >>PANIC<< bochsrc:10: vgaromimage directive malformed.
vgaromimage: /usr/share/vgabios/vgabios.bin
改成
vgaromimage: file=/usr/share/vgabios/vgabios.bin
错误二:
Event type: PANIC Device: [ ] Message: dlopen failed for module 'x': file not found
sudo apt-get install bochs-x
错误三:
bochs-biin: symbol lookup error: /usr/lib/bochs/plugins/libbx_x.so: undefined symbol: XpmCreatePixmapFromData
首先安装 bochs-sdl
sudo apt-get install bochs-sdl
在 bochsrc 文件中,加入一句话:
display_library: sdl
错误四:
00000000000p[KMAP ] >>PANIC<< line 38: unknown host key name 'XK_0' (wrong keymap ?)
注释掉下面这行
#keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map
错误五:
若出现Message: ROM: System BIOS must end at 0xfffff 错误的原因如下:
In previous versions of Bochs the BIOS size was 64k and you always had to
specify the start address at 0xf0000. Starting with release 2.2.5 Bochs
supports BIOS images up to 512k and it's no longer necessary to specify the
start address if the BIOS ends at memory top
就是不要再指定address了。
================================================================================
颜色代码对照表
闪烁 字符底色 加亮 字符颜色
1 2 3 4 5 6 7 8
BL R G B I R G B
0ch: 0 000 1 100:
黑 红 ; 黑底红字,高亮
================================================================================
二进制编辑
HexEdit
F2 保存(save)
Ctrl+X 保存并退出(save and exit)
================================================================================
11.
读写磁盘镜像文件的方法
软盘镜像文件:
mount -t minix rootimage-0.12-fd /home/dslab/mnt/ -o loop
硬盘镜像文件:
losetup /dev/loop1 rootimage-0.12-hd
fdisk /dev/loop1 >> $num = $Start * 512 (135217152)
losetup -d /dev/loop1
losetup -o $num /dev/loop1 rootimage-0.12-hd
mount -t minix /dev/loop1 /mnt/
umount /mnt/
losetup -d /dev/loop1
================================================================================
12.
使用 bochs 调试内核
-*- Debugger control -*-
help, q|quit|exit, set, instrument, show, trace, trace-reg,
trace-mem, u|disasm, ldsym, slist
-*- Execution control -*-
c|cont|continue, s|step, p|n|next, modebp, vmexitbp
-*- Breakpoint management -*-
vb|vbreak, lb|lbreak, pb|pbreak|b|break, sb, sba, blist,
bpe, bpd, d|del|delete, watch, unwatch
-*- CPU and memory contents -*-
x, xp, setpmem, writemem, crc, info,
r|reg|regs|registers, fp|fpu, mmx, sse, sreg, dreg, creg,
page, set, ptime, print-stack, ?|calc
-*- Working with bochs param tree -*-
show "param", restore
================================================================================
最新版源码包下载地址:
http://bochs.sourceforge.net/getcurrent.html (官方网站)
http://download.csdn.net/detail/wangyezi19930928/7412551 (本地上传)
2. 为了安装Bochs,还要安装一些必要的东西,执行一下命令 如下:
1)、依赖包安装:
sudo apt-get install build-essential sudo apt-get install xorg-dev sudo apt-get install libgtk2.0-dev2)、为了要调试功能的话 需要添加如下参数:
./configure 如果要调试功能的话,可查看configure文件做相应调整 --enable-debugger compile in support for Bochs internal debugger --enable-disasm compile in support for disassembler --enable-debugger-gui compile in support for Bochs internal debugger GUI
所以最后执行的命令如下:
./configure --enable-debugger --enable-disasm --enable-debugger-gui
3)、编译
sudo make install #若不加sudo 安装会出错
cp bochs /bin/bochsdbg
3.安装成功后输入命令bochs 就可以看到启动画面了:
./bochs
4. 安装 nasm
# aptitude install nasm
5. BOCHS运行需要.bochsrc文件,在LINUX下以.开头的文件都是隐藏文件
1) : 可查看这些文件。
vi .bochsrc
2 :如果要运行 image 文件需要先编写bochs配置文件,先看一下其中的几项比较重要的参数:
1)、选择虚拟机的内存
megs: 32 //将前面的注视去掉,是说内存是32M
2)、 ROMIMAGE:
romimage: file=$BXSHARE/BIOS-bochs-latest vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
3)、
floppya: 1_44=hello.img, status=inserted 指定了软盘映像文件
4)、
boot: floppy 从软盘启动。
创建自己的 hello.bxrc:
romimage: file=/home/dslab/Downloads/bochs-20150201/bios/BIOS-bochs-latest vgaromimage: file=/home/dslab/Downloads/bochs-20150201/bios/VGABIOS-lgpl-latest floppya: 1_44="hello.img", status=inserted boot: a # 使用 debug 版时,注释掉 #display_library: sdl
6、创建 hello world OS
1)、编写 hello.asm
org 07c00h mov ax, cs ;数据传送指令,将代码段寄存器cs的内容赋给通用寄存器ax mov ds, ax ;使数据段与代码段在同一个段 mov es, ax ;使附加段与代码段在同一个段 call DispStr jmp $ ;$表示当前地址,无限循环 DispStr: mov ax, BootMessage mov bp, ax ;es:bp=串地址 mov cx, 15 ;串长度 mov ax, 01301h ;ah=13h, al=01h 视频中断13h号功能:写字符串; ;AL=01H,表示写完字符串后,更新光标位置 mov bx, 000ch ;页号为0(bh=0) 黑底红字(bl=0ch,高亮) mov dl, 0 ;DH、DL=写串的光标位置,DH=行号,DL=列号 int 10h ret BootMessage: db "Hello,World OS!" times 510-($-$$) db 0 ;填充剩下的空间,使生成的二进制代码恰好为512字节 dw 0xaa55
2)、编译hello.asm
nasm hello.asm
3)、
创建 hello.img : 进入到Bochs的目录下,执行如下操作
<span style="color: rgb(95, 101, 108); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; line-height: 28px;">bximage</span>
Do you want to create a floppy disk image or a hard disk image? Please type hd or fd. [hd] fd Choose the size of floppy disk image to create, in megabytes. Please type 0.16, 0.18, 0.32, 0.36, 0.72, 1.2, 1.44, 1.68, 1.72, or 2.88. [1.44] I will create a floppy image with cyl=80 heads=2 sectors per track=18 total sectors=2880 total bytes=1474560 What should I name the image? [a.img] hello.img Writing: [] Done. I wrote 1474560 bytes to hello.img. The following line should appear in your bochsrc: floppya: image="hello.img", status=inserted
4)、
把 hello 写入 hello.img 中
dd if=hello of=hello.img读入了 0+1 个块
输出了 0+1 个块
================================================================================
8.
运行 hello world OS
bochs -q -f hello.bxrc bochsdbg -q -f hello.bxrc
================================================================================
================================================================================
bochs安装一系列问题:
错误一:
00000000000p[ ] >>PANIC<< bochsrc:10: vgaromimage directive malformed.
vgaromimage: /usr/share/vgabios/vgabios.bin
改成
vgaromimage: file=/usr/share/vgabios/vgabios.bin
错误二:
Event type: PANIC Device: [ ] Message: dlopen failed for module 'x': file not found
sudo apt-get install bochs-x
错误三:
bochs-biin: symbol lookup error: /usr/lib/bochs/plugins/libbx_x.so: undefined symbol: XpmCreatePixmapFromData
首先安装 bochs-sdl
sudo apt-get install bochs-sdl
在 bochsrc 文件中,加入一句话:
display_library: sdl
错误四:
00000000000p[KMAP ] >>PANIC<< line 38: unknown host key name 'XK_0' (wrong keymap ?)
注释掉下面这行
#keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map
错误五:
若出现Message: ROM: System BIOS must end at 0xfffff 错误的原因如下:
In previous versions of Bochs the BIOS size was 64k and you always had to
specify the start address at 0xf0000. Starting with release 2.2.5 Bochs
supports BIOS images up to 512k and it's no longer necessary to specify the
start address if the BIOS ends at memory top
就是不要再指定address了。
================================================================================
颜色代码对照表
闪烁 字符底色 加亮 字符颜色
1 2 3 4 5 6 7 8
BL R G B I R G B
0ch: 0 000 1 100:
黑 红 ; 黑底红字,高亮
================================================================================
二进制编辑
HexEdit
F2 保存(save)
Ctrl+X 保存并退出(save and exit)
================================================================================
11.
读写磁盘镜像文件的方法
软盘镜像文件:
mount -t minix rootimage-0.12-fd /home/dslab/mnt/ -o loop
硬盘镜像文件:
losetup /dev/loop1 rootimage-0.12-hd
fdisk /dev/loop1 >> $num = $Start * 512 (135217152)
losetup -d /dev/loop1
losetup -o $num /dev/loop1 rootimage-0.12-hd
mount -t minix /dev/loop1 /mnt/
umount /mnt/
losetup -d /dev/loop1
================================================================================
12.
使用 bochs 调试内核
-*- Debugger control -*-
help, q|quit|exit, set, instrument, show, trace, trace-reg,
trace-mem, u|disasm, ldsym, slist
-*- Execution control -*-
c|cont|continue, s|step, p|n|next, modebp, vmexitbp
-*- Breakpoint management -*-
vb|vbreak, lb|lbreak, pb|pbreak|b|break, sb, sba, blist,
bpe, bpd, d|del|delete, watch, unwatch
-*- CPU and memory contents -*-
x, xp, setpmem, writemem, crc, info,
r|reg|regs|registers, fp|fpu, mmx, sse, sreg, dreg, creg,
page, set, ptime, print-stack, ?|calc
-*- Working with bochs param tree -*-
show "param", restore
================================================================================
相关文章推荐
- poj 2342 树形dp
- 自动调节图像的对比度 和改变图像的大小
- GRE写作必备句型
- 详解clientHeight、offsetHeight、scrollHeight
- SystemUI源码分析
- android 中的组合控件的设计
- xml的第一次小试牛刀
- JADX 的使用方法 。
- Unity3D中的C#事件
- 怎么样不利用第三变量交换x,y
- jQuery使用方法简介
- 证明 poj 1014 模优化修剪,部分递归 有错误
- themeforest 模板
- linux下用phpize给PHP动态添加扩展
- Spring MVC 中 引入 Mybatis 的实现方法(一)
- r语言学习(2)
- Linux怎么查看系统开机时间
- 最值得阅读学习的 10 个 C 语言开源项目代码
- [TOJ 4108] Hearthstone
- 第十三周