《一个操作系统的实现》学习笔记(一) bochs源码安装及配置

前言:本机环境ubuntu 14.04 bochs 2.4.5

 

一.下载

  官网 http://bochs.sourceforge.net/

 

二.安装

  1.将下载好的压缩包解压并进入该目录

tar vxzf bochs-2.4.5.tar.gz
cd bochs-2.4.5

  2.安装编译程序依赖的包

sudo apt-get install build-essential

  3.检测环境,打开调试功能的开关

./configure --enable-debugger --enable-disasm

    (1)如出现 ERROR: X windows gui was selected, but X windows libraries were not found.  输入

sudo apt-get install xorg-dev

    (2)如出现 ERROR: pkg-config was not found, or unable to access the gtk+-2.0 package. 输入

sudo apt-get install libgtk2.0-dev

  如有ERROR,依赖包安装好后,需重新configure

  (注*:我下载bochs-2.3.5时出现错误1,安装xorg-dev也无法解决,不知什么原因。还请前辈们多多指教!于是换成了bochs-2.4.5,亲测可用)

  4.编译

make

    (1)如出现 Error: collect2: error: ld returned 1 exit status

             make: *** [bochs] Error 1

    编辑boches-2.4.5/Makefile.in文件,找到 LIBS = ... 一行,在行尾加上 -lpthread,保存

    重新configure之后,再重新make,成功

  5.安装

sudo make install

 

三.配置

  如书中11页所言,安装好bochs后需要自己编写配置文件。存储路径却并未明确指出,但原书中后面有提示:“如果你输入一个不带任何参数的Bochs并执行之,那么Bochs将在当前目录顺序寻找以下文件作为默认配置文件:

  .bochsrc

  bochsrc

  bochsrc.txt

  bochsrc.bxrc(仅对windows有效)”

  意思是配置文件存放位置为你当前的工作目录,即存放.bin .asm .img的文件夹。

  于是我在工作目录下新建 bochsrc 文件,如书中代码2.1所示,并更改路径匹配我电脑中的bochs

 1 #Configuration file for Bochs
 2 
 3 #how much memory the emulated machine will have
 4 megs: 32
 5 
 6 #filename of ROM images
 7 romimage: file=$BXSHARE/BIOS-bochs-latest
 8 vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
 9 
10 #what disk images will be used
11 floppya: 1_44=a.img, status=inserted
12 
13 #choose the boot disk.
14 boot: floppy
15 
16 #where do we send log messages
17 log: bochsout.txt
18 
19 #disable the mouse
20 mouse: enabled=0
21 
22 #enable key mapping, using US layout as default
23 keyboard_mapping: enabled=1, map=/usr/local/share/bochs/keymaps/x11-pc-us.map

  第7,8行的romimage和vgaromimage对应真实机器的BIOS和VGA BIOS,路径该如何设置呢?

  (注:此处不同系统,不同软件版本下,路径可能会有差异)

  方法一:在我的电脑里 /usr/local/share/doc/bochs下有示例文件,名为bochsrc-sample.txt,打开之后,查找romimage和vgaromimage可得到路径;

  方法二:以23行的map为例,用find命令,在/usr文件夹下查找x11-pc-us.map即可

find -name x11-pc-us.map

  配置文件写好之后,在当前目录下输入bochs,可看到:

========================================================================
                       Bochs x86 Emulator 2.4.5
              Build from CVS snapshot, on April 25, 2010
========================================================================
00000000000i[     ] reading configuration from bochsrc
------------------------------
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: [6] 

   此时默认选项为6. Begin simulation

   回车,弹出Bochs虚拟机界面,成功!

   (注:若缺少配置文件,默认选项为2;若配置文件错误,则会报错)

 

参考资料: http://www.cnblogs.com/sobe/archive/2010/09/05/1818367.html

      http://m.blog.csdn.net/blog/u010066564/26068283

转载于:https://www.cnblogs.com/KoalaDream/p/5045875.html

