问题
I am developing an embedded program for an intel i386, and I am trying to figure out how to use the hardware timer. I have read here (and other places) that the timer interrupt is 0x08, but this page (And various other sources) say that the first 32 interrupts are reserved for exceptions, and interrupt 0x08 specifically is for double fault. Which is true? How can I setup a timer interrupt handler, using either assembly or very low-level C with no operating system calls?
I am developing a simple operating system to learn about operating system development, so I don't have access to anything like Linux or system calls (unless I implement the system calls myself. But creating a fully POSIX-compliant OS is far outside the scope of this project, so I would rather stick to simple, if slightly hacky, solutions).
If it matters, I am running this on QEMU, not an actual physical i386.
回答1:
Most people assume this (Timer using INT8) a design flaw in the original IBM PC architecture. To (partially) protect the guilty, the original 8088 really didn't use this vector - It was, however, marked as "reserved" by Intel from the very beginning.
Before protected mode was invented, that conflict didn't really occur (CPUs < 80286 didn't use this double fault). In most of today's PCs, the 8259 PIC is still there, albeit not as separate chip, but hidden somewhere in the PCs chip set. Thankfully, INT08 for the timer interrupt is not carved in hardware, but rather initialized into the PIC by the PC BIOS. So protected mode OSs can easily re-map the PIC interrupts to other, more convenient places in order to avoid the conflict. To my knowledge, only DOS and other early operating systems assume the timer interrupt on INT8.
来源:https://stackoverflow.com/questions/42208827/how-can-the-timer-interrupt-be-0x08-if-the-first-32-interrupts-are-reserved-for