pci_intr, pci_intr_map, pci_intr_string, pci_intr_establish,
pci_intr_disestablish - PCI bus interrupt manipulation functions
pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ih);
const char *
pci_intr_string(pci_chipset_t *pc, pci_intr_handle_t ih);
pci_intr_establish(pci_chipset_t *pc, pci_intr_handle_t ih, int ipl,
int (*intrhand)(void *), void *intrarg);
pci_intr_disestablish(pci_chipset_t *pc, void *ih);
The pci_intr functions exist to allow device drivers machine-independent
access to PCI bus interrupts. The functions described in this page are
typically declared in a port's ~ <machine/pci_machdep.h> header file;
however, drivers should generally include ~ <dev/pci/pcivar.h> to get
other PCI-specific declarations as well.
Each driver has an attach() function which has a bus-specific attach_args
structure. Each driver for a PCI device is passed a pointer to an object
of type struct pci_attach_args which contains, among other things, information
about the location of the device in the PCI bus topology sufficient
to allow interrupts from the device to be handled.
If a driver wishes to establish an interrupt handler for the device, it
should pass the struct pci_attach_args * to the pci_intr_map() function,
which returns zero on success, and nonzero on failure. The function sets
the pci_intr_handle_t pointed at by its second argument to a machinedependent
value which identifies a particular interrupt source.
If the driver wishes to refer to the interrupt source in an attach or
error message, it should use the value returned by pci_intr_string().
Subsequently, when the driver is prepared to receive interrupts, it
should call pci_intr_establish() to actually establish the handler; when
the device interrupts, intrhand will be called with a single argument
intrarg, and will run at the interrupt priority level ipl.
The return value of pci_intr_establish() may be saved and passed to
pci_intr_disestablish() to disable the interrupt handler when the driver
is no longer interested in interrupts from the device.
PORTING [Toc] [Back]
A port's implementation of pci_intr_map() may use the following members
of struct pci_attach_args to determine how the device's interrupts are
pcitag_t pa_intrtag; /* intr. appears to come from here */
pci_intr_pin_t pa_intrpin; /* intr. appears on this pin */
pci_intr_line_t pa_intrline; /* intr. routing information */
pci_intr_pin_t pa_rawintrpin; /* unswizzled pin */
PCI-PCI bridges swizzle (permute) interrupt wiring. Depending on implementation
details, it may be more convenient to use either original or
the swizzled interrupt parameters. The original device tag and interrupt
pin can be found in pa_tag and pa_rawintrpin respectively, while the
swizzled tag and pin can be found in pa_intrtag and pa_intrpin.
When a device is attached to a primary bus, both pairs of fields contain
the same values. When a device is found behind one or more pci-pci
bridges, pa_intrpin contains the ``swizzled'' interrupt pin number, while
pa_rawintrpin contains the original interrupt pin; pa_tag contains the
PCI tag of the device itself, and pa_intrtag contains the PCI tag of the
uppermost bridge device.
BSD May 19, 2002 BSD
[ Back ]