简体   繁体   English

bochs:无法使用软盘映像加载引导加载程序

[英]bochs: can not load bootloader using a floppy image

I have a simple (probably the simplest) bootloader.我有一个简单的(可能是最简单的)引导加载程序。 Very similar to this and this .非常类似于thisthis The code is shown below代码如下所示

[org  0x7c00]

mov ah, 0x0e
mov al, 'h'

int 0x10

jmp  $

times  510-($-$$)  db  0

dw  0xaa55

The code is taken from the video series tutorial from here .代码取自此处的视频系列教程。

I have tried everything to compile and load this bootloader using bochs.我已经尝试了一切来使用 bochs 编译和加载这个引导加载程序。 But whatever I do, I get a black screen like the following但无论我做什么,都会出现如下黑屏

在此处输入图像描述

Nothing comes on the screen and after a bit I get that bochs is not responding.屏幕上什么也没有,过了一会儿我发现 bochs 没有响应。

My present approach to load the image is -我目前加载图像的方法是 -

  1. nasm boot_simple.asm -f bin -o boot.bin

  2. dd if=boot.bin of=boot.img bs=512

  3. bochs -f /dev/null -q 'display_library: sdl2' 'boot:a' 'floppya: 1_44=boot.img, status=inserted'

I tried many other approaches (slight variations of the above) (even tried to compile and load a separate bootloader from here ) But nothing worked.我尝试了许多其他方法(上述方法的细微变化)(甚至尝试从此处编译和加载单独的引导加载程序)但没有任何效果。 Always the same black screen and does not show any other information.始终相同的黑屏,不显示任何其他信息。

I am becoming mad.我快疯了。 What am I missing?我错过了什么?

Ubuntu 22.04 Ubuntu 22.04

Bochs version : Bochs x86 Emulator 2.7 (installed via sudo apt install ) Bochs 版本:Bochs x86 Emulator 2.7(通过sudo apt install

I am super new to OS development and I want to learn it as a side project.我对操作系统开发非常陌生,我想将它作为一个副项目来学习。 Please help me getting started.请帮助我开始。 Could not find suitable information anywhere.在任何地方都找不到合适的信息。


Checking the log I see the following检查日志我看到以下内容

00000000000i[FLOPPY] fd0: 'boot.img' ro=0, h=2,t=80,spt=18
00000000000i[FLOPPY] Using boot sequence floppy, none, none
00000000000i[FLOPPY] Floppy boot signature check is enabled

Not sure how to interpret this (if this is normal or some kind of error / mistake is hiding in them)不知道如何解释(如果这是正常的或某种错误/错误隐藏在其中)


Tried to follow these steps as per here and here which I believe should create a simple 1.44 MB image, place the bin in the first sector and leave it to it.尝试按照此处此处执行这些步骤,我认为应该创建一个简单的 1.44 MB 图像,将 bin 放在第一个扇区中并留给它。 When done in this way (as well not padding it) in both cases qemu loads the image and shows the h each time without fault.当以这种方式完成时(以及不填充它),在这两种情况下, qemu都会加载图像并每次都显示h而没有错误。 Bochs does not load anything. Bochs 不加载任何内容。 Whatever I do.不管我做什么。 Always the same black screen and afterwards Not responding总是一样的黑屏,然后Not responding

I uninstalled, purged, and then reinstalled bochs.我卸载、清除并重新安装了 bochs。 I do not know what else I can do.我不知道我还能做什么。 I can't understand why it fails to load the simple bootloader.我不明白为什么它无法加载简单的引导加载程序。


Here are the steps以下是步骤

  1. nasm boot_simple.asm -f bin -o boot.bin

  2. dd if=/dev/zero of=floppy.img bs=1024 count=1440

  3. dd if=boot.bin of=floppy.img seek=0 count=1 conv=notrunc

  4. mkfs.vfat -F 12 ./floppy.img (This step makes the floppy un-bootable in qemu but really does not change anything for bochs) mkfs.vfat -F 12 ./floppy.img (此步骤使软盘在 qemu 中无法启动,但实际上并没有改变 bochs 的任何内容)

  5. bochs -f /dev/null -q 'display_library: x' 'boot:floppy' 'floppya: 1_44=floppy.img, status=inserted' 'romimage: file=/usr/share/bochs/BIOS-bochs-latest' 'error: action=report'

But nothing happens.但什么也没有发生。 Bochs boots to a black screen. Bochs 启动到黑屏。


Ok I have a slight idea.好的,我有一个小想法。 It seems that for some reason bochs halts at the first line of the code.似乎由于某种原因 bochs 在代码的第一行停止了。

Printing something like this -打印这样的东西 -

Next at t=0
(0) [0x0000fffffff0] f000:fff0 (unk. ctxt): jmpf 0xf000:e05b          ; ea5be000f0
<bochs:1>

Then waiting at the prompt <bochs:1> .然后在提示符<bochs:1>处等待。 If I do step there it does step through some instructions.如果我这样做,它确实会step执行一些说明。 Is there something I am missing here?我在这里缺少什么吗? Is there a bug in my code?我的代码中有错误吗?

BOCHS will always stop at the first instruction in the BIOS when launched.启动时,BOCHS 将始终在 BIOS 中的第一条指令处停止。 The first instruction is at 0xf000:0xfff0 which is what you see in the output.第一条指令位于 0xf000:0xfff0,这就是您在输出中看到的。 This gives you a chance to set breakpoints ahead of time.这使您有机会提前设置断点。 For example b 0x7c00 would break at the first instruction of the bootloader if you wished.例如,如果您愿意, b 0x7c00会在引导加载程序的第一条指令处中断。 To continue running just use the command c to continue.要继续运行,只需使用命令c继续。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM