我正在研究一个名为 pintos 的操作系统编程项目。它按照命令在 bochs 上运行pintos run nameOfProcess
这是我收到的错误消息
Writing command line to /tmp/eKW3NMXoGT.dsk...
squish-pty bochs -q
========================================================================
                     Bochs x86 Emulator 2.5.1.svn
             Built from SVN snapshot, after release 2.5.1
                  Compiled on Apr  6 2012 at 19:37:19
========================================================================
00000000000i[     ] reading configuration from bochsrc.txt
00000000000i[     ] installing x module as the Bochs GUI
00000000000i[     ] using log file bochsout.txt
Next at t=0
Writing command line to /tmp/eKW3NMXoGT.dsk...
squish-pty bochs -q
========================================================================
                     Bochs x86 Emulator 2.5.1.svn
             Built from SVN snapshot, after release …Run Code Online (Sandbox Code Playgroud) 在使用GRUB作为引导加载程序进行了数周的工作后,我决定自己动手做,以便我了解它们的工作原理。我在互联网上找到了Brokenthorn的教程(当前在http://www.brokenthorn.com/Resources/OSDev9.html上)。当我尝试切换到保护模式时,cpu硬件会在跳远后重置。我正在运行bochs v。2.6。
这是我的第二阶段引导程序(几乎是本教程的副本,因为我认为它可以解决我的问题-不会)
    bits    16
; Remember the memory map-- 0x500 through 0x7bff is unused above the BIOS data area.
; We are loaded at 0x500 (0x50:0)
org 0x50:0x0
jmp main                ; go to start
;*******************************************************
;   Preprocessor directives
;*******************************************************
%include "Gdt.inc"          ; Gdt routines
;*******************************************************
;   Data Section
;*******************************************************
;*******************************************************
;   STAGE 2 ENTRY POINT
;
;       -Store BIOS information
;       -Load Kernel
;       -Install GDT; go into protected mode (pmode)
;       -Jump to Stage 3
;******************************************************* …Run Code Online (Sandbox Code Playgroud) 我试图在x86程序集中创建一个简单的命令系统.命令系统是在0x1000:0000中加载的第二个阶段.要查看我的引导加载程序,请单击此stackoverflow问题.
这是第二阶段命令系统:
[BITS 16]
[ORG 0x0000]      
mov ax, cs
mov ds, ax   
xor cx, cx  
mov bx, welcome_msg
call str_prt
call new_line
mov bx, creator_msg
call str_prt
call new_line
mov bx, boot_msg
call str_prt
call new_line
mov bx, [buffer]
call new_line
mov ah, 0x0e
mov al, 0x0a
int 0x10
mov al, 0x0d
int 0x10
mov al, '>'
int 0x10
loop:
in al, 64h  
test al, 1    
je loop
xor ah, ah
int 0x16
call key_scan
jmp loop …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试在 bochs 中编译并运行一个简单的引导加载程序。目前,这是我的 bootloader.asm 文件:
\n\n[BITS 16]\n[ORG 0x7C00] ;Where the code gets mapped\ntop:\n    jmp top ;Loop forever\ntimes 510-($-$$) db 0 ;Pad with 0\ndw 0xAA55 ;Bootloader signature (backwards)\n    ;; dw declares a word (2 bytes because we\xe2\x80\x99re 16 bits)\nRun Code Online (Sandbox Code Playgroud)\n\n然后,从我的 pragmalinux-img 目录中输入以下命令:
\n\nyasm bootloader.asm\ndd if=bootloader bs=512 \nbochs\nRun Code Online (Sandbox Code Playgroud)\n\n运行 bochs 后,我收到以下错误消息。(抱歉文字墙)
\n\n                        Bochs x86 Emulator 2.6\n            Built from SVN snapshot on September 2nd, 2012\n========================================================================\n00000000000i[     ] LTDL_LIBRARY_PATH not set. using compile time default        '/usr/lib/bochs/plugins'\n00000000000i[     ] BXSHARE not set. using …Run Code Online (Sandbox Code Playgroud) 我将引导加载程序从CHS更改为LBA,因此我将其替换int 13h 02h为int 13h 42h.它在QEMU中正常工作,但是,我在使用Bochs和笔记本电脑时遇到了麻烦.
我把bootloader写入了USB闪存盘dd if=main.bin of=/dev/sdb bs=512.笔记本电脑加载英特尔UNDI并给我以下错误:No bootable device - insert boot disk and press any key.
所以我尝试用Bochs调试它,并注意到Bochs将这个二进制文件识别为可引导的.但是,int 13h执行后没有加载任何内容.
然后我尝试从这个闪存驱动器加载我的旧PC,它的工作原理!它加载程序并正确执行它.QEMU给了我相同的结果.
这是引导加载程序代码:
org 0x7c00
bits 16
boot:
    cli
    ; Overlap CS and DS
    mov ax, cs
    mov ds, ax
    mov es, ax
    ; Setup 4K stack before this bootloader
    mov ax, 0x07c0
    mov ss, ax
    mov sp, 4096
    ; Load next sectors
    mov si, DAP
    mov ah, 42h
    ; …Run Code Online (Sandbox Code Playgroud) 我在 bochs 中调试引导扇区时遇到了几个问题。
在 bochs 中调试引导扇区时,bochs 调试器首先在
(0) [0x0000fffffff0] f000:fff0 (unk. ctxt): jmpf 0xf000:e05b      ; ea5be000f0
Run Code Online (Sandbox Code Playgroud)
Q1:这条指令jmpf 0xf000:e05b是这最后16字节内存中的跳转指令吗?
Q2: address 中有什么指令0xf000:e05b? 
然后我们想让代码停在地址 0x7c00
<bochs:1> b 0x7c00
<bochs:2> c
(0) Breakpoint 1, 0x0000000000007c00 in ?? ()  
Next at t=61419250
(0) [0x000000007c00] 0000:7c00 (unk. ctxt): jmpf 0x07c0:0005   ; ea0500c007
<bochs:3> s                                   
Next at t=61419251
(0) [0x000000007c05] 07c0:0005 (unk. ctxt): mov ax, cs         ; 8cc8
Run Code Online (Sandbox Code Playgroud)
这些代码行由jmpi go,#0x7c00 go: move ax,cx.
Q3:指令jmpi翻译成jmpf机器码ea,对吗? …
我正在尝试在图形模式下打印字符.通常当我打印一个我正在做的角色时:
mov ah,14   ; ah=14
mov al,'x' 
int 10h     ; print the character
Run Code Online (Sandbox Code Playgroud)
这次它不起作用.我想问题是我切换到图形模式:
push ax
mov ah, 0
mov al, 13h
int 10h
pop ax
ret
Run Code Online (Sandbox Code Playgroud)
那我怎么还能使用图形模式(我需要它)并打印一个字符?我正在使用nasm编译器,bochs调试器和8086平台.
非常感谢!