NetBSD/share/man/man9/pci_intr.9
2001-09-15 23:57:33 +00:00

112 lines
4.2 KiB
Groff

.\" $NetBSD: pci_intr.9,v 1.5 2001/09/15 23:57:33 uwe Exp $
.\"
.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Bill Sommerfeld
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgment:
.\" This product includes software developed by the NetBSD
.\" Foundation, Inc. and its contributors.
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
.\" contributors may be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd December 27, 2000
.Dt PCI_INTR 9
.Os
.Sh NAME
.Nm pci_intr ,
.Nm pci_intr_map ,
.Nm pci_intr_string ,
.Nm pci_intr_establish ,
.Nm pci_intr_disestablish
.Nd PCI bus interrupt manipulation functions
.Sh SYNOPSIS
.Fd #include <dev/pci/pcivar.h>
.Ft int
.Fn pci_intr_map "struct pci_attach_args *pa" "pci_intr_handle_t *ih"
.Ft const char *
.Fn pci_intr_string "pci_chipset_t *pc" "pci_intr_handle_t ih"
.Ft void *
.Fn pci_intr_establish "pci_chipset_t *pc" "pci_intr_handle_t ih" \
"int ipl" "int (*intrhand)(void *)" "void *intrarg"
.Ft void
.Fn pci_intr_disestablish "pci_chipset_t *pc" "void *ih"
.Sh DESCRIPTION
.Pp
The
.Nm
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
.Pa Aq machine/pci_machdep.h
header file; however, drivers should generally include
.Pa Aq dev/pci/pcivar.h
to get other PCI-specific declarations as well.
.Pp
Each driver has an
.Fn attach
function which has a bus-specific
.Ft attach_args
structure.
Each driver for a PCI device is passed a pointer to an object of type
.Ft 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.
.Pp
If a driver wishes to establish an interrupt handler for the device,
it should pass the
.Ft struct pci_attach_args *
to the
.Fn pci_intr_map
function, which returns zero on success, and nonzero on failure. The function
sets the
.Ft "pci_intr_handle_t"
pointed at by its second argument to a machine-dependent value which
identifies a particular interrupt source.
.Pp
If the driver wishes to refer to the interrupt source in an attach or
error message, it should use the value returned by
.Fn pci_intr_string .
.Pp
Subsequently, when the driver is prepared to receive interrupts, it
should call
.Fn pci_intr_establish
to actually establish the handler; when the device interrupts,
.Fa intrhand
will be called with a single argument
.Fa intrarg ,
and will run at the interrupt priority level
.Fa ipl .
.Pp
The return value of
.Fn pci_intr_establish
may be saved and passed to
.Fn pci_intr_disestablish
to disable the interrupt handler
when the driver is no longer interested in interrupts from the device.