Added a bit of missing functionality to make this work correctly on a

wider variety of systems.  Include the deivers from pci_intel.c in
pci_config.c (I hope this is what was intended; my system works ok).
Use pmap_mapdev().  Automatically map any large linear frame buffers
or whatnot in VGA-style devices which ordinarily would not have their
own drivers, and don't call not_supported() for them.  (This shuts up
complaints about my Matrox card.)  Include the beginnings of what could
eventually become dynamically-loadable PCI devices.  Allow for the
possibility of PCI devices simply providing a PCI veneer over an existing
ISA device, and shut up about them, too.
Make autoconfiguration text conform more to the style of other supported
buses.
This commit is contained in:
Garrett Wollman 1994-09-14 01:34:51 +00:00
parent 36156bf4fe
commit f86233fe54
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=2753
7 changed files with 350 additions and 228 deletions

View file

@ -1,6 +1,6 @@
/**************************************************************************
**
** $Id: pci.c,v 2.0.0.8 94/08/21 19:57:39 wolf Exp $
** $Id: pci.c,v 1.2 1994/09/01 02:01:34 se Exp $
**
** General subroutines for the PCI bus on 80*86 systems.
** pci_configure ()
@ -35,7 +35,12 @@
**
**-------------------------------------------------------------------------
**
** $Log: pci.c,v $
** $Log: pci.c,v $
* Revision 1.2 1994/09/01 02:01:34 se
* Submitted by: Wolfgang Stanglmeier <wolf@dentaro.GUN.de>
* Merged in changes required for NetBSD support (by mycroft@gnu.ai.mit.edu)
* and support for multiple NCR chips.
*
** Revision 2.0.0.8 94/08/21 19:57:39 wolf
** Unneeded declarations removed (FreeBSD2.0)
**
@ -104,10 +109,9 @@
**========================================================
*/
#include <types.h>
#include <cdefs.h>
#include <errno.h>
#include <param.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@ -122,15 +126,13 @@
char ident_pci_c[] =
"\n$Id: pci.c,v 2.0.0.8 94/08/21 19:57:39 wolf Exp $\n"
"\n$Id: pci.c,v 1.2 1994/09/01 02:01:34 se Exp $\n"
"Copyright (c) 1994, Wolfgang Stanglmeier\n";
/*
** Function prototypes missing in system headers
*/
extern int printf();
extern int ffs();
#if ! (__FreeBSD__ >= 2)
extern pmap_t pmap_kernel(void);
#endif
@ -273,7 +275,7 @@ void pci_configure()
#ifndef PCI_QUIET
printf ("PCI configuration mode %d.\n", pci_mode);
printf ("Scanning device 0..%d on pci bus 0..%d "
"($Revision: 2.0.0.8 $)\n",
"($Revision: 1.2 $)\n",
last_device, last_bus);
#endif
@ -288,35 +290,68 @@ void pci_configure()
** lookup device in ioconfiguration:
*/
for (dvp = pci_devtab; drp=dvp->pd_driver; dvp++) {
if (drp->device_id == type) break;
for (dvp = pci_devtab; dvp->pd_device_id; dvp++) {
if (dvp->pd_device_id == type) break;
};
drp = dvp->pd_driver;
#ifdef PCI_QUIET
if (!drp) continue;
#endif
printf ("on pci%d:%d ", bus, device);
if (!dvp->pd_device_id) {
int data = pci_conf_read(tag, PCI_CLASS_REV_REG);
enum pci_majclass class = PCI_MAJCLASS_OF(data);
vm_offset_t va;
vm_offset_t pa;
int reg;
switch(class) {
case PCI_MJC_OLD:
if(PCI_MINCLASS_OF(data) != PCI_MIN_OVGA)
break;
case PCI_MJC_DISPLAY:
for (reg = PCI_MAP_REG_START;
reg < PCI_MAP_REG_END;
reg += 4) {
data = pci_map_mem(tag, reg, &va, &pa);
if(data == 0)
printf(
"pci%d:%d: mapped VGA-like device at physaddr %lx\n",
bus, device, (u_long)pa);
}
continue;
default:
#ifndef PCI_QUIET
if (!drp) {
not_supported (tag, type);
continue;
};
printf("pci%d:%d: ", bus, device);
not_supported (tag, type);
#endif
}
}
if (!drp) {
if(dvp->pd_flags & PDF_LOADABLE) {
printf("%s: loadable device on pci%d:%d\n",
dvp->pd_name, bus, device);
}
continue;
}
/*
** found it.
** probe returns the device unit.
*/
printf ("<%s>", drp -> vendor);
unit = (*drp->probe) (tag);
if (unit<0) {
printf (" probe failed.\n");
printf ("%s <%s>: probe failed on pci%d:%d\n",
drp->name, drp->vendor, bus, device);
continue;
};
if (drp->name) {
printf ("%s%d <%s>", drp->name, unit, drp->vendor);
} else {
printf ("pci%d: <%s>", bus, drp->vendor);
}
/*
** install interrupts
*/
@ -337,8 +372,8 @@ void pci_configure()
for (idx = 0; idx < NPCI; idx++) {
if (pcidata[idx].isanum == isanum)
break;
};
};
}
}
/*
** Or believe to the interrupt pin register.
@ -362,8 +397,8 @@ void pci_configure()
pcidata[idx].number=entry;
} else {
printf (" not installed");
};
};
}
}
/*
** enable memory access
@ -372,19 +407,20 @@ void pci_configure()
& 0xffff | PCI_COMMAND_MEM_ENABLE;
pci_conf_write (tag, (u_char) PCI_COMMAND_STATUS_REG, data);
printf (" on pci%d:%d\n", bus, device);
/*
** attach device
** may produce additional log messages,
** i.e. when installing subdevices.
*/
printf (" as %s%d\n", drp->name,unit);
(void) (*drp->attach) (tag);
}
};
printf ("pci uses physical addresses from %x to %x\n",
PCI_PMEM_START, pci_paddr);
#ifndef PCI_QUIET
printf ("pci uses physical addresses from %lx to %lx\n",
(u_long)PCI_PMEM_START, (u_long)pci_paddr);
#endif
}
/*-----------------------------------------------------------------------
@ -455,24 +491,8 @@ int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa)
vsize = round_page (-(data & PCI_MAP_MEMORY_ADDRESS_MASK));
printf (" memory size=0x%x", vsize);
if (!vsize) return (EINVAL);
/*
** try to map device to virtual space
*/
vaddr = vm_map_min (kernel_map);
result = vm_map_find (kernel_map, (void*)0, (vm_offset_t) 0,
&vaddr, vsize, TRUE);
if (result != KERN_SUCCESS) {
printf (" vm_map_find failed(%d)\n", result);
return (ENOMEM);
};
/*
** align physical address to virtual size
*/
@ -480,11 +500,16 @@ int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa)
if (data = pci_paddr % vsize)
pci_paddr += vsize - data;
vaddr = pmap_mapdev (pci_paddr, vsize);
#if 0
/*
** display values.
*/
printf (" virtual=0x%x physical=0x%x\n", vaddr, pci_paddr);
printf (" virtual=0x%lx physical=0x%lx\n", (u_long)vaddr,
(u_long)pci_paddr);
#endif
/*
** return them to the driver
@ -499,18 +524,6 @@ int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa)
pci_conf_write (tag, reg, pci_paddr);
/*
** map physical
*/
while (vsize >= NBPG) {
pmap_enter (pmap_kernel(), vaddr, pci_paddr,
VM_PROT_READ|VM_PROT_WRITE, TRUE);
vaddr += NBPG;
pci_paddr += NBPG;
vsize -= NBPG;
};
return (0);
}
@ -542,6 +555,11 @@ static struct dt DeviceTable[] = {
{0x04A38086, " 82434LX pci cache memory controller"},
{0,0}
};
static const char *const majclasses[] = {
"old", "storage", "network", "display", "multimedia", "memory",
"bridge"
};
void not_supported (pcici_t tag, u_long type)
{
@ -567,10 +585,14 @@ void not_supported (pcici_t tag, u_long type)
*/
if (vp->ident) printf (vp->name);
else printf ("vendor=%x", type & 0xffff);
else printf ("vendor=%lx", type & 0xffff);
if (dp->ident) printf (dp->name);
else printf (", device=%x", type >> 16);
else printf (", device=%lx", type >> 16);
data = pci_conf_read(tag, PCI_CLASS_REV_REG);
if (PCI_MAJCLASS_OF(data) < sizeof(majclasses) / sizeof(majclasses[0]))
printf(", class=%s", majclasses[PCI_MAJCLASS_OF(data)]);
printf (" [not supported]\n");
@ -581,18 +603,18 @@ void not_supported (pcici_t tag, u_long type)
case 1:
case 5:
printf (" map(%x): io(%x)\n", reg, data & ~3);
printf (" map(%lx): io(%lx)\n", reg, data & ~3);
break;
case 0:
printf (" map(%x): mem32(%x)\n", reg, data & ~7);
printf (" map(%lx): mem32(%lx)\n", reg, data & ~7);
break;
case 2:
printf (" map(%x): mem20(%x)\n", reg, data & ~7);
printf (" map(%lx): mem20(%lx)\n", reg, data & ~7);
break;
case 4:
printf (" map(%x): mem64(%x)\n", reg, data & ~7);
printf (" map(%lx): mem64(%lx)\n", reg, data & ~7);
break;
};
};
}
}
}
#endif

