安装:
sudo apt-get install bochs bochs-x
调用命令:
bochs -f bochsrc
bochsrc文件要点:
1.指定BIOS镜像
romimage: file=/usr/share/bochs/BIOS-bochs-latest
2.指定显卡镜像
vgaromimage: file=/usr/share/bochs/VGABIOS-lgpl-latest
3.指定内存大小
megs: 16
4.指定软盘镜像
floppya: 1_44="Image", status=inserted
5.指定启动盘
boot: a
6.指定远程调试
gdbstub: enabled=1, port = 1234, text_base=0, data_base=0, bss_base=0
7.其它(略)
常见问题小结
1.>>PANIC<<dlopen failed for module ‘x':file not found
- miracle@sunshine:~/study/oldlinux/linux-0.11-devel-060625$ bochs -qf bochsrc-hd.bxrc
- 00000000000i[APIC?] local apic in initializing
- ========================================================================
- Bochs x86 Emulator 2.3.7
- Build from CVS snapshot, on June 3, 2008
- ========================================================================
- 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-hd.bxrc
- 00000000000e[ ] bochsrc-hd.bxrc:194: unknown parameter for parport1 ignored.
- 00000000000e[ ] bochsrc-hd.bxrc:306: ips directive is DEPRECATED (use cpu directive parameter 'ips').
- 00000000000i[ ] lt_dlhandle is (nil)
- 00000000000p[ ] > > PANIC < < dlopen failed for module 'x': file not found
- ========================================================================
- Event type: PANIC
- Device: [ ]
- Message: dlopen failed for module 'x': file not found
- A PANIC has occurred. Do you want to:
- cont - continue execution
- alwayscont - continue execution, and don't ask again.
- This affects only PANIC events from device [ ]
- die - stop execution now
- abort - dump core
- debug - hand control to gdb
- Choose one of the actions above: [die]
- 00000000000i[CTRL ] quit_sim called with exit code 1
这个问题需要通过安装gtk2.0的库文件(具体是什么没考证:))
sudo apt-get install libgtk2.0-dev
2.Message: ROM: System BIOS must end at 0xfffff
- miracle@sunshine:~/study/oldlinux/linux-0.11-devel-060625$ bochs -qf bochsrc-hd.bxrc
- 00000000000i[APIC?] local apic in initializing
- ========================================================================
- Bochs x86 Emulator 2.3.7
- Build from CVS snapshot, on June 3, 2008
- ========================================================================
- 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-hd.bxrc
- 00000000000e[ ] bochsrc-hd.bxrc:194: unknown parameter for parport1 ignored.
- 00000000000e[ ] bochsrc-hd.bxrc:306: ips directive is DEPRECATED (use cpu directive parameter 'ips').
- 00000000000i[ ] lt_dlhandle is 0x99bd928
- 00000000000i[PLGIN] loaded plugin libbx_x.la
- 00000000000i[ ] installing x module as the Bochs GUI
- 00000000000i[ ] using log file bochsout.txt
- ========================================================================
- Event type: PANIC
- Device: [MEM0 ]
- Message: ROM: System BIOS must end at 0xfffff
- A PANIC has occurred. Do you want to:
- cont - continue execution
- alwayscont - continue execution, and don't ask again.
- This affects only PANIC events from device [MEM0 ]
- die - stop execution now
- abort - dump core
- debug - hand control to gdb
- Choose one of the actions above: [die] cont
问题原因:
在2.3.5以前的bochs使用的BIOS-bochs-latest是64k的,那个时候需要加上
romimage: file=BIOS-bochs-latest,address=0xf0000
在2.3.5中的BIOS-bochs-latest更新了,变成了128k的,这个时候配置需要改为
romimage: file=$BXSHARE/BIOS-bochs-latest
解决方法:
去掉配置文件中的address那个
3. directive 'floppy_command_delay' not understood
解决方法:
注掉floppy_command_delay: 50000
参考:
http://forum.ubuntu.org.cn/viewtopic.php?f=65&t=179279&start=0
http://blog.csdn.net/wuyao721/archive/2009/05/13/4178866.aspx
小结:通过apt-get安装bochs固然方便,不过在我学习linux-0.11时,需要跟踪调试内核,则使用bochs debugger版本。
在有些文章中提到的bochsdbg,实际就是通过配置(./configure --enable-debugger --enable-disasm)编译源代码得到的
bochs debugger版本后重命令为bochsdbg得到的!
关于bochsdbg详见《编译安装bochsdbg 2.4》