下载bochs
当前版本:2.6.11
下载地址:https://sourceforge.net/projects/bochs/files/bochs/2.6.11/bochs-2.6.11.tar.gz
下载命令:
wget https://sourceforge.net/projects/bochs/files/bochs/2.6.11/bochs-2.6.11.tar.gz
安装
解压
tar zxvf bochs-2.6.11.tar.gz
配置
./configure --prefix=/home/wxer/opt/bochs --with-x11 --with-wx --enable-debugger --enable-disasm --enable-all-optimizations --enable-readline --enable-long-phy-address --enable-ltdl-install --enable-idle-hack --enable-plugins --enable-a20-pin --enable-x86-64 --enable-smp --enable-cpu-level=6 --enable-large-ramfile --enable-repeat-speedups --enable-fast-function-calls --enable-handlers-chaining --enable-trace-linking --enable-configurable-msrs --enable-show-ips --enable-cpp --enable-debugger-gui --enable-iodebug --enable-logging --enable-assert-checks --enable-fpu --enable-vmx=2 --enable-svm --enable-3dnow --enable-alignment-check --enable-monitor-mwait --enable-avx --enable-evex --enable-x86-debugger --enable-pci --enable-usb --enable-voodoo
编译
make
出现如下错误
make[1]: 进入目录“/home/wxer/os_dev/bochs/bochs-2.6.11/bx_debug”
g++ -c -I.. -I./.. -I../instrument/stubs -I./../instrument/stubs -I. -I./. -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -pthread dbg_main.cpp -o dbg_main.o
In file included from dbg_main.cpp:28:
dbg_main.cpp: In function ‘void bx_dbg_tlb_lookup(bx_lin_address)’:
../cpu/cpu.h:383:28: error: invalid use of ‘this’ in non-member function
383 | # define BX_CPU_THIS_PTR this->
| ^~~~
../cpu/tlb.h:62:32: note: in expansion of macro ‘BX_CPU_THIS_PTR’
62 | #define BX_ITLB_INDEX_OF(lpf) (BX_CPU_THIS_PTR ITLB.get_index_of(lpf))
| ^~~~~~~~~~~~~~~
dbg_main.cpp:1497:18: note: in expansion of macro ‘BX_ITLB_INDEX_OF’
1497 | Bit32u index = BX_ITLB_INDEX_OF(laddr);
| ^~~~~~~~~~~~~~~~
../cpu/cpu.h:383:28: error: invalid use of ‘this’ in non-member function
383 | # define BX_CPU_THIS_PTR this->
| ^~~~
../cpu/tlb.h:59:37: note: in expansion of macro ‘BX_CPU_THIS_PTR’
59 | #define BX_DTLB_INDEX_OF(lpf, len) (BX_CPU_THIS_PTR DTLB.get_index_of((lpf), (len)))
| ^~~~~~~~~~~~~~~
dbg_main.cpp:1501:11: note: in expansion of macro ‘BX_DTLB_INDEX_OF’
1501 | index = BX_DTLB_INDEX_OF(laddr, 0);
| ^~~~~~~~~~~~~~~~
make[1]: *** [Makefile:67:dbg_main.o] 错误 1
make[1]: 离开目录“/home/wxer/os_dev/bochs/bochs-2.6.11/bx_debug”
make: *** [Makefile:330:bx_debug/libdebug.a] 错误 2
解决方法:
Description: Fix the build with SMP enabled
Origin: https://sourceforge.net/p/bochs/code/13778/
Index: bochs/bx_debug/dbg_main.cc
===================================================================
--- bochs/bx_debug/dbg_main.cc (revision 13777)
+++ bochs/bx_debug/dbg_main.cc (working copy)
@@ -1494,11 +1494,11 @@
{
char cpu_param_name[16];
- Bit32u index = BX_ITLB_INDEX_OF(laddr); //这一行改成下面一行
+ Bit32u index = BX_CPU(dbg_cpu)->ITLB.get_index_of(laddr);
sprintf(cpu_param_name, "ITLB.entry%d", index);
bx_dbg_show_param_command(cpu_param_name, 0);
- index = BX_DTLB_INDEX_OF(laddr, 0); //同理
+ index = BX_CPU(dbg_cpu)->DTLB.get_index_of(laddr);
sprintf(cpu_param_name, "DTLB.entry%d", index);
bx_dbg_show_param_command(cpu_param_name, 0);
}
这个修改后,还会有如下错误
make: *** 没有规则可制作目标“misc/bximage.cc”,由“misc/bximage.o” 需求。 停止。
解决方法:
cp misc/bximage.cpp misc/bximage.cc
cp iodev/hdimage/hdimage.cpp iodev/hdimage/hdimage.cc
cp iodev/hdimage/vmware3.cpp iodev/hdimage/vmware3.cc
cp iodev/hdimage/vmware4.cpp iodev/hdimage/vmware4.cc
cp iodev/hdimage/vpc-img.cpp iodev/hdimage/vpc-img.cc
cp iodev/hdimage/vbox.cpp iodev/hdimage/vbox.cc
安装
make install
接着在HOME目录下的.bashrc文件中添加安装的bochs所在目录
...
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
export PATH=~/bin/repo:$PATH
export PATH=~/opt/bochs/bin:$PATH