1996-12-17 04:55:56 +03:00
|
|
|
/* $NetBSD: pci_machdep.c,v 1.27 1996/12/17 01:55:56 thorpej Exp $ */
|
1994-10-27 07:14:23 +03:00
|
|
|
|
1994-08-09 04:47:46 +04:00
|
|
|
/*
|
modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) deprecate the pci_map_* functions, and provide them only
as compatibility interfaces (in pci_compat.c) which will
eventually go away, implemented as wrappers around
the functions described above.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
1996-03-27 07:01:10 +03:00
|
|
|
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
|
1994-08-09 04:47:46 +04:00
|
|
|
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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 acknowledgement:
|
|
|
|
* This product includes software developed by Charles Hannum.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Machine-specific functions for PCI autoconfiguration.
|
|
|
|
*
|
|
|
|
* On PCs, there are two methods of generating PCI configuration cycles.
|
|
|
|
* We try to detect the appropriate mechanism for this machine and set
|
|
|
|
* up a few function pointers to access the correct method directly.
|
|
|
|
*
|
|
|
|
* The configuration method can be hard-coded in the config file by
|
|
|
|
* using `options PCI_CONF_MODE=N', where `N' is the configuration mode
|
|
|
|
* as defined section 3.6.4.1, `Generating Configuration Cycles'.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/vm_kern.h>
|
|
|
|
|
|
|
|
#include <machine/pio.h>
|
|
|
|
|
|
|
|
#include <i386/isa/icu.h>
|
1995-04-17 16:06:30 +04:00
|
|
|
#include <dev/isa/isavar.h>
|
1995-01-27 08:46:39 +03:00
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcireg.h>
|
1994-08-09 04:47:46 +04:00
|
|
|
|
|
|
|
int pci_mode = -1;
|
|
|
|
|
|
|
|
#define PCI_MODE1_ENABLE 0x80000000UL
|
|
|
|
#define PCI_MODE1_ADDRESS_REG 0x0cf8
|
|
|
|
#define PCI_MODE1_DATA_REG 0x0cfc
|
|
|
|
|
|
|
|
#define PCI_MODE2_ENABLE_REG 0x0cf8
|
|
|
|
#define PCI_MODE2_FORWARD_REG 0x0cfa
|
|
|
|
|
modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) deprecate the pci_map_* functions, and provide them only
as compatibility interfaces (in pci_compat.c) which will
eventually go away, implemented as wrappers around
the functions described above.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
1996-03-27 07:01:10 +03:00
|
|
|
void
|
|
|
|
pci_attach_hook(parent, self, pba)
|
|
|
|
struct device *parent, *self;
|
|
|
|
struct pcibus_attach_args *pba;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (pba->pba_bus == 0)
|
1996-10-13 07:19:38 +04:00
|
|
|
printf(": configuration mode %d", pci_mode);
|
modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) deprecate the pci_map_* functions, and provide them only
as compatibility interfaces (in pci_compat.c) which will
eventually go away, implemented as wrappers around
the functions described above.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
1996-03-27 07:01:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
pci_bus_maxdevs(pc, busno)
|
|
|
|
pci_chipset_tag_t pc;
|
|
|
|
int busno;
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bus number is irrelevant. If Configuration Mechanism 2 is in
|
|
|
|
* use, can only have devices 0-15 on any bus. If Configuration
|
|
|
|
* Mechanism 1 is in use, can have devices 0-32 (i.e. the `normal'
|
|
|
|
* range).
|
|
|
|
*/
|
|
|
|
if (pci_mode == 2)
|
|
|
|
return (16);
|
|
|
|
else
|
|
|
|
return (32);
|
|
|
|
}
|
|
|
|
|
1994-08-09 04:47:46 +04:00
|
|
|
pcitag_t
|
modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) deprecate the pci_map_* functions, and provide them only
as compatibility interfaces (in pci_compat.c) which will
eventually go away, implemented as wrappers around
the functions described above.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
1996-03-27 07:01:10 +03:00
|
|
|
pci_make_tag(pc, bus, device, function)
|
|
|
|
pci_chipset_tag_t pc;
|
1994-08-09 04:47:46 +04:00
|
|
|
int bus, device, function;
|
|
|
|
{
|
|
|
|
pcitag_t tag;
|
|
|
|
|
|
|
|
#ifndef PCI_CONF_MODE
|
|
|
|
switch (pci_mode) {
|
|
|
|
case 1:
|
|
|
|
goto mode1;
|
|
|
|
case 2:
|
|
|
|
goto mode2;
|
|
|
|
default:
|
|
|
|
panic("pci_make_tag: mode not configured");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 1)
|
1996-10-24 16:32:29 +04:00
|
|
|
#ifndef PCI_CONF_MODE
|
1994-08-09 04:47:46 +04:00
|
|
|
mode1:
|
1996-10-24 16:32:29 +04:00
|
|
|
#endif
|
1994-08-09 04:47:46 +04:00
|
|
|
if (bus >= 256 || device >= 32 || function >= 8)
|
|
|
|
panic("pci_make_tag: bad request");
|
|
|
|
|
|
|
|
tag.mode1 = PCI_MODE1_ENABLE |
|
|
|
|
(bus << 16) | (device << 11) | (function << 8);
|
|
|
|
return tag;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 2)
|
1996-10-24 16:32:29 +04:00
|
|
|
#ifndef PCI_CONF_MODE
|
1994-08-09 04:47:46 +04:00
|
|
|
mode2:
|
1996-10-24 16:32:29 +04:00
|
|
|
#endif
|
1994-08-09 04:47:46 +04:00
|
|
|
if (bus >= 256 || device >= 16 || function >= 8)
|
|
|
|
panic("pci_make_tag: bad request");
|
|
|
|
|
|
|
|
tag.mode2.port = 0xc000 | (device << 8);
|
1994-12-28 22:45:41 +03:00
|
|
|
tag.mode2.enable = 0xf0 | (function << 1);
|
1994-08-09 04:47:46 +04:00
|
|
|
tag.mode2.forward = bus;
|
|
|
|
return tag;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1996-12-17 04:55:56 +03:00
|
|
|
void
|
|
|
|
pci_decompose_tag(pc, tag, bp, dp, fp)
|
|
|
|
pci_chipset_tag_t pc;
|
|
|
|
pcitag_t tag;
|
|
|
|
int *bp, *dp, *fp;
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifndef PCI_CONF_MODE
|
|
|
|
switch (pci_mode) {
|
|
|
|
case 1:
|
|
|
|
goto mode1;
|
|
|
|
case 2:
|
|
|
|
goto mode2;
|
|
|
|
default:
|
|
|
|
panic("pci_decompose_tag: mode not configured");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 1)
|
|
|
|
#ifndef PCI_CONF_MODE
|
|
|
|
mode1:
|
|
|
|
#endif
|
|
|
|
if (bp != NULL)
|
|
|
|
*bp = (tag.mode1 >> 16) & 0xff;
|
|
|
|
if (dp != NULL)
|
|
|
|
*dp = (tag.mode1 >> 11) & 0x1f;
|
|
|
|
if (fp != NULL)
|
|
|
|
*fp = (tag.mode1 >> 8) & 0x7;
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 2)
|
|
|
|
#ifndef PCI_CONF_MODE
|
|
|
|
mode2:
|
|
|
|
#endif
|
|
|
|
if (bp != NULL)
|
|
|
|
*bp = tag.mode2.forward & 0xff;
|
|
|
|
if (dp != NULL)
|
|
|
|
*dp = (tag.mode2.port >> 8) & 0xf;
|
|
|
|
if (fp != NULL)
|
|
|
|
*fp = (tag.mode2.enable >> 1) & 0x7;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1994-08-09 04:47:46 +04:00
|
|
|
pcireg_t
|
modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) deprecate the pci_map_* functions, and provide them only
as compatibility interfaces (in pci_compat.c) which will
eventually go away, implemented as wrappers around
the functions described above.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
1996-03-27 07:01:10 +03:00
|
|
|
pci_conf_read(pc, tag, reg)
|
|
|
|
pci_chipset_tag_t pc;
|
1994-08-09 04:47:46 +04:00
|
|
|
pcitag_t tag;
|
|
|
|
int reg;
|
|
|
|
{
|
|
|
|
pcireg_t data;
|
|
|
|
|
|
|
|
#ifndef PCI_CONF_MODE
|
|
|
|
switch (pci_mode) {
|
|
|
|
case 1:
|
|
|
|
goto mode1;
|
|
|
|
case 2:
|
|
|
|
goto mode2;
|
|
|
|
default:
|
|
|
|
panic("pci_conf_read: mode not configured");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 1)
|
1996-10-24 16:32:29 +04:00
|
|
|
#ifndef PCI_CONF_MODE
|
1994-08-09 04:47:46 +04:00
|
|
|
mode1:
|
1996-10-24 16:32:29 +04:00
|
|
|
#endif
|
1994-08-09 04:47:46 +04:00
|
|
|
outl(PCI_MODE1_ADDRESS_REG, tag.mode1 | reg);
|
|
|
|
data = inl(PCI_MODE1_DATA_REG);
|
|
|
|
outl(PCI_MODE1_ADDRESS_REG, 0);
|
|
|
|
return data;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 2)
|
1996-10-24 16:32:29 +04:00
|
|
|
#ifndef PCI_CONF_MODE
|
1994-08-09 04:47:46 +04:00
|
|
|
mode2:
|
1996-10-24 16:32:29 +04:00
|
|
|
#endif
|
1994-08-09 04:47:46 +04:00
|
|
|
outb(PCI_MODE2_ENABLE_REG, tag.mode2.enable);
|
|
|
|
outb(PCI_MODE2_FORWARD_REG, tag.mode2.forward);
|
|
|
|
data = inl(tag.mode2.port | reg);
|
|
|
|
outb(PCI_MODE2_ENABLE_REG, 0);
|
|
|
|
return data;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) deprecate the pci_map_* functions, and provide them only
as compatibility interfaces (in pci_compat.c) which will
eventually go away, implemented as wrappers around
the functions described above.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
1996-03-27 07:01:10 +03:00
|
|
|
pci_conf_write(pc, tag, reg, data)
|
|
|
|
pci_chipset_tag_t pc;
|
1994-08-09 04:47:46 +04:00
|
|
|
pcitag_t tag;
|
|
|
|
int reg;
|
|
|
|
pcireg_t data;
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifndef PCI_CONF_MODE
|
|
|
|
switch (pci_mode) {
|
|
|
|
case 1:
|
|
|
|
goto mode1;
|
|
|
|
case 2:
|
|
|
|
goto mode2;
|
|
|
|
default:
|
|
|
|
panic("pci_conf_write: mode not configured");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 1)
|
1996-10-24 16:32:29 +04:00
|
|
|
#ifndef PCI_CONF_MODE
|
1994-08-09 04:47:46 +04:00
|
|
|
mode1:
|
1996-10-24 16:32:29 +04:00
|
|
|
#endif
|
1994-08-09 04:47:46 +04:00
|
|
|
outl(PCI_MODE1_ADDRESS_REG, tag.mode1 | reg);
|
|
|
|
outl(PCI_MODE1_DATA_REG, data);
|
|
|
|
outl(PCI_MODE1_ADDRESS_REG, 0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 2)
|
1996-10-24 16:32:29 +04:00
|
|
|
#ifndef PCI_CONF_MODE
|
1994-08-09 04:47:46 +04:00
|
|
|
mode2:
|
1996-10-24 16:32:29 +04:00
|
|
|
#endif
|
1994-08-09 04:47:46 +04:00
|
|
|
outb(PCI_MODE2_ENABLE_REG, tag.mode2.enable);
|
|
|
|
outb(PCI_MODE2_FORWARD_REG, tag.mode2.forward);
|
|
|
|
outl(tag.mode2.port | reg, data);
|
|
|
|
outb(PCI_MODE2_ENABLE_REG, 0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
pci_mode_detect()
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef PCI_CONF_MODE
|
|
|
|
#if (PCI_CONF_MODE == 1) || (PCI_CONF_MODE == 2)
|
|
|
|
return (pci_mode = PCI_CONF_MODE);
|
|
|
|
#else
|
|
|
|
#error Invalid PCI configuration mode.
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
if (pci_mode != -1)
|
|
|
|
return pci_mode;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We try to divine which configuration mode the host bridge wants. We
|
|
|
|
* try mode 2 first, because our probe for mode 1 is likely to succeed
|
|
|
|
* for mode 2 also.
|
|
|
|
*
|
|
|
|
* XXX
|
1994-08-10 08:37:52 +04:00
|
|
|
* This should really be done using the PCI BIOS.
|
1994-08-09 04:47:46 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
outb(PCI_MODE2_ENABLE_REG, 0);
|
|
|
|
outb(PCI_MODE2_FORWARD_REG, 0);
|
|
|
|
if (inb(PCI_MODE2_ENABLE_REG) != 0 ||
|
|
|
|
inb(PCI_MODE2_FORWARD_REG) != 0)
|
|
|
|
goto not2;
|
|
|
|
return (pci_mode = 2);
|
|
|
|
|
|
|
|
not2:
|
|
|
|
outl(PCI_MODE1_ADDRESS_REG, PCI_MODE1_ENABLE);
|
|
|
|
if (inl(PCI_MODE1_ADDRESS_REG) != PCI_MODE1_ENABLE)
|
|
|
|
goto not1;
|
|
|
|
outl(PCI_MODE1_ADDRESS_REG, 0);
|
|
|
|
if (inl(PCI_MODE1_ADDRESS_REG) != 0)
|
|
|
|
goto not1;
|
|
|
|
return (pci_mode = 1);
|
|
|
|
|
|
|
|
not1:
|
|
|
|
return (pci_mode = 0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) deprecate the pci_map_* functions, and provide them only
as compatibility interfaces (in pci_compat.c) which will
eventually go away, implemented as wrappers around
the functions described above.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
1996-03-27 07:01:10 +03:00
|
|
|
pci_intr_map(pc, intrtag, pin, line, ihp)
|
|
|
|
pci_chipset_tag_t pc;
|
|
|
|
pcitag_t intrtag;
|
1994-08-09 04:47:46 +04:00
|
|
|
int pin, line;
|
modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) deprecate the pci_map_* functions, and provide them only
as compatibility interfaces (in pci_compat.c) which will
eventually go away, implemented as wrappers around
the functions described above.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
1996-03-27 07:01:10 +03:00
|
|
|
pci_intr_handle_t *ihp;
|
|
|
|
{
|
1994-08-09 04:47:46 +04:00
|
|
|
|
|
|
|
if (pin == 0) {
|
|
|
|
/* No IRQ used. */
|
1996-03-27 09:49:54 +03:00
|
|
|
goto bad;
|
1994-08-09 04:47:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pin > 4) {
|
1996-10-13 07:19:38 +04:00
|
|
|
printf("pci_intr_map: bad interrupt pin %d\n", pin);
|
1996-03-27 09:49:54 +03:00
|
|
|
goto bad;
|
1994-08-09 04:47:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Section 6.2.4, `Miscellaneous Functions', says that 255 means
|
|
|
|
* `unknown' or `no connection' on a PC. We assume that a device with
|
|
|
|
* `no connection' either doesn't have an interrupt (in which case the
|
|
|
|
* pin number should be 0, and would have been noticed above), or
|
1994-09-06 05:25:22 +04:00
|
|
|
* wasn't configured by the BIOS (in which case we punt, since there's
|
1995-06-05 07:07:34 +04:00
|
|
|
* no real way we can know how the interrupt lines are mapped in the
|
|
|
|
* hardware).
|
1994-08-09 04:47:46 +04:00
|
|
|
*
|
|
|
|
* XXX
|
|
|
|
* Since IRQ 0 is only used by the clock, and we can't actually be sure
|
1994-09-06 05:25:22 +04:00
|
|
|
* that the BIOS did its job, we also recognize that as meaning that
|
|
|
|
* the BIOS has not configured the device.
|
1994-08-09 04:47:46 +04:00
|
|
|
*/
|
|
|
|
if (line == 0 || line == 255) {
|
1996-10-13 07:19:38 +04:00
|
|
|
printf("pci_intr_map: no mapping for pin %c\n", '@' + pin);
|
1996-03-27 09:49:54 +03:00
|
|
|
goto bad;
|
1994-08-09 04:47:46 +04:00
|
|
|
} else {
|
|
|
|
if (line >= ICU_LEN) {
|
1996-10-13 07:19:38 +04:00
|
|
|
printf("pci_intr_map: bad interrupt line %d\n", line);
|
1996-03-27 09:49:54 +03:00
|
|
|
goto bad;
|
1994-08-09 04:47:46 +04:00
|
|
|
}
|
|
|
|
if (line == 2) {
|
1996-10-13 07:19:38 +04:00
|
|
|
printf("pci_intr_map: changed line 2 to line 9\n");
|
1994-08-09 04:47:46 +04:00
|
|
|
line = 9;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) deprecate the pci_map_* functions, and provide them only
as compatibility interfaces (in pci_compat.c) which will
eventually go away, implemented as wrappers around
the functions described above.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
1996-03-27 07:01:10 +03:00
|
|
|
*ihp = line;
|
|
|
|
return 0;
|
1996-03-27 09:49:54 +03:00
|
|
|
|
|
|
|
bad:
|
|
|
|
*ihp = -1;
|
|
|
|
return 1;
|
modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) deprecate the pci_map_* functions, and provide them only
as compatibility interfaces (in pci_compat.c) which will
eventually go away, implemented as wrappers around
the functions described above.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
1996-03-27 07:01:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
pci_intr_string(pc, ih)
|
|
|
|
pci_chipset_tag_t pc;
|
|
|
|
pci_intr_handle_t ih;
|
|
|
|
{
|
|
|
|
static char irqstr[8]; /* 4 + 2 + NULL + sanity */
|
|
|
|
|
|
|
|
if (ih == 0 || ih >= ICU_LEN || ih == 2)
|
|
|
|
panic("pci_intr_string: bogus handle 0x%x\n", ih);
|
|
|
|
|
1996-10-13 07:19:38 +04:00
|
|
|
sprintf(irqstr, "irq %d", ih);
|
modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) deprecate the pci_map_* functions, and provide them only
as compatibility interfaces (in pci_compat.c) which will
eventually go away, implemented as wrappers around
the functions described above.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
1996-03-27 07:01:10 +03:00
|
|
|
return (irqstr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
|
|
|
pci_intr_establish(pc, ih, level, func, arg)
|
|
|
|
pci_chipset_tag_t pc;
|
|
|
|
pci_intr_handle_t ih;
|
|
|
|
int level, (*func) __P((void *));
|
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (ih == 0 || ih >= ICU_LEN || ih == 2)
|
|
|
|
panic("pci_intr_establish: bogus handle 0x%x\n", ih);
|
|
|
|
|
1996-04-12 02:15:08 +04:00
|
|
|
return isa_intr_establish(NULL, ih, IST_LEVEL, level, func, arg);
|
modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) deprecate the pci_map_* functions, and provide them only
as compatibility interfaces (in pci_compat.c) which will
eventually go away, implemented as wrappers around
the functions described above.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
1996-03-27 07:01:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pci_intr_disestablish(pc, cookie)
|
|
|
|
pci_chipset_tag_t pc;
|
|
|
|
void *cookie;
|
|
|
|
{
|
1994-08-09 04:47:46 +04:00
|
|
|
|
1996-04-12 02:15:08 +04:00
|
|
|
return isa_intr_disestablish(NULL, cookie);
|
1994-08-09 04:47:46 +04:00
|
|
|
}
|