LyricalRain wrote:
I have a functioning AHCI driver with read and write functions. However, currently I just poll the status in a while loop until the operation is done. I want to enable interrupts for the driver so that i get an interrupt through the PIC. However, there are quite a few "interrupt" bits throughout the structs related to AHCI, and I'm confused on which ones need to be enabled to get the controller to send interrupts.
Could anyone briefly explain the steps to enable interrupts?
Enabling interrupts is quite trivial with AHCI. You first have to set GHC.IE. GHC.IE (interrupt enable) enables all interrupts from the HBA. (You also need to enable interrupts in PCI/PCIe via the command register and, if you want to use it, you need to also configure MSI/MSI-X.) Once interrupts are globally enabled, you can proceed to configure interrupts for each port.
For each port, you have a PxIS and PxIE register. These registers are symmetrical with each other; that is, a bit in PxIE corresponds to the same bit in PxIS and vice-versa. Section 3.3.5 describes the status bits (PxIS) and section 3.3.6 describes the PxIE bits. There are a lot of bits, for sure, so you can choose which ones to enable. (I'm pretty sure you should enable all of them.)