Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1997, Stefan Esser <se@freebsd.org>
|
|
|
|
* 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 unmodified, 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 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.
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
*
|
|
|
|
*/
|
1994-09-01 01:45:19 +00:00
|
|
|
|
1999-04-16 21:22:55 +00:00
|
|
|
#include "opt_bus.h"
|
|
|
|
|
1998-06-07 17:13:14 +00:00
|
|
|
#include "opt_simos.h"
|
1998-01-24 02:54:56 +00:00
|
|
|
|
1994-09-14 01:34:51 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1994-10-12 02:33:23 +00:00
|
|
|
#include <sys/malloc.h>
|
1999-04-24 19:59:20 +00:00
|
|
|
#include <sys/module.h>
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
#include <sys/fcntl.h>
|
1996-10-22 20:20:14 +00:00
|
|
|
#include <sys/conf.h>
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
#include <sys/kernel.h>
|
1998-09-15 08:21:13 +00:00
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/buf.h>
|
1995-03-21 23:01:06 +00:00
|
|
|
|
1994-09-01 01:45:19 +00:00
|
|
|
#include <vm/vm.h>
|
1995-12-07 12:48:31 +00:00
|
|
|
#include <vm/pmap.h>
|
1998-09-15 08:21:13 +00:00
|
|
|
#include <vm/vm_extern.h>
|
1994-09-01 01:45:19 +00:00
|
|
|
|
1999-04-16 21:22:55 +00:00
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
#include <machine/resource.h>
|
1999-07-01 22:58:03 +00:00
|
|
|
#include <machine/md_var.h> /* For the Alpha */
|
1999-04-16 21:22:55 +00:00
|
|
|
|
1995-03-21 23:01:06 +00:00
|
|
|
#include <pci/pcireg.h>
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
#include <pci/pcivar.h>
|
1999-12-08 17:44:04 +00:00
|
|
|
#include <sys/pciio.h>
|
1995-03-21 23:01:06 +00:00
|
|
|
|
2000-03-15 23:50:31 +00:00
|
|
|
#ifdef __alpha__
|
|
|
|
#include <machine/rpb.h>
|
|
|
|
#endif
|
|
|
|
|
1997-06-25 20:56:29 +00:00
|
|
|
#ifdef APIC_IO
|
|
|
|
#include <machine/smp.h>
|
|
|
|
#endif /* APIC_IO */
|
|
|
|
|
1999-10-28 08:06:59 +00:00
|
|
|
struct pci_quirk {
|
|
|
|
u_int32_t devid; /* Vendor/device of the card */
|
|
|
|
int type;
|
|
|
|
#define PCI_QUIRK_MAP_REG 1 /* PCI map register in wierd place */
|
|
|
|
int arg1;
|
|
|
|
int arg2;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pci_quirk pci_quirks[] = {
|
|
|
|
/*
|
|
|
|
* The Intel 82371AB has a map register at offset 0x90.
|
|
|
|
*/
|
|
|
|
{ 0x71138086, PCI_QUIRK_MAP_REG, 0x90, 0 },
|
|
|
|
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
1999-10-14 21:38:33 +00:00
|
|
|
/* map register information */
|
|
|
|
#define PCI_MAPMEM 0x01 /* memory map */
|
|
|
|
#define PCI_MAPMEMP 0x02 /* prefetchable memory map */
|
|
|
|
#define PCI_MAPPORT 0x04 /* port map */
|
|
|
|
|
|
|
|
struct pci_devinfo {
|
|
|
|
STAILQ_ENTRY(pci_devinfo) pci_links;
|
|
|
|
struct resource_list resources;
|
|
|
|
pcicfgregs cfg;
|
|
|
|
struct pci_conf conf;
|
|
|
|
};
|
|
|
|
|
1999-04-11 02:50:42 +00:00
|
|
|
static STAILQ_HEAD(devlist, pci_devinfo) pci_devq;
|
1998-09-15 08:21:13 +00:00
|
|
|
u_int32_t pci_numdevs = 0;
|
1999-04-11 02:50:42 +00:00
|
|
|
static u_int32_t pci_generation = 0;
|
1998-09-15 08:21:13 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
/* return base address of memory or port map */
|
1994-10-12 02:33:23 +00:00
|
|
|
|
1999-10-14 21:38:33 +00:00
|
|
|
static u_int32_t
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
pci_mapbase(unsigned mapreg)
|
1995-03-21 23:01:06 +00:00
|
|
|
{
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
int mask = 0x03;
|
|
|
|
if ((mapreg & 0x01) == 0)
|
|
|
|
mask = 0x0f;
|
|
|
|
return (mapreg & ~mask);
|
1995-03-21 23:01:06 +00:00
|
|
|
}
|
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
/* return map type of memory or port map */
|
1996-04-14 20:14:36 +00:00
|
|
|
|
|
|
|
static int
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
pci_maptype(unsigned mapreg)
|
|
|
|
{
|
|
|
|
static u_int8_t maptype[0x10] = {
|
|
|
|
PCI_MAPMEM, PCI_MAPPORT,
|
|
|
|
PCI_MAPMEM, 0,
|
|
|
|
PCI_MAPMEM, PCI_MAPPORT,
|
|
|
|
0, 0,
|
|
|
|
PCI_MAPMEM|PCI_MAPMEMP, PCI_MAPPORT,
|
|
|
|
PCI_MAPMEM|PCI_MAPMEMP, 0,
|
|
|
|
PCI_MAPMEM|PCI_MAPMEMP, PCI_MAPPORT,
|
|
|
|
0, 0,
|
1997-01-21 23:23:40 +00:00
|
|
|
};
|
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
return maptype[mapreg & 0x0f];
|
1997-01-21 23:23:40 +00:00
|
|
|
}
|
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
/* return log2 of map size decoded for memory or port map */
|
1995-03-21 23:01:06 +00:00
|
|
|
|
1996-01-30 01:14:29 +00:00
|
|
|
static int
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
pci_mapsize(unsigned testval)
|
1996-01-30 01:14:29 +00:00
|
|
|
{
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
int ln2size;
|
1996-01-30 01:14:29 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
testval = pci_mapbase(testval);
|
1997-05-28 10:01:03 +00:00
|
|
|
ln2size = 0;
|
|
|
|
if (testval != 0) {
|
|
|
|
while ((testval & 1) == 0)
|
|
|
|
{
|
|
|
|
ln2size++;
|
|
|
|
testval >>= 1;
|
|
|
|
}
|
1995-09-07 15:20:53 +00:00
|
|
|
}
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
return (ln2size);
|
1995-03-21 23:01:06 +00:00
|
|
|
}
|
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
/* return log2 of address range supported by map register */
|
1995-03-21 23:01:06 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
static int
|
|
|
|
pci_maprange(unsigned mapreg)
|
|
|
|
{
|
|
|
|
int ln2range = 0;
|
|
|
|
switch (mapreg & 0x07) {
|
|
|
|
case 0x00:
|
|
|
|
case 0x01:
|
|
|
|
case 0x05:
|
|
|
|
ln2range = 32;
|
|
|
|
break;
|
|
|
|
case 0x02:
|
|
|
|
ln2range = 20;
|
|
|
|
break;
|
|
|
|
case 0x04:
|
|
|
|
ln2range = 64;
|
|
|
|
break;
|
1996-04-14 20:14:36 +00:00
|
|
|
}
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
return (ln2range);
|
1995-02-02 13:12:18 +00:00
|
|
|
}
|
1995-03-21 23:01:06 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
/* adjust some values from PCI 1.0 devices to match 2.0 standards ... */
|
1997-01-21 23:23:40 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
static void
|
|
|
|
pci_fixancient(pcicfgregs *cfg)
|
1997-01-21 23:23:40 +00:00
|
|
|
{
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
if (cfg->hdrtype != 0)
|
|
|
|
return;
|
1997-01-21 23:23:40 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
/* PCI to PCI bridges use header type 1 */
|
1998-08-13 19:12:20 +00:00
|
|
|
if (cfg->baseclass == PCIC_BRIDGE && cfg->subclass == PCIS_BRIDGE_PCI)
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
cfg->hdrtype = 1;
|
1997-01-21 23:23:40 +00:00
|
|
|
}
|
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
/* read config data specific to header type 1 device (PCI to PCI bridge) */
|
|
|
|
|
|
|
|
static void *
|
|
|
|
pci_readppb(pcicfgregs *cfg)
|
1994-09-01 01:45:19 +00:00
|
|
|
{
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
pcih1cfgregs *p;
|
1995-02-02 13:12:18 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
p = malloc(sizeof (pcih1cfgregs), M_DEVBUF, M_WAITOK);
|
|
|
|
if (p == NULL)
|
|
|
|
return (NULL);
|
1995-02-02 13:12:18 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
bzero(p, sizeof *p);
|
1995-02-02 13:12:18 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
p->secstat = pci_cfgread(cfg, PCIR_SECSTAT_1, 2);
|
|
|
|
p->bridgectl = pci_cfgread(cfg, PCIR_BRIDGECTL_1, 2);
|
1995-02-02 13:12:18 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
p->seclat = pci_cfgread(cfg, PCIR_SECLAT_1, 1);
|
1995-02-02 13:12:18 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
p->iobase = PCI_PPBIOBASE (pci_cfgread(cfg, PCIR_IOBASEH_1, 2),
|
|
|
|
pci_cfgread(cfg, PCIR_IOBASEL_1, 1));
|
|
|
|
p->iolimit = PCI_PPBIOLIMIT (pci_cfgread(cfg, PCIR_IOLIMITH_1, 2),
|
|
|
|
pci_cfgread(cfg, PCIR_IOLIMITL_1, 1));
|
1995-02-02 13:12:18 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
p->membase = PCI_PPBMEMBASE (0,
|
|
|
|
pci_cfgread(cfg, PCIR_MEMBASE_1, 2));
|
|
|
|
p->memlimit = PCI_PPBMEMLIMIT (0,
|
|
|
|
pci_cfgread(cfg, PCIR_MEMLIMIT_1, 2));
|
1995-02-02 13:12:18 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
p->pmembase = PCI_PPBMEMBASE (
|
|
|
|
(pci_addr_t)pci_cfgread(cfg, PCIR_PMBASEH_1, 4),
|
|
|
|
pci_cfgread(cfg, PCIR_PMBASEL_1, 2));
|
1995-02-02 13:12:18 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
p->pmemlimit = PCI_PPBMEMLIMIT (
|
|
|
|
(pci_addr_t)pci_cfgread(cfg, PCIR_PMLIMITH_1, 4),
|
|
|
|
pci_cfgread(cfg, PCIR_PMLIMITL_1, 2));
|
|
|
|
return (p);
|
1994-09-01 01:45:19 +00:00
|
|
|
}
|
1995-03-21 23:01:06 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
/* read config data specific to header type 2 device (PCI to CardBus bridge) */
|
1994-09-01 01:45:19 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
static void *
|
|
|
|
pci_readpcb(pcicfgregs *cfg)
|
|
|
|
{
|
|
|
|
pcih2cfgregs *p;
|
1995-02-22 14:17:15 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
p = malloc(sizeof (pcih2cfgregs), M_DEVBUF, M_WAITOK);
|
|
|
|
if (p == NULL)
|
|
|
|
return (NULL);
|
1994-09-16 00:33:29 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
bzero(p, sizeof *p);
|
1995-03-21 23:01:06 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
p->secstat = pci_cfgread(cfg, PCIR_SECSTAT_2, 2);
|
|
|
|
p->bridgectl = pci_cfgread(cfg, PCIR_BRIDGECTL_2, 2);
|
|
|
|
|
|
|
|
p->seclat = pci_cfgread(cfg, PCIR_SECLAT_2, 1);
|
1995-03-21 23:01:06 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
p->membase0 = pci_cfgread(cfg, PCIR_MEMBASE0_2, 4);
|
|
|
|
p->memlimit0 = pci_cfgread(cfg, PCIR_MEMLIMIT0_2, 4);
|
|
|
|
p->membase1 = pci_cfgread(cfg, PCIR_MEMBASE1_2, 4);
|
|
|
|
p->memlimit1 = pci_cfgread(cfg, PCIR_MEMLIMIT1_2, 4);
|
1994-09-01 01:45:19 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
p->iobase0 = pci_cfgread(cfg, PCIR_IOBASE0_2, 4);
|
|
|
|
p->iolimit0 = pci_cfgread(cfg, PCIR_IOLIMIT0_2, 4);
|
|
|
|
p->iobase1 = pci_cfgread(cfg, PCIR_IOBASE1_2, 4);
|
|
|
|
p->iolimit1 = pci_cfgread(cfg, PCIR_IOLIMIT1_2, 4);
|
1994-09-16 00:33:29 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
p->pccardif = pci_cfgread(cfg, PCIR_PCCARDIF_2, 4);
|
|
|
|
return p;
|
1994-09-01 01:45:19 +00:00
|
|
|
}
|
1995-02-27 17:17:14 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
/* extract header type specific config data */
|
1995-03-21 23:01:06 +00:00
|
|
|
|
|
|
|
static void
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
pci_hdrtypedata(pcicfgregs *cfg)
|
1995-03-21 23:01:06 +00:00
|
|
|
{
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
switch (cfg->hdrtype) {
|
|
|
|
case 0:
|
|
|
|
cfg->subvendor = pci_cfgread(cfg, PCIR_SUBVEND_0, 2);
|
|
|
|
cfg->subdevice = pci_cfgread(cfg, PCIR_SUBDEV_0, 2);
|
1999-10-14 21:38:33 +00:00
|
|
|
cfg->nummaps = PCI_MAXMAPS_0;
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
cfg->subvendor = pci_cfgread(cfg, PCIR_SUBVEND_1, 2);
|
|
|
|
cfg->subdevice = pci_cfgread(cfg, PCIR_SUBDEV_1, 2);
|
|
|
|
cfg->secondarybus = pci_cfgread(cfg, PCIR_SECBUS_1, 1);
|
|
|
|
cfg->subordinatebus = pci_cfgread(cfg, PCIR_SUBBUS_1, 1);
|
1999-10-14 21:38:33 +00:00
|
|
|
cfg->nummaps = PCI_MAXMAPS_1;
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
cfg->hdrspec = pci_readppb(cfg);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
cfg->subvendor = pci_cfgread(cfg, PCIR_SUBVEND_2, 2);
|
|
|
|
cfg->subdevice = pci_cfgread(cfg, PCIR_SUBDEV_2, 2);
|
|
|
|
cfg->secondarybus = pci_cfgread(cfg, PCIR_SECBUS_2, 1);
|
|
|
|
cfg->subordinatebus = pci_cfgread(cfg, PCIR_SUBBUS_2, 1);
|
1999-10-14 21:38:33 +00:00
|
|
|
cfg->nummaps = PCI_MAXMAPS_2;
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
cfg->hdrspec = pci_readpcb(cfg);
|
|
|
|
break;
|
1995-09-07 15:20:53 +00:00
|
|
|
}
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
}
|
1995-03-21 23:01:06 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
/* read configuration header into pcicfgrect structure */
|
|
|
|
|
1998-09-15 08:21:13 +00:00
|
|
|
static struct pci_devinfo *
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
pci_readcfg(pcicfgregs *probe)
|
|
|
|
{
|
|
|
|
pcicfgregs *cfg = NULL;
|
1998-09-15 08:21:13 +00:00
|
|
|
struct pci_devinfo *devlist_entry;
|
|
|
|
struct devlist *devlist_head;
|
|
|
|
|
|
|
|
devlist_head = &pci_devq;
|
|
|
|
|
|
|
|
devlist_entry = NULL;
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
|
|
|
|
if (pci_cfgread(probe, PCIR_DEVVENDOR, 4) != -1) {
|
1999-10-03 21:09:30 +00:00
|
|
|
|
1998-09-15 08:21:13 +00:00
|
|
|
devlist_entry = malloc(sizeof(struct pci_devinfo),
|
|
|
|
M_DEVBUF, M_WAITOK);
|
|
|
|
if (devlist_entry == NULL)
|
|
|
|
return (NULL);
|
1999-04-16 21:22:55 +00:00
|
|
|
bzero(devlist_entry, sizeof *devlist_entry);
|
1998-09-15 08:21:13 +00:00
|
|
|
|
|
|
|
cfg = &devlist_entry->cfg;
|
1999-05-20 15:33:33 +00:00
|
|
|
|
|
|
|
cfg->hose = probe->hose;
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
cfg->bus = probe->bus;
|
|
|
|
cfg->slot = probe->slot;
|
|
|
|
cfg->func = probe->func;
|
|
|
|
cfg->vendor = pci_cfgread(cfg, PCIR_VENDOR, 2);
|
|
|
|
cfg->device = pci_cfgread(cfg, PCIR_DEVICE, 2);
|
|
|
|
cfg->cmdreg = pci_cfgread(cfg, PCIR_COMMAND, 2);
|
|
|
|
cfg->statreg = pci_cfgread(cfg, PCIR_STATUS, 2);
|
1998-08-13 19:12:20 +00:00
|
|
|
cfg->baseclass = pci_cfgread(cfg, PCIR_CLASS, 1);
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
cfg->subclass = pci_cfgread(cfg, PCIR_SUBCLASS, 1);
|
|
|
|
cfg->progif = pci_cfgread(cfg, PCIR_PROGIF, 1);
|
|
|
|
cfg->revid = pci_cfgread(cfg, PCIR_REVID, 1);
|
|
|
|
cfg->hdrtype = pci_cfgread(cfg, PCIR_HEADERTYPE, 1);
|
|
|
|
cfg->cachelnsz = pci_cfgread(cfg, PCIR_CACHELNSZ, 1);
|
|
|
|
cfg->lattimer = pci_cfgread(cfg, PCIR_LATTIMER, 1);
|
|
|
|
cfg->intpin = pci_cfgread(cfg, PCIR_INTPIN, 1);
|
|
|
|
cfg->intline = pci_cfgread(cfg, PCIR_INTLINE, 1);
|
1998-07-22 08:40:46 +00:00
|
|
|
#ifdef __alpha__
|
|
|
|
alpha_platform_assign_pciintr(cfg);
|
|
|
|
#endif
|
1997-05-27 04:09:01 +00:00
|
|
|
|
|
|
|
#ifdef APIC_IO
|
1997-05-27 19:24:36 +00:00
|
|
|
if (cfg->intpin != 0) {
|
|
|
|
int airq;
|
1997-05-27 04:09:01 +00:00
|
|
|
|
1998-09-06 22:41:42 +00:00
|
|
|
airq = pci_apic_irq(cfg->bus, cfg->slot, cfg->intpin);
|
1998-04-01 21:07:37 +00:00
|
|
|
if (airq >= 0) {
|
|
|
|
/* PCI specific entry found in MP table */
|
|
|
|
if (airq != cfg->intline) {
|
|
|
|
undirect_pci_irq(cfg->intline);
|
|
|
|
cfg->intline = airq;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* PCI interrupts might be redirected to the
|
|
|
|
* ISA bus according to some MP tables. Use the
|
|
|
|
* same methods as used by the ISA devices
|
|
|
|
* devices to find the proper IOAPIC int pin.
|
|
|
|
*/
|
1998-09-06 22:41:42 +00:00
|
|
|
airq = isa_apic_irq(cfg->intline);
|
1998-04-01 21:07:37 +00:00
|
|
|
if ((airq >= 0) && (airq != cfg->intline)) {
|
|
|
|
/* XXX: undirect_pci_irq() ? */
|
|
|
|
undirect_isa_irq(cfg->intline);
|
|
|
|
cfg->intline = airq;
|
|
|
|
}
|
1997-05-27 04:09:01 +00:00
|
|
|
}
|
|
|
|
}
|
1997-06-25 20:56:29 +00:00
|
|
|
#endif /* APIC_IO */
|
1997-05-27 04:09:01 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
cfg->mingnt = pci_cfgread(cfg, PCIR_MINGNT, 1);
|
|
|
|
cfg->maxlat = pci_cfgread(cfg, PCIR_MAXLAT, 1);
|
|
|
|
|
|
|
|
cfg->mfdev = (cfg->hdrtype & PCIM_MFDEV) != 0;
|
|
|
|
cfg->hdrtype &= ~PCIM_MFDEV;
|
|
|
|
|
|
|
|
pci_fixancient(cfg);
|
|
|
|
pci_hdrtypedata(cfg);
|
1998-09-15 08:21:13 +00:00
|
|
|
|
|
|
|
STAILQ_INSERT_TAIL(devlist_head, devlist_entry, pci_links);
|
|
|
|
|
|
|
|
devlist_entry->conf.pc_sel.pc_bus = cfg->bus;
|
|
|
|
devlist_entry->conf.pc_sel.pc_dev = cfg->slot;
|
|
|
|
devlist_entry->conf.pc_sel.pc_func = cfg->func;
|
|
|
|
devlist_entry->conf.pc_hdr = cfg->hdrtype;
|
|
|
|
|
|
|
|
devlist_entry->conf.pc_subvendor = cfg->subvendor;
|
|
|
|
devlist_entry->conf.pc_subdevice = cfg->subdevice;
|
|
|
|
devlist_entry->conf.pc_vendor = cfg->vendor;
|
|
|
|
devlist_entry->conf.pc_device = cfg->device;
|
|
|
|
|
|
|
|
devlist_entry->conf.pc_class = cfg->baseclass;
|
|
|
|
devlist_entry->conf.pc_subclass = cfg->subclass;
|
|
|
|
devlist_entry->conf.pc_progif = cfg->progif;
|
|
|
|
devlist_entry->conf.pc_revid = cfg->revid;
|
|
|
|
|
|
|
|
pci_numdevs++;
|
|
|
|
pci_generation++;
|
1995-09-07 15:20:53 +00:00
|
|
|
}
|
1998-09-15 08:21:13 +00:00
|
|
|
return (devlist_entry);
|
1995-03-21 23:01:06 +00:00
|
|
|
}
|
|
|
|
|
1997-11-07 08:53:44 +00:00
|
|
|
#if 0
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
/* free pcicfgregs structure and all depending data structures */
|
1995-03-21 23:01:06 +00:00
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
static int
|
1998-09-15 08:21:13 +00:00
|
|
|
pci_freecfg(struct pci_devinfo *dinfo)
|
1995-03-21 23:01:06 +00:00
|
|
|
{
|
1998-09-15 08:21:13 +00:00
|
|
|
struct devlist *devlist_head;
|
|
|
|
|
|
|
|
devlist_head = &pci_devq;
|
|
|
|
|
|
|
|
if (dinfo->cfg.hdrspec != NULL)
|
|
|
|
free(dinfo->cfg.hdrspec, M_DEVBUF);
|
|
|
|
if (dinfo->cfg.map != NULL)
|
|
|
|
free(dinfo->cfg.map, M_DEVBUF);
|
|
|
|
/* XXX this hasn't been tested */
|
|
|
|
STAILQ_REMOVE(devlist_head, dinfo, pci_devinfo, pci_links);
|
|
|
|
free(dinfo, M_DEVBUF);
|
|
|
|
|
|
|
|
/* increment the generation count */
|
|
|
|
pci_generation++;
|
|
|
|
|
|
|
|
/* we're losing one device */
|
|
|
|
pci_numdevs--;
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
return (0);
|
1995-03-21 23:01:06 +00:00
|
|
|
}
|
1997-11-07 08:53:44 +00:00
|
|
|
#endif
|
1995-03-21 23:01:06 +00:00
|
|
|
|
1999-05-20 15:33:33 +00:00
|
|
|
|
1996-10-22 20:20:14 +00:00
|
|
|
/*
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
* This is the user interface to PCI configuration space.
|
1996-10-22 20:20:14 +00:00
|
|
|
*/
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
|
1996-10-22 20:20:14 +00:00
|
|
|
static int
|
|
|
|
pci_open(dev_t dev, int oflags, int devtype, struct proc *p)
|
|
|
|
{
|
|
|
|
if ((oflags & FWRITE) && securelevel > 0) {
|
|
|
|
return EPERM;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pci_close(dev_t dev, int flag, int devtype, struct proc *p)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-09-15 08:21:13 +00:00
|
|
|
/*
|
|
|
|
* Match a single pci_conf structure against an array of pci_match_conf
|
|
|
|
* structures. The first argument, 'matches', is an array of num_matches
|
|
|
|
* pci_match_conf structures. match_buf is a pointer to the pci_conf
|
|
|
|
* structure that will be compared to every entry in the matches array.
|
|
|
|
* This function returns 1 on failure, 0 on success.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
pci_conf_match(struct pci_match_conf *matches, int num_matches,
|
|
|
|
struct pci_conf *match_buf)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if ((matches == NULL) || (match_buf == NULL) || (num_matches <= 0))
|
|
|
|
return(1);
|
|
|
|
|
|
|
|
for (i = 0; i < num_matches; i++) {
|
|
|
|
/*
|
|
|
|
* I'm not sure why someone would do this...but...
|
|
|
|
*/
|
|
|
|
if (matches[i].flags == PCI_GETCONF_NO_MATCH)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look at each of the match flags. If it's set, do the
|
|
|
|
* comparison. If the comparison fails, we don't have a
|
|
|
|
* match, go on to the next item if there is one.
|
|
|
|
*/
|
|
|
|
if (((matches[i].flags & PCI_GETCONF_MATCH_BUS) != 0)
|
|
|
|
&& (match_buf->pc_sel.pc_bus != matches[i].pc_sel.pc_bus))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (((matches[i].flags & PCI_GETCONF_MATCH_DEV) != 0)
|
|
|
|
&& (match_buf->pc_sel.pc_dev != matches[i].pc_sel.pc_dev))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (((matches[i].flags & PCI_GETCONF_MATCH_FUNC) != 0)
|
|
|
|
&& (match_buf->pc_sel.pc_func != matches[i].pc_sel.pc_func))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (((matches[i].flags & PCI_GETCONF_MATCH_VENDOR) != 0)
|
|
|
|
&& (match_buf->pc_vendor != matches[i].pc_vendor))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (((matches[i].flags & PCI_GETCONF_MATCH_DEVICE) != 0)
|
|
|
|
&& (match_buf->pc_device != matches[i].pc_device))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (((matches[i].flags & PCI_GETCONF_MATCH_CLASS) != 0)
|
|
|
|
&& (match_buf->pc_class != matches[i].pc_class))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (((matches[i].flags & PCI_GETCONF_MATCH_UNIT) != 0)
|
|
|
|
&& (match_buf->pd_unit != matches[i].pd_unit))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (((matches[i].flags & PCI_GETCONF_MATCH_NAME) != 0)
|
|
|
|
&& (strncmp(matches[i].pd_name, match_buf->pd_name,
|
|
|
|
sizeof(match_buf->pd_name)) != 0))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
1999-05-31 22:13:37 +00:00
|
|
|
/*
|
|
|
|
* Locate the parent of a PCI device by scanning the PCI devlist
|
|
|
|
* and return the entry for the parent.
|
|
|
|
* For devices on PCI Bus 0 (the host bus), this is the PCI Host.
|
|
|
|
* For devices on secondary PCI busses, this is that bus' PCI-PCI Bridge.
|
|
|
|
*/
|
|
|
|
|
|
|
|
pcicfgregs *
|
|
|
|
pci_devlist_get_parent(pcicfgregs *cfg)
|
|
|
|
{
|
|
|
|
struct devlist *devlist_head;
|
|
|
|
struct pci_devinfo *dinfo;
|
|
|
|
pcicfgregs *bridge_cfg;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
dinfo = STAILQ_FIRST(devlist_head = &pci_devq);
|
|
|
|
|
|
|
|
/* If the device is on PCI bus 0, look for the host */
|
|
|
|
if (cfg->bus == 0) {
|
|
|
|
for (i = 0; (dinfo != NULL) && (i < pci_numdevs);
|
|
|
|
dinfo = STAILQ_NEXT(dinfo, pci_links), i++) {
|
|
|
|
bridge_cfg = &dinfo->cfg;
|
|
|
|
if (bridge_cfg->baseclass == PCIC_BRIDGE
|
|
|
|
&& bridge_cfg->subclass == PCIS_BRIDGE_HOST
|
|
|
|
&& bridge_cfg->bus == cfg->bus) {
|
|
|
|
return bridge_cfg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the device is not on PCI bus 0, look for the PCI-PCI bridge */
|
|
|
|
if (cfg->bus > 0) {
|
|
|
|
for (i = 0; (dinfo != NULL) && (i < pci_numdevs);
|
|
|
|
dinfo = STAILQ_NEXT(dinfo, pci_links), i++) {
|
|
|
|
bridge_cfg = &dinfo->cfg;
|
|
|
|
if (bridge_cfg->baseclass == PCIC_BRIDGE
|
|
|
|
&& bridge_cfg->subclass == PCIS_BRIDGE_PCI
|
|
|
|
&& bridge_cfg->secondarybus == cfg->bus) {
|
|
|
|
return bridge_cfg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1996-10-22 20:20:14 +00:00
|
|
|
static int
|
1998-06-07 17:13:14 +00:00
|
|
|
pci_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
|
1996-10-22 20:20:14 +00:00
|
|
|
{
|
|
|
|
struct pci_io *io;
|
1999-05-09 20:27:26 +00:00
|
|
|
const char *name;
|
1996-10-22 20:20:14 +00:00
|
|
|
int error;
|
|
|
|
|
1998-09-15 08:21:13 +00:00
|
|
|
if (!(flag & FWRITE))
|
1996-10-22 20:20:14 +00:00
|
|
|
return EPERM;
|
|
|
|
|
1998-09-15 08:21:13 +00:00
|
|
|
|
1996-10-22 20:20:14 +00:00
|
|
|
switch(cmd) {
|
|
|
|
case PCIOCGETCONF:
|
1998-09-15 08:21:13 +00:00
|
|
|
{
|
|
|
|
struct pci_devinfo *dinfo;
|
|
|
|
struct pci_conf_io *cio;
|
|
|
|
struct devlist *devlist_head;
|
|
|
|
struct pci_match_conf *pattern_buf;
|
|
|
|
int num_patterns;
|
|
|
|
size_t iolen;
|
|
|
|
int ionum, i;
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
|
1996-10-22 20:20:14 +00:00
|
|
|
cio = (struct pci_conf_io *)data;
|
|
|
|
|
1998-09-15 08:21:13 +00:00
|
|
|
num_patterns = 0;
|
|
|
|
dinfo = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hopefully the user won't pass in a null pointer, but it
|
|
|
|
* can't hurt to check.
|
|
|
|
*/
|
|
|
|
if (cio == NULL) {
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the user specified an offset into the device list,
|
|
|
|
* but the list has changed since they last called this
|
|
|
|
* ioctl, tell them that the list has changed. They will
|
|
|
|
* have to get the list from the beginning.
|
|
|
|
*/
|
|
|
|
if ((cio->offset != 0)
|
|
|
|
&& (cio->generation != pci_generation)){
|
|
|
|
cio->num_matches = 0;
|
|
|
|
cio->status = PCI_GETCONF_LIST_CHANGED;
|
|
|
|
error = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check to see whether the user has asked for an offset
|
|
|
|
* past the end of our list.
|
|
|
|
*/
|
|
|
|
if (cio->offset >= pci_numdevs) {
|
|
|
|
cio->num_matches = 0;
|
|
|
|
cio->status = PCI_GETCONF_LAST_DEVICE;
|
|
|
|
error = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get the head of the device queue */
|
|
|
|
devlist_head = &pci_devq;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine how much room we have for pci_conf structures.
|
|
|
|
* Round the user's buffer size down to the nearest
|
|
|
|
* multiple of sizeof(struct pci_conf) in case the user
|
|
|
|
* didn't specify a multiple of that size.
|
|
|
|
*/
|
|
|
|
iolen = min(cio->match_buf_len -
|
|
|
|
(cio->match_buf_len % sizeof(struct pci_conf)),
|
|
|
|
pci_numdevs * sizeof(struct pci_conf));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since we know that iolen is a multiple of the size of
|
|
|
|
* the pciconf union, it's okay to do this.
|
|
|
|
*/
|
|
|
|
ionum = iolen / sizeof(struct pci_conf);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this test is true, the user wants the pci_conf
|
|
|
|
* structures returned to match the supplied entries.
|
|
|
|
*/
|
|
|
|
if ((cio->num_patterns > 0)
|
|
|
|
&& (cio->pat_buf_len > 0)) {
|
|
|
|
/*
|
|
|
|
* pat_buf_len needs to be:
|
|
|
|
* num_patterns * sizeof(struct pci_match_conf)
|
|
|
|
* While it is certainly possible the user just
|
|
|
|
* allocated a large buffer, but set the number of
|
|
|
|
* matches correctly, it is far more likely that
|
|
|
|
* their kernel doesn't match the userland utility
|
|
|
|
* they're using. It's also possible that the user
|
|
|
|
* forgot to initialize some variables. Yes, this
|
|
|
|
* may be overly picky, but I hazard to guess that
|
|
|
|
* it's far more likely to just catch folks that
|
|
|
|
* updated their kernel but not their userland.
|
|
|
|
*/
|
|
|
|
if ((cio->num_patterns *
|
|
|
|
sizeof(struct pci_match_conf)) != cio->pat_buf_len){
|
|
|
|
/* The user made a mistake, return an error*/
|
|
|
|
cio->status = PCI_GETCONF_ERROR;
|
|
|
|
printf("pci_ioctl: pat_buf_len %d != "
|
|
|
|
"num_patterns (%d) * sizeof(struct "
|
|
|
|
"pci_match_conf) (%d)\npci_ioctl: "
|
|
|
|
"pat_buf_len should be = %d\n",
|
|
|
|
cio->pat_buf_len, cio->num_patterns,
|
1999-04-16 21:22:55 +00:00
|
|
|
(int)sizeof(struct pci_match_conf),
|
|
|
|
(int)sizeof(struct pci_match_conf) *
|
1998-09-15 08:21:13 +00:00
|
|
|
cio->num_patterns);
|
|
|
|
printf("pci_ioctl: do your headers match your "
|
|
|
|
"kernel?\n");
|
|
|
|
cio->num_matches = 0;
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check the user's buffer to make sure it's readable.
|
|
|
|
*/
|
1999-10-29 19:03:18 +00:00
|
|
|
if (!useracc((caddr_t)cio->patterns,
|
1999-10-30 06:32:05 +00:00
|
|
|
cio->pat_buf_len, VM_PROT_READ)) {
|
1998-11-09 08:08:06 +00:00
|
|
|
printf("pci_ioctl: pattern buffer %p, "
|
1998-09-15 08:21:13 +00:00
|
|
|
"length %u isn't user accessible for"
|
1998-09-16 08:28:11 +00:00
|
|
|
" READ\n", cio->patterns,
|
1998-09-15 08:21:13 +00:00
|
|
|
cio->pat_buf_len);
|
|
|
|
error = EACCES;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Allocate a buffer to hold the patterns.
|
|
|
|
*/
|
|
|
|
pattern_buf = malloc(cio->pat_buf_len, M_TEMP,
|
|
|
|
M_WAITOK);
|
|
|
|
error = copyin(cio->patterns, pattern_buf,
|
|
|
|
cio->pat_buf_len);
|
|
|
|
if (error != 0)
|
|
|
|
break;
|
|
|
|
num_patterns = cio->num_patterns;
|
|
|
|
|
|
|
|
} else if ((cio->num_patterns > 0)
|
|
|
|
|| (cio->pat_buf_len > 0)) {
|
|
|
|
/*
|
|
|
|
* The user made a mistake, spit out an error.
|
|
|
|
*/
|
|
|
|
cio->status = PCI_GETCONF_ERROR;
|
|
|
|
cio->num_matches = 0;
|
|
|
|
printf("pci_ioctl: invalid GETCONF arguments\n");
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
pattern_buf = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure we can write to the match buffer.
|
|
|
|
*/
|
1999-10-29 19:03:18 +00:00
|
|
|
if (!useracc((caddr_t)cio->matches,
|
1999-10-30 06:32:05 +00:00
|
|
|
cio->match_buf_len, VM_PROT_WRITE)) {
|
1998-11-09 08:08:06 +00:00
|
|
|
printf("pci_ioctl: match buffer %p, length %u "
|
1998-09-15 08:21:13 +00:00
|
|
|
"isn't user accessible for WRITE\n",
|
1998-09-16 08:28:11 +00:00
|
|
|
cio->matches, cio->match_buf_len);
|
1998-09-15 08:21:13 +00:00
|
|
|
error = EACCES;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Go through the list of devices and copy out the devices
|
|
|
|
* that match the user's criteria.
|
|
|
|
*/
|
|
|
|
for (cio->num_matches = 0, error = 0, i = 0,
|
|
|
|
dinfo = STAILQ_FIRST(devlist_head);
|
|
|
|
(dinfo != NULL) && (cio->num_matches < ionum)
|
|
|
|
&& (error == 0) && (i < pci_numdevs);
|
|
|
|
dinfo = STAILQ_NEXT(dinfo, pci_links), i++) {
|
|
|
|
|
|
|
|
if (i < cio->offset)
|
|
|
|
continue;
|
|
|
|
|
1999-05-09 20:27:26 +00:00
|
|
|
/* Populate pd_name and pd_unit */
|
|
|
|
name = NULL;
|
|
|
|
if (dinfo->cfg.dev && dinfo->conf.pd_name[0] == '\0')
|
|
|
|
name = device_get_name(dinfo->cfg.dev);
|
|
|
|
if (name) {
|
|
|
|
strncpy(dinfo->conf.pd_name, name,
|
|
|
|
sizeof(dinfo->conf.pd_name));
|
|
|
|
dinfo->conf.pd_name[PCI_MAXNAMELEN] = 0;
|
|
|
|
dinfo->conf.pd_unit =
|
|
|
|
device_get_unit(dinfo->cfg.dev);
|
|
|
|
}
|
|
|
|
|
1998-09-15 08:21:13 +00:00
|
|
|
if ((pattern_buf == NULL) ||
|
|
|
|
(pci_conf_match(pattern_buf, num_patterns,
|
|
|
|
&dinfo->conf) == 0)) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we've filled up the user's buffer,
|
|
|
|
* break out at this point. Since we've
|
|
|
|
* got a match here, we'll pick right back
|
|
|
|
* up at the matching entry. We can also
|
|
|
|
* tell the user that there are more matches
|
|
|
|
* left.
|
|
|
|
*/
|
|
|
|
if (cio->num_matches >= ionum)
|
|
|
|
break;
|
|
|
|
|
|
|
|
error = copyout(&dinfo->conf,
|
|
|
|
&cio->matches[cio->num_matches],
|
|
|
|
sizeof(struct pci_conf));
|
|
|
|
cio->num_matches++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the pointer into the list, so if the user is getting
|
|
|
|
* n records at a time, where n < pci_numdevs,
|
|
|
|
*/
|
|
|
|
cio->offset = i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the generation, the user will need this if they make
|
|
|
|
* another ioctl call with offset != 0.
|
|
|
|
*/
|
|
|
|
cio->generation = pci_generation;
|
1996-10-22 20:20:14 +00:00
|
|
|
|
1998-09-15 08:21:13 +00:00
|
|
|
/*
|
|
|
|
* If this is the last device, inform the user so he won't
|
|
|
|
* bother asking for more devices. If dinfo isn't NULL, we
|
|
|
|
* know that there are more matches in the list because of
|
|
|
|
* the way the traversal is done.
|
|
|
|
*/
|
|
|
|
if (dinfo == NULL)
|
|
|
|
cio->status = PCI_GETCONF_LAST_DEVICE;
|
|
|
|
else
|
|
|
|
cio->status = PCI_GETCONF_MORE_DEVS;
|
|
|
|
|
|
|
|
if (pattern_buf != NULL)
|
|
|
|
free(pattern_buf, M_TEMP);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
1996-10-22 20:20:14 +00:00
|
|
|
case PCIOCREAD:
|
|
|
|
io = (struct pci_io *)data;
|
|
|
|
switch(io->pi_width) {
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
pcicfgregs probe;
|
1996-10-22 20:20:14 +00:00
|
|
|
case 4:
|
|
|
|
case 2:
|
|
|
|
case 1:
|
1999-10-12 22:10:53 +00:00
|
|
|
probe.hose = -1;
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
probe.bus = io->pi_sel.pc_bus;
|
|
|
|
probe.slot = io->pi_sel.pc_dev;
|
|
|
|
probe.func = io->pi_sel.pc_func;
|
|
|
|
io->pi_data = pci_cfgread(&probe,
|
|
|
|
io->pi_reg, io->pi_width);
|
1996-10-22 20:20:14 +00:00
|
|
|
error = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = ENODEV;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
case PCIOCWRITE:
|
1997-01-21 23:23:40 +00:00
|
|
|
io = (struct pci_io *)data;
|
|
|
|
switch(io->pi_width) {
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
pcicfgregs probe;
|
1997-01-21 23:23:40 +00:00
|
|
|
case 4:
|
|
|
|
case 2:
|
|
|
|
case 1:
|
1999-10-12 22:10:53 +00:00
|
|
|
probe.hose = -1;
|
Completely replace the PCI bus driver code to make it better reflect
reality. There will be a new call interface, but for now the file
pci_compat.c (which is to be deleted, after all drivers are converted)
provides an emulation of the old PCI bus driver functions. The only
change that might be visible to drivers is, that the type pcici_t
(which had been meant to be just a handle, whose exact definition
should not be relied on), has been converted into a pcicfgregs* .
The Tekram AMD SCSI driver bogusly relied on the definition of pcici_t
and has been converted to just call the PCI drivers functions to access
configuration space register, instead of inventing its own ...
This code is by no means complete, but assumed to be fully operational,
and brings the official code base more in line with my development code.
A new generic device descriptor data type has to be agreed on. The PCI
code will then use that data type to provide new functionality:
1) userconfig support
2) "wired" PCI devices
3) conflicts checking against ISA/EISA
4) maps will depend on the command register enable bits
5) PCI to Anything bridges can be defined as devices,
and are probed like any "standard" PCI device.
The following features are currently missing, but will be added back,
soon:
1) unknown device probe message
2) suppression of "mirrored" devices caused by ancient, broken chip-sets
This code relies on generic shared interrupt support just commited to
kern_intr.c (plus the modifications of isa.c and isa_device.h).
1997-05-26 15:08:43 +00:00
|
|
|
probe.bus = io->pi_sel.pc_bus;
|
|
|
|
probe.slot = io->pi_sel.pc_dev;
|
|
|
|
probe.func = io->pi_sel.pc_func;
|
|
|
|
pci_cfgwrite(&probe,
|
|
|
|
io->pi_reg, io->pi_data, io->pi_width);
|
|
|
|
error = 0;
|
|
|
|
break;
|
1997-01-21 23:23:40 +00:00
|
|
|
default:
|
|
|
|
error = ENODEV;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1996-10-22 20:20:14 +00:00
|
|
|
default:
|
|
|
|
error = ENOTTY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PCI_CDEV 78
|
|
|
|
|
|
|
|
static struct cdevsw pcicdev = {
|
1999-05-30 16:53:49 +00:00
|
|
|
/* open */ pci_open,
|
|
|
|
/* close */ pci_close,
|
|
|
|
/* read */ noread,
|
|
|
|
/* write */ nowrite,
|
|
|
|
/* ioctl */ pci_ioctl,
|
|
|
|
/* poll */ nopoll,
|
|
|
|
/* mmap */ nommap,
|
|
|
|
/* strategy */ nostrategy,
|
|
|
|
/* name */ "pci",
|
|
|
|
/* maj */ PCI_CDEV,
|
|
|
|
/* dump */ nodump,
|
|
|
|
/* psize */ nopsize,
|
|
|
|
/* flags */ 0,
|
|
|
|
/* bmaj */ -1
|
1996-10-22 20:20:14 +00:00
|
|
|
};
|
|
|
|
|
1999-04-16 21:22:55 +00:00
|
|
|
#include "pci_if.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A simple driver to wrap the old pci driver mechanism for back-compat.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
|
|
|
pci_compat_probe(device_t dev)
|
|
|
|
{
|
|
|
|
struct pci_device *dvp;
|
|
|
|
struct pci_devinfo *dinfo;
|
|
|
|
pcicfgregs *cfg;
|
|
|
|
const char *name;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
dinfo = device_get_ivars(dev);
|
|
|
|
cfg = &dinfo->cfg;
|
|
|
|
dvp = device_get_driver(dev)->priv;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do the wrapped probe.
|
|
|
|
*/
|
|
|
|
error = ENXIO;
|
|
|
|
if (dvp && dvp->pd_probe) {
|
|
|
|
name = dvp->pd_probe(cfg, (cfg->device << 16) + cfg->vendor);
|
|
|
|
if (name) {
|
|
|
|
device_set_desc_copy(dev, name);
|
1999-11-30 01:34:46 +00:00
|
|
|
/* Allow newbus drivers to match "better" */
|
1999-12-05 18:50:22 +00:00
|
|
|
error = -200;
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pci_compat_attach(device_t dev)
|
|
|
|
{
|
|
|
|
struct pci_device *dvp;
|
|
|
|
struct pci_devinfo *dinfo;
|
|
|
|
pcicfgregs *cfg;
|
|
|
|
int unit;
|
|
|
|
|
|
|
|
dinfo = device_get_ivars(dev);
|
|
|
|
cfg = &dinfo->cfg;
|
|
|
|
dvp = device_get_driver(dev)->priv;
|
|
|
|
|
|
|
|
unit = device_get_unit(dev);
|
|
|
|
if (unit > *dvp->pd_count)
|
|
|
|
*dvp->pd_count = unit;
|
|
|
|
if (dvp->pd_attach)
|
|
|
|
dvp->pd_attach(cfg, unit);
|
2000-01-29 15:37:36 +00:00
|
|
|
device_printf(dev, "driver is using old-style compatability shims\n");
|
1999-04-16 21:22:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static device_method_t pci_compat_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, pci_compat_probe),
|
|
|
|
DEVMETHOD(device_attach, pci_compat_attach),
|
|
|
|
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static devclass_t pci_devclass;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a new style driver around each old pci driver.
|
|
|
|
*/
|
1999-04-24 19:59:20 +00:00
|
|
|
int
|
1999-05-06 22:05:39 +00:00
|
|
|
compat_pci_handler(module_t mod, int type, void *data)
|
1999-04-16 21:22:55 +00:00
|
|
|
{
|
1999-04-24 19:59:20 +00:00
|
|
|
struct pci_device *dvp = (struct pci_device *)data;
|
|
|
|
driver_t *driver;
|
1999-04-16 21:22:55 +00:00
|
|
|
|
1999-04-24 19:59:20 +00:00
|
|
|
switch (type) {
|
|
|
|
case MOD_LOAD:
|
1999-04-16 21:22:55 +00:00
|
|
|
driver = malloc(sizeof(driver_t), M_DEVBUF, M_NOWAIT);
|
|
|
|
if (!driver)
|
1999-04-24 19:59:20 +00:00
|
|
|
return ENOMEM;
|
1999-04-16 21:22:55 +00:00
|
|
|
bzero(driver, sizeof(driver_t));
|
|
|
|
driver->name = dvp->pd_name;
|
|
|
|
driver->methods = pci_compat_methods;
|
|
|
|
driver->softc = sizeof(struct pci_devinfo *);
|
|
|
|
driver->priv = dvp;
|
|
|
|
devclass_add_driver(pci_devclass, driver);
|
1999-04-24 19:59:20 +00:00
|
|
|
break;
|
|
|
|
case MOD_UNLOAD:
|
1999-05-06 22:05:39 +00:00
|
|
|
printf("%s: module unload not supported!\n", dvp->pd_name);
|
1999-04-24 19:59:20 +00:00
|
|
|
return EOPNOTSUPP;
|
|
|
|
default:
|
|
|
|
break;
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
1999-04-24 19:59:20 +00:00
|
|
|
return 0;
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* New style pci driver. Parent device is either a pci-host-bridge or a
|
|
|
|
* pci-pci-bridge. Both kinds are represented by instances of pcib.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
pci_print_verbose(struct pci_devinfo *dinfo)
|
|
|
|
{
|
|
|
|
if (bootverbose) {
|
|
|
|
pcicfgregs *cfg = &dinfo->cfg;
|
|
|
|
|
|
|
|
printf("found->\tvendor=0x%04x, dev=0x%04x, revid=0x%02x\n",
|
|
|
|
cfg->vendor, cfg->device, cfg->revid);
|
|
|
|
printf("\tclass=%02x-%02x-%02x, hdrtype=0x%02x, mfdev=%d\n",
|
|
|
|
cfg->baseclass, cfg->subclass, cfg->progif,
|
|
|
|
cfg->hdrtype, cfg->mfdev);
|
|
|
|
printf("\tsubordinatebus=%x \tsecondarybus=%x\n",
|
|
|
|
cfg->subordinatebus, cfg->secondarybus);
|
|
|
|
#ifdef PCI_DEBUG
|
|
|
|
printf("\tcmdreg=0x%04x, statreg=0x%04x, cachelnsz=%d (dwords)\n",
|
|
|
|
cfg->cmdreg, cfg->statreg, cfg->cachelnsz);
|
|
|
|
printf("\tlattimer=0x%02x (%d ns), mingnt=0x%02x (%d ns), maxlat=0x%02x (%d ns)\n",
|
|
|
|
cfg->lattimer, cfg->lattimer * 30,
|
|
|
|
cfg->mingnt, cfg->mingnt * 250, cfg->maxlat, cfg->maxlat * 250);
|
|
|
|
#endif /* PCI_DEBUG */
|
|
|
|
if (cfg->intpin > 0)
|
|
|
|
printf("\tintpin=%c, irq=%d\n", cfg->intpin +'a' -1, cfg->intline);
|
1999-10-14 21:38:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pci_porten(pcicfgregs *cfg)
|
|
|
|
{
|
|
|
|
return ((cfg->cmdreg & PCIM_CMD_PORTEN) != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pci_memen(pcicfgregs *cfg)
|
|
|
|
{
|
|
|
|
return ((cfg->cmdreg & PCIM_CMD_MEMEN) != 0);
|
|
|
|
}
|
|
|
|
|
1999-10-28 08:06:59 +00:00
|
|
|
/*
|
|
|
|
* Add a resource based on a pci map register. Return 1 if the map
|
|
|
|
* register is a 32bit map register or 2 if it is a 64bit register.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
pci_add_map(device_t dev, pcicfgregs* cfg, int reg)
|
1999-10-14 21:38:33 +00:00
|
|
|
{
|
|
|
|
struct pci_devinfo *dinfo = device_get_ivars(dev);
|
|
|
|
struct resource_list *rl = &dinfo->resources;
|
1999-10-28 08:06:59 +00:00
|
|
|
u_int32_t map;
|
|
|
|
u_int64_t base;
|
|
|
|
u_int8_t ln2size;
|
|
|
|
u_int8_t ln2range;
|
|
|
|
u_int32_t testval;
|
1999-10-14 21:38:33 +00:00
|
|
|
|
1999-10-28 08:06:59 +00:00
|
|
|
int type;
|
|
|
|
|
|
|
|
map = pci_cfgread(cfg, reg, 4);
|
|
|
|
|
|
|
|
if (map == 0 || map == 0xffffffff)
|
|
|
|
return 1; /* skip invalid entry */
|
|
|
|
|
|
|
|
pci_cfgwrite(cfg, reg, 0xffffffff, 4);
|
|
|
|
testval = pci_cfgread(cfg, reg, 4);
|
|
|
|
pci_cfgwrite(cfg, reg, map, 4);
|
|
|
|
|
|
|
|
base = pci_mapbase(map);
|
|
|
|
if (pci_maptype(map) & PCI_MAPMEM)
|
|
|
|
type = SYS_RES_MEMORY;
|
|
|
|
else
|
|
|
|
type = SYS_RES_IOPORT;
|
|
|
|
ln2size = pci_mapsize(testval);
|
|
|
|
ln2range = pci_maprange(testval);
|
|
|
|
if (ln2range == 64) {
|
|
|
|
/* Read the other half of a 64bit map register */
|
|
|
|
base |= (u_int64_t) pci_cfgread(cfg, reg + 4, 4) << 32;
|
|
|
|
}
|
1999-10-14 21:38:33 +00:00
|
|
|
|
|
|
|
#ifdef __alpha__
|
1999-10-28 08:06:59 +00:00
|
|
|
/*
|
|
|
|
* XXX: encode hose number in the base addr,
|
|
|
|
* This will go away once the bus_space functions
|
|
|
|
* can deal with multiple hoses
|
|
|
|
*/
|
1999-10-14 21:38:33 +00:00
|
|
|
|
2000-03-15 23:50:31 +00:00
|
|
|
if (cfg->hose) {
|
|
|
|
u_int32_t mask, shift, maxh;
|
|
|
|
|
|
|
|
switch (hwrpb->rpb_type) {
|
|
|
|
case ST_DEC_21000:
|
|
|
|
case ST_DEC_4100:
|
|
|
|
mask = 0xf8000000;
|
|
|
|
shift = 27;
|
|
|
|
maxh = 32;
|
|
|
|
break;
|
|
|
|
case ST_DEC_6600:
|
|
|
|
mask = 0x80000000;
|
|
|
|
shift = 31;
|
|
|
|
maxh = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mask = 0;
|
|
|
|
shift = 0;
|
|
|
|
maxh = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (base & mask) {
|
|
|
|
printf("base addr = 0x%llx\n", (long long) base);
|
|
|
|
printf("mask addr = 0x%lx\n", (long) mask);
|
|
|
|
printf("hacked addr = 0x%llx\n", (long long)
|
|
|
|
(base | ((u_int64_t)cfg->hose << shift)));
|
1999-10-28 08:06:59 +00:00
|
|
|
panic("hose encoding hack would clobber base addr");
|
2000-03-15 23:50:31 +00:00
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
if (cfg->hose >= maxh) {
|
|
|
|
panic("Hose %d - can only encode %d hose(s)",
|
|
|
|
cfg->hose, maxh);
|
|
|
|
/* NOTREACHED */
|
1999-10-14 21:38:33 +00:00
|
|
|
}
|
2000-03-15 23:50:31 +00:00
|
|
|
base |= ((u_int64_t)cfg->hose << shift);
|
1999-10-28 08:06:59 +00:00
|
|
|
}
|
1999-10-14 21:38:33 +00:00
|
|
|
#endif
|
1999-10-28 08:06:59 +00:00
|
|
|
if (type == SYS_RES_IOPORT && !pci_porten(cfg))
|
|
|
|
return 1;
|
|
|
|
if (type == SYS_RES_MEMORY && !pci_memen(cfg))
|
|
|
|
return 1;
|
1999-10-14 21:38:33 +00:00
|
|
|
|
1999-10-28 08:06:59 +00:00
|
|
|
resource_list_add(rl, type, reg,
|
|
|
|
base, base + (1 << ln2size) - 1,
|
|
|
|
(1 << ln2size));
|
1999-10-14 21:38:33 +00:00
|
|
|
|
1999-10-28 08:06:59 +00:00
|
|
|
if (bootverbose) {
|
|
|
|
printf("\tmap[%02x]: type %x, range %2d, base %08x, size %2d\n",
|
|
|
|
reg, pci_maptype(base), ln2range,
|
|
|
|
(unsigned int) base, ln2size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ln2range == 64) ? 2 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pci_add_resources(device_t dev, pcicfgregs* cfg)
|
|
|
|
{
|
|
|
|
struct pci_devinfo *dinfo = device_get_ivars(dev);
|
|
|
|
struct resource_list *rl = &dinfo->resources;
|
|
|
|
struct pci_quirk *q;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < cfg->nummaps;) {
|
|
|
|
i += pci_add_map(dev, cfg, PCIR_MAPS + i*4);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (q = &pci_quirks[0]; q->devid; q++) {
|
|
|
|
if (q->devid == ((cfg->device << 16) | cfg->vendor)
|
|
|
|
&& q->type == PCI_QUIRK_MAP_REG)
|
|
|
|
pci_add_map(dev, cfg, q->arg1);
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
1999-10-28 08:06:59 +00:00
|
|
|
|
2000-01-08 10:12:21 +00:00
|
|
|
if (cfg->intpin > 0 && cfg->intline != 255)
|
1999-10-14 21:38:33 +00:00
|
|
|
resource_list_add(rl, SYS_RES_IRQ, 0,
|
|
|
|
cfg->intline, cfg->intline, 1);
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
|
|
|
|
1999-10-14 21:38:33 +00:00
|
|
|
static void
|
1999-04-16 21:22:55 +00:00
|
|
|
pci_add_children(device_t dev, int busno)
|
|
|
|
{
|
|
|
|
pcicfgregs probe;
|
|
|
|
|
|
|
|
#ifdef SIMOS
|
|
|
|
#undef PCI_SLOTMAX
|
|
|
|
#define PCI_SLOTMAX 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bzero(&probe, sizeof probe);
|
1999-05-20 15:33:33 +00:00
|
|
|
#ifdef __alpha__
|
|
|
|
probe.hose = pcib_get_hose(dev);
|
|
|
|
#endif
|
|
|
|
#ifdef __i386__
|
|
|
|
probe.hose = 0;
|
|
|
|
#endif
|
1999-04-16 21:22:55 +00:00
|
|
|
probe.bus = busno;
|
1999-05-20 15:33:33 +00:00
|
|
|
|
1999-04-16 21:22:55 +00:00
|
|
|
for (probe.slot = 0; probe.slot <= PCI_SLOTMAX; probe.slot++) {
|
|
|
|
int pcifunchigh = 0;
|
|
|
|
for (probe.func = 0; probe.func <= pcifunchigh; probe.func++) {
|
|
|
|
struct pci_devinfo *dinfo = pci_readcfg(&probe);
|
|
|
|
if (dinfo != NULL) {
|
|
|
|
if (dinfo->cfg.mfdev)
|
|
|
|
pcifunchigh = 7;
|
|
|
|
|
|
|
|
pci_print_verbose(dinfo);
|
1999-12-03 08:41:24 +00:00
|
|
|
dinfo->cfg.dev = device_add_child(dev, NULL, -1);
|
|
|
|
device_set_ivars(dinfo->cfg.dev, dinfo);
|
1999-10-14 21:38:33 +00:00
|
|
|
pci_add_resources(dinfo->cfg.dev, &dinfo->cfg);
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pci_new_probe(device_t dev)
|
|
|
|
{
|
1999-08-23 20:59:21 +00:00
|
|
|
static int once;
|
1999-04-16 21:22:55 +00:00
|
|
|
|
1999-08-23 20:59:21 +00:00
|
|
|
device_set_desc(dev, "PCI bus");
|
1999-04-16 21:22:55 +00:00
|
|
|
pci_add_children(dev, device_get_unit(dev));
|
1999-08-23 20:59:21 +00:00
|
|
|
if (!once) {
|
|
|
|
make_dev(&pcicdev, 0, UID_ROOT, GID_WHEEL, 0644, "pci");
|
|
|
|
once++;
|
|
|
|
}
|
1999-04-16 21:22:55 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-01-08 10:12:21 +00:00
|
|
|
static int
|
|
|
|
pci_print_resources(struct resource_list *rl, const char *name, int type,
|
|
|
|
const char *format)
|
|
|
|
{
|
|
|
|
struct resource_list_entry *rle;
|
|
|
|
int printed, retval;
|
|
|
|
|
|
|
|
printed = 0;
|
|
|
|
retval = 0;
|
|
|
|
/* Yes, this is kinda cheating */
|
|
|
|
SLIST_FOREACH(rle, rl, link) {
|
|
|
|
if (rle->type == type) {
|
|
|
|
if (printed == 0)
|
|
|
|
retval += printf(" %s ", name);
|
|
|
|
else if (printed > 0)
|
|
|
|
retval += printf(",");
|
|
|
|
printed++;
|
|
|
|
retval += printf(format, rle->start);
|
|
|
|
if (rle->count > 1) {
|
|
|
|
retval += printf("-");
|
|
|
|
retval += printf(format, rle->start +
|
|
|
|
rle->count - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
1999-07-29 01:03:04 +00:00
|
|
|
static int
|
1999-04-16 21:22:55 +00:00
|
|
|
pci_print_child(device_t dev, device_t child)
|
|
|
|
{
|
1999-05-08 20:28:01 +00:00
|
|
|
struct pci_devinfo *dinfo;
|
2000-01-08 10:12:21 +00:00
|
|
|
struct resource_list *rl;
|
1999-05-08 20:28:01 +00:00
|
|
|
pcicfgregs *cfg;
|
1999-07-29 01:03:04 +00:00
|
|
|
int retval = 0;
|
1999-05-08 20:28:01 +00:00
|
|
|
|
|
|
|
dinfo = device_get_ivars(child);
|
|
|
|
cfg = &dinfo->cfg;
|
2000-01-08 10:12:21 +00:00
|
|
|
rl = &dinfo->resources;
|
1999-07-29 01:03:04 +00:00
|
|
|
|
|
|
|
retval += bus_print_child_header(dev, child);
|
|
|
|
|
2000-01-08 10:12:21 +00:00
|
|
|
retval += pci_print_resources(rl, "port", SYS_RES_IOPORT, "%#lx");
|
|
|
|
retval += pci_print_resources(rl, "mem", SYS_RES_MEMORY, "%#lx");
|
|
|
|
retval += pci_print_resources(rl, "irq", SYS_RES_IRQ, "%ld");
|
|
|
|
if (device_get_flags(dev))
|
|
|
|
retval += printf(" flags %#x", device_get_flags(dev));
|
|
|
|
|
1999-07-29 01:03:04 +00:00
|
|
|
retval += printf(" at device %d.%d", pci_get_slot(child),
|
|
|
|
pci_get_function(child));
|
|
|
|
|
|
|
|
retval += bus_print_child_footer(dev, child);
|
|
|
|
|
|
|
|
return (retval);
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
|
|
|
|
1999-07-27 04:28:14 +00:00
|
|
|
static void
|
|
|
|
pci_probe_nomatch(device_t dev, device_t child)
|
|
|
|
{
|
|
|
|
struct pci_devinfo *dinfo;
|
|
|
|
pcicfgregs *cfg;
|
1999-12-10 17:44:22 +00:00
|
|
|
const char *desc;
|
2000-02-22 21:44:39 +00:00
|
|
|
int unknown;
|
1999-11-22 03:34:43 +00:00
|
|
|
|
2000-02-22 21:44:39 +00:00
|
|
|
unknown = 0;
|
1999-07-27 04:28:14 +00:00
|
|
|
dinfo = device_get_ivars(child);
|
|
|
|
cfg = &dinfo->cfg;
|
1999-12-10 17:44:22 +00:00
|
|
|
desc = pci_ata_match(child);
|
2000-02-19 09:44:06 +00:00
|
|
|
if (!desc) desc = pci_usb_match(child);
|
|
|
|
if (!desc) desc = pci_vga_match(child);
|
2000-02-22 21:44:39 +00:00
|
|
|
if (!desc) {
|
|
|
|
desc = "unknown card";
|
|
|
|
unknown++;
|
|
|
|
}
|
|
|
|
device_printf(dev, "<%s>", desc);
|
|
|
|
if (bootverbose || unknown) {
|
|
|
|
printf(" (vendor=0x%04x, dev=0x%04x)",
|
|
|
|
cfg->vendor,
|
|
|
|
cfg->device);
|
|
|
|
}
|
|
|
|
printf(" at %d.%d",
|
1999-07-27 04:28:14 +00:00
|
|
|
pci_get_slot(child),
|
|
|
|
pci_get_function(child));
|
|
|
|
if (cfg->intpin > 0 && cfg->intline != 255) {
|
|
|
|
printf(" irq %d", cfg->intline);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-04-16 21:22:55 +00:00
|
|
|
static int
|
|
|
|
pci_read_ivar(device_t dev, device_t child, int which, u_long *result)
|
|
|
|
{
|
|
|
|
struct pci_devinfo *dinfo;
|
|
|
|
pcicfgregs *cfg;
|
|
|
|
|
|
|
|
dinfo = device_get_ivars(child);
|
|
|
|
cfg = &dinfo->cfg;
|
|
|
|
|
|
|
|
switch (which) {
|
|
|
|
case PCI_IVAR_SUBVENDOR:
|
|
|
|
*result = cfg->subvendor;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_SUBDEVICE:
|
|
|
|
*result = cfg->subdevice;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_VENDOR:
|
|
|
|
*result = cfg->vendor;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_DEVICE:
|
|
|
|
*result = cfg->device;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_DEVID:
|
|
|
|
*result = (cfg->device << 16) | cfg->vendor;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_CLASS:
|
|
|
|
*result = cfg->baseclass;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_SUBCLASS:
|
|
|
|
*result = cfg->subclass;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_PROGIF:
|
|
|
|
*result = cfg->progif;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_REVID:
|
|
|
|
*result = cfg->revid;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_INTPIN:
|
|
|
|
*result = cfg->intpin;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_IRQ:
|
|
|
|
*result = cfg->intline;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_BUS:
|
|
|
|
*result = cfg->bus;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_SLOT:
|
|
|
|
*result = cfg->slot;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_FUNCTION:
|
|
|
|
*result = cfg->func;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_SECONDARYBUS:
|
|
|
|
*result = cfg->secondarybus;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_SUBORDINATEBUS:
|
|
|
|
*result = cfg->subordinatebus;
|
|
|
|
break;
|
1999-05-20 15:33:33 +00:00
|
|
|
case PCI_IVAR_HOSE:
|
|
|
|
/*
|
|
|
|
* Pass up to parent bridge.
|
|
|
|
*/
|
|
|
|
*result = pcib_get_hose(dev);
|
|
|
|
break;
|
1999-04-16 21:22:55 +00:00
|
|
|
default:
|
|
|
|
return ENOENT;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pci_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
|
|
|
|
{
|
|
|
|
struct pci_devinfo *dinfo;
|
|
|
|
pcicfgregs *cfg;
|
|
|
|
|
|
|
|
dinfo = device_get_ivars(child);
|
|
|
|
cfg = &dinfo->cfg;
|
|
|
|
|
|
|
|
switch (which) {
|
|
|
|
case PCI_IVAR_SUBVENDOR:
|
|
|
|
case PCI_IVAR_SUBDEVICE:
|
|
|
|
case PCI_IVAR_VENDOR:
|
|
|
|
case PCI_IVAR_DEVICE:
|
|
|
|
case PCI_IVAR_DEVID:
|
|
|
|
case PCI_IVAR_CLASS:
|
|
|
|
case PCI_IVAR_SUBCLASS:
|
|
|
|
case PCI_IVAR_PROGIF:
|
|
|
|
case PCI_IVAR_REVID:
|
|
|
|
case PCI_IVAR_INTPIN:
|
|
|
|
case PCI_IVAR_IRQ:
|
|
|
|
case PCI_IVAR_BUS:
|
|
|
|
case PCI_IVAR_SLOT:
|
|
|
|
case PCI_IVAR_FUNCTION:
|
|
|
|
return EINVAL; /* disallow for now */
|
|
|
|
|
|
|
|
case PCI_IVAR_SECONDARYBUS:
|
|
|
|
cfg->secondarybus = value;
|
|
|
|
break;
|
|
|
|
case PCI_IVAR_SUBORDINATEBUS:
|
|
|
|
cfg->subordinatebus = value;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return ENOENT;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-10-14 21:38:33 +00:00
|
|
|
static struct resource *
|
|
|
|
pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
|
|
|
u_long start, u_long end, u_long count, u_int flags)
|
1999-04-16 21:22:55 +00:00
|
|
|
{
|
1999-10-14 21:38:33 +00:00
|
|
|
struct pci_devinfo *dinfo = device_get_ivars(child);
|
|
|
|
struct resource_list *rl = &dinfo->resources;
|
1999-04-16 21:22:55 +00:00
|
|
|
|
1999-10-14 21:38:33 +00:00
|
|
|
return resource_list_alloc(rl, dev, child, type, rid,
|
|
|
|
start, end, count, flags);
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1999-10-14 21:38:33 +00:00
|
|
|
pci_release_resource(device_t dev, device_t child, int type, int rid,
|
|
|
|
struct resource *r)
|
1999-04-16 21:22:55 +00:00
|
|
|
{
|
1999-10-14 21:38:33 +00:00
|
|
|
struct pci_devinfo *dinfo = device_get_ivars(child);
|
|
|
|
struct resource_list *rl = &dinfo->resources;
|
1999-04-16 21:22:55 +00:00
|
|
|
|
1999-10-14 21:38:33 +00:00
|
|
|
return resource_list_release(rl, dev, child, type, rid, r);
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1999-10-14 21:38:33 +00:00
|
|
|
pci_set_resource(device_t dev, device_t child, int type, int rid,
|
|
|
|
u_long start, u_long count)
|
1999-04-16 21:22:55 +00:00
|
|
|
{
|
1999-10-28 08:06:59 +00:00
|
|
|
struct pci_devinfo *dinfo = device_get_ivars(child);
|
|
|
|
struct resource_list *rl = &dinfo->resources;
|
|
|
|
|
|
|
|
resource_list_add(rl, type, rid, start, start + count - 1, count);
|
|
|
|
return 0;
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1999-10-14 21:38:33 +00:00
|
|
|
pci_get_resource(device_t dev, device_t child, int type, int rid,
|
|
|
|
u_long *startp, u_long *countp)
|
1999-04-16 21:22:55 +00:00
|
|
|
{
|
|
|
|
struct pci_devinfo *dinfo = device_get_ivars(child);
|
1999-10-14 21:38:33 +00:00
|
|
|
struct resource_list *rl = &dinfo->resources;
|
|
|
|
struct resource_list_entry *rle;
|
1999-04-16 21:22:55 +00:00
|
|
|
|
1999-10-14 21:38:33 +00:00
|
|
|
rle = resource_list_find(rl, type, rid);
|
|
|
|
if (!rle)
|
|
|
|
return ENOENT;
|
|
|
|
|
1999-11-20 14:56:55 +00:00
|
|
|
if (startp)
|
|
|
|
*startp = rle->start;
|
|
|
|
if (countp)
|
|
|
|
*countp = rle->count;
|
1999-04-16 21:22:55 +00:00
|
|
|
|
1999-10-14 21:38:33 +00:00
|
|
|
return 0;
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
|
|
|
|
1999-10-14 21:38:33 +00:00
|
|
|
static void
|
|
|
|
pci_delete_resource(device_t dev, device_t child, int type, int rid)
|
1999-04-16 21:22:55 +00:00
|
|
|
{
|
2000-02-01 18:02:12 +00:00
|
|
|
printf("pci_delete_resource: PCI resources can not be deleted\n");
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u_int32_t
|
|
|
|
pci_read_config_method(device_t dev, device_t child, int reg, int width)
|
|
|
|
{
|
|
|
|
struct pci_devinfo *dinfo = device_get_ivars(child);
|
|
|
|
pcicfgregs *cfg = &dinfo->cfg;
|
|
|
|
return pci_cfgread(cfg, reg, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pci_write_config_method(device_t dev, device_t child, int reg,
|
|
|
|
u_int32_t val, int width)
|
|
|
|
{
|
|
|
|
struct pci_devinfo *dinfo = device_get_ivars(child);
|
|
|
|
pcicfgregs *cfg = &dinfo->cfg;
|
|
|
|
pci_cfgwrite(cfg, reg, val, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pci_modevent(module_t mod, int what, void *arg)
|
|
|
|
{
|
|
|
|
switch (what) {
|
|
|
|
case MOD_LOAD:
|
1999-05-09 15:54:04 +00:00
|
|
|
STAILQ_INIT(&pci_devq);
|
1999-04-16 21:22:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MOD_UNLOAD:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static device_method_t pci_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, pci_new_probe),
|
|
|
|
DEVMETHOD(device_attach, bus_generic_attach),
|
|
|
|
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
1999-05-10 17:56:23 +00:00
|
|
|
DEVMETHOD(device_suspend, bus_generic_suspend),
|
|
|
|
DEVMETHOD(device_resume, bus_generic_resume),
|
1999-04-16 21:22:55 +00:00
|
|
|
|
|
|
|
/* Bus interface */
|
|
|
|
DEVMETHOD(bus_print_child, pci_print_child),
|
1999-07-27 05:08:36 +00:00
|
|
|
DEVMETHOD(bus_probe_nomatch, pci_probe_nomatch),
|
1999-04-16 21:22:55 +00:00
|
|
|
DEVMETHOD(bus_read_ivar, pci_read_ivar),
|
|
|
|
DEVMETHOD(bus_write_ivar, pci_write_ivar),
|
|
|
|
DEVMETHOD(bus_driver_added, bus_generic_driver_added),
|
|
|
|
DEVMETHOD(bus_alloc_resource, pci_alloc_resource),
|
|
|
|
DEVMETHOD(bus_release_resource, pci_release_resource),
|
|
|
|
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
|
|
|
|
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
|
|
|
|
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
|
|
|
|
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
|
1999-10-14 21:38:33 +00:00
|
|
|
DEVMETHOD(bus_set_resource, pci_set_resource),
|
|
|
|
DEVMETHOD(bus_get_resource, pci_get_resource),
|
|
|
|
DEVMETHOD(bus_delete_resource, pci_delete_resource),
|
1999-04-16 21:22:55 +00:00
|
|
|
|
|
|
|
/* PCI interface */
|
|
|
|
DEVMETHOD(pci_read_config, pci_read_config_method),
|
|
|
|
DEVMETHOD(pci_write_config, pci_write_config_method),
|
|
|
|
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t pci_driver = {
|
|
|
|
"pci",
|
|
|
|
pci_methods,
|
|
|
|
1, /* no softc */
|
|
|
|
};
|
|
|
|
|
|
|
|
DRIVER_MODULE(pci, pcib, pci_driver, pci_devclass, pci_modevent, 0);
|