[BACK]Return to pci_intr.9 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / share / man / man9

File: [cvs.NetBSD.org] / src / share / man / man9 / pci_intr.9 (download)

Revision 1.17.4.1, Wed Mar 18 07:42:44 2015 UTC (9 years, 1 month ago) by snj
Branch: netbsd-7
CVS Tags: netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0
Changes since 1.17: +5 -5 lines

Pull up following revision(s) (requested by riastradh in ticket #599):
	share/man/man9/pci_intr.9: revision 1.18
Fix type of pc argument in pci_intr(9) man page.

.\" $NetBSD: pci_intr.9,v 1.17.4.1 2015/03/18 07:42:44 snj 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.
.\"
.\" 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 February 25, 2015
.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
.In dev/pci/pcivar.h
.Ft int
.Fn pci_intr_map "const struct pci_attach_args *pa" "pci_intr_handle_t *ih"
.Ft const char *
.Fn pci_intr_string "pci_chipset_tag_t pc" "pci_intr_handle_t ih" "char *buf" "size_t len"
.Ft void *
.Fn pci_intr_establish "pci_chipset_tag_t pc" "pci_intr_handle_t ih" \
"int ipl" "int (*intrhand)(void *)" "void *intrarg"
.Ft void
.Fn pci_intr_disestablish "pci_chipset_tag_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
.In machine/pci_machdep.h
header file; however, drivers should generally include
.In 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 .
The buffer passed to
.Fn pci_intr_string
should be at least
.Dv PCI_INTRSTR_LEN
bytes.
.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.