BIOS 将哪些信息加载到 RAM 中?

发布于 2024-07-26 00:39:24 字数 319 浏览 8 评论 0原文

我知道,启动时,BIOS 会在内存 0x7c00 上加载预定义设备驱动器的第一个扇区(512 字节),然后跳转到该地址。

因此,0x7c00 到 0x7dff 的内存被占用。 RAM 是否还有其他部分被占用?

如果我正在编写操作系统,我可以将除 0x7c00 到 ox7dff 之外的所有 RAM 用于我自己的目的吗?或者,是否有任何其他部分在启动时填充了我不能覆盖的“宝贵”信息?

我知道在给定时刻,我可以覆盖内存上加载的 MBR(链式加载),我的问题集中在...内存的哪一部分可用于操作系统?

对不起,我的英语不好。 感谢您的回答!

I know that, on booting, BIOS loads the first sector (512 bytes) of a pre-defined device drive on memory 0x7c00 and then jump to that address.

So, memory from 0x7c00 to 0x7dff is occupied. Is there any other section of RAM that is occupied?

If I'm programming an Operating System, could I use all the RAM except 0x7c00 to ox7dff for my own purposes?, or, is there any other section filled with "precious" information at boot time that I must not overwrite?

I know that at a given moment, I can overwrite MBR loaded on memory (chainloading), my question is focused on... what part of the memory is available for an Operating System?

Sorry for my bad english. Thanks for your answers!!

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

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

发布评论

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

评论(3

小镇女孩 2024-08-02 00:39:24

x86实模式内存映射如下:

 - 0x00000000 - 0x000003FF - Real Mode Interrupt Vector Table
 - 0x00000400 - 0x000004FF - BIOS Data Area
 - 0x00000500 - 0x00007BFF - Unused
 - 0x00007C00 - 0x00007DFF - Our Bootloader
 - 0x00007E00 - 0x0009FFFF - Unused
 - 0x000A0000 - 0x000BFFFF - Video RAM (VRAM) Memory
 - 0x000B0000 - 0x000B7777 - Monochrome Video Memory
 - 0x000B8000 - 0x000BFFFF - Color Video Memory
 - 0x000C0000 - 0x000C7FFF - Video ROM BIOS
 - 0x000C8000 - 0x000EFFFF - BIOS Shadow Area
 - 0x000F0000 - 0x000FFFFF - System BIOS

在我的实模式编程中,我通常坚持从0x00007E00 - 0x0009FFFF(不是全部)..我使用段:偏移寻址来使用内存..从1阶段引导加载程序到内核或引导加载程序第二阶段,我使用:

; bootloader.s

BITS  16
ORG   0x7C00

  CLI
  JMP 0xE000      ; Can also be JMP 0x7C00:200
  HLT

TIMES 510 - ($-$) DB 0
DW 0xAA55

--

; Something.s

BITS  16
ORG   0x7E00      ; Can also be ORG   0x7C00:200

; Code goes here for your purposes.. whether it be a 2nd stage
; bootloader or your 16bit kernel..

CLI
HLT

如果您要进入保护模式,您仍然需要一个存根,如上所示。在 Something.s 中,您可以在保护模式例程中进行编程(GDT、A20、Set视频模式等..)

为了解释 0x7C00(引导加载程序入口点)的内存位置,0x7C00 - 0x7DFF 是放置引导加载程序(上面的 bootloader.s)的位置。 您将其放在那里是因为 BIOS 在执行完例程后会跳转到该位置。 引导加载程序的大小必须恰好为 512 字节(请注意 TIMES 指令)。 从那里,您的代码可以是任意大小(只要它适合内存映射),并且您将能够完全在操作系统上工作。

如果您进入 32 位保护模式,您将能够使用有关 1MiB 标记的任何内容。

The x86 Real Mode Memory Map is as follows:

 - 0x00000000 - 0x000003FF - Real Mode Interrupt Vector Table
 - 0x00000400 - 0x000004FF - BIOS Data Area
 - 0x00000500 - 0x00007BFF - Unused
 - 0x00007C00 - 0x00007DFF - Our Bootloader
 - 0x00007E00 - 0x0009FFFF - Unused
 - 0x000A0000 - 0x000BFFFF - Video RAM (VRAM) Memory
 - 0x000B0000 - 0x000B7777 - Monochrome Video Memory
 - 0x000B8000 - 0x000BFFFF - Color Video Memory
 - 0x000C0000 - 0x000C7FFF - Video ROM BIOS
 - 0x000C8000 - 0x000EFFFF - BIOS Shadow Area
 - 0x000F0000 - 0x000FFFFF - System BIOS

In my real mode programming I usually stick from 0x00007E00 - 0x0009FFFF (Not all of it).. I use segment:offset addressing to use the memory.. To go from a 1 Stage bootloader to a Kernel or a Bootloader 2nd Stage, I use:

; bootloader.s

BITS  16
ORG   0x7C00

  CLI
  JMP 0xE000      ; Can also be JMP 0x7C00:200
  HLT

TIMES 510 - ($-$) DB 0
DW 0xAA55

--

; Something.s

BITS  16
ORG   0x7E00      ; Can also be ORG   0x7C00:200

; Code goes here for your purposes.. whether it be a 2nd stage
; bootloader or your 16bit kernel..

CLI
HLT

If you are going into Protected mode, you will still need a stub as shown above.. In Something.s you can program in your protected mode routines (GDT, A20, Set video mode, etc..)

To explain about the memory location at 0x7C00 (Bootloader Entry Point), 0x7C00 - 0x7DFF is where you place your bootloader (the bootloader.s above). You place it there because the BIOS jumps to that location after doing its routines. The bootloader must be exactly 512 bytes in size (notice the TIMES directive). From there, your code can be any size (as long as it fits in the memory map), and you will be able to work on the OS fully.

If you DO go into 32Bit Protected Mode, you will be able to use ANYTHING about the 1MiB mark.

甜警司 2024-08-02 00:39:24

对于任何最新的 BIOS,您都可以使用 BIOS Int 15/AX= 获取内存映射信息E820h 调用。 这将告诉您操作系统可以使用哪些内存。

有关如何检测可用内存以及BIOS 内存映射 可以在 OSDev

With any remotely recent BIOS, you can obtain memory map information by using the BIOS Int 15/AX=E820h call. This will tell you what memory you can use for your OS.

A more detailed explanation on how to detect available memory, and the contents of the BIOS memory map can be found at OSDev.

如若梦似彩虹 2024-08-02 00:39:24

如果你编写一个操作系统,一旦进入保护模式,你就会忘记 BIOS(除非你正在使用一些坏设备)并使用你拥有的一切。

或者你正在写一个引导加载程序?

If you write an OS, as soon as you go into protected mode, you get forget the BIOS (unless you are working with some bad device) and use all you have.

Or are you writing a bootloader?

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