View file

@ -1,6 +1,6 @@
/**************************************************************************
**
** $Id: pci.c,v 2.0.0.8 94/08/21 19:57:39 wolf Exp $
** $Id: pci.c,v 1.2 1994/09/01 02:01:34 se Exp $
**
** General subroutines for the PCI bus on 80*86 systems.
** pci_configure ()
@ -35,7 +35,12 @@
**
**-------------------------------------------------------------------------
**
** $Log: pci.c,v $
** $Log: pci.c,v $
* Revision 1.2 1994/09/01 02:01:34 se
* Submitted by: Wolfgang Stanglmeier <wolf@dentaro.GUN.de>
* Merged in changes required for NetBSD support (by mycroft@gnu.ai.mit.edu)
* and support for multiple NCR chips.
*
** Revision 2.0.0.8 94/08/21 19:57:39 wolf
** Unneeded declarations removed (FreeBSD2.0)
**
@ -104,10 +109,9 @@
**========================================================
*/
#include <types.h>
#include <cdefs.h>
#include <errno.h>
#include <param.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@ -122,15 +126,13 @@
char ident_pci_c[] =
"\n$Id: pci.c,v 2.0.0.8 94/08/21 19:57:39 wolf Exp $\n"
"\n$Id: pci.c,v 1.2 1994/09/01 02:01:34 se Exp $\n"
"Copyright (c) 1994, Wolfgang Stanglmeier\n";
/*
** Function prototypes missing in system headers
*/
extern int printf();
extern int ffs();
#if ! (__FreeBSD__ >= 2)
extern pmap_t pmap_kernel(void);
#endif
@ -273,7 +275,7 @@ void pci_configure()
#ifndef PCI_QUIET
printf ("PCI configuration mode %d.\n", pci_mode);
printf ("Scanning device 0..%d on pci bus 0..%d "
"($Revision: 2.0.0.8 $)\n",
"($Revision: 1.2 $)\n",
last_device, last_bus);
#endif
@ -288,35 +290,68 @@ void pci_configure()
** lookup device in ioconfiguration:
*/
for (dvp = pci_devtab; drp=dvp->pd_driver; dvp++) {
if (drp->device_id == type) break;
for (dvp = pci_devtab; dvp->pd_device_id; dvp++) {
if (dvp->pd_device_id == type) break;
};
drp = dvp->pd_driver;
#ifdef PCI_QUIET
if (!drp) continue;
#endif
printf ("on pci%d:%d ", bus, device);
if (!dvp->pd_device_id) {
int data = pci_conf_read(tag, PCI_CLASS_REV_REG);
enum pci_majclass class = PCI_MAJCLASS_OF(data);
vm_offset_t va;
vm_offset_t pa;
int reg;
switch(class) {
case PCI_MJC_OLD:
if(PCI_MINCLASS_OF(data) != PCI_MIN_OVGA)
break;
case PCI_MJC_DISPLAY:
for (reg = PCI_MAP_REG_START;
reg < PCI_MAP_REG_END;
reg += 4) {
data = pci_map_mem(tag, reg, &va, &pa);
if(data == 0)
printf(
"pci%d:%d: mapped VGA-like device at physaddr %lx\n",
bus, device, (u_long)pa);
}
continue;
default:
#ifndef PCI_QUIET
if (!drp) {
not_supported (tag, type);
continue;
};
printf("pci%d:%d: ", bus, device);
not_supported (tag, type);
#endif
}
}
if (!drp) {
if(dvp->pd_flags & PDF_LOADABLE) {
printf("%s: loadable device on pci%d:%d\n",
dvp->pd_name, bus, device);
}
continue;
}
/*
** found it.
** probe returns the device unit.
*/
printf ("<%s>", drp -> vendor);
unit = (*drp->probe) (tag);
if (unit<0) {
printf (" probe failed.\n");
printf ("%s <%s>: probe failed on pci%d:%d\n",
drp->name, drp->vendor, bus, device);
continue;
};
if (drp->name) {
printf ("%s%d <%s>", drp->name, unit, drp->vendor);
} else {
printf ("pci%d: <%s>", bus, drp->vendor);
}
/*
** install interrupts
*/
@ -337,8 +372,8 @@ void pci_configure()
for (idx = 0; idx < NPCI; idx++) {
if (pcidata[idx].isanum == isanum)
break;
};
};
}
}
/*
** Or believe to the interrupt pin register.
@ -362,8 +397,8 @@ void pci_configure()
pcidata[idx].number=entry;
} else {
printf (" not installed");
};
};
}
}
/*
** enable memory access
@ -372,19 +407,20 @@ void pci_configure()
& 0xffff | PCI_COMMAND_MEM_ENABLE;
pci_conf_write (tag, (u_char) PCI_COMMAND_STATUS_REG, data);
printf (" on pci%d:%d\n", bus, device);
/*
** attach device
** may produce additional log messages,
** i.e. when installing subdevices.
*/
printf (" as %s%d\n", drp->name,unit);
(void) (*drp->attach) (tag);
}
};
printf ("pci uses physical addresses from %x to %x\n",
PCI_PMEM_START, pci_paddr);
#ifndef PCI_QUIET
printf ("pci uses physical addresses from %lx to %lx\n",
(u_long)PCI_PMEM_START, (u_long)pci_paddr);
#endif
}
/*-----------------------------------------------------------------------
@ -455,24 +491,8 @@ int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa)
vsize = round_page (-(data & PCI_MAP_MEMORY_ADDRESS_MASK));
printf (" memory size=0x%x", vsize);
if (!vsize) return (EINVAL);
/*
** try to map device to virtual space
*/
vaddr = vm_map_min (kernel_map);
result = vm_map_find (kernel_map, (void*)0, (vm_offset_t) 0,
&vaddr, vsize, TRUE);
if (result != KERN_SUCCESS) {
printf (" vm_map_find failed(%d)\n", result);
return (ENOMEM);
};
/*
** align physical address to virtual size
*/
@ -480,11 +500,16 @@ int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa)
if (data = pci_paddr % vsize)
pci_paddr += vsize - data;
vaddr = pmap_mapdev (pci_paddr, vsize);
#if 0
/*
** display values.
*/
printf (" virtual=0x%x physical=0x%x\n", vaddr, pci_paddr);
printf (" virtual=0x%lx physical=0x%lx\n", (u_long)vaddr,
(u_long)pci_paddr);
#endif
/*
** return them to the driver
@ -499,18 +524,6 @@ int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa)
pci_conf_write (tag, reg, pci_paddr);
/*
** map physical
*/
while (vsize >= NBPG) {
pmap_enter (pmap_kernel(), vaddr, pci_paddr,
VM_PROT_READ|VM_PROT_WRITE, TRUE);
vaddr += NBPG;
pci_paddr += NBPG;
vsize -= NBPG;
};
return (0);
}
@ -542,6 +555,11 @@ static struct dt DeviceTable[] = {
{0x04A38086, " 82434LX pci cache memory controller"},
{0,0}
};
static const char *const majclasses[] = {
"old", "storage", "network", "display", "multimedia", "memory",
"bridge"
};
void not_supported (pcici_t tag, u_long type)
{
@ -567,10 +585,14 @@ void not_supported (pcici_t tag, u_long type)
*/
if (vp->ident) printf (vp->name);
else printf ("vendor=%x", type & 0xffff);
else printf ("vendor=%lx", type & 0xffff);
if (dp->ident) printf (dp->name);
else printf (", device=%x", type >> 16);
else printf (", device=%lx", type >> 16);
data = pci_conf_read(tag, PCI_CLASS_REV_REG);
if (PCI_MAJCLASS_OF(data) < sizeof(majclasses) / sizeof(majclasses[0]))
printf(", class=%s", majclasses[PCI_MAJCLASS_OF(data)]);
printf (" [not supported]\n");
@ -581,18 +603,18 @@ void not_supported (pcici_t tag, u_long type)
case 1:
case 5:
printf (" map(%x): io(%x)\n", reg, data & ~3);
printf (" map(%lx): io(%lx)\n", reg, data & ~3);
break;
case 0:
printf (" map(%x): mem32(%x)\n", reg, data & ~7);
printf (" map(%lx): mem32(%lx)\n", reg, data & ~7);
break;
case 2:
printf (" map(%x): mem20(%x)\n", reg, data & ~7);
printf (" map(%lx): mem20(%lx)\n", reg, data & ~7);
break;
case 4:
printf (" map(%x): mem64(%x)\n", reg, data & ~7);
printf (" map(%lx): mem64(%lx)\n", reg, data & ~7);
break;
};
};
}
}
}
#endif

