.\" $OpenBSD: pci_intr_map.9,v 1.5 2006/04/27 16:04:22 pedro Exp $ .\" .\" Copyright (c) 2005 Michael Shalayeff .\" All rights reserved. .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .Dd April 25, 2006 .Dt PCI_INTR_MAP 9 .Os .Sh NAME .Nm pci_intr_map , .Nm pci_intr_line , .Nm pci_intr_string , .Nm pci_intr_establish , .Nm pci_intr_disestablish .Nd PCI interrupts .Sh SYNOPSIS .Fd #include .Fd #include .Fd #include .Fd #include .Fd #include .Fd #include .Ft int .Fn pci_intr_map "struct pci_attach_args *paa" "pci_intr_handle_t *ih" .Ft int .Fn pci_intr_line "pci_intr_handle_t *ih" .Ft const char * .Fn pci_intr_string "pci_chipset_tag_t pc" "pci_intr_handle_t ih" .Ft void * .Fn pci_intr_establish "pci_chipset_tag_t pc" "pci_intr_handle_t ih" \ "int level" "int (*func)(void *)" "void *arg" "char *name" .Ft void .Fn pci_intr_disestablish "pci_chipset_tag_t pc" "void *v" .Sh DESCRIPTION These functions are provided by the machine-dependent implementation for attaching handler functions to the interrupts of PCI devices. .Pp An architect type is provided by the machine-dependent code .Va pci_intr_handle_t , to be initialised by .Fn pci_intr_map . .Pp The .Fn pci_intr_map function should be called first to establish a mapping between a PCI pin and the interrupt controller's interrupt vector. This process may include resolving the mapping through firmware-provided information. .Pp Having initialised the .Va pci_intr_handle_t in the previous step, an interrupt handler can be established using .Fn pci_intr_establish or converted into printable form using .Fn pci_intr_string . A handler established using .Fn pci_intr_establish is always called with the system interrupt priority level set equal to, or higher than, .Va level . .Pp .Fn pci_intr_line provides the interrupt line extracted from the MD interrupt handle. Upon device detachment, .Fn pci_intr_disestablish should be used to disassociate the handler from the interrupt. .Pp See .Xr spl 9 for an explanation of the .Va ipl .Dq interrupt priority levels. .Sh EXAMPLES A typical code sequence for establishing a handler for a device interrupt in the driver might be: .Bd -literal -offset 3n int xxxattach(struct device *parent, struct device *self, void *aux) { struct xxx_softc *sc = (struct xxx_softc *)self; struct pci_attach_args *pa = aux; pci_intr_handle_t ih; const char *intrstr; bus_size_t size; \&... if (pci_intr_map(pa, &ih)) { printf(": can't map interrupt\\n"); bus_space_unmap(sc->iot, sc->ioh, size); return; } intrstr = pci_intr_string(pa->pa_pc, ih); sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_NET, xxx_intr, sc, sc->sc_dev.dv_xname); if (!sc->sc_ih) { printf(": can't establish interrupt"); if (intrstr) printf(" at %s", intrstr); printf("\\n"); bus_space_unmap(sc->iot, sc->ioh, size); return; } printf(": %s\\n", intrstr); \&... } .Ed .Sh SEE ALSO .Xr cardbus 4 , .Xr pci 4 , .Xr pcibios 4 , .Xr pci_conf_read 9 , .Xr spl 9 .Sh HISTORY These functions first appeared in .Ox 1.2 . .\" .Sh AUTHORS