Bx_dbg_read_linear: Physical Memory Read Error (Phy=0x0000000000000000, Lin=0x0000000000000000)
学习环境
Ubuntu 11.04 + Bochs 2.4.6 + NASM
主要工作
ane. 第一章 马上动手写一个最小的"操作系统"
代码如下:
i org 07c00h ; tell the compiler that the program is loaded at 7c00
2 mov ax, cs
three mov ds, ax
4 mov es, ax
5 call DispStr ; call the example about string display
6 jmp $ ; unlimited loop
seven DispStr:
8 mov ax, BootMessage
9 mov bp, ax ; ES:BP = address of cord
10 mov cx, 16 ; CX = length of cord
xi mov ax, 01301h ; AH = xiii, AL = 01h
12 mov bx, 000ch ; page num = 0 (BH = 0), red discussion with black backgroud (BL = 0ch, highlight)
thirteen mov dl, 0
14 int 10h ; interruption at 10h
15 ret
16 BootMessage: db " Hello, OS World! "
17 times 510 -($-$$) db 0 ; fill up the remaining space to the number of the binary code reach 512 bytes
18 dw 0xaa55 ; end
要用NASM编译上述代码,首先要安章NASM,然后编译。
sudo aptitude install nasm
nasm boot.asm -o kicking.bin
实 际上,这只是一个引导扇区。当BIOS检查第一个扇区,发现以0xAA55结束,BIOS就认为这是一个引导扇区。"一旦BIOS"发现了引导扇区,就会 将512字节的内容装载到内存地址0000:7c00处,然后跳转到0000:7c00处将控制权彻底交给这段引导代码。到此为止,计算机不再由BIOS 中固有的程序来控制,而变成由操作系统的一部分来控制。"
指令部分说明
- org: 伪指令,用来规定目标程序存放单元的偏移量。比如,如果在源程序的第一条指令前用了如下指令: org 200h,那么,汇编程序会把指令指针的ip的值设成200h,即目标程序的第一个字节放在200h处,后面的 内容则顺序存放,除非遇上另一个org 语句;
- $: 当前被编译的地址;
- $$: 一个section开始被编译的地址。
其他nasm指令参见nasm中文手册(有需要的,可以留下e-mail)或登录http://www.mouseos.com/assembly/nasm03.html查看。
2. 第二章 搭建你的工作环境
通过安装Bochs来搭建我们的工作环境。目前Bochs最新的版本是2.4.6,下载地址是http://sourceforge.internet /projects/bochs/files/bochs/2.four.vi/。
(one)Bochs安装及使用步骤
- 下载源程序;
- 安装build-essential,xorg-dev,libgtk2.0-dev;
sudo apt-get install build-essential xorg-dev libgtk2. 0 -dev
- 编译安装;
$ ./configure --enable-debugger --enable-disasm
$ make
$ sudo brand install
- 利用bximage生成虚拟软盘。在输入bximage命令后,在第一步提示选择fd即可;
- 将引导扇区写入软盘;
dd if=kick.bin of=a.img bs= 512 count= ane conv=notrunc
- 配置bochsrc,具体内容如下,
1 ###############################################################
ii # Configuration file for Bochs
three ###############################################################
4
five # how much memory the emulated machine will have
6 megs: 32
seven
8 # filename of ROM images
9 romimage: file=/usr/local/share/bochs/BIOS-bochs-latest #/usr/share/bochs/BIOS-bochs-latest
x vgaromimage: file=/usr/local/share/bochs/VGABIOS-lgpl-latest #/usr/share/vgabios/vgabios.bin
11
12 # what disk images will be used
13 floppya: 1_44=a.img, status=inserted
fourteen
15 # cull the boot deejay.
16 boot: floppy
17
18 # where do nosotros send log messages?
xix # log: bochsout.txt
xx
21 # disable the mouse
22 mouse: enabled= 0
23
24 # enable primal mapping, using United states of america layout every bit default.
25 keyboard_mapping: enabled= 1 , map=/usr/local/share/bochs/keymaps/x11-pc-us.map #/usr/share/bochs/keymaps/x11-pc-united states of america.map
- 运行Bochs,显示效果如下图所示,
(2)错误列表
在安装过程中和使用书带的光盘中的bochsrc时,出现了一些错误,解决方案列举如下,
- Fault i:安装Bochs时,出现错误"install: cannot stat `./bochsdbg': No such file or directory"
Solution:将源文件中bochs的文件夹名称改为bochsdbg即可。
- Error two: 运行bochs时,出现错误"bochsrc:10: vgaromimage directive malformed,"
Solution: 将bochsrc文件中第10行vgaromimage: /usr/share/vgabios/vgabios.bin改为
vgaromimage: file=/usr/share/vgabios/vgabios.bin
具体错误输出如下:
bochs -f bochsrc
========================================================================
Bochs x86 Emulator 2 . iv . 6
Build from CVS snapshot, on February 22 , 2011
Compiled at Jun ten 2011 , xviii : 44 : 49
========================================================================
00000000000i[ ] reading configuration from bochsrc
00000000000p[ ] >>PANIC<< bochsrc: 10 : vgaromimage directive malformed.
00000000000e [CTRL ] notify called, just no bxevent_callback function is registered
========================================================================
Bochs is exiting with the post-obit message:
[ ] bochsrc: 10 : vgaromimage directive malformed.
========================================================================
00000000000i[CPU0 ] CPU is in real way (active)
00000000000i[CPU0 ] CS.d_b = sixteen bit
00000000000i[CPU0 ] SS.d_b = 16 bit
00000000000i[CPU0 ] | EAX= 00000000 EBX= 00000000 ECX= 00000000 EDX= 00000000
00000000000i[CPU0 ] | ESP= 00000000 EBP= 00000000 ESI= 00000000 EDI= 00000000
00000000000i[CPU0 ] | IOPL= 0 id vip vif air-conditioning vm rf nt of df if tf sf zf af pf cf
00000000000i[CPU0 ] | SEG selector base limit Grand D
00000000000i[CPU0 ] | SEG sltr(alphabetize|ti|rpl) base limit Yard D
00000000000i[CPU0 ] | CS: 0000 ( 0000 | 0 | 0 ) 00000000 00000000 0 0
00000000000i[CPU0 ] | DS: 0000 ( 0000 | 0 | 0 ) 00000000 00000000 0 0
00000000000i[CPU0 ] | SS: 0000 ( 0000 | 0 | 0 ) 00000000 00000000 0 0
00000000000i[CPU0 ] | ES: 0000 ( 0000 | 0 | 0 ) 00000000 00000000 0 0
00000000000i[CPU0 ] | FS: 0000 ( 0000 | 0 | 0 ) 00000000 00000000 0 0
00000000000i[CPU0 ] | GS: 0000 ( 0000 | 0 | 0 ) 00000000 00000000 0 0
00000000000i[CPU0 ] | EIP= 00000000 ( 00000000 )
00000000000i[CPU0 ] | CR0=0x00000000 CR2=0x00000000
00000000000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
bx_dbg_read_linear: physical retentivity read error (phy=0x0000000000000000, lin=0x00000000)
00000000000i[CTRL ] quit_sim chosen with exit code i
- Fault three: 运行bochsrc时,出现错误"ROM: couldn't open up ROM prototype file '/usr/share/bochs/BIOS-bochs-latest'."
Solution: 将bochsrc文件中第9行romimage: file=/usr/share/bochs/BIOS-bochs-latest改为
romimage: file=/usr/local/share/bochs/BIOS-bochs-latest #/usr/share/bochs/BIOS-bochs-latest
具体错误输出如下:
Event type: PANIC
Device: [MEM0 ]
Bulletin: ROM: couldn ' t open ROM image file ' /usr/share/bochs/BIOS-bochs-latest ' .A PANIC has occurred. Do you want to:
' t ask again.
cont - continue execution
alwayscont - continue execution, and don
This affects only PANIC events from device [MEM0 ]
dice - terminate execution now
abort - dump core
debug - continue and return to bochs debugger
Choose i of the deportment in a higher place: [die]
- Fault 4: 运行bochsrc时,出现关于Keymap的错误,见下图,
Solution: 将bochsrc文件中最后一行keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-usa.map改为
keyboard_mapping: enabled=1, map=/usr/local/share/bochs/keymaps/x11-pc-u.s..map #/usr/share/bochs/keymaps
/x11-pc-u.s..map
- Error 5: 调试引导扇区程序是,出现错误"syntax fault at 'dump_cpu'"
Solution: None. bochs 2.3.5 以上的版本没有dump_cpu了,可以用r,fp,mmx,sse,dreg,sreg,creg命令代替。
附录
希望大家多多指正,如有转载,请注明出处http://www.cnblogs.com/JohnShao/archive/2011/06/11/2078419.html。
继续学习,更多惊喜!
Source: https://www.cnblogs.com/JohnShao/archive/2011/06/11/2078419.html
0 Response to "Bx_dbg_read_linear: Physical Memory Read Error (Phy=0x0000000000000000, Lin=0x0000000000000000)"
Postar um comentário