View file

@ -1,6 +1,6 @@
/**************************************************************************
**
** $Id: pci_config.c,v 2.0.0.1 94/08/18 23:07:28 wolf Exp $
** $Id: pci_config.c,v 1.2 1994/09/01 02:01:39 se Exp $
**
** @PCI@ this should be part of "ioconf.c".
**
@ -34,7 +34,12 @@
**
**-------------------------------------------------------------------------
**
** $Log: pci_config.c,v $
** $Log: pci_config.c,v $
* Revision 1.2 1994/09/01 02:01:39 se
* Submitted by: Wolfgang Stanglmeier <wolf@dentaro.GUN.de>
* Merged in changes required for NetBSD support (by mycroft@gnu.ai.mit.edu)
* and support for multiple NCR chips.
*
** Revision 2.0.0.1 94/08/18 23:07:28 wolf
** Copyright message.
** Hook for DEC ethernet driver "de".
@ -48,9 +53,9 @@
***************************************************************************
*/
#include "types.h"
#include "i386/pci/pci.h"
#include "i386/pci/pci_device.h"
#include <sys/types.h>
#include <i386/pci/pci.h>
#include <i386/pci/pci_device.h>
#include "ncr.h"
#if NNCR>0
@ -61,14 +66,27 @@ extern struct pci_driver ncrdevice;
#if NDE > 0
extern struct pci_driver dedevice;
#endif
extern struct pci_driver intel82378_device;
extern struct pci_driver intel82424_device;
extern struct pci_driver intel82375_device;
extern struct pci_driver intel82434_device;
struct pci_device pci_devtab[] = {
#if NNCR>0
{&ncrdevice},
{&ncrdevice, 0x00011000ul, "ncr", 0},
#else
{0, 0x00011000ul, "ncr", PDF_LOADABLE},
#endif
#if NDE>0
{&dedevice},
{&dedevice, 0x00011011ul, "de", 0}, /* FIXME!!! */
#else
{0, 0x00011011ul, "de", PDF_LOADABLE}, /* FIXME!!! */
#endif
{0}
{0, 0x10001042ul, "wd", PDF_COVERED},
{&intel82378_device, 0x04848086, "ichip", 0},
{&intel82424_device, 0x04838086, "ichip", 0},
{&intel82375_device, 0x04828086, "ichip", 0},
{&intel82434_device, 0x04a38086, "ichip", 0},
{0, 0, 0}
};

