views:

145

answers:

4

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?

A: 

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.

Anon.
+1  A: 

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

Alon
A: 

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.

Jonas Gulle
A: 

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.

Mike Gonta