New bus.h implementation/interface:

- No more distinction between i/o-mapped and memory-mapped
	  devices.  It's all "bus space" now, and space tags
	  differentiate the space with finer grain than the
	  bus chipset tag.
	- Add memory barrier methods.
	- Implement space alloc/free methods.
	- Implement region read/write methods (like memcpy to/from
	  bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
This commit is contained in:
thorpej 1996-10-21 22:56:24 +00:00
parent 769a499800
commit 546c8abcee
13 changed files with 198 additions and 188 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ahc_pci.c,v 1.8 1996/10/13 01:38:16 christos Exp $ */
/* $NetBSD: ahc_pci.c,v 1.9 1996/10/21 22:56:24 thorpej Exp $ */
/*
* Product specific probe and attach routines for:
@ -306,9 +306,9 @@ ahc_pci_attach(parent, self, aux)
#elif defined(__NetBSD__)
struct pci_attach_args *pa = aux;
struct ahc_data *ahc = (void *)self;
bus_io_addr_t iobase;
bus_io_size_t iosize;
bus_io_handle_t ioh;
bus_addr_t iobase;
bus_size_t iosize;
bus_space_handle_t ioh;
pci_intr_handle_t ih;
const char *intrstr;
#endif
@ -333,7 +333,7 @@ ahc_pci_attach(parent, self, aux)
#elif defined(__NetBSD__)
if (pci_io_find(pa->pa_pc, pa->pa_tag, PCI_BASEADR0, &iobase, &iosize))
return;
if (bus_io_map(pa->pa_bc, iobase, iosize, &ioh))
if (bus_space_map(pa->pa_iot, iobase, iosize, 0, &ioh))
return;
#endif
@ -390,16 +390,17 @@ ahc_pci_attach(parent, self, aux)
if(ahc_t & AHC_ULTRA)
ultra_enb = inb(SXFRCTL0 + io_port) & ULTRAEN;
#else
our_id = bus_io_read_1(pa->pa_bc, ioh, SCSIID) & OID;
our_id = bus_space_read_1(pa->pa_iot, ioh, SCSIID) & OID;
if(ahc_t & AHC_ULTRA)
ultra_enb = bus_io_read_1(pa->pa_bc, ioh, SXFRCTL0) & ULTRAEN;
ultra_enb = bus_space_read_1(pa->pa_iot, ioh,
SXFRCTL0) & ULTRAEN;
#endif
#if defined(__FreeBSD__)
ahc_reset(io_port);
#elif defined(__NetBSD__)
printf("\n");
ahc_reset(ahc->sc_dev.dv_xname, pa->pa_bc, ioh);
ahc_reset(ahc->sc_dev.dv_xname, pa->pa_iot, ioh);
#endif
if(ahc_t & AHC_AIC7870){
@ -449,7 +450,7 @@ ahc_pci_attach(parent, self, aux)
return;
}
#elif defined(__NetBSD__)
ahc_construct(ahc, pa->pa_bc, ioh, ahc_t, ahc_f);
ahc_construct(ahc, pa->pa_iot, ioh, ahc_t, ahc_f);
if (pci_intr_map(pa->pa_pc, pa->pa_intrtag, pa->pa_intrpin,
pa->pa_intrline, &ih)) {
@ -620,7 +621,7 @@ load_seeprom(ahc)
#if defined(__FreeBSD__)
sd.sd_iobase = ahc->baseport + SEECTL;
#elif defined(__NetBSD__)
sd.sd_bc = ahc->sc_bc;
sd.sd_iot = ahc->sc_iot;
sd.sd_ioh = ahc->sc_ioh;
sd.sd_offset = SEECTL;
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: bha_pci.c,v 1.4 1996/10/13 01:38:17 christos Exp $ */
/* $NetBSD: bha_pci.c,v 1.5 1996/10/21 22:56:27 thorpej Exp $ */
/*
* Copyright (c) 1994, 1996 Charles M. Hannum. All rights reserved.
@ -66,10 +66,10 @@ bha_pci_match(parent, match, aux)
void *match, *aux;
{
struct pci_attach_args *pa = aux;
bus_chipset_tag_t bc = pa->pa_bc;
bus_io_addr_t iobase;
bus_io_size_t iosize;
bus_io_handle_t ioh;
bus_space_tag_t iot = pa->pa_iot;
bus_addr_t iobase;
bus_size_t iosize;
bus_space_handle_t ioh;
pci_chipset_tag_t pc = pa->pa_pc;
int rv;
@ -82,12 +82,12 @@ bha_pci_match(parent, match, aux)
if (pci_io_find(pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize))
return (0);
if (bus_io_map(bc, iobase, iosize, &ioh))
if (bus_space_map(iot, iobase, iosize, 0, &ioh))
return (0);
rv = bha_find(bc, ioh, NULL);
rv = bha_find(iot, ioh, NULL);
bus_io_unmap(bc, ioh, iosize);
bus_space_unmap(iot, ioh, iosize);
return (rv);
}
@ -102,10 +102,10 @@ bha_pci_attach(parent, self, aux)
{
struct pci_attach_args *pa = aux;
struct bha_softc *sc = (void *)self;
bus_chipset_tag_t bc = pa->pa_bc;
bus_io_addr_t iobase;
bus_io_size_t iosize;
bus_io_handle_t ioh;
bus_space_tag_t iot = pa->pa_iot;
bus_addr_t iobase;
bus_size_t iosize;
bus_space_handle_t ioh;
pci_chipset_tag_t pc = pa->pa_pc;
pci_intr_handle_t ih;
pcireg_t csr;
@ -121,12 +121,12 @@ bha_pci_attach(parent, self, aux)
if (pci_io_find(pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize))
panic("bha_attach: pci_io_find failed!");
if (bus_io_map(bc, iobase, iosize, &ioh))
panic("bha_attach: bus_io_map failed!");
if (bus_space_map(iot, iobase, iosize, 0, &ioh))
panic("bha_attach: bus_space_map failed!");
sc->sc_bc = bc;
sc->sc_iot = iot;
sc->sc_ioh = ioh;
if (!bha_find(bc, ioh, sc))
if (!bha_find(iot, ioh, sc))
panic("bha_attach: bha_find failed!");
csr = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);

View File

@ -1,4 +1,4 @@
/* $NetBSD: cy_pci.c,v 1.3 1996/10/13 01:38:18 christos Exp $ */
/* $NetBSD: cy_pci.c,v 1.4 1996/10/21 22:56:29 thorpej Exp $ */
/*
* cy_pci.c
@ -27,9 +27,9 @@
static int cy_probe_pci __P((struct device *, void *, void *));
static void cy_attach_pci __P((struct device *, struct device *, void *));
static int cy_map_pci __P((struct pci_attach_args *, struct cy_softc *,
bus_io_handle_t *, bus_mem_size_t *, bus_io_size_t *));
static void cy_unmap_pci __P((struct cy_softc *, bus_io_handle_t,
bus_mem_size_t, bus_io_size_t));
bus_space_handle_t *, bus_size_t *, bus_size_t *));
static void cy_unmap_pci __P((struct cy_softc *, bus_space_handle_t,
bus_size_t, bus_size_t));
struct cfattach cy_pci_ca = {
sizeof(struct cy_softc), cy_probe_pci, cy_attach_pci
@ -39,12 +39,12 @@ static int
cy_map_pci(pa, sc, ioh, iosize, memsize)
struct pci_attach_args *pa;
struct cy_softc *sc;
bus_io_handle_t *ioh;
bus_mem_size_t *memsize;
bus_io_size_t *iosize;
bus_space_handle_t *ioh;
bus_size_t *memsize;
bus_size_t *iosize;
{
bus_io_addr_t iobase;
bus_mem_addr_t memaddr;
bus_addr_t iobase;
bus_addr_t memaddr;
int cacheable;
if (pci_mem_find(pa->pa_pc, pa->pa_tag, 0x18, &memaddr, memsize,
@ -53,7 +53,8 @@ cy_map_pci(pa, sc, ioh, iosize, memsize)
return 0;
}
/* map the memory (non-cacheable) */
if (bus_mem_map(sc->sc_bc, memaddr, *memsize, 0, &sc->sc_memh) != 0) {
if (bus_space_map(sc->sc_memt, memaddr, *memsize, 0,
&sc->sc_bsh) != 0) {
printf("%s: couldn't map PCI memory region\n",
sc->sc_dev.dv_xname);
return 0;
@ -64,29 +65,29 @@ cy_map_pci(pa, sc, ioh, iosize, memsize)
sc->sc_dev.dv_xname);
goto unmapmem;
}
if (bus_io_map(sc->sc_bc, iobase, *iosize, ioh) != 0) {
if (bus_space_map(sc->sc_iot, iobase, *iosize, 0, ioh) != 0) {
printf("%s: couldn't map PCI io region\n", sc->sc_dev.dv_xname);
goto unmapio;
}
return 1;
unmapio:
bus_io_unmap(sc->sc_bc, *ioh, *iosize);
bus_space_unmap(sc->sc_iot, *ioh, *iosize);
unmapmem:
bus_mem_unmap(sc->sc_bc, sc->sc_memh, *memsize);
bus_space_unmap(sc->sc_memt, sc->sc_bsh, *memsize);
return 0;
}
static void
cy_unmap_pci(sc, ioh, iosize, memsize)
struct cy_softc *sc;
bus_io_handle_t ioh;
bus_io_size_t iosize;
bus_mem_size_t memsize;
bus_space_handle_t ioh;
bus_size_t iosize;
bus_size_t memsize;
{
bus_io_unmap(sc->sc_bc, ioh, iosize);
bus_mem_unmap(sc->sc_bc, sc->sc_memh, memsize);
bus_space_unmap(sc->sc_iot, ioh, iosize);
bus_space_unmap(sc->sc_memt, sc->sc_bsh, memsize);
}
static int
@ -95,9 +96,9 @@ cy_probe_pci(parent, match, aux)
void *match, *aux;
{
struct pci_attach_args *pa = aux;
bus_io_handle_t ioh;
bus_mem_size_t memsize;
bus_io_size_t iosize;
bus_space_handle_t ioh;
bus_size_t memsize;
bus_size_t iosize;
int rv = 0;
struct cy_softc sc;
@ -116,9 +117,11 @@ cy_probe_pci(parent, match, aux)
#ifdef CY_DEBUG
printf("cy: Found Cyclades PCI device, id = 0x%x\n", pa->pa_id);
#endif
/* XXX THIS IS TOTALLY WRONG! XXX */
memcpy(&sc.sc_dev, match, sizeof(struct device));
sc.sc_bc = pa->pa_bc;
sc.sc_iot = pa->pa_iot;
sc.sc_memt = pa->pa_memt;
sc.sc_bustype = CY_BUSTYPE_PCI;
if (cy_map_pci(pa, &sc, &ioh, &iosize, &memsize) == 0)
@ -145,12 +148,13 @@ cy_attach_pci(parent, self, aux)
{
struct cy_softc *sc = (void *) self;
pci_intr_handle_t intrhandle;
bus_io_handle_t ioh;
bus_mem_size_t memsize;
bus_io_size_t iosize;
bus_space_handle_t ioh;
bus_size_t memsize;
bus_size_t iosize;
struct pci_attach_args *pa = aux;
sc->sc_bc = pa->pa_bc;
sc->sc_iot = pa->pa_iot;
sc->sc_memt = pa->pa_memt;
sc->sc_bustype = CY_BUSTYPE_PCI;
if (cy_map_pci(pa, sc, &ioh, &iosize, &memsize) == 0)
@ -162,8 +166,8 @@ cy_attach_pci(parent, self, aux)
cy_attach(parent, self, aux);
/* Enable PCI card interrupts */
bus_io_write_2(sc->sc_bc, ioh, CY_PCI_INTENA,
bus_io_read_2(sc->sc_bc, ioh, CY_PCI_INTENA) | 0x900);
bus_space_write_2(sc->sc_iot, ioh, CY_PCI_INTENA,
bus_space_read_2(sc->sc_iot, ioh, CY_PCI_INTENA) | 0x900);
if (pci_intr_map(pa->pa_pc, pa->pa_intrtag, pa->pa_intrpin,
pa->pa_intrline, &intrhandle) != 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_de.c,v 1.26 1996/10/13 01:38:19 christos Exp $ */
/* $NetBSD: if_de.c,v 1.27 1996/10/21 22:56:32 thorpej Exp $ */
/*-
* Copyright (c) 1994, 1995 Matt Thomas (matt@lkg.dec.com)
@ -138,6 +138,25 @@ typedef struct {
int ri_free;
} tulip_ringinfo_t;
#ifdef __NetBSD__
/*
* These macros are the same for NetBSD regardless of TULIP_IOMAPPED.
*/
typedef bus_size_t tulip_csrptr_t;
#define TULIP_READ_CSR(sc, csr) \
bus_space_read_4((sc)->tulip_bst, (sc)->tulip_bsh, (sc)->tulip_csrs.csr)
#define TULIP_WRITE_CSR(sc, csr, val) \
bus_space_write_4((sc)->tulip_bst, (sc)->tulip_bsh, (sc)->tulip_csrs.csr, \
(val))
#define TULIP_READ_CSRBYTE(sc, csr) \
bus_space_read_1((sc)->tulip_bst, (sc)->tulip_bsh, (sc)->tulip_csrs.csr)
#define TULIP_WRITE_CSRBYTE(sc, csr, val) \
bus_space_write_1((sc)->tulip_bst, (sc)->tulip_bsh, (sc)->tulip_csrs.csr, \
(val))
#endif /* __NetBSD__ */
#ifdef TULIP_IOMAPPED
#define TULIP_EISA_CSRSIZE 16
@ -151,19 +170,7 @@ typedef tulip_uint16_t tulip_csrptr_t;
#define TULIP_READ_CSRBYTE(sc, csr) (inb((sc)->tulip_csrs.csr))
#define TULIP_WRITE_CSRBYTE(sc, csr, val) outb((sc)->tulip_csrs.csr, val)
#else
typedef bus_io_size_t tulip_csrptr_t;
#define TULIP_READ_CSR(sc, csr) \
bus_io_read_4((sc)->tulip_bc, (sc)->tulip_ioh, (sc)->tulip_csrs.csr)
#define TULIP_WRITE_CSR(sc, csr, val) \
bus_io_write_4((sc)->tulip_bc, (sc)->tulip_ioh, (sc)->tulip_csrs.csr, (val))
#define TULIP_READ_CSRBYTE(sc, csr) \
bus_io_read_1((sc)->tulip_bc, (sc)->tulip_ioh, (sc)->tulip_csrs.csr)
#define TULIP_WRITE_CSRBYTE(sc, csr, val) \
bus_io_write_1((sc)->tulip_bc, (sc)->tulip_ioh, (sc)->tulip_csrs.csr, (val))
#endif
#endif /* ! __NetBSD__ */
#else /* TULIP_IOMAPPED */
@ -180,15 +187,8 @@ typedef volatile tulip_uint32_t *tulip_csrptr_t;
#define TULIP_READ_CSR(sc, csr) (0 + *(sc)->tulip_csrs.csr)
#define TULIP_WRITE_CSR(sc, csr, val) \
((void)(*(sc)->tulip_csrs.csr = (val)))
#else
typedef bus_mem_size_t tulip_csrptr_t;
#endif /* ! __NetBSD__ */
#define TULIP_READ_CSR(sc, csr) \
bus_mem_read_4((sc)->tulip_bc, (sc)->tulip_memh, (sc)->tulip_csrs.csr)
#define TULIP_WRITE_CSR(sc, csr, val) \
bus_mem_write_4((sc)->tulip_bc, (sc)->tulip_memh, (sc)->tulip_csrs.csr, \
(val))
#endif
#endif /* TULIP_IOMAPPED */
typedef struct {
@ -312,13 +312,9 @@ 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;
pci_chipset_tag_t tulip_pc;
#ifdef TULIP_IOMAPPED
bus_io_handle_t tulip_ioh; /* I/O region handle */
#else
bus_io_handle_t tulip_memh; /* memory region handle */
#endif
pci_chipset_tag_t tulip_pc; /* PCI chipset cookie */
bus_space_tag_t tulip_bst; /* bus space tag */
bus_space_handle_t tulip_bsh; /* bus space handle */
#endif
char tulip_xname[IFNAMSIZ]; /* name + unit number */
struct arpcom tulip_ac;
@ -425,7 +421,7 @@ static void tulip_addr_filter(tulip_softc_t *sc);
#if defined(__NetBSD__) && defined(__alpha__)
/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
#undef vtophys
#define vtophys(va) __alpha_bus_XXX_dmamap(sc->tulip_bc, (void *)(va))
#define vtophys(va) __alpha_bus_XXX_dmamap(sc->tulip_bst, (void *)(va))
#endif
@ -2438,15 +2434,9 @@ 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
bus_addr_t tulipbase;
bus_size_t tulipsize;
#if defined(__FreeBSD__)
int unit = sc->tulip_dev.dv_unit;
#endif
@ -2578,17 +2568,20 @@ tulip_pci_attach(
#endif /* __bsdi__ */
#if defined(__NetBSD__)
sc->tulip_bc = bc;
sc->tulip_pc = pc;
#if defined(TULIP_IOMAPPED)
retval = pci_io_find(pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize);
sc->tulip_bst = pa->pa_iot;
retval = pci_io_find(pc, pa->pa_tag, PCI_CBIO, &tulipbase, &tulipsize);
if (!retval)
retval = bus_io_map(bc, iobase, iosize, &sc->tulip_ioh);
retval = bus_space_map(pa->pa_iot, tulipbase, tulipsize, 0,
&sc->tulip_bsh);
#else
retval = pci_mem_find(pc, pa->pa_tag, PCI_CBMA, &membase, &memsize,
NULL);
sc->tulip_bst = pa->pa_memt;
retval = pci_mem_find(pc, pa->pa_tag, PCI_CBMA, &tulipbase, &tulipsize,
NULL);
if (!retval)
retval = bus_mem_map(bc, membase, memsize, 0, &sc->tulip_memh);
retval = bus_space_map(pa->pa_memt, tulipbase, tulipsize, 0,
&sc->tulip_bsh);
#endif
csr_base = 0;
if (retval) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_en_pci.c,v 1.4 1996/10/13 01:38:21 christos Exp $ */
/* $NetBSD: if_en_pci.c,v 1.5 1996/10/21 22:56:35 thorpej Exp $ */
/*
*
@ -143,14 +143,14 @@ void *aux;
struct en_softc *sc = (void *)self;
struct en_pci_softc *scp = (void *)self;
struct pci_attach_args *pa = aux;
bus_mem_addr_t membase;
bus_addr_t membase;
pci_intr_handle_t ih;
const char *intrstr;
int retval;
printf("\n");
sc->en_bc = pa->pa_bc;
sc->en_memt = pa->pa_memt;
scp->en_pc = pa->pa_pc;
/*
@ -181,7 +181,8 @@ void *aux;
retval = pci_mem_find(scp->en_pc, pa->pa_tag, PCI_CBMA,
&membase, &sc->en_obmemsz, NULL);
if (retval == 0)
retval = bus_mem_map(sc->en_bc, membase, sc->en_obmemsz, 0, &sc->en_base);
retval = bus_space_map(sc->en_memt, membase, sc->en_obmemsz, 0,
&sc->en_base);
if (retval) {
printf("%s: couldn't map memory\n", sc->sc_dev.dv_xname);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ep_pci.c,v 1.12 1996/10/15 23:41:56 christos Exp $ */
/* $NetBSD: if_ep_pci.c,v 1.13 1996/10/21 22:56:38 thorpej Exp $ */
/*
* Copyright (c) 1994 Herb Peyerl <hpeyerl@beer.org>
@ -120,9 +120,9 @@ ep_pci_attach(parent, self, aux)
struct ep_softc *sc = (void *)self;
struct pci_attach_args *pa = aux;
pci_chipset_tag_t pc = pa->pa_pc;
bus_chipset_tag_t bc = pa->pa_bc;
bus_io_addr_t iobase;
bus_io_size_t iosize;
bus_space_tag_t iot = pa->pa_iot;
bus_addr_t iobase;
bus_size_t iosize;
pci_intr_handle_t ih;
u_short conn = 0;
pcireg_t i;
@ -134,12 +134,12 @@ ep_pci_attach(parent, self, aux)
return;
}
if (bus_io_map(bc, iobase, iosize, &sc->sc_ioh)) {
if (bus_space_map(iot, iobase, iosize, 0, &sc->sc_ioh)) {
printf(": can't map i/o space\n");
return;
}
sc->sc_bc = bc;
sc->sc_iot = iot;
sc->bustype = EP_BUS_PCI;
i = pci_conf_read(pc, pa->pa_tag, PCI_CONN);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_fpa.c,v 1.14 1996/10/13 01:38:22 christos Exp $ */
/* $NetBSD: if_fpa.c,v 1.15 1996/10/21 22:56:40 thorpej Exp $ */
/*-
* Copyright (c) 1995, 1996 Matt Thomas <matt@3am-software.com>
@ -386,13 +386,9 @@ pdq_pci_attach(
pdq_uint32_t data;
pci_intr_handle_t intrhandle;
const char *intrstr;
#ifdef PDQ_IOMAPPED
bus_io_addr_t iobase;
bus_io_size_t iosize;
#else
bus_mem_addr_t membase;
bus_mem_size_t memsize;
#endif
bus_addr_t csrbase;
bus_size_t csrsize;
int cacheable = 0;
data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CFLT);
if ((data & 0xFF00) < (DEFPA_LATENCY << 8)) {
@ -401,26 +397,36 @@ pdq_pci_attach(
pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_CFLT, data);
}
sc->sc_bc = pa->pa_bc;
bcopy(sc->sc_dev.dv_xname, sc->sc_if.if_xname, IFNAMSIZ);
sc->sc_if.if_flags = 0;
sc->sc_if.if_softc = sc;
/*
* NOTE: sc_bc is an alias for sc_csrtag and sc_membase is an
* alias for sc_csrhandle. sc_iobase is not used in this front-end.
*/
#ifdef PDQ_IOMAPPED
if (pci_io_find(pa->pa_pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize)
|| bus_io_map(pa->pa_bc, iobase, iosize, &sc->sc_iobase)){
printf("\n%s: can't map I/O space!\n", sc->sc_dev.dv_xname);
sc->sc_csrtag = pa->pa_iot;
if (pci_io_find(pa->pa_pc, pa->pa_tag, PCI_CBIO, &csrbase, &csrsize)) {
printf("\n%s: can't find I/O space!\n", sc->sc_dev.dv_xname);
return;
}
#else
if (pci_mem_find(pa->pa_pc, pa->pa_tag, PCI_CBMA, &membase, &memsize, NULL)
|| bus_mem_map(pa->pa_bc, membase, memsize, 0, &sc->sc_membase)) {
printf("\n%s: can't map memory space!\n", sc->sc_dev.dv_xname);
sc->sc_csrtag = pa->pa_memt;
if (pci_mem_find(pa->pa_pc, pa->pa_tag, PCI_CBMA, &csrbase, &csrsize,
&cacheable)) {
printf("\n%s: can't find memory space!\n", sc->sc_dev.dv_xname);
return;
}
#endif
sc->sc_pdq = pdq_initialize(sc->sc_bc, sc->sc_membase,
if (bus_space_map(sc->sc_csrtag, csrbase, csrsize, cacheable,
&sc->sc_csrhandle)) {
printf("\n%s: can't map CSRs!\n", sc->sc_dev.dv_xname);
return;
}
sc->sc_pdq = pdq_initialize(sc->sc_csrtag, sc->sc_csrhandle,
sc->sc_if.if_xname, 0,
(void *) sc, PDQ_DEFPA);
if (sc->sc_pdq == NULL) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_le_pci.c,v 1.10 1996/10/13 01:38:23 christos Exp $ */
/* $NetBSD: if_le_pci.c,v 1.11 1996/10/21 22:56:43 thorpej Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@ -77,7 +77,7 @@
#ifdef __alpha__ /* XXX */
/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
#undef vtophys
#define vtophys(va) __alpha_bus_XXX_dmamap(lesc->sc_bc, (void *)(va))
#define vtophys(va) __alpha_bus_XXX_dmamap(lesc->sc_iot, (void *)(va))
#endif
int le_pci_match __P((struct device *, void *, void *));
@ -102,11 +102,11 @@ le_pci_wrcsr(sc, port, val)
u_int16_t port, val;
{
struct le_softc *lesc = (struct le_softc *)sc;
bus_chipset_tag_t bc = lesc->sc_bc;
bus_io_handle_t ioh = lesc->sc_ioh;
bus_space_tag_t iot = lesc->sc_iot;
bus_space_handle_t ioh = lesc->sc_ioh;
bus_io_write_2(bc, ioh, lesc->sc_rap, port);
bus_io_write_2(bc, ioh, lesc->sc_rdp, val);
bus_space_write_2(iot, ioh, lesc->sc_rap, port);
bus_space_write_2(iot, ioh, lesc->sc_rdp, val);
}
hide u_int16_t
@ -115,12 +115,12 @@ le_pci_rdcsr(sc, port)
u_int16_t port;
{
struct le_softc *lesc = (struct le_softc *)sc;
bus_chipset_tag_t bc = lesc->sc_bc;
bus_io_handle_t ioh = lesc->sc_ioh;
bus_space_tag_t iot = lesc->sc_iot;
bus_space_handle_t ioh = lesc->sc_ioh;
u_int16_t val;
bus_io_write_2(bc, ioh, lesc->sc_rap, port);
val = bus_io_read_2(bc, ioh, lesc->sc_rdp);
bus_space_write_2(iot, ioh, lesc->sc_rap, port);
val = bus_space_read_2(iot, ioh, lesc->sc_rdp);
return (val);
}
@ -151,10 +151,10 @@ le_pci_attach(parent, self, aux)
struct am7990_softc *sc = &lesc->sc_am7990;
struct pci_attach_args *pa = aux;
pci_intr_handle_t ih;
bus_io_addr_t iobase;
bus_io_size_t iosize;
bus_io_handle_t ioh;
bus_chipset_tag_t bc = pa->pa_bc;
bus_addr_t iobase;
bus_size_t iosize;
bus_space_handle_t ioh;
bus_space_tag_t iot = pa->pa_iot;
pci_chipset_tag_t pc = pa->pa_pc;
pcireg_t csr;
int i;
@ -177,7 +177,7 @@ le_pci_attach(parent, self, aux)
printf("%s: can't find I/O base\n", sc->sc_dev.dv_xname);
return;
}
if (bus_io_map(bc, iobase, iosize, &ioh)) {
if (bus_space_map(iot, iobase, iosize, 0, &ioh)) {
printf("%s: can't map I/O space\n", sc->sc_dev.dv_xname);
return;
}
@ -186,7 +186,7 @@ le_pci_attach(parent, self, aux)
* Extract the physical MAC address from the ROM.
*/
for (i = 0; i < sizeof(sc->sc_arpcom.ac_enaddr); i++)
sc->sc_arpcom.ac_enaddr[i] = bus_io_read_1(bc, ioh, i);
sc->sc_arpcom.ac_enaddr[i] = bus_space_read_1(iot, ioh, i);
sc->sc_mem = malloc(16384, M_DEVBUF, M_NOWAIT);
if (sc->sc_mem == 0) {
@ -195,7 +195,7 @@ le_pci_attach(parent, self, aux)
return;
}
lesc->sc_bc = bc;
lesc->sc_iot = iot;
lesc->sc_ioh = ioh;
sc->sc_conf3 = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_levar.h,v 1.2 1996/05/12 02:30:05 thorpej Exp $ */
/* $NetBSD: if_levar.h,v 1.3 1996/10/21 22:56:46 thorpej Exp $ */
/*
* LANCE Ethernet driver header file
@ -27,7 +27,7 @@ struct le_softc {
struct am7990_softc sc_am7990; /* glue to MI code */
void *sc_ih;
bus_chipset_tag_t sc_bc; /* chipset cookie */
bus_io_handle_t sc_ioh; /* bus i/o handle */
bus_space_tag_t sc_iot; /* space cookie */
bus_space_handle_t sc_ioh; /* bus space handle */
int sc_rap, sc_rdp; /* offsets to LANCE registers */
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: ncr.c,v 1.44 1996/10/13 01:38:25 christos Exp $ */
/* $NetBSD: ncr.c,v 1.45 1996/10/21 22:56:51 thorpej Exp $ */
/**************************************************************************
**
@ -213,7 +213,7 @@ extern PRINT_ADDR();
#if defined(__NetBSD__) && defined(__alpha__)
/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
#undef vtophys
#define vtophys(va) __alpha_bus_XXX_dmamap(np->sc_bc, (void *)(va))
#define vtophys(va) __alpha_bus_XXX_dmamap(np->sc_memt, (void *)(va))
#endif
/*==========================================================
@ -286,44 +286,44 @@ extern PRINT_ADDR();
#define INB(r) \
INB_OFF(offsetof(struct ncr_reg, r))
#define INB_OFF(o) \
bus_io_read_1 (np->sc_bc, np->sc_ioh, (o))
bus_space_read_1 (np->sc_memt, np->sc_bah, (o))
#define INW(r) \
bus_io_read_2 (np->sc_bc, np->sc_ioh, offsetof(struct ncr_reg, r))
bus_space_read_2 (np->sc_memt, np->sc_bah, offsetof(struct ncr_reg, r))
#define INL(r) \
INL_OFF(offsetof(struct ncr_reg, r))
#define INL_OFF(o) \
bus_io_read_4 (np->sc_bc, np->sc_ioh, (o))
bus_space_read_4 (np->sc_memt, np->sc_bah, (o))
#define OUTB(r, val) \
bus_io_write_1 (np->sc_bc, np->sc_ioh, offsetof(struct ncr_reg, r), (val))
bus_space_write_1 (np->sc_memt, np->sc_bah, offsetof(struct ncr_reg, r), (val))
#define OUTW(r, val) \
bus_io_write_2 (np->sc_bc, np->sc_ioh, offsetof(struct ncr_reg, r), (val))
bus_space_write_2 (np->sc_memt, np->sc_bah, offsetof(struct ncr_reg, r), (val))
#define OUTL(r, val) \
OUTL_OFF(offsetof(struct ncr_reg, r), (val))
#define OUTL_OFF(o, val) \
bus_io_write_4 (np->sc_bc, np->sc_ioh, (o), (val))
bus_space_write_4 (np->sc_memt, np->sc_bah, (o), (val))
#else
#define INB(r) \
INB_OFF(offsetof(struct ncr_reg, r))
#define INB_OFF(o) \
bus_mem_read_1 (np->sc_bc, np->sc_memh, (o))
bus_space_read_1 (np->sc_memt, np->sc_bah, (o))
#define INW(r) \
bus_mem_read_2 (np->sc_bc, np->sc_memh, offsetof(struct ncr_reg, r))
bus_space_read_2 (np->sc_memt, np->sc_bah, offsetof(struct ncr_reg, r))
#define INL(r) \
INL_OFF(offsetof(struct ncr_reg, r))
#define INL_OFF(o) \
bus_mem_read_4 (np->sc_bc, np->sc_memh, (o))
bus_space_read_4 (np->sc_memt, np->sc_bah, (o))
#define OUTB(r, val) \
bus_mem_write_1 (np->sc_bc, np->sc_memh, offsetof(struct ncr_reg, r), (val))
bus_space_write_1 (np->sc_memt, np->sc_bah, offsetof(struct ncr_reg, r), (val))
#define OUTW(r, val) \
bus_mem_write_2 (np->sc_bc, np->sc_memh, offsetof(struct ncr_reg, r), (val))
bus_space_write_2 (np->sc_memt, np->sc_bah, offsetof(struct ncr_reg, r), (val))
#define OUTL(r, val) \
OUTL_OFF(offsetof(struct ncr_reg, r), (val))
#define OUTL_OFF(o, val) \
bus_mem_write_4 (np->sc_bc, np->sc_memh, (o), (val))
bus_space_write_4 (np->sc_memt, np->sc_bah, (o), (val))
#endif
@ -999,13 +999,9 @@ struct ncb {
#ifdef __NetBSD__
struct device sc_dev;
void *sc_ih;
bus_chipset_tag_t sc_bc;
bus_space_tag_t sc_memt;
pci_chipset_tag_t sc_pc;
#ifdef NCR_IOMAPPED
bus_io_handle_t sc_ioh;
#else /* !NCR_IOMAPPED */
bus_mem_handle_t sc_memh;
#endif /* NCR_IOMAPPED */
bus_space_handle_t sc_bah;
#else /* !__NetBSD__ */
int unit;
#endif /* __NetBSD__ */
@ -1035,7 +1031,7 @@ struct ncb {
vm_offset_t vaddr;
vm_offset_t paddr;
#else
bus_mem_addr_t paddr;
bus_addr_t paddr;
#endif
#ifndef __NetBSD__
@ -1332,7 +1328,7 @@ static void ncr_attach (pcici_t tag, int unit);
#if 0
static char ident[] =
"\n$NetBSD: ncr.c,v 1.44 1996/10/13 01:38:25 christos Exp $\n";
"\n$NetBSD: ncr.c,v 1.45 1996/10/21 22:56:51 thorpej Exp $\n";
#endif
u_long ncr_version = NCR_VERSION * 11
@ -3349,13 +3345,14 @@ ncr_attach(parent, self, aux)
void *aux;
{
struct pci_attach_args *pa = aux;
bus_chipset_tag_t bc = pa->pa_bc;
bus_space_tag_t memt = pa->pa_memt;
pci_chipset_tag_t pc = pa->pa_pc;
bus_mem_size_t memsize;
bus_size_t memsize;
int retval, cacheable;
pci_intr_handle_t intrhandle;
const char *intrstr;
ncb_p np = (void *)self;
int wide = 0;
printf(": NCR ");
switch (pa->pa_id) {
@ -3370,17 +3367,19 @@ ncr_attach(parent, self, aux)
break;
case NCR_825_ID:
printf("53c825 Wide");
wide = 1;
break;
case NCR_860_ID:
printf("53c860");
break;
case NCR_875_ID:
printf("53c875 Wide");
wide = 1;
break;
}
printf(" SCSI\n");
np->sc_bc = bc;
np->sc_memt = memt;
np->sc_pc = pc;
/*
@ -3396,7 +3395,8 @@ ncr_attach(parent, self, aux)
}
/* 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);
retval = bus_space_map(pa->pa_memt, np->paddr, memsize, 0,
&np->sc_bah);
if (retval) {
printf("%s: couldn't map memory region\n", self->dv_xname);
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci.c,v 1.23 1996/10/13 01:38:28 christos Exp $ */
/* $NetBSD: pci.c,v 1.24 1996/10/21 22:56:55 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996 Christopher G. Demetriou. All rights reserved.
@ -88,14 +88,15 @@ pciattach(parent, self, aux)
void *aux;
{
struct pcibus_attach_args *pba = aux;
bus_chipset_tag_t bc;
bus_space_tag_t iot, memt;
pci_chipset_tag_t pc;
int bus, device, maxndevs, function, nfunctions;
pci_attach_hook(parent, self, pba);
printf("\n");
bc = pba->pba_bc;
iot = pba->pba_iot;
memt = pba->pba_memt;
pc = pba->pba_pc;
bus = pba->pba_bus;
maxndevs = pci_bus_maxdevs(pc, bus);
@ -122,7 +123,8 @@ pciattach(parent, self, aux)
class = pci_conf_read(pc, tag, PCI_CLASS_REG);
intr = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
pa.pa_bc = bc;
pa.pa_iot = iot;
pa.pa_memt = memt;
pa.pa_pc = pc;
pa.pa_device = device;
pa.pa_function = function;
@ -195,8 +197,8 @@ 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;
bus_addr_t *iobasep;
bus_size_t *iosizep;
{
pcireg_t addrdata, sizedata;
int s;
@ -238,8 +240,8 @@ 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;
bus_addr_t *membasep;
bus_size_t *memsizep;
int *cacheablep;
{
pcireg_t addrdata, sizedata;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcivar.h,v 1.15 1996/03/28 02:16:23 cgd Exp $ */
/* $NetBSD: pcivar.h,v 1.16 1996/10/21 22:56:57 thorpej Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@ -67,8 +67,9 @@ ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE.
* 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 */
char *pba_busname; /* XXX should be common */
bus_space_tag_t pba_iot; /* pci i/o space tag */
bus_space_tag_t pba_memt; /* pci mem space tag */
pci_chipset_tag_t pba_pc;
int pba_bus; /* PCI bus number */
@ -85,7 +86,8 @@ struct pcibus_attach_args {
* PCI device attach arguments.
*/
struct pci_attach_args {
bus_chipset_tag_t pa_bc;
bus_space_tag_t pa_iot; /* pci i/o space tag */
bus_space_tag_t pa_memt; /* pci mem space tag */
pci_chipset_tag_t pa_pc;
u_int pa_device;
@ -126,10 +128,10 @@ struct pci_attach_args {
* 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 *));
int pci_io_find __P((pci_chipset_tag_t, pcitag_t, int, bus_addr_t *,
bus_size_t *));
int pci_mem_find __P((pci_chipset_tag_t, pcitag_t, int, bus_addr_t *,
bus_size_t *, int *));
/*
* Helper functions for autoconfiguration.

View File

@ -1,4 +1,4 @@
/* $NetBSD: ppb.c,v 1.11 1996/10/13 01:38:30 christos Exp $ */
/* $NetBSD: ppb.c,v 1.12 1996/10/21 22:57:00 thorpej Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@ -119,7 +119,8 @@ ppbattach(parent, self, aux)
* Attach the PCI bus than hangs off of it.
*/
pba.pba_busname = "pci";
pba.pba_bc = pa->pa_bc;
pba.pba_iot = pa->pa_iot;
pba.pba_memt = pa->pa_memt;
pba.pba_pc = pc;
pba.pba_bus = PPB_BUSINFO_SECONDARY(busdata);
pba.pba_intrswiz = pa->pa_intrswiz;