Chapter 1 x86 体系结构与PC 系统概要.....................................1 1.1 x86 CPU 结构...............................................................................................................1 1.1.1 冯诺依曼架构和CISC 指令集......................................................................1 1.1.2 CPU 结构........................................................................................................1 1.1.3 CPU 工作模式................................................................................................2 1.2 x86 体系结构概览........................................................................................................3 1.3 PC 系统.........................................................................................................................5 1.3.1 PC 系统概述...................................................................................................5 2.3.2 总线拓扑.........................................................................................................6 2.3.3 存储器与I/O 编址.........................................................................................6 2.3.4 关于系统的启动与引导.................................................................................8 Chapter 2 Bochs 工程概述....................................................... 11 2.1 开源项目Bochs 介绍.................................................................................................11 2.2 版本2.2.1 源码组织..................................................................................................11 2.3 工程类结构.................................................................................................................12 2.4 主体框架结构分析.....................................................................................................13 2.4.1 Bochs 工程中的重要类................................................................................13 (1) VM 控制台界面类.............................................................................................13 (2) CPU 模拟............................................................................................................14 (3) Memory 模拟......................................................................................................14 (4).I/O device 模拟...................................................................................................15 2.4.2 入口函数main()及Win32 Gui 初始化........................................................15 2.5 Bochs 的工作方式......................................................................................................18 Chapter 3 CPU 类的源码分析...................................................20 3.1 CPU 类概述................................................................................................................20 3.1.1 CPU 逻辑结构框图......................................................................................20 3.1.2 类BX_CPU_C 成员归纳.............................................................................20 3.2 类BX_CPU_C 源码分析..........................................................................................21 3.2.1 CPU 特性声明..............................................................................................21 3.2.2 类bxInstruction_c 成员分析........................................................................22 3.2.3 类BX_CPU_C 源码注释.............................................................................22 3.3 通用寄存器.................................................................................................................29 3.3.1 数据结构与注释...........................................................................................29 3.3.2 通用寄存器归纳...........................................................................................30 3.4 段寄存器、全局寄存器GDI 和IDT ........................................................................31 3.4.1 数据结构与注释...........................................................................................31 3.4.2 段寄存器结构分析.......................................................................................33 3.5 CPU 状态字EFLAGS................................................................................................35 3.5.1 数据结构与注释...........................................................................................35
Bochs项目源码分析与注释 Table of Content Chapter 1 x86 体系结构与 PC 系统概要1 1.1 x86 CPU 结构1 1.1.1 冯诺依曼架构和CISC 指令集 1.1.2 CPU 结构 1.1.3 CPU 工作模式 1.2 x86 体系结构概览 1.3 PC 系统 1.3.1 PC 系统概述 2.3.2 总线拓扑 2.3.3 存储器与I/O 编址 2.3.4 关于系统的启动与引导 Chapter 2 Bochs 工程概述 2.1 开源项目Bochs 介绍........................................11 2.2 版本2.2.1 源码组织..................................................................................................11 2.3 工程类结构.................................................................................................................12 2.4 主体框架结构分析.....................................................................................................13 2.4.1 Bochs 工程中的重要类................................................................................13 (1) VM 控制台界面类.............................................................................................13 (2 ) CPU 模拟............................................................................................................14 (3) Memory 模拟......................................................................................................14 (4 ).I/O device 模拟...................................................................................................15 2.4.2 入口函数main()及Win32 Gui 初始化........................................................15 2.5 Bochs 的工作方式......................................................................................................18 Chapter 3 CPU 类的源码分析...................................................20 3.1 CPU 类概述................................................................................................................20 3.1.1 CPU 逻辑结构框图......................................................................................20 3.1.2 类BX_CPU_C 成员归纳.............................................................................20 3.2 类BX_CPU_C 源码分析..........................................................................................21 3.2.1 CPU 特性声明..............................................................................................21 3.2.2 类bxInstruction_c 成员分析........................................................................22 3.2.3 类BX_CPU_C 源码注释.............................................................................22 3.3 通用寄存器.................................................................................................................29 3.3.1 数据结构与注释...........................................................................................29 3.3.2 通用寄存器归纳...........................................................................................30 3.4 段寄存器、全局寄存器GDI 和IDT ........................................................................31 3.4.1 数据结构与注释...........................................................................................31 3.4.2 段寄存器结构分析.......................................................................................33 3.5 CPU 状态字EFLAGS................................................................................................35 3.5.1 数据结构与注释...........................................................................................35 Understanding the source code of bochs
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值