如何确定启动设备

发布于 2024-11-25 23:06:02 字数 92 浏览 0 评论 0 原文

我再次有一个不太容易通过谷歌搜索的问题。假设 BIOS 已从指定设备加载了我的引导加载程序,我现在如何找出它是哪个设备,以便我可以将操作系统的其余部分加载到 RAM 中?

again I have a question that is not so easily googlable. Let's assume BIOS has loaded my bootloader from designated device, how do I now find out which device it is so I can load the rest of my os into ram?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哆啦不做梦 2024-12-02 23:06:02

如果它是 MBR bootstrap (也可能是其他情况?我不是 100% 确定) DL 将包含
驱动器号,即您可以执行类似的操作(替换您自己的内存布局等):

EntryPoint: 
    xor ax, ax
    mov ss, ax
    mov ds, ax
    mov sp, 0x7c00
.DiskReset:
    mov ah, 0
    int 0x13
    jc .DiskReset
    mov ax, 0x50 ; load to 0x500 linear address. It has unused space up to 0x7bff
    mov es, ax
    xor bx, bx
    mov ax, 0x023B ; count = 0x3b = 59, the maximum..
    mov cx, 0x0002
    xor dh, dh ; leave (dl = drive number) intact
    int 0x13
    jnc .ReadDone
    mov si, ReadError
    call PrintString16
    jmp .DiskReset
.ReadDone:
    ; ......

If it's MBR bootstrap (And possibly also otherwise? I'm not 100% sure) DL will contain
the drive number i.e. you can do something like this (substitute your own memory layout and so on):

EntryPoint: 
    xor ax, ax
    mov ss, ax
    mov ds, ax
    mov sp, 0x7c00
.DiskReset:
    mov ah, 0
    int 0x13
    jc .DiskReset
    mov ax, 0x50 ; load to 0x500 linear address. It has unused space up to 0x7bff
    mov es, ax
    xor bx, bx
    mov ax, 0x023B ; count = 0x3b = 59, the maximum..
    mov cx, 0x0002
    xor dh, dh ; leave (dl = drive number) intact
    int 0x13
    jnc .ReadDone
    mov si, ReadError
    call PrintString16
    jmp .DiskReset
.ReadDone:
    ; ......
時窥 2024-12-02 23:06:02

实际上有固件和引导程序之间的完整协议位于#0扇区。但是,正如您所看到的,其中大部分仅存在于标准文档的页面中,而不是现实中。实际上,当以旧的 PC/AT 和 PC98 方式启动时,人们使用 DL 作为固件驱动器号,并使用 BIOS 参数块(或者,更不优选,使用某种形式的专业工具维护的“嵌入式块列表”)用于确定驱动器中卷的位置。

当然,如果您以新的方式(至少是 x86 PC 世界)进行引导,那么 事情有很大不同。操作系统引导加载程序是引导管理器菜单上的一个条目,引导管理器菜单条目具有一个参数系统,这些参数在运行时由引导管理器传递给加载程序。参数之一是引导卷的位置,操作系统引导加载程序使用该位置来查找操作系统文件。事实上,Windows NT 长期以来就是这样工作的。

There's actually a whole protocol between the firmware and the bootstrap program in sector #0. As you can see, however, most of it exists only in the pages of standards documents and not in reality. In reality, when booting in the old PC/AT and PC98 way one uses DL for the firmware drive number and uses the "hidden sectors" field in the BIOS Parameter Block (or, far less preferably, an "embedded block list" maintained with some form of specialist tool) for the location of the volume within the drive.

If one is bootstrapping in the new (to the x86 PC world at least) way, of course, then things are a lot different. The operating system boot loader is an entry on the boot manager menu, and boot manager menu entries have a system of parameters, that are passed to the loader programs by the boot manager when they are run. One of the parameters is the location of the boot volume, which the operating system boot loader uses to find the operating system files. This is how Windows NT has worked for a long time, in fact.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文