4

How do BIOS extensions (option ROMs) work? I understand that an installed device may have it's own BIOS that adds features to the system but I'm not sure of how they are set up.

I keep reading the following address range 0x0C0000 to 0x0F0000 is used but I don't understand what this is used for. It's as if the ROMs are stored at these address but I don't see how that works. What if you installed 2 devices that both expected to be at 0x0C0000?

Then the BIOS jumps to the option ROM and starts running from there, my next question is that when the ROM writes into the Interrupt Vector Table and hooks an interrupt to point to itself, what address does this point to?

For example on a VGA card what address would it hook INT 10h to?

Or is it that the entire option ROM gets mapped into an area between 0x0C0000 to 0x0F0000 and the IVT would point to somewhere in this range?

I know this is regarding older technologies that aren't used any more (e.g. using interrupts) but I'm interested as to how they worked.

If anyone can help answer the above questions or just give a brief overview it would be greatly appreciated,

Thanks

RJSmith92
  • 870
  • 3
  • 15
  • 32

1 Answers1

5

In the IBM PC days, with the ISA bus, each device simply had to use a different address. Often times they had hardware jumpers or dip switches you could configure to change the address to avoid conflicts. With the advent of the PCI bus, hardware addresses are configured automatically by the system bios to assign each device a unique address.

If the oprom hooks an interrupt, it points to an address within the assigned address that the oprom lives at. In the case of VGA bios, that normally was within the 0xC0000 block. Using the msdos debugger, you could inspect the interrupt vector table to see the entry point, and start disassembling the instructions there to see what they did.

psusi
  • 7,837
  • 21
  • 25
  • Thanks. So with the ISA cards you would manually set an address between 0x0C0000 to 0x0F0000 so they don't conflict. With PCI cards that are PnP the BIOS would automatically assign an address range for the device BIOS between 0x0C0000 to 0x0F0000? So a device would have 2 or more address ranges, it would map it's ROM BIOS into a range between 0x0C0000 to 0x0F0000 for interrupts and it would also have addresses assigned to it for MMIO that could be accessed via a driver? – RJSmith92 Apr 28 '14 at 10:41
  • So for example a modern GPU, would it still map it's video BIOS between 0x0C0000 to 0x0F0000 and then still have addresses such as 0xE0000000 - 0xEFFFFFFF assigned to it that the driver will use to access the card? – RJSmith92 Apr 28 '14 at 21:53
  • 1
    @RJSmith92, yes, generally devices only request addresses in the old 0xC0000 to 0xF0000 range for bios oproms, and use addresses in the 3-4 GB range for MMIO. – psusi Apr 29 '14 at 03:02
  • Thanks, last question, so the option ROMs sort of provide an API to access the hardware via interrupts? and an alternative to this is to access the hardware directly via a device driver? – RJSmith92 Apr 29 '14 at 09:46
  • 1
    @RJSmith92, pretty much, yea. VGA bios hooks int 10h, which provides an api for basic text output, and disk controllers hook int 13h, which provides basic disk read/write interfaces. You might google for Ralph Brown's interrupt list for the nitty gritty details. – psusi Apr 29 '14 at 13:40
  • Sorry, last question. Is there a reason why these mapped ROMs don't show up in Windows? for example the resources assigned to my GPU in device manager shows the 0xA0000 - 0xbffff VGA address but doesn't show the C0000h to C7FFFh range assigned to the card for the Video BIOS? – RJSmith92 Apr 30 '14 at 11:24
  • @RJSmith92, because Windows doesn't run in 16 bit mode, it has no need of the bios oprom, so it unassigns it. – psusi Apr 30 '14 at 14:18
  • What do you mean by unassign it? When Windows switches into 32/64 bit mode is the oprom still mapped to C0000h to C7FFFh, but Windows just doesn't report it? 0xA0000 - 0xbffff is still mapped so why not the option ROMs. – RJSmith92 Apr 30 '14 at 14:33
  • @RJSmith92, windows disables the mapping because it doesn't need it. – psusi Apr 30 '14 at 14:37
  • Thanks, just ran a tool called PCIScope that gives details on all devices on the PCI bus. It showed that the ROM for my GPU was 128KB in size and was disabled. I assume Windows just disables it then when it is enumerated. Although I thought Windows used int 10h for VBE to show the splash screen or if it was running using the vgasave driver? Wouldn't the ROM need to be enabled at this point? – RJSmith92 May 01 '14 at 09:41
  • 1
    @RJSmith92, yes, if you use the base vga driver then it should remain enabled, but it is only used for setting the resolution, not drawing to the screen. – psusi May 01 '14 at 13:40
  • Hmmm, I disabled my GPU and was running the VGA driver but the ROM is still disabled. Not entirely sure how a modern day OS would work with the video BIOS as it is in protected mode. – RJSmith92 May 02 '14 at 00:06
  • 1
    @RJSmith92, like I said, it is only used to switch modes, so the rest of the time it can be disabled. It also may be copied to ram and run from there. Come to think of it, most bioses back in the day had options to shadow the bios and video bios in ram. After copying it to ram, it would be disabled. – psusi May 02 '14 at 00:36