152 lines
5.4 KiB
Groff
152 lines
5.4 KiB
Groff
.\" $NetBSD: pci_intr.9,v 1.10 2002/10/14 13:43:28 wiz 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 May 19, 2002
|
|
.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 \*[Lt]dev/pci/pcivar.h\*[Gt]
|
|
.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
|
|
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.
|
|
.Ss PORTING
|
|
A port's implementation of
|
|
.Fn pci_intr_map
|
|
may use the following members of
|
|
.Ft struct pci_attach_args
|
|
to determine how the device's interrupts are routed.
|
|
.Bd -literal
|
|
pci_chipset_tag_t pa_pc;
|
|
pcitag_t pa_tag;
|
|
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 */
|
|
.Ed
|
|
.Pp
|
|
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
|
|
.Ft pa_tag
|
|
and
|
|
.Ft pa_rawintrpin
|
|
respectively, while the swizzled tag and pin can be found in
|
|
.Ft pa_intrtag
|
|
and
|
|
.Ft pa_intrpin .
|
|
.Pp
|
|
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,
|
|
.Ft pa_intrpin
|
|
contains the
|
|
.Dq swizzled
|
|
interrupt pin number, while
|
|
.Ft pa_rawintrpin
|
|
contains the original interrupt pin;
|
|
.Ft pa_tag
|
|
contains the PCI tag of the device itself, and
|
|
.Ft pa_intrtag
|
|
contains the PCI tag of the uppermost bridge device.
|