summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/aic7870.c14
-rw-r--r--sys/dev/pci/files.pci24
-rw-r--r--sys/dev/pci/if_de.c95
-rw-r--r--sys/dev/pci/if_fpa.c4
-rw-r--r--sys/dev/pci/ncr.c79
-rw-r--r--sys/dev/pci/ncrstat.c16
-rw-r--r--sys/dev/pci/pci.c170
-rw-r--r--sys/dev/pci/pcidevs8
-rw-r--r--sys/dev/pci/pcidevs.h3
-rw-r--r--sys/dev/pci/pcidevs_data.h18
-rw-r--r--sys/dev/pci/pcireg.h37
-rw-r--r--sys/dev/pci/pcivar.h75
-rw-r--r--sys/dev/pci/ppb.c39
13 files changed, 454 insertions, 128 deletions
diff --git a/sys/dev/pci/aic7870.c b/sys/dev/pci/aic7870.c
index b481014d4f0..0c91a4d8dcb 100644
--- a/sys/dev/pci/aic7870.c
+++ b/sys/dev/pci/aic7870.c
@@ -1,4 +1,4 @@
-/* $NetBSD: aic7870.c,v 1.7 1996/03/04 19:30:50 cgd Exp $ */
+/* $NetBSD: aic7870.c,v 1.8 1996/03/17 00:55:23 thorpej Exp $ */
/*
* Product specific probe and attach routines for:
@@ -45,9 +45,12 @@
static int aic7870_probe __P((struct device *, void *, void *));
static void aic7870_attach __P((struct device *, struct device *, void *));
-struct cfdriver ahccd = {
- NULL, "ahc", aic7870_probe, aic7870_attach, DV_DULL,
- sizeof(struct ahc_softc)
+struct cfattach ahc_ca = {
+ sizeof(struct ahc_softc), aic7870_probe, aic7870_attach
+};
+
+struct cfdriver ahc_cd = {
+ NULL, "ahc", DV_DULL
};
int ahcintr __P((void *));
@@ -106,6 +109,5 @@ aic7870_attach(parent, self, aux)
ahcattach(ahc);
- ahc->sc_ih = pci_map_int(pa->pa_tag, IPL_BIO, ahcintr, ahc,
- ahc->sc_dev.dv_xname);
+ ahc->sc_ih = pci_map_int(pa->pa_tag, IPL_BIO, ahcintr, ahc);
}
diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci
index b1eaca631c6..149d0d98785 100644
--- a/sys/dev/pci/files.pci
+++ b/sys/dev/pci/files.pci
@@ -1,30 +1,36 @@
-# $OpenBSD: files.pci,v 1.3 1996/04/18 23:47:55 niklas Exp $
-# $NetBSD: files.pci,v 1.12 1996/03/04 03:29:19 cgd Exp $
+# $OpenBSD: files.pci,v 1.4 1996/04/21 22:25:06 deraadt Exp $
+# $NetBSD: files.pci,v 1.13 1996/03/17 00:55:24 thorpej Exp $
#
-# Config file and device description for machine-independent PCI code.
+# Config.new file and device description for machine-independent PCI code.
# Included by ports that need it. Requires that the SCSI files be
# defined first.
-device pci at pcibus {[dev = -1], [function = -1]}
+device pci {[dev = -1], [function = -1]}
+attach pci at pcibus
file dev/pci/pci.c pci needs-flag
file dev/pci/pci_subr.c pci
# Adaptec 7870 chips
-device ahc at pci: scsi, aic7xxx
+device ahc: scsi, aic7xxx
+attach ahc at pci
file dev/pci/aic7870.c ahc
# Ethernet driver for DC21040-based boards
-device de at pci: ether, ifnet
+device de: ether, ifnet
+attach de at pci
file dev/pci/if_de.c de
# Digital DEFPA PCI FDDI Controller
-device fpa at pci: pdq, fddi, ifnet
+device fpa: pdq, fddi, ifnet
+attach fpa at pci
file dev/pci/if_fpa.c fpa
# NCR 53c8xx SCSI chips
-device ncr at pci: scsi
+device ncr: scsi
+attach ncr at pci
file dev/pci/ncr.c ncr
# PCI-PCI bridge chips
-device ppb at pci: pcibus
+device ppb: pcibus
+attach ppb at pci
file dev/pci/ppb.c ppb
diff --git a/sys/dev/pci/if_de.c b/sys/dev/pci/if_de.c
index fbddb089889..0eaa370660a 100644
--- a/sys/dev/pci/if_de.c
+++ b/sys/dev/pci/if_de.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: if_de.c,v 1.5 1996/04/18 23:47:56 niklas Exp $ */
-/* $NetBSD: if_de.c,v 1.13 1996/03/14 03:04:17 cgd Exp $ */
+/* $OpenBSD: if_de.c,v 1.6 1996/04/21 22:25:13 deraadt Exp $ */
+/* $NetBSD: if_de.c,v 1.17 1996/04/01 19:37:54 cgd Exp $ */
/*-
* Copyright (c) 1994, 1995 Matt Thomas (matt@lkg.dec.com)
@@ -109,12 +109,12 @@
#if defined(__NetBSD__)
#include <machine/bus.h>
+#ifdef __alpha__
+#include <machine/intr.h>
+#endif
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/ic/dc21040reg.h>
-#ifdef __i386__ /* XXX -- fix later -- cgd */
-#include <i386/isa/isa_machdep.h>
-#endif
#endif /* __NetBSD__ */
/*
@@ -141,9 +141,6 @@ typedef struct {
} tulip_ringinfo_t;
#ifdef TULIP_IOMAPPED
-#ifndef __NetBSD__
-#else
-#endif
#define TULIP_EISA_CSRSIZE 16
#define TULIP_PCI_CSRSIZE 8
@@ -317,7 +314,8 @@ struct _tulip_softc_t {
struct device tulip_dev; /* base device */
void *tulip_ih; /* intrrupt vectoring */
void *tulip_ats; /* shutdown hook */
- bus_chipset_tag_t tulip_bc; /* bus chipset tag */
+ bus_chipset_tag_t tulip_bc;
+ pci_chipset_tag_t tulip_pc;
#ifdef TULIP_IOMAPPED
bus_io_handle_t tulip_ioh; /* I/O region handle */
#else
@@ -385,8 +383,9 @@ extern struct cfdriver decd;
#if defined(__NetBSD__)
typedef void ifnet_ret_t;
typedef u_long ioctl_cmd_t;
-extern struct cfdriver decd;
-#define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) decd.cd_devs[unit])
+extern struct cfattach de_ca;
+extern struct cfdriver de_cd;
+#define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) de_cd.cd_devs[unit])
#endif
#ifndef TULIP_BURSTSIZE
@@ -416,6 +415,10 @@ static ifnet_ret_t tulip_start(struct ifnet *ifp);
static void tulip_rx_intr(tulip_softc_t *sc);
static void tulip_addr_filter(tulip_softc_t *sc);
+#if defined(__NetBSD__) && defined(__alpha__)
+/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
+#define vtophys(va) (vtophys(va) | 0x40000000)
+#endif
static int
tulip_dc21040_media_probe(
@@ -670,7 +673,7 @@ tulip_dc21140_de500_media_probe(
if ((TULIP_READ_CSR(sc, csr_gp) &
(TULIP_GP_DE500_NOTOK_100|TULIP_GP_DE500_NOTOK_10)) !=
(TULIP_GP_DE500_NOTOK_100|TULIP_GP_DE500_NOTOK_10))
- return (TULIP_READ_CSR(sc, csr_gp) & TULIP_GP_DE500_NOTOK_100) != 0;
+ return (TULIP_READ_CSR(sc, csr_gp) & TULIP_GP_DE500_NOTOK_100) == 0;
TULIP_WRITE_CSR(sc, csr_gp,
TULIP_GP_DE500_HALFDUPLEX|TULIP_GP_DE500_FORCE_100);
TULIP_WRITE_CSR(sc, csr_command,
@@ -679,7 +682,7 @@ tulip_dc21140_de500_media_probe(
TULIP_WRITE_CSR(sc, csr_command,
TULIP_READ_CSR(sc, csr_command) & ~TULIP_CMD_TXTHRSHLDCTL);
DELAY(1000000);
- return (TULIP_READ_CSR(sc, csr_gp) & TULIP_GP_DE500_NOTOK_100) != 0;
+ return (TULIP_READ_CSR(sc, csr_gp) & TULIP_GP_DE500_NOTOK_100) == 0;
}
static void
@@ -1189,10 +1192,10 @@ tulip_rx_intr(
#error BIG_PACKET is incompatible with TULIP_COPY_RXDATA
#endif
if (ms == me)
- bcopy(mtod(m, caddr_t) + sizeof(struct ether_header),
+/*XXX?*/ bcopy(mtod(ms, caddr_t) + sizeof(struct ether_header),
mtod(m0, caddr_t), total_len);
else
- m_copydata(m, 0, total_len, mtod(m0, caddr_t));
+/*XXX?*/ m_copydata(ms, 0, total_len, mtod(m0, caddr_t));
m0->m_len = m0->m_pkthdr.len = total_len;
m0->m_pkthdr.rcvif = ifp;
ether_input(ifp, &eh, m0);
@@ -2406,8 +2409,12 @@ tulip_pci_probe(
static void tulip_pci_attach(TULIP_PCI_ATTACH_ARGS);
-struct cfdriver decd = {
- 0, "de", tulip_pci_probe, tulip_pci_attach, DV_IFNET, sizeof(tulip_softc_t)
+struct cfattach de_ca = {
+ sizeof(tulip_softc_t), tulip_pci_probe, tulip_pci_attach
+};
+
+struct cfdriver de_cd = {
+ 0, "de", DV_IFNET
};
#endif /* __NetBSD__ */
@@ -2428,10 +2435,20 @@ tulip_pci_attach(
#if defined(__NetBSD__)
tulip_softc_t * const sc = (tulip_softc_t *) self;
struct pci_attach_args * const pa = (struct pci_attach_args *) aux;
+ bus_chipset_tag_t bc = pa->pa_bc;
+ pci_chipset_tag_t pc = pa->pa_pc;
+#if defined(TULIP_IOMAPPED)
+ bus_io_addr_t iobase;
+ bus_io_size_t iosize;
+#else
+ bus_mem_addr_t membase;
+ bus_mem_size_t memsize;
+#endif
int unit = sc->tulip_dev.dv_unit;
+ const char *intrstr = NULL;
#endif
int retval, idx, revinfo, id;
-#if !defined(TULIP_IOMAPPED) && !defined(__bsdi__)
+#if !defined(TULIP_IOMAPPED) && !defined(__bsdi__) && !defined(__NetBSD__)
vm_offset_t pa_csrs;
#endif
unsigned csrsize = TULIP_PCI_CSRSIZE;
@@ -2464,7 +2481,7 @@ tulip_pci_attach(
}
#endif
#if defined(__NetBSD__)
- revinfo = pci_conf_read(pa->pa_tag, PCI_CFRV) & 0xFF;
+ revinfo = pci_conf_read(pc, pa->pa_tag, PCI_CFRV) & 0xFF;
id = pa->pa_id;
#endif
@@ -2546,11 +2563,17 @@ tulip_pci_attach(
#endif /* __bsdi__ */
#if defined(__NetBSD__)
- sc->tulip_bc = pa->pa_bc;
+ sc->tulip_bc = bc;
+ sc->tulip_pc = pc;
#if defined(TULIP_IOMAPPED)
- retval = pci_map_io(pa->pa_tag, PCI_CBIO, &sc->tulip_ioh);
+ retval = pci_io_find(pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize);
+ if (!retval)
+ retval = bus_io_map(bc, iobase, iosize, &sc->tulip_ioh);
#else
- retval = pci_map_mem(pa->pa_tag, PCI_CBMA, &sc->tulip_memh, &pa_csrs);
+ retval = pci_mem_find(pc, pa->pa_tag, PCI_CBMA, &membase, &memsize,
+ NULL);
+ if (!retval)
+ retval = bus_mem_map(bc, membase, memsize, 0, &sc->tulip_memh);
#endif
csr_base = 0;
if (retval) {
@@ -2587,21 +2610,27 @@ tulip_pci_attach(
bit longer anyways) */
#if defined(__NetBSD__)
if (sc->tulip_boardsw->bd_type != TULIP_DC21040_ZX314_SLAVE) {
- sc->tulip_ih = pci_map_int(pa->pa_tag, IPL_NET, tulip_intr, sc,
- sc->tulip_dev.dv_xname);
+ pci_intr_handle_t intrhandle;
+
+ if (pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin,
+ pa->pa_intrline, &intrhandle)) {
+ printf(": couldn't map interrupt\n", self->dv_xname);
+ return;
+ }
+ intrstr = pci_intr_string(pc, intrhandle);
+ sc->tulip_ih = pci_intr_establish(pc, intrhandle, IPL_NET,
+ tulip_intr, sc, self->dv_xname);
if (sc->tulip_ih == NULL) {
- printf("%s%d: couldn't map interrupt\n",
- sc->tulip_name, sc->tulip_unit);
+ printf(": couldn't establish interrupt", self->dv_xname);
+ if (intrstr != NULL)
+ printf(" at %s", intrstr);
+ printf("\n");
return;
}
-#if defined(__i386__)
- /* gross but netbsd won't print the irq otherwise */
- printf(" irq %d", ((struct intrhand *) sc->tulip_ih)->ih_irq);
-#endif
}
sc->tulip_ats = shutdownhook_establish(tulip_pci_shutdown, sc);
if (sc->tulip_ats == NULL)
- printf("%s%d: warning: couldn't establish shutdown hook\n",
+ printf("\n%s%d: warning: couldn't establish shutdown hook",
sc->tulip_name, sc->tulip_unit);
#endif
#if defined(__FreeBSD__)
@@ -2628,6 +2657,10 @@ tulip_pci_attach(
#endif
tulip_reset(sc);
tulip_attach(sc);
+#if defined(__NetBSD__)
+ if (intrstr != NULL)
+ printf("%s: interrupting at %s\n", self->dv_xname, intrstr);
+#endif
}
}
#endif /* NDE > 0 */
diff --git a/sys/dev/pci/if_fpa.c b/sys/dev/pci/if_fpa.c
index c9451163c5c..eb6be356f02 100644
--- a/sys/dev/pci/if_fpa.c
+++ b/sys/dev/pci/if_fpa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_fpa.c,v 1.4 1996/04/18 23:47:58 niklas Exp $ */
+/* $OpenBSD: if_fpa.c,v 1.5 1996/04/21 22:25:19 deraadt Exp $ */
/* $NetBSD: if_fpa.c,v 1.7 1996/03/17 00:55:30 thorpej Exp $ */
/*-
@@ -389,7 +389,7 @@ pdq_pci_attach(
sc->sc_ih.ih_fun = pdq_pci_ifintr;
sc->sc_ih.ih_arg = (void *)sc;
- intr_establish(ia->ia_irq, &sc->sc_ih, DV_NET);
+ intr_establish(ia->ia_irq, &sc->sc_ih, DV_NET, sc->sc_dv.dv_xname);
sc->sc_ats.func = (void (*)(void *)) pdq_hwreset;
sc->sc_ats.arg = (void *) sc->sc_pdq;
diff --git a/sys/dev/pci/ncr.c b/sys/dev/pci/ncr.c
index d96230821b1..d98f8d2b3d7 100644
--- a/sys/dev/pci/ncr.c
+++ b/sys/dev/pci/ncr.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ncr.c,v 1.6 1996/04/18 23:47:59 niklas Exp $ */
-/* $NetBSD: ncr.c,v 1.29 1996/03/14 05:21:20 cgd Exp $ */
+/* $OpenBSD: ncr.c,v 1.7 1996/04/21 22:25:22 deraadt Exp $ */
+/* $NetBSD: ncr.c,v 1.33 1996/04/03 08:44:15 mycroft Exp $ */
/**************************************************************************
**
@@ -195,10 +195,15 @@ extern PRINT_ADDR();
#else
#include <sys/device.h>
#include <machine/bus.h>
+#ifdef __alpha__
+#include <machine/intr.h>
+#endif
#include <dev/pci/ncr_reg.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#ifndef __alpha__
#define DELAY(x) delay(x)
+#endif
#endif /* __NetBSD__ */
#include <scsi/scsi_all.h>
@@ -207,6 +212,10 @@ extern PRINT_ADDR();
#include <machine/clock.h>
#endif /* __NetBSD__ */
+#if defined(__NetBSD__) && defined(__alpha__)
+/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
+#define vtophys(va) (vtophys(va) | 0x40000000)
+#endif
/*==========================================================
**
@@ -991,6 +1000,7 @@ struct ncb {
struct device sc_dev;
void *sc_ih;
bus_chipset_tag_t sc_bc;
+ pci_chipset_tag_t sc_pc;
#ifdef NCR_IOMAPPED
bus_io_handle_t sc_ioh;
#else /* !NCR_IOMAPPED */
@@ -1320,7 +1330,7 @@ static void ncr_attach (pcici_t tag, int unit);
static char ident[] =
- "\n$NetBSD: ncr.c,v 1.29 1996/03/14 05:21:20 cgd Exp $\n";
+ "\n$NetBSD: ncr.c,v 1.33 1996/04/03 08:44:15 mycroft Exp $\n";
u_long ncr_version = NCR_VERSION * 11
+ (u_long) sizeof (struct ncb) * 7
@@ -1357,8 +1367,12 @@ int ncr_cache; /* to be aligned _NOT_ static */
#ifdef __NetBSD__
-struct cfdriver ncrcd = {
- NULL, "ncr", ncr_probe, ncr_attach, DV_DULL, sizeof(struct ncb)
+struct cfattach ncr_ca = {
+ sizeof(struct ncb), ncr_probe, ncr_attach
+};
+
+struct cfdriver ncr_cd = {
+ NULL, "ncr", DV_DULL
};
#else /* !__NetBSD__ */
@@ -3326,8 +3340,14 @@ static char* ncr_probe (pcici_t tag, pcidi_t type)
#ifdef __NetBSD__
int
-ncr_print()
+ncr_print(aux, name)
+ void *aux;
+ char *name;
{
+
+ if (name != NULL)
+ printf("%s: scsibus ", name);
+ return UNCONF;
}
void
@@ -3336,7 +3356,12 @@ ncr_attach(parent, self, aux)
void *aux;
{
struct pci_attach_args *pa = aux;
- int retval;
+ bus_chipset_tag_t bc = pa->pa_bc;
+ pci_chipset_tag_t pc = pa->pa_pc;
+ bus_mem_size_t memsize;
+ int retval, cacheable;
+ pci_intr_handle_t intrhandle;
+ const char *intrstr;
ncb_p np = (void *)self;
printf(": NCR ");
@@ -3362,21 +3387,49 @@ ncr_attach(parent, self, aux)
}
printf(" SCSI\n");
+ np->sc_bc = bc;
+ np->sc_pc = pc;
+
/*
** Try to map the controller chip to
** virtual and physical memory.
*/
- retval = pci_map_mem(pa->pa_tag, 0x14, (vm_offset_t *)&np->sc_memh,
- &np->paddr);
- if (retval)
+ retval = pci_mem_find(pc, pa->pa_tag, 0x14, &np->paddr,
+ &memsize, &cacheable);
+ if (retval) {
+ printf("%s: couldn't find memory region\n", self->dv_xname);
return;
+ }
- np->sc_ih = pci_map_int(pa->pa_tag, IPL_BIO, ncr_intr, np,
- np->sc_dev.dv_xname);
- if (np->sc_ih == NULL)
+ /* Map the memory. Note that we never want it to be cacheable. */
+ retval = bus_mem_map(pa->pa_bc, np->paddr, memsize, 0, &np->sc_memh);
+ if (retval) {
+ printf("%s: couldn't map memory region\n", self->dv_xname);
return;
+ }
+ /*
+ ** Set up the controller chip's interrupt.
+ */
+ retval = pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin,
+ pa->pa_intrline, &intrhandle);
+ if (retval) {
+ printf("%s: couldn't map interrupt\n", self->dv_xname);
+ return;
+ }
+ intrstr = pci_intr_string(pc, intrhandle);
+ np->sc_ih = pci_intr_establish(pc, intrhandle, IPL_BIO,
+ ncr_intr, np, self->dv_xname);
+ if (np->sc_ih == NULL) {
+ printf("%s: couldn't establish interrupt", self->dv_xname);
+ if (intrstr != NULL)
+ printf(" at %s", intrstr);
+ printf("\n");
+ return;
+ }
+ if (intrstr != NULL)
+ printf("%s: interrupting at %s\n", self->dv_xname, intrstr);
#else /* !__NetBSD__ */
diff --git a/sys/dev/pci/ncrstat.c b/sys/dev/pci/ncrstat.c
index 37374c88b38..6925cd42352 100644
--- a/sys/dev/pci/ncrstat.c
+++ b/sys/dev/pci/ncrstat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ncrstat.c,v 1.6 1995/01/27 05:44:31 cgd Exp $ */
+/* $NetBSD: ncrstat.c,v 1.7 1996/03/17 00:55:36 thorpej Exp $ */
/**************************************************************************
**
@@ -92,7 +92,7 @@ struct nlist nl[] = {
{ "_ncr_version" },
#ifdef __NetBSD__
#define N_NCRCD 1
- { "_ncrcd" },
+ { "_ncr_cd" },
#else
#define N_NCRP 1
{ "_ncrp" },
@@ -114,7 +114,7 @@ u_long ccb_base;
u_long ncr_unit;
#ifdef __NetBSD__
-struct cfdriver ncrcd;
+struct cfdriver ncr_cd;
#else
u_long ncr_units;
#endif
@@ -224,20 +224,20 @@ void open_kvm(int flags)
if (!KVM_READ (
nl[N_NCRCD].n_value,
- &ncrcd,
- sizeof (ncrcd))) {
+ &ncr_cd,
+ sizeof (ncr_cd))) {
fprintf (stderr, "%s: bad kvm read.\n", prog);
exit (1);
};
- if (ncr_unit >= ncrcd.cd_ndevs){
+ if (ncr_unit >= ncr_cd.cd_ndevs){
fprintf (stderr, "%s: bad unit number (valid range: 0-%d).\n",
- prog, ncrcd.cd_ndevs-1);
+ prog, ncr_cd.cd_ndevs-1);
exit (1);
};
if (!KVM_READ (
- ncrcd.cd_devs+4*ncr_unit,
+ ncr_cd.cd_devs+4*ncr_unit,
&ncr_base,
sizeof (ncr_base))) {
fprintf (stderr, "%s: bad kvm read.\n", prog);
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index e5e770a5242..1e69d44b454 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: pci.c,v 1.1 1996/04/18 23:48:02 niklas Exp $ */
-/* $NetBSD: pci.c,v 1.15 1996/03/14 04:03:01 cgd Exp $ */
+/* $OpenBSD: pci.c,v 1.2 1996/04/21 22:25:34 deraadt Exp $ */
+/* $NetBSD: pci.c,v 1.18 1996/03/27 04:08:24 cgd Exp $ */
/*
* Copyright (c) 1995, 1996 Christopher G. Demetriou. All rights reserved.
@@ -45,8 +45,12 @@
int pcimatch __P((struct device *, void *, void *));
void pciattach __P((struct device *, struct device *, void *));
-struct cfdriver pcicd = {
- NULL, "pci", pcimatch, pciattach, DV_DULL, sizeof(struct device)
+struct cfattach pci_ca = {
+ sizeof(struct device), pcimatch, pciattach
+};
+
+struct cfdriver pci_cd = {
+ NULL, "pci", DV_DULL
};
int pciprint __P((void *, char *));
@@ -86,39 +90,70 @@ pciattach(parent, self, aux)
{
struct pcibus_attach_args *pba = aux;
bus_chipset_tag_t bc;
- int device, function, nfunctions;
+ pci_chipset_tag_t pc;
+ int bus, device, maxndevs, function, nfunctions;
- pci_md_attach_hook(parent, self, pba);
+ pci_attach_hook(parent, self, pba);
printf("\n");
- for (device = 0; device < PCI_MAX_DEVICE_NUMBER; device++) {
+ bc = pba->pba_bc;
+ pc = pba->pba_pc;
+ bus = pba->pba_bus;
+ maxndevs = pci_bus_maxdevs(pc, bus);
+
+ for (device = 0; device < maxndevs; device++) {
pcitag_t tag;
- pcireg_t id, class;
+ pcireg_t id, class, intr, bhlcr;
struct pci_attach_args pa;
struct cfdata *cf;
- int supported;
+ int supported, pin;
- tag = pci_make_tag(pba->pba_bus, device, 0);
- id = pci_conf_read(tag, PCI_ID_REG);
+ tag = pci_make_tag(pc, bus, device, 0);
+ id = pci_conf_read(pc, tag, PCI_ID_REG);
if (id == 0 || id == 0xffffffff)
continue;
- nfunctions = 1; /* XXX */
+ bhlcr = pci_conf_read(pc, tag, PCI_BHLC_REG);
+ nfunctions = PCI_HDRTYPE_MULTIFN(bhlcr) ? 8 : 1;
for (function = 0; function < nfunctions; function++) {
- tag = pci_make_tag(pba->pba_bus, device, function);
- id = pci_conf_read(tag, PCI_ID_REG);
+ tag = pci_make_tag(pc, bus, device, function);
+ id = pci_conf_read(pc, tag, PCI_ID_REG);
if (id == 0 || id == 0xffffffff)
continue;
- class = pci_conf_read(tag, PCI_CLASS_REG);
+ class = pci_conf_read(pc, tag, PCI_CLASS_REG);
+ intr = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
- pa.pa_bc = pba->pba_bc;
+ pa.pa_bc = bc;
+ pa.pa_pc = pc;
pa.pa_device = device;
pa.pa_function = function;
pa.pa_tag = tag;
pa.pa_id = id;
pa.pa_class = class;
+ if (bus == 0) {
+ pa.pa_intrswiz = 0;
+ pa.pa_intrtag = tag;
+ } else {
+ pa.pa_intrswiz = pba->pba_intrswiz + device;
+ pa.pa_intrtag = pba->pba_intrtag;
+ }
+ pin = PCI_INTERRUPT_PIN(intr);
+ if (pin == PCI_INTERRUPT_PIN_NONE) {
+ /* no interrupt */
+ pa.pa_intrpin = 0;
+ } else {
+ /*
+ * swizzle it based on the number of
+ * busses we're behind and our device
+ * number.
+ */
+ pa.pa_intrpin = /* XXX */
+ ((pin + pa.pa_intrswiz - 1) % 4) + 1;
+ }
+ pa.pa_intrline = PCI_INTERRUPT_LINE(intr);
+
config_found_sm(self, &pa, pciprint, pcisubmatch);
}
}
@@ -154,5 +189,106 @@ pcisubmatch(parent, match, aux)
if (cf->pcicf_function != PCI_UNK_FUNCTION &&
cf->pcicf_function != pa->pa_function)
return 0;
- return ((*cf->cf_driver->cd_match)(parent, match, aux));
+ return ((*cf->cf_attach->ca_match)(parent, match, aux));
+}
+
+int
+pci_io_find(pc, pcitag, reg, iobasep, iosizep)
+ pci_chipset_tag_t pc;
+ pcitag_t pcitag;
+ int reg;
+ bus_io_addr_t *iobasep;
+ bus_io_size_t *iosizep;
+{
+ pcireg_t addrdata, sizedata;
+ int s;
+
+ if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3))
+ panic("pci_io_find: bad request");
+
+ /* XXX?
+ * Section 6.2.5.1, `Address Maps', tells us that:
+ *
+ * 1) The builtin software should have already mapped the device in a
+ * reasonable way.
+ *
+ * 2) A device which wants 2^n bytes of memory will hardwire the bottom
+ * n bits of the address to 0. As recommended, we write all 1s and see
+ * what we get back.
+ */
+ addrdata = pci_conf_read(pc, pcitag, reg);
+
+ s = splhigh();
+ pci_conf_write(pc, pcitag, reg, 0xffffffff);
+ sizedata = pci_conf_read(pc, pcitag, reg);
+ pci_conf_write(pc, pcitag, reg, addrdata);
+ splx(s);
+
+ if (PCI_MAPREG_TYPE(addrdata) != PCI_MAPREG_TYPE_IO)
+ panic("pci_io_find: not an I/O region");
+
+ if (iobasep != NULL)
+ *iobasep = PCI_MAPREG_IO_ADDR(addrdata);
+ if (iosizep != NULL)
+ *iosizep = ~PCI_MAPREG_IO_ADDR(sizedata) + 1;
+
+ return (0);
+}
+
+int
+pci_mem_find(pc, pcitag, reg, membasep, memsizep, cacheablep)
+ pci_chipset_tag_t pc;
+ pcitag_t pcitag;
+ int reg;
+ bus_mem_addr_t *membasep;
+ bus_mem_size_t *memsizep;
+ int *cacheablep;
+{
+ pcireg_t addrdata, sizedata;
+ int s;
+
+ if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3))
+ panic("pci_find_mem: bad request");
+
+ /*
+ * Section 6.2.5.1, `Address Maps', tells us that:
+ *
+ * 1) The builtin software should have already mapped the device in a
+ * reasonable way.
+ *
+ * 2) A device which wants 2^n bytes of memory will hardwire the bottom
+ * n bits of the address to 0. As recommended, we write all 1s and see
+ * what we get back.
+ */
+ addrdata = pci_conf_read(pc, pcitag, reg);
+
+ s = splhigh();
+ pci_conf_write(pc, pcitag, reg, 0xffffffff);
+ sizedata = pci_conf_read(pc, pcitag, reg);
+ pci_conf_write(pc, pcitag, reg, addrdata);
+ splx(s);
+
+ if (PCI_MAPREG_TYPE(addrdata) == PCI_MAPREG_TYPE_IO)
+ panic("pci_find_mem: I/O region");
+
+ switch (PCI_MAPREG_MEM_TYPE(addrdata)) {
+ case PCI_MAPREG_MEM_TYPE_32BIT:
+ case PCI_MAPREG_MEM_TYPE_32BIT_1M:
+ break;
+ case PCI_MAPREG_MEM_TYPE_64BIT:
+/* XXX */ printf("pci_find_mem: 64-bit region\n");
+/* XXX */ return (1);
+ default:
+ printf("pci_find_mem: reserved region type\n");
+ return (1);
+ }
+
+ if (membasep != NULL)
+ *membasep = PCI_MAPREG_MEM_ADDR(addrdata); /* PCI addr */
+ if (memsizep != NULL)
+ *memsizep = ~PCI_MAPREG_MEM_ADDR(sizedata) + 1;
+ if (cacheablep != NULL)
+ *cacheablep = PCI_MAPREG_MEM_CACHEABLE(addrdata);
+
+ return 0;
}
diff --git a/sys/dev/pci/pcidevs b/sys/dev/pci/pcidevs
index 8dedc4d7b67..29c507c824b 100644
--- a/sys/dev/pci/pcidevs
+++ b/sys/dev/pci/pcidevs
@@ -1,5 +1,6 @@
-$OpenBSD: pcidevs,v 1.6 1996/04/18 23:48:04 niklas Exp $
-/* $NetBSD: pcidevs,v 1.6 1996/02/19 20:08:25 christos Exp $ */
+$OpenBSD: pcidevs,v 1.7 1996/04/21 22:25:38 deraadt Exp $
+/* $NetBSD: pcidevs,v 1.7 1996/04/04 21:46:33 mycroft Exp $ */
+
/*
* Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -468,6 +469,9 @@ product OLDNCR 810 0x0001 53c810
product OLDNCR 820 0x0002 53c820
product OLDNCR 825 0x0003 53c825
product OLDNCR 815 0x0004 53c815
+product OLDNCR 810AP 0x0005 53c810AP
+product OLDNCR 860 0x0006 53c860
+product OLDNCR 875 0x000f 53c875
/* do the NCR chips use the new ID, as well? */
/* Number Nine products */
diff --git a/sys/dev/pci/pcidevs.h b/sys/dev/pci/pcidevs.h
index f5c48baa207..0e86ed3cd96 100644
--- a/sys/dev/pci/pcidevs.h
+++ b/sys/dev/pci/pcidevs.h
@@ -473,6 +473,9 @@
#define PCI_PRODUCT_OLDNCR_820 0x0002 /* 53c820 */
#define PCI_PRODUCT_OLDNCR_825 0x0003 /* 53c825 */
#define PCI_PRODUCT_OLDNCR_815 0x0004 /* 53c815 */
+#define PCI_PRODUCT_OLDNCR_810AP 0x0005 /* 53c810AP */
+#define PCI_PRODUCT_OLDNCR_860 0x0006 /* 53c860 */
+#define PCI_PRODUCT_OLDNCR_875 0x000f /* 53c875 */
/* do the NCR chips use the new ID, as well? */
/* Number Nine products */
diff --git a/sys/dev/pci/pcidevs_data.h b/sys/dev/pci/pcidevs_data.h
index b55e1510a05..c9858b6d554 100644
--- a/sys/dev/pci/pcidevs_data.h
+++ b/sys/dev/pci/pcidevs_data.h
@@ -267,6 +267,24 @@ struct pci_knowndev pci_knowndevs[] = {
"53c815",
},
{
+ PCI_VENDOR_OLDNCR, PCI_PRODUCT_OLDNCR_810AP,
+ 0,
+ "NCR",
+ "53c810AP",
+ },
+ {
+ PCI_VENDOR_OLDNCR, PCI_PRODUCT_OLDNCR_860,
+ 0,
+ "NCR",
+ "53c860",
+ },
+ {
+ PCI_VENDOR_OLDNCR, PCI_PRODUCT_OLDNCR_875,
+ 0,
+ "NCR",
+ "53c875",
+ },
+ {
PCI_VENDOR_NUMBER9, PCI_PRODUCT_NUMBER9_IMAG128,
0,
"Number 9 Computer Company",
diff --git a/sys/dev/pci/pcireg.h b/sys/dev/pci/pcireg.h
index 1422e846559..fab00dfa6fb 100644
--- a/sys/dev/pci/pcireg.h
+++ b/sys/dev/pci/pcireg.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: pcireg.h,v 1.2 1996/04/18 23:48:07 niklas Exp $ */
-/* $NetBSD: pcireg.h,v 1.5 1996/03/04 19:30:51 cgd Exp $ */
+/* $OpenBSD: pcireg.h,v 1.3 1996/04/21 22:25:49 deraadt Exp $ */
+/* $NetBSD: pcireg.h,v 1.7 1996/03/27 04:08:27 cgd Exp $ */
/*
* Copyright (c) 1995, 1996 Christopher G. Demetriou. All rights reserved.
@@ -31,6 +31,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _DEV_PCI_PCIREG_H_
+#define _DEV_PCI_PCIREG_H_
+
/*
* Standardized PCI configuration information
*
@@ -165,6 +168,34 @@ typedef u_int8_t pci_revision_t;
#define PCI_SUBCLASS_BRIDGE_MISC 0x80
/*
+ * PCI BIST/Header Type/Latency Timer/Cache Line Size Register.
+ */
+#define PCI_BHLC_REG 0x0c
+
+#define PCI_BIST_SHIFT 24
+#define PCI_BIST_MASK 0xff
+#define PCI_BIST(bhlcr) \
+ (((bhlcr) >> PCI_BIST_SHIFT) & PCI_BIST_MASK)
+
+#define PCI_HDRTYPE_SHIFT 24
+#define PCI_HDRTYPE_MASK 0xff
+#define PCI_HDRTYPE(bhlcr) \
+ (((bhlcr) >> PCI_HDRTYPE_SHIFT) & PCI_HDRTYPE_MASK)
+
+#define PCI_HDRTYPE_MULTIFN(bhlcr) \
+ ((PCI_HDRTYPE(bhlcr) & 0x80) != 0)
+
+#define PCI_LATTIMER_SHIFT 24
+#define PCI_LATTIMER_MASK 0xff
+#define PCI_LATTIMER(bhlcr) \
+ (((bhlcr) >> PCI_LATTIMER_SHIFT) & PCI_LATTIMER_MASK)
+
+#define PCI_CACHELINE_SHIFT 24
+#define PCI_CACHELINE_MASK 0xff
+#define PCI_CACHELINE(bhlcr) \
+ (((bhlcr) >> PCI_CACHELINE_SHIFT) & PCI_CACHELINE_MASK)
+
+/*
* Mapping registers
*/
#define PCI_MAPREG_START 0x10
@@ -220,3 +251,5 @@ typedef u_int8_t pci_intr_line_t;
#define PCI_INTERRUPT_PIN_B 0x02
#define PCI_INTERRUPT_PIN_C 0x03
#define PCI_INTERRUPT_PIN_D 0x04
+
+#endif /* _DEV_PCI_PCIREG_H_ */
diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h
index 659a87ed6db..42c170f4971 100644
--- a/sys/dev/pci/pcivar.h
+++ b/sys/dev/pci/pcivar.h
@@ -1,7 +1,8 @@
-/* $OpenBSD: pcivar.h,v 1.6 1996/04/18 23:48:08 niklas Exp $ */
-/* $NetBSD: pcivar.h,v 1.8 1995/06/18 01:26:50 cgd Exp $ */
+/* $OpenBSD: pcivar.h,v 1.7 1996/04/21 22:25:51 deraadt Exp $ */
+/* $NetBSD: pcivar.h,v 1.15 1996/03/28 02:16:23 cgd Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
* Copyright (c) 1994 Charles Hannum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,52 +39,73 @@
*
* This file describes types and functions which are used for PCI
* configuration. Some of this information is machine-specific, and is
- * separated into pci_machdep.h.
+ * provided by pci_machdep.h.
*/
#include <machine/bus.h>
+#include <dev/pci/pcireg.h>
+/*
+ * Structures and definitions needed by the machine-dependent header.
+ */
+typedef u_int32_t pcireg_t; /* configuration space register XXX */
+struct pcibus_attach_args;
+
+/*
+ * Machine-dependent definitions.
+ */
#if (alpha + i386 != 1)
ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE.
#endif
-
#if alpha
#include <alpha/pci/pci_machdep.h>
#endif
-
#if i386
#include <i386/pci/pci_machdep.h>
#endif
/*
- * The maximum number of devices on a PCI bus is 32. However, some
- * PCI chipsets (e.g. chipsets that implement 'Configuration Mechanism #2'
- * on the i386) can't deal with that many, so let pci_machdep.h override it.
- */
-#ifndef PCI_MAX_DEVICE_NUMBER
-#define PCI_MAX_DEVICE_NUMBER 32
-#endif
-
-/*
* PCI bus attach arguments.
*/
struct pcibus_attach_args {
char *pba_busname; /* XXX should be common */
bus_chipset_tag_t pba_bc; /* XXX should be common */
+ pci_chipset_tag_t pba_pc;
int pba_bus; /* PCI bus number */
+
+ /*
+ * Interrupt swizzling information. These fields
+ * are only used by secondary busses.
+ */
+ u_int pba_intrswiz; /* how to swizzle pins */
+ pcitag_t pba_intrtag; /* intr. appears to come from here */
};
/*
* PCI device attach arguments.
*/
struct pci_attach_args {
- bus_chipset_tag_t pa_bc; /* bus chipset tag */
+ bus_chipset_tag_t pa_bc;
+ pci_chipset_tag_t pa_pc;
- int pa_device;
- int pa_function;
+ u_int pa_device;
+ u_int pa_function;
pcitag_t pa_tag;
pcireg_t pa_id, pa_class;
+
+ /*
+ * Interrupt information.
+ *
+ * "Intrline" is used on systems whose firmware puts
+ * the right routing data into the line register in
+ * configuration space. The rest are used on systems
+ * that do not.
+ */
+ u_int pa_intrswiz; /* how to swizzle pins if ppb */
+ pcitag_t pa_intrtag; /* intr. appears to come from here */
+ pci_intr_pin_t pa_intrpin; /* intr. appears on this pin */
+ pci_intr_line_t pa_intrline; /* intr. routing information */
};
/*
@@ -101,11 +123,18 @@ struct pci_attach_args {
#define pcicf_function cf_loc[1]
#define PCI_UNK_FUNCTION -1 /* wildcarded 'function' */
-pcireg_t pci_conf_read __P((pcitag_t, int));
-void pci_conf_write __P((pcitag_t, int, pcireg_t));
-void pci_devinfo __P((pcireg_t, pcireg_t, int, char *));
-pcitag_t pci_make_tag __P((int, int, int));
-void *pci_map_int __P((pcitag_t, int, int (*)(void *), void *, char *));
-int pci_map_mem __P((pcitag_t, int, vm_offset_t *, vm_offset_t *));
+/*
+ * Configuration space access and utility functions. (Note that most,
+ * e.g. make_tag, conf_read, conf_write are declared by pci_machdep.h.)
+ */
+int pci_io_find __P((pci_chipset_tag_t, pcitag_t, int, bus_io_addr_t *,
+ bus_io_size_t *));
+int pci_mem_find __P((pci_chipset_tag_t, pcitag_t, int, bus_mem_addr_t *,
+ bus_mem_size_t *, int *));
+
+/*
+ * Helper functions for autoconfiguration.
+ */
+void pci_devinfo __P((pcireg_t, pcireg_t, int, char *));
#endif /* _DEV_PCI_PCIVAR_H_ */
diff --git a/sys/dev/pci/ppb.c b/sys/dev/pci/ppb.c
index 90d11685a20..69ad20265f2 100644
--- a/sys/dev/pci/ppb.c
+++ b/sys/dev/pci/ppb.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ppb.c,v 1.1 1996/04/18 23:48:09 niklas Exp $ */
-/* $NetBSD: ppb.c,v 1.4 1996/03/14 04:03:03 cgd Exp $ */
+/* $OpenBSD: ppb.c,v 1.2 1996/04/21 22:25:53 deraadt Exp $ */
+/* $NetBSD: ppb.c,v 1.7 1996/03/27 04:08:34 cgd Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@@ -53,11 +53,15 @@
int ppbmatch __P((struct device *, void *, void *));
void ppbattach __P((struct device *, struct device *, void *));
-struct cfdriver ppbcd = {
- NULL, "ppb", ppbmatch, ppbattach, DV_DULL, sizeof(struct device)
+struct cfattach ppb_ca = {
+ sizeof(struct device), ppbmatch, ppbattach
};
-static int ppbprint __P((void *, char *pnp));
+struct cfdriver ppb_cd = {
+ NULL, "ppb", DV_DULL
+};
+
+int ppbprint __P((void *, char *pnp));
int
ppbmatch(parent, match, aux)
@@ -85,16 +89,17 @@ ppbattach(parent, self, aux)
void *aux;
{
struct pci_attach_args *pa = aux;
+ pci_chipset_tag_t pc = pa->pa_pc;
struct pcibus_attach_args pba;
- pcireg_t data;
+ pcireg_t busdata;
char devinfo[256];
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
printf(": %s (rev. 0x%02x)\n", devinfo, PCI_REVISION(pa->pa_class));
- data = pci_conf_read(pa->pa_tag, PPB_REG_BUSINFO);
+ busdata = pci_conf_read(pc, pa->pa_tag, PPB_REG_BUSINFO);
- if (PPB_BUSINFO_SECONDARY(data) == 0) {
+ if (PPB_BUSINFO_SECONDARY(busdata) == 0) {
printf("%s: not configured by system firmware\n",
self->dv_xname);
return;
@@ -103,25 +108,29 @@ ppbattach(parent, self, aux)
#if 0
/*
* XXX can't do this, because we're not given our bus number
- * (we shouldn't need it) and we can't decompose our tag.
+ * (we shouldn't need it), and because we've no way to
+ * decompose our tag.
*/
-
/* sanity check. */
- if (pa->pa_bus != PPB_BUSINFO_PRIMARY(data))
+ if (pa->pa_bus != PPB_BUSINFO_PRIMARY(busdata))
panic("ppbattach: bus in tag (%d) != bus in reg (%d)",
- pa->pa_bus, PPB_BUSINFO_PRIMARY(data));
+ pa->pa_bus, PPB_BUSINFO_PRIMARY(busdata));
#endif
/*
* Attach the PCI bus than hangs off of it.
*/
pba.pba_busname = "pci";
- pba.pba_bus = PPB_BUSINFO_SECONDARY(data);
+ pba.pba_bc = pa->pa_bc;
+ pba.pba_pc = pc;
+ pba.pba_bus = PPB_BUSINFO_SECONDARY(busdata);
+ pba.pba_intrswiz = pa->pa_intrswiz;
+ pba.pba_intrtag = pa->pa_intrtag;
config_found(self, &pba, ppbprint);
}
-static int
+int
ppbprint(aux, pnp)
void *aux;
char *pnp;
@@ -132,5 +141,5 @@ ppbprint(aux, pnp)
if (pnp)
printf("pci at %s", pnp);
printf(" bus %d", pba->pba_bus);
- return (UNCONF);
+ return (UNCONF);
}