Home |
RTTarget-32 Programming Manual Running Win32 Programs without Win32 Descriptors and Descriptor Tables Virtual, Linear, and Physical Addresses Exceptions and Interrupts Running a Program on the Target Compiling and Linking with On Time RTOS-32 |
Exceptions and InterruptsThe 386 supports Exceptions, Software Interrupts, and Hardware Interrupts, which are summarized by the term Interrupt. Interrupts are numbered 0 to 255. They are events that transfer control to an Interrupt Handler (or Interrupt Service Routine, ISR) which must handle the event. The interrupt handler's address is read from the IDT. Each descriptor in the IDT contains a pointer to the corresponding handler (along with some supplemental information). Exceptions are triggered by the CPU in case of an error. For example, if a program attempts to write to a memory location for which it only has read access, the CPU will trigger an exception. The exception could be handled by an operating system to abort the misbehaved program or activate a debugger to allow further investigation of the problem. RTTarget-32's boot code will initialize all exception vectors to point to a routine that simply displays a register dump and then stops. If a program wants to handle such exceptions, it can instruct RTTarget-32 to map CPU exceptions to Win32 exceptions. The Debug Monitor, RTTarget-32's debugger interface, will handle all exceptions and allow debugging the cause of the exception. Software interrupts are explicitly triggered by a program using the INT instruction. Actually, this is similar to a procedure call. However, the address of the procedure to be called is found in the IDT and a change of privilege level can occur in the call. RTTarget-32 defines several interrupts for its API and for emulating subsets of some other APIs such as DOS and DPMI. The use of interrupts allows the application to run at CPL 0 or 3 while the RTTarget-32 boot code (which handles some API requests) always runs at CPL 0. Hardware interrupts are triggered by some hardware external to the CPU. The most significant difference from exceptions and software interrupts is that hardware interrupts can occur at any time and at any place in the code. Since this may cause problems, the processing of hardware interrupts can be suspended temporarily using the CLI/STI instructions. RTTarget-32's boot code installs dummy interrupt handlers and displays a warning message if an interrupt occurs (exception: timer and keyboard interrupts on IRQ 0 and 1 are ignored). The application should install interrupt handlers before any external hardware will generate interrupts. Interrupt handlers should not chain to the RTTarget-32 boot code handlers. Virtual, Linear, and Physical Addresses
|