无题
使用centos7 (遇到坑不少)
bochs-gdb安装(2.7)
由于bochs的GDB要么本地要么远程, 所以我们得整两个bochs, 这个就当bochs-gdb
依赖库安装
1 | sudo yum install gtk2 gtk2-devel libXt libXt-devel libXpm libXpm-devel SDL SDL-devel libXrandr-devel.x86_64 xorg-x11-server-devel glibc-headers gcc-c++ SDL SDL-devel |
安装nasm
1 | wget https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.gz |
下载bochs
1 | wget https://sourceforge.net/projects/bochs/files/bochs/2.7/bochs-2.7.tar.gz --no-check-certificate |
配置文件
1 | ./configure --with-x11 --with-x --enable-all-optimizations --enable-readline --enable-a20-pin --enable-fast-function-calls --enable-gdb-stub |
./configure --with-x11 --with-wx --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-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 --enable-gdb-stub
复制文件(保留,不需要执行, 这个是2.6.8遗留)
1 | cp misc/bximage.cpp misc/bximage.cc |
修改makefile
vim Makefile
1 | # prefix = /usr/local |
构建
1 | sudo make && sudo make install |
显示是这样就代表安装成功了
然后可以查看/usr/local/share /usr/local/bin 下面就有了 对应的东西
复制到bin目录下
1 | cp /usr/local/bochs-gdb/bin/bochs /usr/local/bin/bochs-gdb |
创建硬盘
不同的bochs对应的bximage参数可能不同
1 | yes | bximage -q -hd=16 -func=create -sectsize=512 -imgmode=flat maste |
记录下来配置项 ata0-master: type=disk, path=“master.img”, mode=flat
创建bochsrc-gdb
1 | # configuration file generated by Bochs |
创建启动脚本
1 | export LTDL_LIBRARY_PATH=/usr/local/bochs-gdb/lib/bochs/plugins |
创建启动makefile
和上面二选一即可
1 | debug: $(BUILD)/master.img |
bochs安装
再解压一份bochs
1 | tar xvfz bochs-2.7.tar.gz |
配置文件
1 | ./configure --with-x11 --with-x --enable-all-optimizations --enable-readline --enable-a20-pin --enable-fast-function-calls --enable-x86-debugger --enable-debugger |
./configure --with-x11 --with-wx --enable-debugger --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
–enable-gdb-stub 和 --enable-debugger 是互斥的, --enable-debugger 是本地调试 --enable-gdb-stub 是远程调试
复制文件(不需要执行)
1 | cp misc/bximage.cpp misc/bximage.cc |
修改makefile
vim Makefile
1 | # prefix = /usr/local |
构建
1 | sudo make && sudo make install |
复制到bin目录下
1 | cp /usr/local/bochs/bin/bochs /usr/local/bin/bochs |
编写boot.asm
1 | [org 0x7c00] |
编译boot.asm
1 | nasm -f bin boot.asm -o boot.bin |
将boot.bin写入主引导扇区
1 | dd if=boot.bin of=master.img bs=512 count=1 conv=notrunc |
修改bochs启动配置项
1 | # configuration file generated by Bochs |
创建启动脚本
1 | export LTDL_LIBRARY_PATH=/usr/local/bochs/lib/bochs/plugins |
创建启动makefile
和上面二选一即可
1 | run: $(BUILD)/master.img |
删除bochs
1 | # 进入到bochs的解压目录 |
升级gcc
centos7 默认自带的gcc版本为4.8.5, 需要升级为11版本
1 | sudo yum install centos-release-scl |
升级gdb
1 | mv /usr/bin/gdb /usr/bin/gdb-7 |
qemu安装
进入到root用户
1 | yum install qemu-kvm |
转换磁盘镜像文件
1 | qemu-img convert -f raw -O vmdk boot.img boot.vmdk |
参考
文章链接:
书籍参考:
- 一个64位操作系统的设计与实现
test
1 | wget https://sourceforge.net/projects/bochs/files/bochs/2.6.11/bochs-2.6.11.tar.gz --no-check-certificate |
电源