First post, by superfury
Is it smart to simply 'allocate' private memory for a BIOS option ROM by:
- Stealing base memory for a memory area to use
- Hooking an interrupt inside said base memory area, including some extra room for the data storage. The interrupt handler can then give a pointer to the data storage if requested (for example, by the actual interrupt handler in the option ROM).
The data allocation interrupt handler (that's actually at the stolen RAM block) can then be used by the option ROM to store:
- The hooked interrupt handler (so it can perform the original interrupt if the request isn't meant for itself).
- Extra data required by the option ROM to store.
For example, inside my IBM XT RTC option ROM (which provides interrupt 1Ah timing services on a XT with the 'XT RTC' installed, for example on the Samtron 88S, which my BIOS ROM implements for an XT machine) it uses this method to hook interrupt 1Ah (the actual time interrupt, handling the RTC functions) and interrupt 19h (bootstrap itself) and interrupt 15h (for it's data storage).
The INT15h function call used to return the data block's AX=FE00h. It just returns the address of the data block into DS:BX, clears the returned carry flag and swaps AH/AL to identify itself (AH=00h, AL=FEh). Although it hard-codes the BX addresss in the locations using it instead (as it can be guaranteed enough space for it).
The hooked interrupt handlers simply use the single flag (to enable it's functionality and POST properly) and the various INT1A/19/15h interrupt vectors stored inside of it. The INT15h handler is actually a direct copy of the one stored in the ROM, which is copied there to perform it's function (so it's executing from RAM).
The BIOS ROM using this method:
https://bitbucket.org/superfury/unipcemu_pcxtbios_at/
Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io