BIOS中断调用所需的堆栈大小
我正在开发一个用于学习目的的小型引导加载程序。是否有关于 BIOS 中断调用所需的(自由)堆栈大小的任何规范/信息?
I am working on a small bootloader for learning purposes. Is there any specification/information available about the (free) stack size required for a bios interrupt call?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在进入中断处理程序之前,所有寄存器都与远返回地址一起推入堆栈,将寄存器大小相加并添加存储返回地址所需的空间以获得最小堆栈大小。
请注意,如果在中断处理程序中将更多数据推入堆栈,则需要更多空间
before entering the interrupt handler, all registers are pushed to the stack along with the far return address, sum your registers sizes up and add the space needed to store the return address to get the minimal stack size .
take note that you will need some more space if you are pushing more data into the stack while in the interrupt handler
来自http://www.o3one.org/hwdocs/bios_doc/pci_bios_21.pdf(第 3 页的“调用约定”),看起来 BIOS 调用最多可以使用 1024 字节的堆栈空间。我的谷歌搜索没有找到任何其他来源。
From http://www.o3one.org/hwdocs/bios_doc/pci_bios_21.pdf ("Calling Conventions" on page 3), it looks like the BIOS call can use up to 1024 bytes of stack space. My googling hasn't turned up any other sources.
我注意到,如果您使用 int 0x13 您应该有一个堆栈至少 4096 字节。现代 BIOS 通常具有 AHCI 兼容的 int 0x13 处理程序,并且由于 AHCI 相当复杂的BIOS int 0x13需要大量的堆栈空间。
在完美的世界中,BIOS 应该有自己的堆栈,但许多 BIOS 依赖于您提供的堆栈。
I've noticed that if you are using int 0x13 you should have a stack that is at least 4096 bytes. Modern BIOSes often have an AHCI compatible int 0x13 handler, and since AHCI is quite complicated the BIOS int 0x13 requires a lot of stack space.
In the perfect world the BIOS should have it's own stack, but many BIOSes rely on the stack you provide.
简单的答案是,BIOS 在加载引导扇区之前用于进行中断调用的堆栈(包括用于从 USB 闪存驱动器加载引导扇区的 int 13h)足以供引导扇区使用。
令人高兴的答案是,BIOS 中断(除了较新的臃肿的 PCI)被设计为在最小的空间中执行,因此无需在引导扇区中设置堆栈。
The simple answer is that the stack that the BIOS used to make interrupt calls (including the int 13h to load the boot sector from the usb flash drive) prior to loading the boot sector is sufficient for boot sector use.
The happy answer is that the BIOS interrupts (except for the newer bloated PCI) are designed to execute in minimal space so there is no need to setup a stack in the boot sector.