View file

@ -1,6 +1,6 @@
/**************************************************************************
**
** $Id: pci_device.h,v 2.0.0.1 94/08/18 23:06:43 wolf Exp $
** $Id: pci_device.h,v 1.2 1994/09/01 02:01:41 se Exp $
**
** #define for pci based device drivers
**
@ -34,7 +34,12 @@
**
**-------------------------------------------------------------------------
**
** $Log: pci_device.h,v $
** $Log: pci_device.h,v $
* Revision 1.2 1994/09/01 02:01:41 se
* Submitted by: Wolfgang Stanglmeier <wolf@dentaro.GUN.de>
* Merged in changes required for NetBSD support (by mycroft@gnu.ai.mit.edu)
* and support for multiple NCR chips.
*
** Revision 2.0.0.1 94/08/18 23:06:43 wolf
** Copyright message.
**
@ -81,7 +86,12 @@ struct pci_driver {
struct pci_device {
struct pci_driver * pd_driver;
pcidi_t pd_device_id; /* device pci id */
const char *pd_name; /* for future loadable drivers */
int pd_flags;
};
#define PDF_LOADABLE 0x01
#define PDF_COVERED 0x02
/*-----------------------------------------------------------
**

View file

@ -1,6 +1,6 @@
/**************************************************************************
**
** $Id: pci_intel.c,v 1.1 94/09/05 22:38:38 wolf Exp $
** $Id: pci_intel.c,v 1.1 1994/09/06 22:39:11 se Exp $
**
** Device driver for INTEL PCI chipsets.
**
@ -40,7 +40,10 @@
**
**-------------------------------------------------------------------------
**
** $Log: pci_intel.c,v $
** $Log: pci_intel.c,v $
* Revision 1.1 1994/09/06 22:39:11 se
* Initial revision
*
* Revision 1.1 94/09/05 22:38:38 wolf
* Initial revision
*
@ -289,7 +292,7 @@ static void writeconfig(pcici_t config_id, struct condmsg *tbl)
int intel_attach(pcici_t config_id, pcidi_t type)
{
printf (" [40] %x [50] %x [54] %x\n",
printf (" [40] %lx [50] %lx [54] %lx\n",
pci_conf_read (config_id, 0x40),
pci_conf_read (config_id, 0x50),
pci_conf_read (config_id, 0x54));

View file

@ -1,6 +1,6 @@
/**************************************************************************
**
** $Id: pcibios.h,v 2.0.0.1 94/08/18 23:05:36 wolf Exp $
** $Id: pcibios.h,v 1.2 1994/09/01 02:01:45 se Exp $
**
** #define for pci-bus bios functions.
**
@ -34,7 +34,12 @@
**
**-------------------------------------------------------------------------
**
** $Log: pcibios.h,v $
** $Log: pcibios.h,v $
* Revision 1.2 1994/09/01 02:01:45 se
* Submitted by: Wolfgang Stanglmeier <wolf@dentaro.GUN.de>
* Merged in changes required for NetBSD support (by mycroft@gnu.ai.mit.edu)
* and support for multiple NCR chips.
*
** Revision 2.0.0.1 94/08/18 23:05:36 wolf
**
** Copyright message.
@ -94,6 +99,26 @@ void pci_conf_write (pcici_t tag, u_long reg, u_long data);
#define PCI_COMMAND_STATUS_REG 0x04
#define PCI_COMMAND_MEM_ENABLE 0x00000002
#define PCI_CLASS_REV_REG 0x08
#define PCI_MAJCLASS_OF(x) (((x) >> 24) & 0xff)
#define PCI_MINCLASS_OF(x) (((x) >> 16) & 0xff)
#define PCI_PROGINT_OF(x) (((x) >> 8) & 0xff)
#define PCI_REV_OF(x) ((x) & 0xff)
enum pci_majclass { PCI_MJC_OLD = 0, PCI_MJC_STOR, PCI_MJC_NET,
PCI_MJC_DISPLAY, PCI_MJC_MEDIA, PCI_MJC_MEM,
PCI_MJC_BRIDGE };
enum pci_old_minclass { PCI_MIN_OLD = 0, PCI_MIN_OVGA };
enum pci_stor_minclass { PCI_MIN_SCSI = 0, PCI_MIN_IDE, PCI_MIN_FLOP,
PCI_MIN_IPI, PCI_MIN_OSTOR };
enum pci_net_minclass { PCI_MIN_ETHER = 0, PCI_MIN_TOKEN, PCI_MIN_FDDI,
PCI_MIN_ONET };
enum pci_disp_minclass { PCI_MIN_VGA = 0, PCI_MIN_XGA, PCI_MIN_ODISP };
enum pci_media_minclass { PCI_MIN_VIDEO = 0, PCI_MIN_AUDIO, PCI_MIN_OMEDIA };
enum pci_mem_minclass { PCI_MIN_RAM = 0, PCI_MIN_FLASH, PCI_MIN_OMEM };
enum pci_bridge_minclass { PCI_MIN_HOST = 0, PCI_MIN_ISA, PCI_MIN_EISA,
PCI_MIN_MC, PCI_MIN_PCI, PCI_MIN_PCMCIA,
PCI_MIN_OBRIDGE };
#define PCI_MAP_REG_START 0x10
#define PCI_MAP_REG_END 0x28
#define PCI_MAP_MEMORY 0x00000000

View file

@ -1,6 +1,6 @@
/**************************************************************************
**
** $Id: pci.c,v 2.0.0.8 94/08/21 19:57:39 wolf Exp $
** $Id: pci.c,v 1.2 1994/09/01 02:01:34 se Exp $
**
** General subroutines for the PCI bus on 80*86 systems.
** pci_configure ()
@ -35,7 +35,12 @@
**
**-------------------------------------------------------------------------
**
** $Log: pci.c,v $
** $Log: pci.c,v $
* Revision 1.2 1994/09/01 02:01:34 se
* Submitted by: Wolfgang Stanglmeier <wolf@dentaro.GUN.de>
* Merged in changes required for NetBSD support (by mycroft@gnu.ai.mit.edu)
* and support for multiple NCR chips.
*
** Revision 2.0.0.8 94/08/21 19:57:39 wolf
** Unneeded declarations removed (FreeBSD2.0)
**
@ -104,10 +109,9 @@
**========================================================
*/
#include <types.h>
#include <cdefs.h>
#include <errno.h>
#include <param.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@ -122,15 +126,13 @@
char ident_pci_c[] =
"\n$Id: pci.c,v 2.0.0.8 94/08/21 19:57:39 wolf Exp $\n"
"\n$Id: pci.c,v 1.2 1994/09/01 02:01:34 se Exp $\n"
"Copyright (c) 1994, Wolfgang Stanglmeier\n";
/*
** Function prototypes missing in system headers
*/
extern int printf();
extern int ffs();
#if ! (__FreeBSD__ >= 2)
extern pmap_t pmap_kernel(void);
#endif
@ -273,7 +275,7 @@ void pci_configure()
#ifndef PCI_QUIET
printf ("PCI configuration mode %d.\n", pci_mode);
printf ("Scanning device 0..%d on pci bus 0..%d "
"($Revision: 2.0.0.8 $)\n",
"($Revision: 1.2 $)\n",
last_device, last_bus);
#endif
@ -288,35 +290,68 @@ void pci_configure()
** lookup device in ioconfiguration:
*/
for (dvp = pci_devtab; drp=dvp->pd_driver; dvp++) {
if (drp->device_id == type) break;
for (dvp = pci_devtab; dvp->pd_device_id; dvp++) {
if (dvp->pd_device_id == type) break;
};
drp = dvp->pd_driver;
#ifdef PCI_QUIET
if (!drp) continue;
#endif
printf ("on pci%d:%d ", bus, device);
if (!dvp->pd_device_id) {
int data = pci_conf_read(tag, PCI_CLASS_REV_REG);
enum pci_majclass class = PCI_MAJCLASS_OF(data);
vm_offset_t va;
vm_offset_t pa;
int reg;
switch(class) {
case PCI_MJC_OLD:
if(PCI_MINCLASS_OF(data) != PCI_MIN_OVGA)
break;
case PCI_MJC_DISPLAY:
for (reg = PCI_MAP_REG_START;
reg < PCI_MAP_REG_END;
reg += 4) {
data = pci_map_mem(tag, reg, &va, &pa);
if(data == 0)
printf(
"pci%d:%d: mapped VGA-like device at physaddr %lx\n",
bus, device, (u_long)pa);
}
continue;
default:
#ifndef PCI_QUIET
if (!drp) {
not_supported (tag, type);
continue;
};
printf("pci%d:%d: ", bus, device);
not_supported (tag, type);
#endif
}
}
if (!drp) {
if(dvp->pd_flags & PDF_LOADABLE) {
printf("%s: loadable device on pci%d:%d\n",
dvp->pd_name, bus, device);
}
continue;
}
/*
** found it.
** probe returns the device unit.
*/
printf ("<%s>", drp -> vendor);
unit = (*drp->probe) (tag);
if (unit<0) {
printf (" probe failed.\n");
printf ("%s <%s>: probe failed on pci%d:%d\n",
drp->name, drp->vendor, bus, device);
continue;
};
if (drp->name) {
printf ("%s%d <%s>", drp->name, unit, drp->vendor);
} else {
printf ("pci%d: <%s>", bus, drp->vendor);
}
/*
** install interrupts
*/
@ -337,8 +372,8 @@ void pci_configure()
for (idx = 0; idx < NPCI; idx++) {
if (pcidata[idx].isanum == isanum)
break;
};
};
}
}
/*
** Or believe to the interrupt pin register.
@ -362,8 +397,8 @@ void pci_configure()
pcidata[idx].number=entry;
} else {
printf (" not installed");
};
};
}
}
/*
** enable memory access
@ -372,19 +407,20 @@ void pci_configure()
& 0xffff | PCI_COMMAND_MEM_ENABLE;
pci_conf_write (tag, (u_char) PCI_COMMAND_STATUS_REG, data);
printf (" on pci%d:%d\n", bus, device);
/*
** attach device
** may produce additional log messages,
** i.e. when installing subdevices.
*/
printf (" as %s%d\n", drp->name,unit);
(void) (*drp->attach) (tag);
}
};
printf ("pci uses physical addresses from %x to %x\n",
PCI_PMEM_START, pci_paddr);
#ifndef PCI_QUIET
printf ("pci uses physical addresses from %lx to %lx\n",
(u_long)PCI_PMEM_START, (u_long)pci_paddr);
#endif
}
/*-----------------------------------------------------------------------
@ -455,24 +491,8 @@ int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa)
vsize = round_page (-(data & PCI_MAP_MEMORY_ADDRESS_MASK));
printf (" memory size=0x%x", vsize);
if (!vsize) return (EINVAL);
/*
** try to map device to virtual space
*/
vaddr = vm_map_min (kernel_map);
result = vm_map_find (kernel_map, (void*)0, (vm_offset_t) 0,
&vaddr, vsize, TRUE);
if (result != KERN_SUCCESS) {
printf (" vm_map_find failed(%d)\n", result);
return (ENOMEM);
};
/*
** align physical address to virtual size
*/
@ -480,11 +500,16 @@ int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa)
if (data = pci_paddr % vsize)
pci_paddr += vsize - data;
vaddr = pmap_mapdev (pci_paddr, vsize);
#if 0
/*
** display values.
*/
printf (" virtual=0x%x physical=0x%x\n", vaddr, pci_paddr);
printf (" virtual=0x%lx physical=0x%lx\n", (u_long)vaddr,
(u_long)pci_paddr);
#endif
/*
** return them to the driver
@ -499,18 +524,6 @@ int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa)
pci_conf_write (tag, reg, pci_paddr);
/*
** map physical
*/
while (vsize >= NBPG) {
pmap_enter (pmap_kernel(), vaddr, pci_paddr,
VM_PROT_READ|VM_PROT_WRITE, TRUE);
vaddr += NBPG;
pci_paddr += NBPG;
vsize -= NBPG;
};
return (0);
}
@ -542,6 +555,11 @@ static struct dt DeviceTable[] = {
{0x04A38086, " 82434LX pci cache memory controller"},
{0,0}
};
static const char *const majclasses[] = {
"old", "storage", "network", "display", "multimedia", "memory",
"bridge"
};
void not_supported (pcici_t tag, u_long type)
{
@ -567,10 +585,14 @@ void not_supported (pcici_t tag, u_long type)
*/
if (vp->ident) printf (vp->name);
else printf ("vendor=%x", type & 0xffff);
else printf ("vendor=%lx", type & 0xffff);
if (dp->ident) printf (dp->name);
else printf (", device=%x", type >> 16);
else printf (", device=%lx", type >> 16);
data = pci_conf_read(tag, PCI_CLASS_REV_REG);
if (PCI_MAJCLASS_OF(data) < sizeof(majclasses) / sizeof(majclasses[0]))
printf(", class=%s", majclasses[PCI_MAJCLASS_OF(data)]);
printf (" [not supported]\n");
@ -581,18 +603,18 @@ void not_supported (pcici_t tag, u_long type)
case 1:
case 5:
printf (" map(%x): io(%x)\n", reg, data & ~3);
printf (" map(%lx): io(%lx)\n", reg, data & ~3);
break;
case 0:
printf (" map(%x): mem32(%x)\n", reg, data & ~7);
printf (" map(%lx): mem32(%lx)\n", reg, data & ~7);
break;
case 2:
printf (" map(%x): mem20(%x)\n", reg, data & ~7);
printf (" map(%lx): mem20(%lx)\n", reg, data & ~7);
break;
case 4:
printf (" map(%x): mem64(%x)\n", reg, data & ~7);
printf (" map(%lx): mem64(%lx)\n", reg, data & ~7);
break;
};
};
}
}
}
#endif