Linux环境下bochs配置——《一个64位操作系统的设计与实现》

补一下bochs的配置

  • 使用VMware虚拟机,操作系统为Ubuntu

  • bochs用的是2.6.8版本

下载

感觉虚拟机下载比较慢,我在本机上下载后拖进去的,不过也可以直接虚拟机下载

wget -O bochs-2.6.8.tar.gz https://sourceforge.net/projects/bochs/files/bochs/2.6.8/bochs-2.6.8.tar.gz/download

解压

tar zxvf bochs-2.6.8.tar.gz

配置

先进入

cd bochs-2.6.8

配置如果要跟着书写后面的东西,一定一定要按照作者给的configure!鬼知道我后面找bug找了多久

网上有很多bochs的configure,我都试过,刚开始都还好,只是跟着书做后面就做不动了。找了好久的bug,从头装了很多边,发现还是作者大大写得好!!!

./configure --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-voodoo

与作者的还有点不同,我删除了--enable-usb 因为我后面运行的时候出现了问题,具体看这篇文章(感谢大佬救我一命!)

[UB18.04 下搭建bochs 环境_bochs is exiting with the following message: ] bo-CSDN博客

当然如果小伙伴们后面虚拟机开启没有什么问题也可以加上

不得不说电子书很坑,因为我是小白,直接copy的电子书上的,电子书为了排版好看将一些空格后还加了换行……最开始就一直有问题,就没用作者的。当然还是怪我

接着就是make

make

但是我还是有点问题,如下:

 make: *** No rule to make target 'misc/bximage.cc', needed by 'misc/bximage.o'.  Stop.

当然作者大大也写到了,可以运行以下解决:

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

然后运行

sudo make install

等待时间有点长……

模拟

终端输入bochs,如果能正常运行就没有问题啦!

选择6,启动虚拟机

启动成功!

创建虚拟软盘镜像

利用Bochs虚拟机自带的虚拟磁盘镜像创建工具bximage

运行命令

@ubuntu:~/Desktop$ bximage
========================================================================
                                bximage
  Disk Image Creation / Conversion / Resize and Commit Tool for Bochs
         $Id: bximage.cc 13069 2017-02-12 16:51:52Z vruppert $
========================================================================
​
1. Create new floppy or hard disk image
2. Convert hard disk image to other format (mode)
3. Resize hard disk image
4. Commit 'undoable' redolog to base image
5. Disk image info
​
0. Quit
​
Please choose one [0] 1
​
Create image
​
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.
Please type 160k, 180k, 320k, 360k, 720k, 1.2M, 1.44M, 1.68M, 1.72M, or 2.88M.
 [1.44M] 
​
What should be the name of the image?
[a.img] boot.img
​
Creating floppy image 'boot.img' with 2880 sectors
​
The following line should appear in your bochsrc:
  floppya: image="boot.img", status=inserted

选择1,fd,软盘容量1.44MB是通用的3.5英寸软盘,然后对镜像文件取名

接下来可以选择5去查看磁盘信息,不过感觉内存少了点。查阅资料,正常3.5英寸软盘的容量是1.44 MB=1440×1024KB=1474560 B,软盘共包含2个磁头、80个磁道、18个扇区。此处的bximage工具只正确解析出虚拟磁盘容量是1474560 B,bximage工具是按照1MB进行计算的,确实不大对,不过应该不影响?

bochsrc文件

# configuration file generated by Bochs
plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, iodebug=1
config_interface: textconfig
display_library: x
#memory: host=2048, guest=2048
romimage: file="/usr/local/share/bochs/BIOS-bochs-latest"
vgaromimage: file="/usr/local/share/bochs/VGABIOS-lgpl-latest"
boot: floppy
floppy_bootsig_check: disabled=0
floppya: type=1_44, 1_44="boot.img", status=inserted, write_protected=0
# no floppyb
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=none
ata0-slave: type=none
ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata1-master: type=none
ata1-slave: type=none
ata2: enabled=0
ata3: enabled=0
pci: enabled=1, chipset=i440fx
vga: extension=vbe, update_freq=5
​
cpu: count=1:1:1, ips=4000000, quantum=16, model=corei7_haswell_4770,reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0, msrs="msrs.def"
​
cpuid: x86_64=1,level=6, mmx=1, sep=1, simd=avx512, aes=1, movbe=1, xsave=1,apic=x2apic,sha=1,movbe=1,adx=1,xsaveopt=1,avx_f16c=1,avx_fma=1,bmi=bmi2,1g_pages=1,pcid=1,fsgsbase=1,smep=1,smap=1,mwait=1,vmx=1
cpuid: family=6, model=0x1a, stepping=5, vendor_string="GenuineIntel", brand_string="Intel(R) Core(TM) i7-4770 CPU (Haswell)"
​
print_timestamps: enabled=0
debugger_log: -
magic_break: enabled=0
port_e9_hack: enabled=0
private_colormap: enabled=0
clock: sync=none, time0=local, rtc_sync=0
# no cmosimage
# no loader
log: -
logprefix: %t%e%d
debug: action=ignore
info: action=report
error: action=report
panic: action=ask
keyboard: type=mf, serial_delay=250, paste_delay=100000, user_shortcut=none
mouse: type=ps2, enabled=0, toggle=ctrl+mbutton
speaker: enabled=1, mode=system
parport1: enabled=1, file=none
parport2: enabled=0
com1: enabled=1, mode=null
com2: enabled=0
com3: enabled=0
com4: enabled=0
​
megs: 2048

copy作者的,写的很棒!

ok,bochs安装完成,后面就可以直接写了。

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值