Reputation: 3330
I have read about BIOS interrupts, and know that they can be accessed only in 8086 real mode.
My questions:
Are there any other interrupts also available ? I have read about DOS interrupts, but I am confused as to if they are available in real mode also, and what is the list of DOS interrupts.
Once we enter protected mode, what happens to the BIOS interrupt table stored at 0x00 ? Is it replaces, or is it present but just not accessible ?
Upvotes: 3
Views: 2318
Reputation: 86575
DOS interrupts are available in DOS. (A 16-bit program in Windows will be able to use them as well, as it's running in a virtual 8086 mode and Windows tries to present an environment just like the olden days.) They're not there before the OS starts loading, though...and if you're building your own OS, they're not there at all unless you put them in.
Once you switch to protected mode, you're basically running off the interrupt descriptor table (IDT) you set up during the switch. The old table is still there, because its format is different enough that you can't just go overwriting it without risking trouble if an interrupt occurs before the switch. And you'd generally keep it around for a couple of reasons anyway, including its usefulness in case you have to switch back to real mode for some reason. (Windows 9x used to do this. Some drivers were 16-bit, and no one wanted to update them...so Windows had the ability to have those drivers run in real mode.) But it's not used while the processor is in protected mode.
The processor is not directly involved in the actual handling of interrupts. It doesn't even know what type of computer it's running in. Basically, it just sees an entry in the IDT and calls that interrupt handler.
Upvotes: 2
Reputation: 9819
In real mode, you have 256 different SOFTWARE TRIGGERED interrupts. In the early days of BIOS and DOS, they were used as not much more than a "jump address" table. For example, DOS used INT 21 mainly, so applications could be coded to use the INT 21
processor instruction instead of a CALL 1234:5678
- the real address would change with each new version of DOS, but the INT 21 stayed. When dos booted up, it would put the address of its real handler function into that slot of the interrupt table.
The INT XX
processor instruction can use interrupt numbers from 0 to 255, so all of them are available. If there was anything useful in the corresponding interrupt table slot was another thing - there were lots of resident programs however, that used some specific interrupt (which led to collisions if you loaded more than one of these programs).
Apart from this are the HARDWARE interrupts - these are not triggered by software, but by an external device like your keyboard, floppy or hard disk, when they wanted to tell the processor "i need some service". So for example, when you pressed a key on the keyboard, the keyboard controller triggers interrupt 9 (not sure about the number, it's a long time ago, but interrupts 8-15 were reserved for hardware). When booting, the BIOS would put the address of its keyboard-handling-procedure into the corresponding entry of the interrupt table. Whenever you pressed a key, the keyboard controller triggered interrupt 9, which made the processor look up the corresponding address in the interrupt table, call it - this transfers control to the bios - the bios did whatever is neccesary to get the actual key from the keyboard, then returned to the application, which had no idea what hat happened.
So to answer your first question: There are 256 interrupts. 0-7 were used for processor-internal stuff. 07-0F were triggered by hardware. 10-1F were reserved for the Bios, and DOS used 20-27. The rest of them were unused, which means, no valid procedure entry point was stored for them in the interrupt table. (This became very murky later, i'm oversimplifying here).
2nd question: Once you enter protected mode, the interrupt table is replaced by the OS that puts the processor in protected mode, because the BIOS routines were written for the 8086 which did not have a protected mode, often aren't safe to use if not in real mode, and don't handle multitasking well. Any decent OS just has to do this kind of stuff itself. And interrupts from 20-27, which were used by DOS, just have no replacement for them in others OSes. So you can't run dos executables on Linux, apart from not being able to run them, they wouldn't work if they use dos interrupts.
3rd question: The BIOS interrupts themselves are purely software, but they trigger hardware events. Interrupt 13 was for the floppy/hard disk. A program that wanted to read sectors directly from the floppy would fill the processor registers with some predefined values, call interrupt 13 (thus jump into the BIOS routine, the address of which was put into the interrupt table when the BIOS booted), and let the bios do its work. No hardware stuff yet. WITHIN the interrupt handler, of course, the bios would read and write the hardware ports of the floppy controller, but the application didn't have to know about the details.
Upvotes: 9