《一个64位操作系统的设计与实现》学习实践1-环境搭建

感谢一下深圳图书馆,作者田宇哥。

2014年的时候,我也想写的直接在PC上跑的简单操作系统。也准备MASM,NASM,BOCHS,GCC等等,却耽误到现在。这次从深圳图书馆发现了田宇哥书,借助田宇哥的指导完成未尽的愿望。

实践资料百度网盘地址:

链接:https://pan.baidu.com/s/1DjfjqM8Z6M_1Ga4lA6RYcA 
提取码:g9it 

首先安装好虚拟机vmware,ubuntu系统。这个是基本功,如果借助于互联网安装不了,也不要继续下面的事情了。

其次查询一下以下命令工具是否准备好,其中NASM需要下载源码安装,其他可以直接通过apt-get install xxx 安装
 

root@ubuntu:~# gcc -v
root@ubuntu:~# as -v
root@ubuntu:~# ld -v
root@ubuntu:~# dd --version
root@ubuntu:~# mount --version
root@ubuntu:~# umount --version
root@ubuntu:~# cp --version
root@ubuntu:~# sync --version
root@ubuntu:~# rm --version
root@ubuntu:~# objcopy --version
root@ubuntu:~# objdump --version
root@ubuntu:~# make -v
root@ubuntu:~# nasm -v
root@ubuntu:~# wget https://www.nasm.us/pub/nasm/releasebuilds/2.14rc16/nasm-2.14rc16.tar.gz
root@ubuntu:~# tar -zxvf  nasm-2.14rc16.tar.gz
root@ubuntu:~# cd nasm-2.14rc16
root@ubuntu:~/nasm-2.14rc16# ./configure
root@ubuntu:~/nasm-2.14rc16# make
root@ubuntu:~/nasm-2.14rc16# make install
root@ubuntu:~/nasm-2.14rc16# nasm -v
root@ubuntu:~/nasm-2.14rc16# NASM version 2.14rc16 compiled on Mar 28 2019

然后下载编译Bochs虚拟机,Bochs虚拟机能在linux平台下调试。

root@ubuntu:~# wget https://nchc.dl.sourceforge.net/project/bochs/bochs/2.6.9/bochs-2.6.9.tar.gz
root@ubuntu:~# tar -zxvf  bochs-2.6.9.tar.gz
root@ubuntu:~# cd bochs-2.6.9
root@ubuntu:~/bochs-2.6.9# ./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-usb --enable-v

root@ubuntu:~/bochs-2.6.9# make

//会报错,因为系统缺少libxrandr-dev的库,
x.cpp:42:35: fatal error: X11/extensions/Xrandr.h: No such file or directory 

root@ubuntu:~/bochs-2.6.9# apt-get install -y libxrandr-dev
//其他报错处理
root@ubuntu:~/bochs-2.6.9# cp misc/bximage.cpp misc/bximage.cc
root@ubuntu:~/bochs-2.6.9# cp iodev/hdimage/hdimage.cpp iodev/hdimage/hdimage.cc
root@ubuntu:~/bochs-2.6.9# cp iodev/hdimage/vmware3.cpp iodev/hdimage/vmware3.cc
root@ubuntu:~/bochs-2.6.9# cp iodev/hdimage/vmware4.cpp iodev/hdimage/vmware4.cc
root@ubuntu:~/bochs-2.6.9# cp iodev/hdimage/vpc-img.cpp iodev/hdimage/vpc-img.cc
root@ubuntu:~/bochs-2.6.9# cp iodev/hdimage/vbox.cpp iodev/hdimage/vbox.cc

root@ubuntu:~/bochs-2.6.9# make clean
root@ubuntu:~/bochs-2.6.9# make
root@ubuntu:~/bochs-2.6.9#
root@ubuntu:~/bochs-2.6.9# make install

 

启动bochs虚拟机,按下数字6选项,检查安装是否成功。

root@ubuntu:~# bochs
========================================================================
                       Bochs x86 Emulator 2.6.9
               Built from SVN snapshot on April 9, 2017
                  Compiled on Mar 28 2019 at 10:03:12
========================================================================
00000000000i[      ] LTDL_LIBRARY_PATH not set. using compile time default '/usr/local/lib/bochs/plugins'
00000000000i[      ] BXSHARE not set. using compile time default '/usr/local/share/bochs'
00000000000i[      ] lt_dlhandle is 0xb59220
00000000000i[PLUGIN] loaded plugin libbx_usb_common.so
00000000000i[      ] lt_dlhandle is 0xb59ba0
00000000000i[PLUGIN] loaded plugin libbx_unmapped.so
00000000000i[      ] lt_dlhandle is 0xb5a3a0
00000000000i[PLUGIN] loaded plugin libbx_biosdev.so
00000000000i[      ] lt_dlhandle is 0xb5ace0
00000000000i[PLUGIN] loaded plugin libbx_speaker.so
00000000000i[      ] lt_dlhandle is 0xb5bad0
00000000000i[PLUGIN] loaded plugin libbx_extfpuirq.so
00000000000i[      ] lt_dlhandle is 0xb5c310
00000000000i[PLUGIN] loaded plugin libbx_parallel.so
00000000000i[      ] lt_dlhandle is 0xb5df20
00000000000i[PLUGIN] loaded plugin libbx_serial.so
00000000000i[      ] lt_dlhandle is 0xb622d0
00000000000i[PLUGIN] loaded plugin libbx_iodebug.so
------------------------------
Bochs Configuration: Main Menu
------------------------------

This is the Bochs Configuration Interface, where you can describe the
machine that you want to simulate.  Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found.  When you are satisfied with the configuration, go
ahead and start the simulation.

You can also start bochs with the -q option to skip these menus.

1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now

Please choose one: [2] 6

接下来会弹出bochs虚拟机的运行框图,如下图所示:

《一个64位操作系统的设计与实现》学习实践1-环境搭建_第1张图片

在旁边的shell终端里面输入c回车,运行bochs虚拟机。c代表continue命令的意思。

《一个64位操作系统的设计与实现》学习实践1-环境搭建_第2张图片

回车以后,就能看到bochs虚拟机的画面了。

《一个64位操作系统的设计与实现》学习实践1-环境搭建_第3张图片

到这里环境搭建就告一段落。

点开shell界面,按下Ctrl+C后,输入exit命令退出bochs虚拟机

 

 

------------------------------------------------------------------------------------------

预留

你可能感兴趣的:(64位操作系统)