`
lobin
  • 浏览: 425588 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Bochs

 
阅读更多

Bochs

使用Bochs可以很方便的运行和调试主引导程序、内核、操作系统。直接启动bochs.exe或bochsdbg.exe,之后会弹出一个窗口提示做一些简单的配置,主要是配置通过硬盘或软盘引导启动,还有就是配置镜像。这些配置好后可以保存配置,也可以直接加载之前配置好了的配置文件,然后点击启动就好了。

 

当然也可以通过命令行启动:

>bochs.exe -q -f boot_test_1.asm-bochsrc.bxrc

配置

在保存配置是默认的配置文件名:bochsrc.bxrc

里边的配置看着挺复杂的, 如果嫌麻烦的话,可以通过配置界面进行配置, 而不需要自己编写配置文件。

 

下面是配置文件中比较重要的配置内容:

plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, gameport=1, iodebug=0

如果要调试的话,需要设置iodebug为1。

 

romimage: file="BIOS-bochs-latest"

vgaromimage: file="VGABIOS-lgpl-latest"

 

boot: disk

 

ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14

ata0-master: type=disk, path="boot_test_1.asm.img", mode=flat, cylinders=1, heads=1, spt=1, model="Generic 1234", biosdetect=auto, translation=auto

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

 

 

 

BIOS程序:

BIOS-bochs-latest

BIOS-bochs-legacy

 

VGABIOS-lgpl-latest

VGABIOS-lgpl-latest-cirrus

VGABIOS-lgpl-latest-cirrus-debug

VGABIOS-lgpl-latest-debug

 

在Bochs显示屏幕上可以设置显示或隐藏鼠标。也可以使用快捷键控制显示或隐藏鼠标,按住Ctrl同时按下鼠标滚轮可以控制显示或隐藏鼠标。

 

Bochs在运行以及调试时会执行处的一条远跳指令jmpf 0xf000:e05b,它会跳转到BIOS的开始的第一条指令去执行BIOS程序。

0x0000fffffff0这个是一个32位地址,f000:fff0这个是一个20位地址,8086支持20根地址线,也就是0xffff0,其实就是段基地址0xf000左移4位,相当于乘以16得到0xf0000,再加上偏移地址0xfff0,得到0xffff0

 

Next at t=0

(0) [0x0000fffffff0] f000:fff0 (unk. ctxt): jmpf 0xf000:e05b          ; ea5be000

f0

<bochs:1>

 

BIOS程序执行完后,会跳转到0x7c00处去执行MBR主引导程序。

 

调试

查看帮助信息

<bochs:4> help

h|help - show list of debugger commands

h|help command - show short command description

-*- Debugger control -*-

    help, q|quit|exit, set, instrument, show, trace, trace-reg,

    trace-mem, u|disasm, ldsym, slist

-*- Execution control -*-

    c|cont|continue, s|step, p|n|next, modebp, vmexitbp

-*- Breakpoint management -*-

    vb|vbreak, lb|lbreak, pb|pbreak|b|break, sb, sba, blist,

    bpe, bpd, d|del|delete, watch, unwatch

-*- CPU and memory contents -*-

    x, xp, setpmem, writemem, crc, info,

    r|reg|regs|registers, fp|fpu, mmx, sse, sreg, dreg, creg,

    page, set, ptime, print-stack, ?|calc

-*- Working with bochs param tree -*-

    show "param", restore

单步进入

<bochs:3> s

s表示step的缩写,也可以写成:

<bochs:5> step

单步

<bochs:14> p

或者

<bochs:14> n

n表示next的缩写,也可以写成:

<bochs:14> next

 

断点

<bochs:17> b 0x7c41

b表示break的缩写,也可以写成:

<bochs:17> break 0x7c41

或者

<bochs:24> pb 0x7c49

也可以写成:

<bochs:17> pbreak 0x7c41

 

继续执行

<bochs:26> c

 

查看段寄存器值

<bochs:24> sreg

es:0x0030, dh=0x0040930b, dl=0x80008000, valid=7

        Data segment, base=0x000b8000, limit=0x00008000, Read/Write, Accessed

cs:0x0008, dh=0x00cf9b00, dl=0x0000ffff, valid=1

        Code segment, base=0x00000000, limit=0xffffffff, Execute/Read, Non-Confo

rming, Accessed, 32-bit

ss:0x0820, dh=0x00009300, dl=0x8200ffff, valid=7

        Data segment, base=0x00008200, limit=0x0000ffff, Read/Write, Accessed

ds:0x0010, dh=0x00cf9300, dl=0x0000ffff, valid=31

        Data segment, base=0x00000000, limit=0xffffffff, Read/Write, Accessed

fs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1

        Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed

gs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1

        Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed

ldtr:0x0000, dh=0x00008200, dl=0x0000ffff, valid=1

tr:0x0000, dh=0x00008b00, dl=0x0000ffff, valid=1

gdtr:base=0x000000000000e760, limit=0x40

idtr:base=0x000000000000d706, limit=0x800

 

查看中断描述符表

<bochs:25> info idt

Interrupt Descriptor Table (base=0x000000000000d706, limit=2048):

IDT[0x00]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x01]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x02]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x03]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x04]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x05]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x06]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x07]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x08]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x09]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x0a]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x0b]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x0c]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x0d]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x0e]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x0f]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x10]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x11]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x12]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x13]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x14]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x15]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x16]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x17]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x18]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x19]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x1a]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x1b]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x1c]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x1d]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x1e]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x1f]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x20]=32-Bit Interrupt Gate target=0x0008:0x00008195, DPL=0

IDT[0x21]=32-Bit Interrupt Gate target=0x0008:0x000081b3, DPL=0

IDT[0x22]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x23]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x24]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x25]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x26]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x27]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x28]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x29]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x2a]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x2b]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x2c]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x2d]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x2e]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x2f]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x30]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x31]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x32]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x33]=32-Bit Interrupt Gate target=0x0008:0x000081d1, DPL=0

IDT[0x34]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x35]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x36]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x37]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x38]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x39]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x3a]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x3b]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x3c]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x3d]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x3e]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x3f]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x40]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x41]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x42]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x43]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x44]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x45]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x46]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x47]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x48]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x49]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x4a]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x4b]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x4c]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x4d]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x4e]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x4f]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x50]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x51]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x52]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x53]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x54]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x55]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x56]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x57]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x58]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x59]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x5a]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x5b]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x5c]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x5d]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x5e]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x5f]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x60]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x61]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x62]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x63]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x64]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x65]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x66]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x67]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x68]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x69]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x6a]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x6b]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x6c]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x6d]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x6e]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x6f]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x70]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x71]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x72]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x73]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x74]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x75]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x76]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x77]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x78]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x79]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x7a]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x7b]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x7c]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x7d]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x7e]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x7f]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x80]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x81]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x82]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x83]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x84]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x85]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x86]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x87]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x88]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x89]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x8a]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x8b]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x8c]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x8d]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x8e]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x8f]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x90]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x91]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x92]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x93]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x94]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x95]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x96]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x97]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x98]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x99]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x9a]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x9b]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x9c]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x9d]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x9e]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0x9f]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xa0]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xa1]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xa2]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xa3]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xa4]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xa5]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xa6]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xa7]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xa8]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xa9]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xaa]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xab]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xac]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xad]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xae]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xaf]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xb0]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xb1]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xb2]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xb3]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xb4]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xb5]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xb6]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xb7]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xb8]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xb9]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xba]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xbb]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xbc]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xbd]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xbe]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xbf]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xc0]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xc1]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xc2]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xc3]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xc4]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xc5]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xc6]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xc7]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xc8]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xc9]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xca]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xcb]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xcc]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xcd]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xce]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xcf]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xd0]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xd1]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xd2]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xd3]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xd4]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xd5]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xd6]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xd7]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xd8]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xd9]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xda]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xdb]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xdc]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xdd]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xde]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xdf]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xe0]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xe1]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xe2]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xe3]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xe4]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xe5]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xe6]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xe7]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xe8]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xe9]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xea]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xeb]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xec]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xed]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xee]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xef]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xf0]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xf1]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xf2]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xf3]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xf4]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xf5]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xf6]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xf7]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xf8]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xf9]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xfa]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xfb]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xfc]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xfd]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xfe]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

IDT[0xff]=32-Bit Interrupt Gate target=0x0008:0x00008177, DPL=0

You can list individual entries with 'info idt [NUM]' or groups with 'info idt [

NUM] [NUM]'

 

查看汇编

<bochs:23> u /10 0x7c3f

00007c3f: (                    ): int 0x13                  ; cd13

00007c41: (                    ): jnb .+2                   ; 7302

00007c43: (                    ): jmp .-61                  ; ebc3

00007c45: (                    ): cli                       ; fa

00007c46: (                    ): mov ax, 0x1000            ; b80010

00007c49: (                    ): mov ds, ax                ; 8ed8

00007c4b: (                    ): xor ax, ax                ; 31c0

00007c4d: (                    ): mov es, ax                ; 8ec0

00007c4f: (                    ): mov cx, 0x2000            ; b90020

00007c52: (                    ): sub si, si                ; 29f6

 

查看内存

<bochs:31> x /10 0x7c3f

[bochs]:

0x0000000000007c3f <bogus+       0>:    0x027313cd      0xb8fac3eb      0xd88e10

00      0xc08ec031

0x0000000000007c4f <bogus+      16>:    0x292000b9      0xf3ff29f6      0x07c0b8

a5      0x010fd88e

0x0000000000007c5f <bogus+      32>:    0x0f00a11e      0x00a71601

 

Bochs调试的一个简单例子:

 


 


 


 


 


 


 


 


>bochsdbg.exe -q -f boot_test_1.asm-bochsrc.bxrc

 

查看中断向量表的位置

00000000000i[      ] reading configuration from H:\mos\m\bochsrc-floppy.bxrc

00000000000i[      ] Ignoring magic break points

00000000000i[      ] installing win32 module as the Bochs GUI

00000000000i[      ] using log file H:\mos\m\log

Next at t=0

(0) [0x0000fffffff0] f000:fff0 (unk. ctxt): jmpf 0xf000:e05b          ; ea5be000

f0

<bochs:1> b 0x7c00

<bochs:2> sreg

es:0x0000, dh=0x00009300, dl=0x0000ffff, valid=7

        Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed

cs:0xf000, dh=0xff0093ff, dl=0x0000ffff, valid=7

        Data segment, base=0xffff0000, limit=0x0000ffff, Read/Write, Accessed

ss:0x0000, dh=0x00009300, dl=0x0000ffff, valid=7

        Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed

ds:0x0000, dh=0x00009300, dl=0x0000ffff, valid=7

        Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed

fs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=7

        Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed

gs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=7

        Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed

ldtr:0x0000, dh=0x00008200, dl=0x0000ffff, valid=1

tr:0x0000, dh=0x00008b00, dl=0x0000ffff, valid=1

gdtr:base=0x0000000000000000, limit=0xffff

idtr:base=0x0000000000000000, limit=0xffff

<bochs:3>

从这里我们看到IDTR寄存器的内容:

idtr:base=0x0000000000000000, limit=0xffff

由于当前还处于实地址模式下,IDTR寄存器存放的就是中断向量表的基地址和limit。所以中断向量表就存放在0x0000的位置。

 

Bochs网卡配置

以Bochs中内置的DLX V1.0为例

 

Bochs DLX V1.0

配置网卡

如果没有配置网卡,在Bochs的状态栏是不会显示网卡的。


Bochs DLX的配置文件bochsrc.bxrc中添加如下配置:
ne2k: enabled=1, ioaddr=0x300, irq=3, mac=b0:c4:20:00:00:00, ethmod=win32, ethdev=\Device\NPF_{2F7135FD-29EB-4F59-875D-8DFA403B1338}
这串是哪来的?还有这串字符串“\Device\NPF_{2F7135FD-29EB-4F59-875D-8DFA403B1338}”是什么?
 
在Bochs安装目录下有个niclist.exe工具,运行如下:
>niclist
 
1: Broadcom NetXtreme Gigabit Ethernet Driver (Microsoft's Packet Sche
duler)
     Device: \Device\NPF_{2F7135FD-29EB-4F59-875D-8DFA403B1338}
 
Example config for bochsrc:
ne2k: ioaddr=0x300, irq=3, mac=b0:c4:20:00:00:00, ethmod=win32, ethdev
=\Device\NPF_{2F7135FD-29EB-4F59-875D-8DFA403B1338}
 
 
Press any key to continue


上面的那串字符串就是根据这里来的。这里也给出了一个配置的例子。从这里运行的结果来看,我这台机器的网卡是美国博通的网卡:Broadcom NetXtreme Gigabit Ethernet Driver (Microsoft's Packet Sche

duler)。

 

这里配置的是NE2000,配置了网卡后,就会在Bochs的状态栏显示网卡,如下图中,在状态栏会显示一个“NE2K”,这表示配置了网卡。

启动Bochs 

Plex86/Bochs VGABios (PCI) current-cvs 08 Jul 2014
This VGA/VBE Bios is released under the GNU LGPL
 
Please visit :
 . http://bochs.sourceforge.net
 . http://www.nongnu.org/vgabios
 
Bochs VBE Display Adapter enabled
 
Bochs BIOS - build: 04/18/15
$Revision: 12579 $ $Date: 2014-12-26 11:31:39 +0100 (Fr, 26. Dez 2014) $
Options: apmbios pcibios pnpbios eltorito rombios32
 
ata0 master: Generic 1234 ATA-6 Hard-Disk (  10 MBytes)
 
Press F12 for boot menu.
 
Booting from Hard Disk...
 
LILO boot: ?
 
 
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
Floppy drive(s): fd0 is 1.44M, fd1 is 1.44M
Started kswapd v 1.4.2.2
FDC 0 is a 8272A
ne.c:v1.10 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)
NE*000 ethercard probe at 0x300: b0 c4 20 00 00 00
eth0: NE2000 found at 0x300, using IRQ 3.
Partition check:
 hda: hda1
VFS: Mounted root (ext2 filesystem) readonly.
Sep 30 02:41:54 init[1]: version 2.4 booting
EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
Mounting remote file systems...
INET: syslogd
Sep 30 02:41:56 init[1]: Entering runlevel: 4
 
 
 
Welcome to DLX V1.0 (C) 1995-96 Erich Boehm
                    (C) 1995    Hannes Boehm
 
 
dlx login: root
Linux 1.3.89.
dlx:~# ?
dlx:~# ifconfig
lo        Link encap Local Loopback
          inet addr 127.0.0.1  Bcast 127.255.255.255  Mask 255.0.0.0
          UP BROADCAST LOOPBACK RUNNING  MTU 3584  Metric 1
          RX packets 0 errors 0 dropped 0 overruns 0
          TX packets 0 errors 0 dropped 0 overruns 0
 
dlx:~# ?
dlx:~# ifconfig eth0 192.168.0.109
dlx:~# ifconfig
lo        Link encap Local Loopback
          inet addr 127.0.0.1  Bcast 127.255.255.255  Mask 255.0.0.0
          UP BROADCAST LOOPBACK RUNNING  MTU 3584  Metric 1
          RX packets 0 errors 0 dropped 0 overruns 0
          TX packets 0 errors 0 dropped 0 overruns 0
 
eth0      Link encap 10Mbps Ethernet  HWaddr B0:C4:20:00:00:00
          inet addr 192.168.0.109  Bcast 192.168.0.255  Mask 255.255.255.0
          UP BROADCAST RUNNING  MTU 1500  Metric 1
          RX packets 0 errors 0 dropped 0 overruns 0
          TX packets 0 errors 0 dropped 0 overruns 0
 
dlx:~# ?
dlx:~# route
Kernel routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
127.0.0.0       *               255.0.0.0       U     0      0        0 lo
dlx:~# ?
dlx:~# route add -net 192.168.0.0
dlx:~# route
Kernel routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     *               255.255.255.0   U     0      0        0 eth0
127.0.0.0       *               255.0.0.0       U     0      0        1 lo
dlx:~# ?
dlx:~# ping -c 1 192.168.0.1
PING 192.168.0.1 (192.168.0.1): 56 data bytes
64 bytes from 192.168.0.1: icmp_seq=0 ttl=128 time=99.5 ms
 
--- 192.168.0.1 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 99.5/99.5/99.5 ms
dlx:~# ?
dlx:~# route add default gw 192.168.0.1
dlx:~# route
Kernel routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     *               255.255.255.0   U     0      0        2 eth0
127.0.0.0       *               255.0.0.0       U     0      0        2 lo
default         192.168.0.1     *               UG    0      0        0 eth0
dlx:~# ?
dlx:~# ping -c 1 112.80.248.76
PING 112.80.248.76 (112.80.248.76): 56 data bytes
64 bytes from 112.80.248.76: icmp_seq=0 ttl=128 time=41.0 ms
 
--- 112.80.248.76 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 41.0/41.0/41.0 ms
dlx:~# ?
 

 
 

参考另一篇文章:https://www.iteye.com/blog/lobin-2325791

0
1
分享到:
评论

相关推荐

    Bochs配置 - vhd虚拟硬盘.pdf

    Bochs是一款开源的虚拟机软件,主要用来模拟处理器取指令和执行指令的过程,以及模拟整个计算机硬件系统。它可以直接模拟计算机的加电启动过程,非常适合用来学习和调试程序,尤其是对学习保护模式的读者而言,是一...

    linux0.11 bochs 调试.txt

    ### Linux 0.11 Bochs 调试详解 #### 一、概述 Linux 0.11 是一个早期的Linux内核版本,对于学习Linux内核开发来说具有非常重要的意义。它不仅有助于理解现代Linux内核的基本原理,而且还是进行内核调试的良好起点...

    bochs2.6.8(带调试界面)

    Bochs是一款开源、跨平台的x86模拟器,它可以在多种操作系统上运行,包括Linux、Windows、Mac OS X等。这款2.6.8版本是该软件的一个更新迭代,旨在提供更稳定、高效和功能丰富的虚拟化体验。标题中的"带调试界面...

    bochs-2.4.5.tar.gz-虚拟机

    Bochs是一款开源、跨平台的x86模拟器,它可以在多种操作系统上运行,包括Linux、Windows、Mac OS X等。这个"bochs-2.4.5.tar.gz"文件是一个压缩包,其中包含了Bochs的源代码版本2.4.5。在Linux环境下,我们可以使用...

    bochs(Windows和Linux下的都有)

    Bochs是一款开源、跨平台的x86模拟器,它可以在包括Windows和Linux在内的多种操作系统上运行。这个软件的强大之处在于它能够模拟整个x86计算机系统,包括CPU、内存、磁盘、网络接口等硬件组件,使得用户能够在当前...

    Bochs-2.6.11_bochs_bochs2.6.11_

    Bochs是一款开源、跨平台的x86架构模拟器,其版本为2.6.11,这使得用户能够在不支持或没有实际x86硬件的系统上运行基于x86指令集的操作系统和应用程序。Bochs模拟了从处理器、内存到磁盘驱动器、网络接口卡等几乎...

    bochs模拟器win98镜像极简版

    Bochs是一款开源的x86架构的PC模拟器,它可以在多种操作系统上运行,包括Windows、Linux、Mac OS等。这个“bochs模拟器win98镜像极简版”是一个特别为Windows 98系统定制的轻量级版本,旨在帮助用户在现代计算机上...

    bochs的SDL文件夹

    Bochs是一款开源的x86模拟器,它可以在多种操作系统上运行,包括Windows、Linux、Mac OS X等,让你能够在个人计算机上模拟运行其他x86系统。在描述中提到的问题,显然用户在尝试运行Bochs时遇到了由于缺少SDL...

    操作系统 Bochs虚拟机

    操作系统 Bochs 虚拟机 Bochs 是一种开源且高度可移植的 IA-32(x86)PC 模拟器,用 C++ 编写,能够在大部分常见的平台上运行。它包括了对 Intel x86 CPU,通用 I/O 设备,和定制 BIOS 的模拟。通常情况下,Bochs ...

    bochs中文用户手册

    Bochs是一个全功能的X86架构虚拟机,它能够模拟完整的Intel x86计算机。这意味着Bochs可以仿真包括386, 486, Pentium, Pentium III, Pentium 4甚至是x86-64架构的CPU。Bochs在模拟过程中还包含了对MMX, SSE以及3DNow...

    linux-0.11内核bochs实验编译环境

    在本实验中,我们将探索如何在Linux环境下搭建用于编译和模拟早期版本Linux内核——Linux 0.11的Bochs环境。Bochs是一款开源的x86硬件模拟器,能够运行多种操作系统,包括早期的Linux内核,这对于学习和理解内核的...

    Bochs-2.1.1.rar

    Bochs是一款开源的x86架构模拟器,它可以在多种操作系统上运行,如Windows、Linux、Mac OS等。作为一个强大的调试工具,Bochs允许开发者在软件开发过程中对操作系统进行深入的分析和测试,尤其适用于那些需要低级别...

    bochs-2.6.8源码

    Bochs是一款开源的x86架构模拟器,它允许用户在非x86平台上运行基于x86指令集的操作系统和应用程序。Bochs是用C++编写的,它提供了高度可移植性,可以在多种操作系统上运行,如Windows、Linux、Mac OS X等。这款软件...

    bochs 安卓X86虚拟机

    Bochs是一款开源的、高度可移植的X86模拟器,它可以让你在各种平台上运行基于X86架构的操作系统,包括但不限于Windows、Linux、Mac OS X以及我们的关注点——Android。这个“bochs 安卓X86虚拟机”项目正是利用了...

    Bochs-2.4.2 for windows

    Bochs是一款开源的x86架构模拟器,它可以在多种操作系统上运行,包括Windows,Linux等,让开发者和用户能够在个人计算机上模拟运行其他操作系统,如早期版本的Windows或者Linux等,甚至是一些嵌入式系统。Bochs的...

    Bochs-2.6工具

    Bochs是一款开源的、跨平台的x86模拟器,它允许用户在非x86架构的计算机上运行x86指令集的软件,包括操作系统和应用程序。Bochs的使用尤其对开发者和研究人员来说非常有价值,因为它可以在Windows、Mac OS X、Linux...

    Bochs教程 Bochs是一个开源的虚拟机

    Bochs是一款开源的虚拟机软件,它提供了与VPC(Virtual PC)和VMware相似的功能,允许用户在其中安装和运行各种操作系统。虽然Bochs在性能上可能不如VMware,因为它是基于全模拟而非硬件虚拟化的,这导致其运行速度...

    bochs 2.6.2 smp版本

    Bochs是一款开源的x86架构模拟器,它可以在多种操作系统上运行,包括Windows、Linux、Mac OS X等。这个2.6.2版本的Bochs特别强调了对SMP(Symmetric Multi-Processing,对称多处理)的支持,这意味着它可以模拟多核...

    Bochs虚拟机内核仿真

    Bochs虚拟机是一款开源的、跨平台的x86架构模拟器,它可以模拟从8088到 Pentium III及更高版本的CPU,以及多种硬件设备,如内存、磁盘、网络接口等,使得用户可以在非x86系统上运行x86操作系统的程序和系统。Bochs的...

    bochs-2.4.2 for linux

    Bochs是一款开源、跨平台的x86模拟器,它可以在多种操作系统上运行,包括Linux。Bochs 2.4.2是2010年04月10日发布的一个版本,它提供了对操作系统进行调试的强大功能,是开发者和研究者理想的虚拟机选择。 在Bochs ...

Global site tag (gtag.js) - Google Analytics