I am new to interrupt handlers and device i/o and I have a few questions:
When you load a device-driver, i.e. kernel module, its assembly code is stored in the module-mapping region of the Kernel Virtual Address Space. (See https://www.kernel.org/doc/Documentation/x86/x86_64/mm.txt)
Interrupt Vector Tables (IVT) contain addresses of Interrupt-Service Routines (ISR) which are commonly split into Top-Half and Bottom-Half handlers with the latter being more elaborate, and the physical address of the former being stored in the <Interrupt Vector: ISR>
IVT stored in Flash memory (seperate from RAM). Often the top-half handler calls the bottom half handler for further processing (I assume by jumping to some other phsyical address).
Is the bottom-half handler that is jumped to simply some code from the device-driver loaded into the kernel VAS, i.e. in RAM? If yes, how is the address of driver code available to code in flash memory? Are device drivers solely used for machine->device communication? At what point in the interrupt-processing path does device-driver code execute and for what purpose?
My understanding of the interrupt processing path is as follows:
-
Device sends an IRQ (electrical signal) when its internal state (stored in device registers/buffers) is in a condition that requires servicing (handling) by the host machine. This is often an MSI packet sent over a PCIe bus that contains an Interrupt Vector specifying the interrupt type. For example, on-device sensors may change the device state to one that necessitates external servicing and trigger the send of an MSI packet to host machine.
-
MSI packet (containing the Interrupt Vector) reaches the APIC attached to a cpu core. The APIC may have its own APIC driver that provides a canned Interrupt Vector which is used to retrieve the address of the ISR and store it in the CPU PC (thus beginning the switch to interrupt context, and CPU part of interrupt handling)
-
Top-Half interrupt handler begins execution, may call the bottom half handler for further processing.
-
???? Results of bottom half handler are copied-to-user by code in the device-driver kernel addresses ????
Please help me out, thank you.
11