Get the IRQs associated with a device
#include <pci/pci.h> pci_err_t pci_device_read_irq( pci_devhdl_t hdl, int_t *nirq, pci_irq_t *irq );
The pci_device_read_irq() function gets the IRQs associated with a device. You must have already attached to the device by successfully calling pci_device_attach().
There could be multiple IRQs associated with a single device. In general, the irq parameter should point to an array of pci_irq_t types, and you should specify the number of entries the array in the value pointed to by nirq.
By modifying the parameters, you can control returned values as follows:
Otherwise, you should allocate space for an array of pci_irq_t items and set nirq to point to the number of items allocated. Upon successful return, nirq contains a value as follows:
For example, if nirq contains the value of -2 upon successful return, all but two of the requested number of IRQs were successfully returned.
If the device uses more than one IRQ, it is unspecified as to which device functionality is associated with which IRQ. IRQs are returned in the irq array in enabled interrupt source order. See also Capability ID 0x5 (MSI) and Capability ID 0x11 (MSI-X) in the Capability Modules and APIs appendix.
Because the IRQs for a device provide the ability to attach interrupt handlers, it's desirable to control access to this information. This function succeeds only if hdl identifies an attacher that owns the device. When you call pci_device_attach(), you can specify whether you want to be the owner of the device. Only the owner can successfully call pci_device_read_irq() and hence be able to attach interrupt service routines.
If any error occurs, you should assume that the storage that you provided contains invalid data.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |