diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2005-09-11 18:17:09 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2005-09-11 18:17:09 +0000 |
commit | 6eb1a43c2adf5459a605442184d1f77e5b4e550a (patch) | |
tree | d5bec7c0da23f8042ff3f76a5ff3c7d9fed11fe1 | |
parent | 518ca404ae0a296f8bee3306ea9f52b7280a2b94 (diff) |
do not inline pci_mapreg_map() anymore as it is olrite now; brad@ ok
-rw-r--r-- | sys/dev/pci/adv_pci.c | 26 | ||||
-rw-r--r-- | sys/dev/pci/if_en_pci.c | 11 | ||||
-rw-r--r-- | sys/dev/pci/if_ep_pci.c | 15 | ||||
-rw-r--r-- | sys/dev/pci/if_fpa.c | 26 | ||||
-rw-r--r-- | sys/dev/pci/if_le_pci.c | 26 | ||||
-rw-r--r-- | sys/dev/pci/if_lge.c | 45 | ||||
-rw-r--r-- | sys/dev/pci/if_ne_pci.c | 24 | ||||
-rw-r--r-- | sys/dev/pci/if_nge.c | 45 | ||||
-rw-r--r-- | sys/dev/pci/if_rl_pci.c | 21 | ||||
-rw-r--r-- | sys/dev/pci/if_sf.c | 26 | ||||
-rw-r--r-- | sys/dev/pci/if_stge.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/if_tl.c | 39 | ||||
-rw-r--r-- | sys/dev/pci/if_vr.c | 39 | ||||
-rw-r--r-- | sys/dev/pci/if_wb.c | 33 | ||||
-rw-r--r-- | sys/dev/pci/if_wi_pci.c | 17 | ||||
-rw-r--r-- | sys/dev/pci/isp_pci.c | 31 | ||||
-rw-r--r-- | sys/dev/pci/sv.c | 14 | ||||
-rw-r--r-- | sys/dev/pci/wdt.c | 17 |
18 files changed, 179 insertions, 288 deletions
diff --git a/sys/dev/pci/adv_pci.c b/sys/dev/pci/adv_pci.c index e0ed9578d29..e820541cd24 100644 --- a/sys/dev/pci/adv_pci.c +++ b/sys/dev/pci/adv_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adv_pci.c,v 1.7 2002/11/19 18:40:16 jason Exp $ */ +/* $OpenBSD: adv_pci.c,v 1.8 2005/09/11 18:17:08 mickey Exp $ */ /* $NetBSD: adv_pci.c,v 1.5 1998/09/26 15:52:55 dante Exp $ */ /* @@ -127,7 +127,6 @@ adv_pci_attach(parent, self, aux) struct pci_attach_args *pa = aux; ASC_SOFTC *sc = (void *) self; bus_space_handle_t ioh; - bus_addr_t advbase; bus_size_t advsize; pci_intr_handle_t ih; pci_chipset_tag_t pc = pa->pa_pc; @@ -162,15 +161,12 @@ adv_pci_attach(parent, self, aux) /* * Map Device Registers for I/O */ - retval = pci_io_find(pc, pa->pa_tag, PCI_CBIO, &advbase, &advsize); - if (retval == 0) - retval = bus_space_map(pa->pa_iot, advbase, advsize, 0, &ioh); + retval = pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0, + &sc->sc_iot, &ioh, NULL, &advsize, 0); if (retval) { - printf("\n%s: unable to map device registers\n", - sc->sc_dev.dv_xname); + printf(": unable to map device registers\n"); return; } - sc->sc_iot = pa->pa_iot; sc->sc_ioh = ioh; sc->sc_dmat = pa->pa_dmat; sc->pci_device_id = pa->pa_id; @@ -179,14 +175,18 @@ adv_pci_attach(parent, self, aux) /* * Initialize the board */ - if (adv_init(sc)) - panic("adv_pci_attach: adv_init failed"); + if (adv_init(sc)) { + printf(": adv_init failed\n"); + bus_space_unmap(sc->sc_iot, ioh, advsize); + return; + } /* * Map Interrupt line */ if (pci_intr_map(pa, &ih)) { - printf("\n%s: couldn't map interrupt\n", sc->sc_dev.dv_xname); + printf(": couldn't map interrupt\n"); + bus_space_unmap(sc->sc_iot, ioh, advsize); return; } intrstr = pci_intr_string(pc, ih); @@ -197,11 +197,11 @@ adv_pci_attach(parent, self, aux) sc->sc_ih = pci_intr_establish(pc, ih, IPL_BIO, adv_intr, sc, sc->sc_dev.dv_xname); if (sc->sc_ih == NULL) { - printf("\n%s: couldn't establish interrupt", - sc->sc_dev.dv_xname); + printf(": couldn't establish interrupt"); if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); + bus_space_unmap(sc->sc_iot, ioh, advsize); return; } printf(": %s\n", intrstr); diff --git a/sys/dev/pci/if_en_pci.c b/sys/dev/pci/if_en_pci.c index d701fa4e717..1122c4337d0 100644 --- a/sys/dev/pci/if_en_pci.c +++ b/sys/dev/pci/if_en_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_en_pci.c,v 1.10 2002/06/19 18:46:41 fgsch Exp $ */ +/* $OpenBSD: if_en_pci.c,v 1.11 2005/09/11 18:17:08 mickey Exp $ */ /* * @@ -191,12 +191,10 @@ void *aux; struct en_softc *sc = (void *)self; struct en_pci_softc *scp = (void *)self; struct pci_attach_args *pa = aux; - bus_addr_t membase; pci_intr_handle_t ih; const char *intrstr; int retval; - sc->en_memt = pa->pa_memt; sc->is_adaptec = (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ADP) ? 1 : 0; scp->en_pc = pa->pa_pc; @@ -224,11 +222,8 @@ void *aux; * memory map */ - retval = pci_mem_find(scp->en_pc, pa->pa_tag, PCI_CBMA, - &membase, &sc->en_obmemsz, NULL); - if (retval == 0) - retval = bus_space_map(sc->en_memt, membase, sc->en_obmemsz, 0, - &sc->en_base); + retval = pci_mapreg_map(pa, PCI_CBMA, PCI_MAPREG_TYPE_MEM, 0, + &sc->en_memt, &sc->en_base, NULL, &sc->en_obmemsz, 0); if (retval) { printf(": couldn't map memory\n"); diff --git a/sys/dev/pci/if_ep_pci.c b/sys/dev/pci/if_ep_pci.c index 4f2477c4fa3..1886515574c 100644 --- a/sys/dev/pci/if_ep_pci.c +++ b/sys/dev/pci/if_ep_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ep_pci.c,v 1.24 2005/08/09 04:10:12 mickey Exp $ */ +/* $OpenBSD: if_ep_pci.c,v 1.25 2005/09/11 18:17:08 mickey Exp $ */ /* $NetBSD: if_ep_pci.c,v 1.13 1996/10/21 22:56:38 thorpej Exp $ */ /* @@ -112,24 +112,17 @@ 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_space_tag_t iot = pa->pa_iot; - bus_addr_t iobase; bus_size_t iosize; pci_intr_handle_t ih; pcireg_t i; const char *intrstr = NULL; - if (pci_io_find(pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize)) { - printf(": can't find i/o space\n"); - return; - } - - if (bus_space_map(iot, iobase, iosize, 0, &sc->sc_ioh)) { + if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0, + &sc->sc_iot, &sc->sc_ioh, NULL, &iosize, 0)) { printf(": can't map i/o space\n"); return; } - sc->sc_iot = iot; sc->bustype = EP_BUS_PCI; i = pci_conf_read(pc, pa->pa_tag, PCI_CONN); @@ -143,6 +136,7 @@ ep_pci_attach(parent, self, aux) /* Map and establish the interrupt. */ if (pci_intr_map(pa, &ih)) { printf(", couldn't map interrupt\n"); + bus_space_unmap(sc->sc_iot, sc->sc_ioh, iosize); return; } intrstr = pci_intr_string(pc, ih); @@ -153,6 +147,7 @@ ep_pci_attach(parent, self, aux) if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); + bus_space_unmap(sc->sc_iot, sc->sc_ioh, iosize); return; } printf(" %s\n", intrstr); diff --git a/sys/dev/pci/if_fpa.c b/sys/dev/pci/if_fpa.c index 8f6d1677f84..d2ef3a19508 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.23 2004/05/12 06:35:11 tedu Exp $ */ +/* $OpenBSD: if_fpa.c,v 1.24 2005/09/11 18:17:08 mickey Exp $ */ /* $NetBSD: if_fpa.c,v 1.15 1996/10/21 22:56:40 thorpej Exp $ */ /*- @@ -108,9 +108,7 @@ pdq_pci_attach(parent, self, aux) u_int32_t data; pci_intr_handle_t intrhandle; const char *intrstr; - bus_addr_t csrbase; bus_size_t csrsize; - int cacheable = 0; data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG); if (PCI_LATTIMER(data) < DEFPA_LATENCY) { @@ -129,28 +127,22 @@ pdq_pci_attach(parent, self, aux) * alias for sc_csrhandle. sc_iobase is not used in this front-end. */ #ifdef PDQ_IOMAPPED - sc->sc_csrtag = pa->pa_iot; - if (pci_io_find(pa->pa_pc, pa->pa_tag, DEFPA_CBIO, &csrbase, &csrsize)){ - printf(": can't find I/O space!\n"); + if (pci_mapreg_map(pa, DEFPA_CBIO, PCI_MAPREG_TYPE_IO, 0, + &sc->sc_csrtag, &sc->sc_csrhandle, NULL, &csrsize, 0)) { + printf(": can't map I/O space!\n"); return; } #else - sc->sc_csrtag = pa->pa_memt; - if (pci_mem_find(pa->pa_pc, pa->pa_tag, DEFPA_CBMA, &csrbase, &csrsize, - &cacheable)) { - printf(": can't find memory space!\n"); + if (pci_mapreg_map(pa, DEFPA_CBMA, PCI_MAPREG_TYPE_MEM, 0, + &sc->sc_csrtag, &sc->sc_csrhandle, NULL, &csrsize, 0)) { + printf(": can't map memory space!\n"); return; } #endif - if (bus_space_map(sc->sc_csrtag, csrbase, csrsize, cacheable, - &sc->sc_csrhandle)) { - printf(": can't map CSRs!\n"); - return; - } - if (pci_intr_map(pa, &intrhandle)) { printf(": couldn't map interrupt\n"); + bus_space_unmap(sc->sc_csrtag, sc->sc_csrhandle, csrsize); return; } intrstr = pci_intr_string(pa->pa_pc, intrhandle); @@ -161,6 +153,7 @@ pdq_pci_attach(parent, self, aux) if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); + bus_space_unmap(sc->sc_csrtag, sc->sc_csrhandle, csrsize); return; } if (intrstr != NULL) @@ -170,6 +163,7 @@ pdq_pci_attach(parent, self, aux) sc->sc_if.if_xname, 0, (void *) sc, PDQ_DEFPA); if (sc->sc_pdq == NULL) { printf(": initialization failed\n"); + bus_space_unmap(sc->sc_csrtag, sc->sc_csrhandle, csrsize); return; } diff --git a/sys/dev/pci/if_le_pci.c b/sys/dev/pci/if_le_pci.c index 041b7a1370b..7896bbeb3c9 100644 --- a/sys/dev/pci/if_le_pci.c +++ b/sys/dev/pci/if_le_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_le_pci.c,v 1.22 2005/08/09 04:10:12 mickey Exp $ */ +/* $OpenBSD: if_le_pci.c,v 1.23 2005/09/11 18:17:08 mickey Exp $ */ /* $NetBSD: if_le_pci.c,v 1.13 1996/10/25 21:33:32 cgd Exp $ */ /*- @@ -146,10 +146,9 @@ 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_addr_t iobase; bus_size_t iosize; bus_space_handle_t ioh; - bus_space_tag_t iot = pa->pa_iot; + bus_space_tag_t iot; pci_chipset_tag_t pc = pa->pa_pc; int i, rseg; const char *intrstr; @@ -164,12 +163,9 @@ le_pci_attach(parent, self, aux) break; } - if (pci_io_find(pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize)) { - printf(": can't find I/O base\n"); - return; - } - if (bus_space_map(iot, iobase, iosize, 0, &ioh)) { - printf(": can't map I/O space\n"); + if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0, + &iot, &ioh, NULL, &iosize, 0)) { + printf(": can't map I/O base\n"); return; } @@ -182,12 +178,14 @@ le_pci_attach(parent, self, aux) if (bus_dmamem_alloc(pa->pa_dmat, PCNET_MEMSIZE, PAGE_SIZE, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) { printf(": couldn't allocate memory for card\n"); + bus_space_unmap(iot, ioh, iosize); return; } if (bus_dmamem_map(pa->pa_dmat, &seg, rseg, PCNET_MEMSIZE, &kva, BUS_DMA_NOWAIT)) { printf(": couldn't map memory for card\n"); bus_dmamem_free(pa->pa_dmat, &seg, rseg); + bus_space_unmap(iot, ioh, iosize); return; } if (bus_dmamap_create(pa->pa_dmat, PCNET_MEMSIZE, 1, PCNET_MEMSIZE, @@ -195,6 +193,7 @@ le_pci_attach(parent, self, aux) printf(": couldn't create dma map\n"); bus_dmamem_unmap(pa->pa_dmat, kva, PCNET_MEMSIZE); bus_dmamem_free(pa->pa_dmat, &seg, rseg); + bus_space_unmap(iot, ioh, iosize); return; } if (bus_dmamap_load(pa->pa_dmat, dmamap, kva, PCNET_MEMSIZE, @@ -203,6 +202,7 @@ le_pci_attach(parent, self, aux) bus_dmamap_destroy(pa->pa_dmat, dmamap); bus_dmamem_unmap(pa->pa_dmat, kva, PCNET_MEMSIZE); bus_dmamem_free(pa->pa_dmat, &seg, rseg); + bus_space_unmap(iot, ioh, iosize); return; } sc->sc_mem = kva; @@ -211,6 +211,10 @@ le_pci_attach(parent, self, aux) /* Map and establish the interrupt. */ if (pci_intr_map(pa, &ih)) { printf(": couldn't map interrupt\n"); + bus_dmamap_destroy(pa->pa_dmat, dmamap); + bus_dmamem_unmap(pa->pa_dmat, kva, PCNET_MEMSIZE); + bus_dmamem_free(pa->pa_dmat, &seg, rseg); + bus_space_unmap(iot, ioh, iosize); return; } intrstr = pci_intr_string(pc, ih); @@ -221,6 +225,10 @@ le_pci_attach(parent, self, aux) if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); + bus_dmamap_destroy(pa->pa_dmat, dmamap); + bus_dmamem_unmap(pa->pa_dmat, kva, PCNET_MEMSIZE); + bus_dmamem_free(pa->pa_dmat, &seg, rseg); + bus_space_unmap(iot, ioh, iosize); return; } printf(": %s\n", intrstr); diff --git a/sys/dev/pci/if_lge.c b/sys/dev/pci/if_lge.c index 50c2950bba5..2d37b0e8216 100644 --- a/sys/dev/pci/if_lge.c +++ b/sys/dev/pci/if_lge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_lge.c,v 1.22 2005/08/09 04:10:12 mickey Exp $ */ +/* $OpenBSD: if_lge.c,v 1.23 2005/09/11 18:17:08 mickey Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2000, 2001 @@ -428,7 +428,6 @@ void lge_attach(parent, self, aux) pci_chipset_tag_t pc = pa->pa_pc; pci_intr_handle_t ih; const char *intrstr = NULL; - bus_addr_t iobase; bus_size_t iosize; bus_dma_segment_t seg; bus_dmamap_t dmamap; @@ -451,7 +450,7 @@ void lge_attach(parent, self, aux) if (command == 0x01) { command = pci_conf_read(pc, pa->pa_tag, LGE_PCI_PWRMGMTCTRL); if (command & LGE_PSTATE_MASK) { - u_int32_t iobase, membase, irq; + pcireg_t iobase, membase, irq; /* Save important PCI config data. */ iobase = pci_conf_read(pc, pa->pa_tag, LGE_PCI_LOIO); @@ -489,17 +488,12 @@ void lge_attach(parent, self, aux) /* * Map control/status registers. */ - DPRINTFN(5, ("pci_io_find\n")); - if (pci_io_find(pc, pa->pa_tag, LGE_PCI_LOIO, &iobase, &iosize)) { - printf(": can't find i/o space\n"); - goto fail; - } - DPRINTFN(5, ("bus_space_map\n")); - if (bus_space_map(pa->pa_iot, iobase, iosize, 0, &sc->lge_bhandle)) { + DPRINTFN(5, ("pci_mapreg_map\n")); + if (pci_mapreg_map(pa, LGE_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0, + &sc->lge_btag, &sc->lge_bhandle, NULL, &iosize, 0)) { printf(": can't map i/o space\n"); goto fail; } - sc->lge_btag = pa->pa_iot; #else if (!(command & PCI_COMMAND_MEM_ENABLE)) { printf("%s: failed to enable memory mapping!\n", @@ -507,25 +501,18 @@ void lge_attach(parent, self, aux) error = ENXIO; goto fail; } - DPRINTFN(5, ("pci_mem_find\n")); - if (pci_mem_find(pc, pa->pa_tag, LGE_PCI_LOMEM, &iobase, - &iosize, NULL)) { - printf(": can't find mem space\n"); - goto fail; - } - DPRINTFN(5, ("bus_space_map\n")); - if (bus_space_map(pa->pa_memt, iobase, iosize, 0, &sc->lge_bhandle)) { + DPRINTFN(5, ("pci_mapreg_map\n")); + if (pci_mapreg_map(pa, LGE_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0, + &sc->lge_btag, &sc->lge_bhandle, NULL, &iosize, 0)) { printf(": can't map mem space\n"); goto fail; } - - sc->lge_btag = pa->pa_memt; #endif DPRINTFN(5, ("pci_intr_map\n")); if (pci_intr_map(pa, &ih)) { printf(": couldn't map interrupt\n"); - goto fail; + goto fail_1; } DPRINTFN(5, ("pci_intr_string\n")); @@ -538,7 +525,7 @@ void lge_attach(parent, self, aux) if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); - goto fail; + goto fail_1; } printf(": %s", intrstr); @@ -566,7 +553,7 @@ void lge_attach(parent, self, aux) if (bus_dmamem_alloc(sc->sc_dmatag, sizeof(struct lge_list_data), PAGE_SIZE, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) { printf("%s: can't alloc rx buffers\n", sc->sc_dv.dv_xname); - goto fail; + goto fail_1; } DPRINTFN(5, ("bus_dmamem_map\n")); if (bus_dmamem_map(sc->sc_dmatag, &seg, rseg, @@ -575,7 +562,7 @@ void lge_attach(parent, self, aux) printf("%s: can't map dma buffers (%d bytes)\n", sc->sc_dv.dv_xname, sizeof(struct lge_list_data)); bus_dmamem_free(sc->sc_dmatag, &seg, rseg); - goto fail; + goto fail_1; } DPRINTFN(5, ("bus_dmamem_create\n")); if (bus_dmamap_create(sc->sc_dmatag, sizeof(struct lge_list_data), 1, @@ -585,7 +572,7 @@ void lge_attach(parent, self, aux) bus_dmamem_unmap(sc->sc_dmatag, kva, sizeof(struct lge_list_data)); bus_dmamem_free(sc->sc_dmatag, &seg, rseg); - goto fail; + goto fail_1; } DPRINTFN(5, ("bus_dmamem_load\n")); if (bus_dmamap_load(sc->sc_dmatag, dmamap, kva, @@ -595,7 +582,7 @@ void lge_attach(parent, self, aux) bus_dmamem_unmap(sc->sc_dmatag, kva, sizeof(struct lge_list_data)); bus_dmamem_free(sc->sc_dmatag, &seg, rseg); - goto fail; + goto fail_1; } DPRINTFN(5, ("bzero\n")); @@ -607,7 +594,7 @@ void lge_attach(parent, self, aux) if (lge_alloc_jumbo_mem(sc)) { printf("%s: jumbo buffer allocation failed\n", sc->sc_dv.dv_xname); - goto fail; + goto fail_1; } ifp = &sc->arpcom.ac_if; @@ -660,6 +647,8 @@ void lge_attach(parent, self, aux) timeout_set(&sc->lge_timeout, lge_tick, sc); timeout_add(&sc->lge_timeout, hz); +fail_1: + bus_space_unmap(sc->lge_btag, sc->lge_bhandle, iosize); fail: splx(s); } diff --git a/sys/dev/pci/if_ne_pci.c b/sys/dev/pci/if_ne_pci.c index 878b50bce7a..e4eb5967a9b 100644 --- a/sys/dev/pci/if_ne_pci.c +++ b/sys/dev/pci/if_ne_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ne_pci.c,v 1.12 2005/08/09 04:10:12 mickey Exp $ */ +/* $OpenBSD: if_ne_pci.c,v 1.13 2005/09/11 18:17:08 mickey Exp $ */ /* $NetBSD: if_ne_pci.c,v 1.8 1998/07/05 00:51:24 jonathan Exp $ */ /*- @@ -192,10 +192,7 @@ ne_pci_attach(parent, self, aux) struct dp8390_softc *dsc = &nsc->sc_dp8390; struct pci_attach_args *pa = aux; pci_chipset_tag_t pc = pa->pa_pc; -#ifndef __NetBSD__ - bus_addr_t iobase; bus_size_t iosize; -#endif bus_space_tag_t nict; bus_space_handle_t nich; bus_space_tag_t asict; @@ -210,30 +207,17 @@ ne_pci_attach(parent, self, aux) panic("ne_pci_attach: impossible"); } -#ifdef __NetBSD__ if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0, - &nict, &nich, NULL, NULL, 0)) { + &nict, &nich, NULL, &iosize, 0)) { printf(": can't map i/o space\n"); return; } -#else - if (pci_io_find(pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize)) { - printf(": can't find I/O base\n"); - return; - } - - nict = pa->pa_iot; - - if (bus_space_map(nict, iobase, iosize, 0, &nich)) { - printf(": can't map I/O space\n"); - return; - } -#endif asict = nict; if (bus_space_subregion(nict, nich, NE2000_ASIC_OFFSET, NE2000_ASIC_NPORTS, &asich)) { printf(": can't subregion i/o space\n"); + bus_space_unmap(nict, nich, iosize); return; } @@ -254,6 +238,7 @@ ne_pci_attach(parent, self, aux) /* Map and establish the interrupt. */ if (pci_intr_map(pa, &ih)) { printf(": couldn't map interrupt\n"); + bus_space_unmap(nict, nich, iosize); return; } intrstr = pci_intr_string(pc, ih); @@ -264,6 +249,7 @@ ne_pci_attach(parent, self, aux) if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); + bus_space_unmap(nict, nich, iosize); return; } printf(": %s\n", intrstr); diff --git a/sys/dev/pci/if_nge.c b/sys/dev/pci/if_nge.c index 80d9c16337a..5bb1ee24176 100644 --- a/sys/dev/pci/if_nge.c +++ b/sys/dev/pci/if_nge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nge.c,v 1.44 2005/08/09 04:10:12 mickey Exp $ */ +/* $OpenBSD: if_nge.c,v 1.45 2005/09/11 18:17:08 mickey Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2000, 2001 @@ -724,7 +724,6 @@ nge_attach(parent, self, aux) pci_chipset_tag_t pc = pa->pa_pc; pci_intr_handle_t ih; const char *intrstr = NULL; - bus_addr_t iobase; bus_size_t iosize; bus_dma_segment_t seg; bus_dmamap_t dmamap; @@ -745,7 +744,7 @@ nge_attach(parent, self, aux) if (command == 0x01) { command = pci_conf_read(pc, pa->pa_tag, NGE_PCI_PWRMGMTCTRL); if (command & NGE_PSTATE_MASK) { - u_int32_t iobase, membase, irq; + pcireg_t iobase, membase, irq; /* Save important PCI config data. */ iobase = pci_conf_read(pc, pa->pa_tag, NGE_PCI_LOIO); @@ -783,17 +782,12 @@ nge_attach(parent, self, aux) /* * Map control/status registers. */ - DPRINTFN(5, ("%s: pci_io_find\n", sc->sc_dv.dv_xname)); - if (pci_io_find(pc, pa->pa_tag, NGE_PCI_LOIO, &iobase, &iosize)) { - printf(": can't find i/o space\n"); - goto fail; - } - DPRINTFN(5, ("%s: bus_space_map\n", sc->sc_dv.dv_xname)); - if (bus_space_map(pa->pa_iot, iobase, iosize, 0, &sc->nge_bhandle)) { + DPRINTFN(5, ("%s: pci_mapreg_map\n", sc->sc_dv.dv_xname)); + if (pci_mapreg_map(pa, NGE_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0, + &sc->nge_btag, &sc->nge_bhandle, NULL, &iosize, 0)) { printf(": can't map i/o space\n"); goto fail; } - sc->nge_btag = pa->pa_iot; #else if (!(command & PCI_COMMAND_MEM_ENABLE)) { printf("%s: failed to enable memory mapping!\n", @@ -801,19 +795,12 @@ nge_attach(parent, self, aux) error = ENXIO; goto fail; } - DPRINTFN(5, ("%s: pci_mem_find\n", sc->sc_dv.dv_xname)); - if (pci_mem_find(pc, pa->pa_tag, NGE_PCI_LOMEM, &iobase, - &iosize, NULL)) { - printf(": can't find mem space\n"); - goto fail; - } - DPRINTFN(5, ("%s: bus_space_map\n", sc->sc_dv.dv_xname)); - if (bus_space_map(pa->pa_memt, iobase, iosize, 0, &sc->nge_bhandle)) { + DPRINTFN(5, ("%s: pci_mapreg_map\n", sc->sc_dv.dv_xname)); + if (pci_mapreg_map(pa, NGE_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0, + &sc->nge_btag, &sc->nge_bhandle, NULL, &iosize, 0)) { printf(": can't map mem space\n"); goto fail; } - - sc->nge_btag = pa->pa_memt; #endif /* Disable all interrupts */ @@ -822,7 +809,7 @@ nge_attach(parent, self, aux) DPRINTFN(5, ("%s: pci_intr_map\n", sc->sc_dv.dv_xname)); if (pci_intr_map(pa, &ih)) { printf(": couldn't map interrupt\n"); - goto fail; + goto fail_1; } DPRINTFN(5, ("%s: pci_intr_string\n", sc->sc_dv.dv_xname)); @@ -835,7 +822,7 @@ nge_attach(parent, self, aux) if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); - goto fail; + goto fail_1; } printf(": %s", intrstr); @@ -863,7 +850,7 @@ nge_attach(parent, self, aux) if (bus_dmamem_alloc(sc->sc_dmatag, sizeof(struct nge_list_data), PAGE_SIZE, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) { printf("%s: can't alloc rx buffers\n", sc->sc_dv.dv_xname); - goto fail; + goto fail_1; } DPRINTFN(5, ("%s: bus_dmamem_map\n", sc->sc_dv.dv_xname)); if (bus_dmamem_map(sc->sc_dmatag, &seg, rseg, @@ -872,7 +859,7 @@ nge_attach(parent, self, aux) printf("%s: can't map dma buffers (%d bytes)\n", sc->sc_dv.dv_xname, sizeof(struct nge_list_data)); bus_dmamem_free(sc->sc_dmatag, &seg, rseg); - goto fail; + goto fail_1; } DPRINTFN(5, ("%s: bus_dmamem_create\n", sc->sc_dv.dv_xname)); if (bus_dmamap_create(sc->sc_dmatag, sizeof(struct nge_list_data), 1, @@ -882,7 +869,7 @@ nge_attach(parent, self, aux) bus_dmamem_unmap(sc->sc_dmatag, kva, sizeof(struct nge_list_data)); bus_dmamem_free(sc->sc_dmatag, &seg, rseg); - goto fail; + goto fail_1; } DPRINTFN(5, ("%s: bus_dmamem_load\n", sc->sc_dv.dv_xname)); if (bus_dmamap_load(sc->sc_dmatag, dmamap, kva, @@ -892,7 +879,7 @@ nge_attach(parent, self, aux) bus_dmamem_unmap(sc->sc_dmatag, kva, sizeof(struct nge_list_data)); bus_dmamem_free(sc->sc_dmatag, &seg, rseg); - goto fail; + goto fail_1; } DPRINTFN(5, ("%s: bzero\n", sc->sc_dv.dv_xname)); @@ -904,7 +891,7 @@ nge_attach(parent, self, aux) if (nge_alloc_jumbo_mem(sc)) { printf("%s: jumbo buffer allocation failed\n", sc->sc_dv.dv_xname); - goto fail; + goto fail_1; } ifp = &sc->arpcom.ac_if; @@ -982,6 +969,8 @@ nge_attach(parent, self, aux) timeout_set(&sc->nge_timeout, nge_tick, sc); timeout_add(&sc->nge_timeout, hz); +fail_1: + bus_space_unmap(sc->nge_btag, sc->nge_bhandle, iosize); fail: splx(s); } diff --git a/sys/dev/pci/if_rl_pci.c b/sys/dev/pci/if_rl_pci.c index a912bf53dfe..99871148955 100644 --- a/sys/dev/pci/if_rl_pci.c +++ b/sys/dev/pci/if_rl_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rl_pci.c,v 1.9 2003/12/29 23:06:55 brad Exp $ */ +/* $OpenBSD: if_rl_pci.c,v 1.10 2005/09/11 18:17:08 mickey Exp $ */ /* * Copyright (c) 1997, 1998 @@ -119,7 +119,6 @@ rl_pci_attach(parent, self, aux) pci_chipset_tag_t pc = pa->pa_pc; pci_intr_handle_t ih; const char *intrstr = NULL; - bus_addr_t iobase; bus_size_t iosize; u_int32_t command; @@ -134,29 +133,21 @@ rl_pci_attach(parent, self, aux) /* * Map control/status registers. */ - if (pci_io_find(pc, pa->pa_tag, RL_PCI_LOIO, &iobase, &iosize)) { - printf(": can't find i/o space\n"); - return; - } - if (bus_space_map(pa->pa_iot, iobase, iosize, 0, &sc->rl_bhandle)) { + if (pci_mapreg_map(pa, RL_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0, + &sc->rl_btag, &sc->rl_bhandle, NULL, &iosize, 0)) { printf(": can't map i/o space\n"); return; } - sc->rl_btag = pa->pa_iot; #else if (!(command & PCI_COMMAND_MEM_ENABLE)) { printf(": failed to enable memory mapping\n"); return; } - if (pci_mem_find(pc, pa->pa_tag, RL_PCI_LOMEM, &iobase, &iosize, NULL)){ - printf(": can't find mem space\n"); - return; - } - if (bus_space_map(pa->pa_memt, iobase, iosize, 0, &sc->rl_bhandle)) { + if (pci_mapreg_map(pa, RL_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0, + &sc->rl_btag, &sc->rl_bhandle, NULL, &iosize, 0)){ printf(": can't map mem space\n"); return; } - sc->rl_btag = pa->pa_memt; #endif /* @@ -164,6 +155,7 @@ rl_pci_attach(parent, self, aux) */ if (pci_intr_map(pa, &ih)) { printf(": couldn't map interrupt\n"); + bus_space_unmap(sc->rl_btag, sc->rl_bhandle, iosize); return; } @@ -175,6 +167,7 @@ rl_pci_attach(parent, self, aux) if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); + bus_space_unmap(sc->rl_btag, sc->rl_bhandle, iosize); return; } printf(": %s", intrstr); diff --git a/sys/dev/pci/if_sf.c b/sys/dev/pci/if_sf.c index ae9bdd16f36..b47cde943dc 100644 --- a/sys/dev/pci/if_sf.c +++ b/sys/dev/pci/if_sf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sf.c,v 1.31 2005/08/09 04:10:12 mickey Exp $ */ +/* $OpenBSD: if_sf.c,v 1.32 2005/09/11 18:17:08 mickey Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. @@ -635,35 +635,27 @@ void sf_attach(parent, self, aux) printf(": failed to enable I/O ports\n"); goto fail; } - if (pci_io_find(pc, pa->pa_tag, SF_PCI_LOIO, &iobase, &iosize)) { - printf(": can't find I/O space\n"); - goto fail; - } - if (bus_space_map(pa->pa_iot, iobase, iosize, 0, &sc->sf_bhandle)) { + if (pci_mapreg_map(pa, SF_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0, + &sc->sf_btag, &sc->sf_bhandle, NULL, &iosize, 0)) { printf(": can't map I/O space\n"); goto fail; } - sc->sf_btag = pa->pa_iot; #else if (!(command & PCI_COMMAND_MEM_ENABLE)) { printf(": failed to enable memory mapping\n"); goto fail; } - if (pci_mem_find(pc, pa->pa_tag, SF_PCI_LOMEM, &iobase, &iosize, NULL)){ - printf(": can't find mem space\n"); - goto fail; - } - if (bus_space_map(pa->pa_memt, iobase, iosize, 0, &sc->sf_bhandle)) { + if (pci_mapreg_map(pa, SF_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0, + &sc->sf_btag, &sc->sf_bhandle, NULL, &iosize, 0)){ printf(": can't map mem space\n"); goto fail; } - sc->sf_btag = pa->pa_memt; #endif /* Allocate interrupt */ if (pci_intr_map(pa, &ih)) { printf(": couldn't map interrupt\n"); - goto fail; + goto fail_1; } intrstr = pci_intr_string(pc, ih); sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, sf_intr, sc, @@ -673,7 +665,7 @@ void sf_attach(parent, self, aux) if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); - goto fail; + goto fail_1; } printf(": %s", intrstr); @@ -694,7 +686,7 @@ void sf_attach(parent, self, aux) M_DEVBUF, M_NOWAIT); if (sc->sf_ldata_ptr == NULL) { printf("%s: no memory for list buffers!\n", sc->sc_dev.dv_xname); - goto fail; + goto fail_1; } sc->sf_ldata = (struct sf_list_data *)sc->sf_ldata_ptr; @@ -735,6 +727,8 @@ void sf_attach(parent, self, aux) shutdownhook_establish(sf_shutdown, sc); +fail_1: + bus_space_unmap(sc->sf_btag, sc->sf_bhandle, iosize); fail: splx(s); return; diff --git a/sys/dev/pci/if_stge.c b/sys/dev/pci/if_stge.c index 3500cb7ed23..53e767c4ff8 100644 --- a/sys/dev/pci/if_stge.c +++ b/sys/dev/pci/if_stge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_stge.c,v 1.21 2005/09/11 18:04:02 brad Exp $ */ +/* $OpenBSD: if_stge.c,v 1.22 2005/09/11 18:17:08 mickey Exp $ */ /* $NetBSD: if_stge.c,v 1.27 2005/05/16 21:35:32 bouyer Exp $ */ /*- @@ -335,6 +335,7 @@ stge_attach(struct device *parent, struct device *self, void *aux) bus_space_tag_t iot, memt; bus_space_handle_t ioh, memh; bus_dma_segment_t seg; + bus_size_t iosize; int ioh_valid, memh_valid; int i, rseg, error; pcireg_t pmode; @@ -349,10 +350,10 @@ stge_attach(struct device *parent, struct device *self, void *aux) */ ioh_valid = (pci_mapreg_map(pa, STGE_PCI_IOBA, PCI_MAPREG_TYPE_IO, 0, - &iot, &ioh, NULL, NULL, 0) == 0); + &iot, &ioh, NULL, &iosize, 0) == 0); memh_valid = (pci_mapreg_map(pa, STGE_PCI_MMBA, PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT, 0, - &memt, &memh, NULL, NULL, 0) == 0); + &memt, &memh, NULL, &iosize, 0) == 0); if (memh_valid) { sc->sc_st = memt; @@ -391,7 +392,7 @@ stge_attach(struct device *parent, struct device *self, void *aux) */ if (pci_intr_map(pa, &ih)) { printf(": unable to map interrupt\n"); - return; + goto fail_0; } intrstr = pci_intr_string(pc, ih); sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, stge_intr, sc, @@ -401,7 +402,7 @@ stge_attach(struct device *parent, struct device *self, void *aux) if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); - return; + goto fail_0; } printf(": %s", intrstr); @@ -620,6 +621,7 @@ stge_attach(struct device *parent, struct device *self, void *aux) fail_1: bus_dmamem_free(sc->sc_dmat, &seg, rseg); fail_0: + bus_space_unmap(sc->sc_st, sc->sc_sh, iosize); return; } diff --git a/sys/dev/pci/if_tl.c b/sys/dev/pci/if_tl.c index b2f49059c66..8c5ccedaa91 100644 --- a/sys/dev/pci/if_tl.c +++ b/sys/dev/pci/if_tl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tl.c,v 1.34 2005/07/02 22:52:16 brad Exp $ */ +/* $OpenBSD: if_tl.c,v 1.35 2005/09/11 18:17:08 mickey Exp $ */ /* * Copyright (c) 1997, 1998 @@ -1996,7 +1996,6 @@ tl_attach(parent, self, aux) pci_intr_handle_t ih; const char *intrstr = NULL; struct ifnet *ifp = &sc->arpcom.ac_if; - bus_addr_t iobase; bus_size_t iosize; u_int32_t command; int i, rseg; @@ -2014,35 +2013,27 @@ tl_attach(parent, self, aux) printf(": failed to enable I/O ports\n"); return; } - if (pci_io_find(pc, pa->pa_tag, TL_PCI_LOIO, &iobase, &iosize)) { - if (pci_io_find(pc, pa->pa_tag, TL_PCI_LOMEM, - &iobase, &iosize)) { - printf(": failed to find i/o space\n"); + if (pci_mapreg_map(pa, TL_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0, + &sc->tl_btag, &sc->tl_bhandle, NULL, &iosize, 0)) { + if (pci_mapreg_map(pa, TL_PCI_LOMEM, PCI_MAPREG_TYPE_IO, 0, + &sc->tl_btag, &sc->tl_bhandle, NULL, &iosize, 0)) { + printf(": failed to map i/o space\n"); return; } } - if (bus_space_map(pa->pa_iot, iobase, iosize, 0, &sc->tl_bhandle)) { - printf(": failed map i/o space\n"); - return; - } - sc->tl_btag = pa->pa_iot; #else if (!(command & PCI_COMMAND_MEM_ENABLE)) { printf(": failed to enable memory mapping\n"); return; } - if (pci_mem_find(pc, pa->pa_tag, TL_PCI_LOMEM, &iobase, &iosize, NULL)){ - if (pci_mem_find(pc, pa->pa_tag, TL_PCI_LOIO, - &iobase, &iosize, NULL)) { - printf(": failed to find memory space\n"); + if (pci_mapreg_map(pa, TL_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0, + &sc->tl_btag, &sc->tl_bhandle, NULL, &iosize, 0)){ + if (pci_mapreg_map(pa, TL_PCI_LOIO, PCI_MAPREG_TYPE_MEM, 0, + &sc->tl_btag, &sc->tl_bhandle, NULL, &iosize, 0)){ + printf(": failed to map memory space\n"); return; } } - if (bus_space_map(pa->pa_memt, iobase, iosize, 0, &sc->tl_bhandle)) { - printf(": failed map memory space\n"); - return; - } - sc->tl_btag = pa->pa_memt; #endif /* @@ -2057,6 +2048,7 @@ tl_attach(parent, self, aux) */ if (pci_intr_map(pa, &ih)) { printf(": couldn't map interrupt\n"); + bus_space_unmap(sc->tl_btag, sc->tl_bhandle, iosize); return; } intrstr = pci_intr_string(pc, ih); @@ -2067,6 +2059,7 @@ tl_attach(parent, self, aux) if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); + bus_space_unmap(sc->tl_btag, sc->tl_bhandle, iosize); return; } printf(": %s", intrstr); @@ -2075,6 +2068,7 @@ tl_attach(parent, self, aux) if (bus_dmamem_alloc(sc->sc_dmat, sizeof(struct tl_list_data), PAGE_SIZE, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) { printf("%s: can't alloc list\n", sc->sc_dev.dv_xname); + bus_space_unmap(sc->tl_btag, sc->tl_bhandle, iosize); return; } if (bus_dmamem_map(sc->sc_dmat, &seg, rseg, sizeof(struct tl_list_data), @@ -2089,6 +2083,7 @@ tl_attach(parent, self, aux) printf("%s: can't create dma map\n", sc->sc_dev.dv_xname); bus_dmamem_unmap(sc->sc_dmat, kva, sizeof(struct tl_list_data)); bus_dmamem_free(sc->sc_dmat, &seg, rseg); + bus_space_unmap(sc->tl_btag, sc->tl_bhandle, iosize); return; } if (bus_dmamap_load(sc->sc_dmat, dmamap, kva, @@ -2097,6 +2092,7 @@ tl_attach(parent, self, aux) bus_dmamap_destroy(sc->sc_dmat, dmamap); bus_dmamem_unmap(sc->sc_dmat, kva, sizeof(struct tl_list_data)); bus_dmamem_free(sc->sc_dmat, &seg, rseg); + bus_space_unmap(sc->tl_btag, sc->tl_bhandle, iosize); return; } sc->tl_ldata = (struct tl_list_data *)kva; @@ -2130,7 +2126,8 @@ tl_attach(parent, self, aux) sc->tl_eeaddr, ETHER_ADDR_LEN)) { printf("\n%s: failed to read station address\n", sc->sc_dev.dv_xname); - return; + bus_space_unmap(sc->tl_btag, sc->tl_bhandle, iosize); + return; } if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_OLICOM) { diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c index 914d289f2a8..c71e3d60687 100644 --- a/sys/dev/pci/if_vr.c +++ b/sys/dev/pci/if_vr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vr.c,v 1.46 2005/07/06 02:22:28 brad Exp $ */ +/* $OpenBSD: if_vr.c,v 1.47 2005/09/11 18:17:08 mickey Exp $ */ /* * Copyright (c) 1997, 1998 @@ -646,7 +646,6 @@ vr_attach(parent, self, aux) pci_intr_handle_t ih; const char *intrstr = NULL; struct ifnet *ifp = &sc->arpcom.ac_if; - bus_addr_t iobase; bus_size_t iosize; int rseg; caddr_t kva; @@ -662,7 +661,7 @@ vr_attach(parent, self, aux) command = pci_conf_read(pa->pa_pc, pa->pa_tag, VR_PCI_PWRMGMTCTRL); if (command & VR_PSTATE_MASK) { - u_int32_t iobase, membase, irq; + pcireg_t iobase, membase, irq; /* Save important PCI config data. */ iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, @@ -698,35 +697,27 @@ vr_attach(parent, self, aux) printf(": failed to enable I/O ports\n"); goto fail; } - if (pci_io_find(pc, pa->pa_tag, VR_PCI_LOIO, &iobase, &iosize)) { - printf(": failed to find i/o space\n"); + if (pci_mapreg_map(pa, VR_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0, + &sc->vr_btag, &sc->vr_bhandle, NULL, &iosize, 0)) { + printf(": failed to map i/o space\n"); goto fail; } - if (bus_space_map(pa->pa_iot, iobase, iosize, 0, &sc->vr_bhandle)) { - printf(": failed map i/o space\n"); - goto fail; - } - sc->vr_btag = pa->pa_iot; #else if (!(command & PCI_COMMAND_MEM_ENABLE)) { printf(": failed to enable memory mapping\n"); goto fail; } - if (pci_mem_find(pc, pa->pa_tag, VR_PCI_LOMEM, &iobase, &iosize)) { - printf(": failed to find memory space\n"); + if (pci_mapreg_map(pa, VR_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0, + &sc->vr_btag, &sc->vr_bhandle, NULL, &iosize, 0)) { + printf(": failed to map memory space\n"); goto fail; } - if (bus_space_map(pa->pa_memt, iobase, iosize, 0, &sc->vr_bhandle)) { - printf(": failed map memory space\n"); - goto fail; - } - sc->vr_btag = pa->pa_memt; #endif /* Allocate interrupt */ if (pci_intr_map(pa, &ih)) { printf(": couldn't map interrupt\n"); - goto fail; + goto fail_1; } intrstr = pci_intr_string(pc, ih); sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, vr_intr, sc, @@ -736,7 +727,7 @@ vr_attach(parent, self, aux) if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); - goto fail; + goto fail_1; } printf(": %s", intrstr); @@ -780,21 +771,21 @@ vr_attach(parent, self, aux) if (bus_dmamem_alloc(sc->sc_dmat, sizeof(struct vr_list_data), PAGE_SIZE, 0, &sc->sc_listseg, 1, &rseg, BUS_DMA_NOWAIT)) { printf("%s: can't alloc list\n", sc->sc_dev.dv_xname); - goto fail; + goto fail_1; } if (bus_dmamem_map(sc->sc_dmat, &sc->sc_listseg, rseg, sizeof(struct vr_list_data), &kva, BUS_DMA_NOWAIT)) { printf("%s: can't map dma buffers (%d bytes)\n", sc->sc_dev.dv_xname, sizeof(struct vr_list_data)); bus_dmamem_free(sc->sc_dmat, &sc->sc_listseg, rseg); - goto fail; + goto fail_1; } if (bus_dmamap_create(sc->sc_dmat, sizeof(struct vr_list_data), 1, sizeof(struct vr_list_data), 0, BUS_DMA_NOWAIT, &sc->sc_listmap)) { printf("%s: can't create dma map\n", sc->sc_dev.dv_xname); bus_dmamem_unmap(sc->sc_dmat, kva, sizeof(struct vr_list_data)); bus_dmamem_free(sc->sc_dmat, &sc->sc_listseg, rseg); - goto fail; + goto fail_1; } if (bus_dmamap_load(sc->sc_dmat, sc->sc_listmap, kva, sizeof(struct vr_list_data), NULL, BUS_DMA_NOWAIT)) { @@ -802,7 +793,7 @@ vr_attach(parent, self, aux) bus_dmamap_destroy(sc->sc_dmat, sc->sc_listmap); bus_dmamem_unmap(sc->sc_dmat, kva, sizeof(struct vr_list_data)); bus_dmamem_free(sc->sc_dmat, &sc->sc_listseg, rseg); - goto fail; + goto fail_1; } sc->vr_ldata = (struct vr_list_data *)kva; bzero(sc->vr_ldata, sizeof(struct vr_list_data)); @@ -842,6 +833,8 @@ vr_attach(parent, self, aux) shutdownhook_establish(vr_shutdown, sc); +fail_1: + bus_space_unmap(sc->vr_btag, sc->vr_bhandle, iosize); fail: splx(s); return; diff --git a/sys/dev/pci/if_wb.c b/sys/dev/pci/if_wb.c index c3804a8de1d..d877f9d368c 100644 --- a/sys/dev/pci/if_wb.c +++ b/sys/dev/pci/if_wb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wb.c,v 1.29 2005/08/09 04:10:12 mickey Exp $ */ +/* $OpenBSD: if_wb.c,v 1.30 2005/09/11 18:17:08 mickey Exp $ */ /* * Copyright (c) 1997, 1998 @@ -715,7 +715,6 @@ wb_attach(parent, self, aux) pci_intr_handle_t ih; const char *intrstr = NULL; struct ifnet *ifp = &sc->arpcom.ac_if; - bus_addr_t iobase; bus_size_t iosize; int s, rseg; pcireg_t command; @@ -766,35 +765,27 @@ wb_attach(parent, self, aux) printf(": failed to enable I/O ports!\n"); goto fail; } - if (pci_io_find(pc, pa->pa_tag, WB_PCI_LOIO, &iobase, &iosize)) { - printf(": can't find i/o space\n"); - goto fail; - } - if (bus_space_map(pa->pa_iot, iobase, iosize, 0, &sc->wb_bhandle)) { + if (pci_mapreg_map(pa, WB_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0, + &sc->wb_btag, &sc->wb_bhandle, NULL, &iosize, 0)) { printf(": can't map i/o space\n"); goto fail; } - sc->wb_btag = pa->pa_iot; #else if (!(command & PCI_COMMAND_MEM_ENABLE)) { printf(": failed to enable memory mapping!\n"); goto fail; } - if (pci_mem_find(pc, pa->pa_tag, WB_PCI_LOMEM, &iobase, &iosize, NULL)){ - printf(": can't find mem space\n"); - goto fail; - } - if (bus_space_map(pa->pa_memt, iobase, iosize, 0, &sc->wb_bhandle)) { + if (pci_mapreg_map(pa, WB_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0, + &sc->wb_btag, &sc->wb_bhandle, NULL, &iosize, 0)){ printf(": can't map mem space\n"); goto fail; } - sc->wb_btag = pa->pa_memt; #endif /* Allocate interrupt */ if (pci_intr_map(pa, &ih)) { printf(": couldn't map interrupt\n"); - goto fail; + goto fail_1; } intrstr = pci_intr_string(pc, ih); sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, wb_intr, sc, @@ -804,7 +795,7 @@ wb_attach(parent, self, aux) if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); - goto fail; + goto fail_1; } printf(": %s", intrstr); @@ -822,14 +813,14 @@ wb_attach(parent, self, aux) if (bus_dmamem_alloc(pa->pa_dmat, sizeof(struct wb_list_data), PAGE_SIZE, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) { printf("%s: can't alloc list data\n", sc->sc_dev.dv_xname); - goto fail; + goto fail_1; } if (bus_dmamem_map(pa->pa_dmat, &seg, rseg, sizeof(struct wb_list_data), &kva, BUS_DMA_NOWAIT)) { printf("%s: can't map list data, size %d\n", sc->sc_dev.dv_xname, sizeof(struct wb_list_data)); bus_dmamem_free(pa->pa_dmat, &seg, rseg); - goto fail; + goto fail_1; } if (bus_dmamap_create(pa->pa_dmat, sizeof(struct wb_list_data), 1, sizeof(struct wb_list_data), 0, BUS_DMA_NOWAIT, &dmamap)) { @@ -837,7 +828,7 @@ wb_attach(parent, self, aux) bus_dmamem_unmap(pa->pa_dmat, kva, sizeof(struct wb_list_data)); bus_dmamem_free(pa->pa_dmat, &seg, rseg); - goto fail; + goto fail_1; } if (bus_dmamap_load(pa->pa_dmat, dmamap, kva, sizeof(struct wb_list_data), NULL, BUS_DMA_NOWAIT)) { @@ -846,7 +837,7 @@ wb_attach(parent, self, aux) bus_dmamem_unmap(pa->pa_dmat, kva, sizeof(struct wb_list_data)); bus_dmamem_free(pa->pa_dmat, &seg, rseg); - goto fail; + goto fail_1; } sc->wb_ldata = (struct wb_list_data *)kva; bzero(sc->wb_ldata, sizeof(struct wb_list_data)); @@ -888,6 +879,8 @@ wb_attach(parent, self, aux) shutdownhook_establish(wb_shutdown, sc); +fail_1: + bus_space_unmap(sc->wb_btag, sc->wb_bhandle, iosize); fail: splx(s); return; diff --git a/sys/dev/pci/if_wi_pci.c b/sys/dev/pci/if_wi_pci.c index ae2a22e236c..86f07d31582 100644 --- a/sys/dev/pci/if_wi_pci.c +++ b/sys/dev/pci/if_wi_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi_pci.c,v 1.40 2004/12/08 15:40:40 markus Exp $ */ +/* $OpenBSD: if_wi_pci.c,v 1.41 2005/09/11 18:17:08 mickey Exp $ */ /* * Copyright (c) 2001-2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -298,7 +298,6 @@ wi_pci_plx_attach(struct pci_attach_args *pa, struct wi_softc *sc) bus_space_tag_t localt; bus_space_tag_t iot = pa->pa_iot; bus_space_tag_t memt = pa->pa_memt; - bus_addr_t localbase; bus_size_t localsize, memsize, iosize; u_int32_t intcsr; @@ -329,17 +328,9 @@ wi_pci_plx_attach(struct pci_attach_args *pa, struct wi_softc *sc) localsize = 0; if (pci_mapreg_type(pa->pa_pc, pa->pa_tag, WI_PLX_LOCALRES) == PCI_MAPREG_TYPE_IO) { - if (pci_io_find(pa->pa_pc, pa->pa_tag, - WI_PLX_LOCALRES, &localbase, &localsize) != 0) - printf(": can't find PLX I/O space\n"); - if (localsize != 0) { - if (bus_space_map(pa->pa_iot, localbase, - localsize, 0, &localh) != 0) { - printf(": can't map PLX I/O space\n"); - localsize = 0; - } else - localt = pa->pa_iot; - } + if (pci_mapreg_map(pa, WI_PLX_LOCALRES, PCI_MAPREG_TYPE_IO, + 0, &localt, &localh, NULL, &localsize, 0) != 0) + printf(": can't map PLX I/O space\n"); } if (wi_pci_common_attach(pa, sc) != 0) { diff --git a/sys/dev/pci/isp_pci.c b/sys/dev/pci/isp_pci.c index bc19df45794..507e4156631 100644 --- a/sys/dev/pci/isp_pci.c +++ b/sys/dev/pci/isp_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isp_pci.c,v 1.37 2005/08/09 04:10:13 mickey Exp $ */ +/* $OpenBSD: isp_pci.c,v 1.38 2005/09/11 18:17:08 mickey Exp $ */ /* * PCI specific probe and attach routines for Qlogic ISP SCSI adapters. * @@ -398,55 +398,42 @@ isp_pci_attach(struct device *parent, struct device *self, void *aux) pci_intr_handle_t ih; const char *intrstr; int ioh_valid, memh_valid; - bus_addr_t iobase, mbase; bus_size_t iosize, msize; ioh_valid = memh_valid = 0; #if SCSI_ISP_PREFER_MEM_MAP == 1 - if (pci_mem_find(pa->pa_pc, pa->pa_tag, MEM_MAP_REG, &mbase, &msize, - NULL)) { - printf(": can't find mem space\n"); - } else if (bus_space_map(pa->pa_memt, mbase, msize, 0, &memh)) { + if (pci_mapreg_map(pa, MEM_MAP_REG, PCI_MAPREG_TYPE_MEM, 0, + &memt, &memh, NULL, &msize, 0)) { printf(": can't map mem space\n"); } else { - memt = pa->pa_memt; st = memt; sh = memh; memh_valid = 1; } if (memh_valid == 0) { - if (pci_io_find(pa->pa_pc, pa->pa_tag, IO_MAP_REG, &iobase, - &iosize)) { - printf(": can't find i/o space\n"); - } else if (bus_space_map(pa->pa_iot, iobase, iosize, 0, &ioh)) { - printf(": can't map i/o space\n"); + if (pci_mapreg_map(pa, IO_MAP_REG, PCI_MAPREG_TYPE_IO, 0, + &iot, &ioh, NULL, &iosize, 0)) { } else { - iot = pa->pa_iot; st = iot; sh = ioh; ioh_valid = 1; } } #else - if (pci_io_find(pa->pa_pc, pa->pa_tag, IO_MAP_REG, &iobase, &iosize)) { - printf(": can't find i/o space\n"); - } else if (bus_space_map(pa->pa_iot, iobase, iosize, 0, &ioh)) { + if (pci_mapreg_map(pa, IO_MAP_REG, PCI_MAPREG_TYPE_IO, 0, + &iot, &ioh, NULL, &iosize, 0)) { printf(": can't map i/o space\n"); } else { - iot = pa->pa_iot; st = iot; sh = ioh; ioh_valid = 1; } if (ioh_valid == 0) { - if (pci_mem_find(pa->pa_pc, pa->pa_tag, MEM_MAP_REG, &mbase, - &msize, NULL)) { - printf(": can't find mem space\n"); - } else if (bus_space_map(pa->pa_memt, mbase, msize, 0, &memh)) { + if (pci_mapreg_map(pa, MEM_MAP_REG, PCI_MAPREG_TYPE_MEM, 0, + &memt, &memh, NULL, &msize, 0)) { printf(": can't map mem space\n"); } else { - memt = pa->pa_memt; st = memt; sh = memh; memh_valid = 1; diff --git a/sys/dev/pci/sv.c b/sys/dev/pci/sv.c index 9df487819aa..07002c45f64 100644 --- a/sys/dev/pci/sv.c +++ b/sys/dev/pci/sv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sv.c,v 1.20 2005/08/09 04:10:13 mickey Exp $ */ +/* $OpenBSD: sv.c,v 1.21 2005/09/11 18:17:08 mickey Exp $ */ /* * Copyright (c) 1998 Constantine Paul Sapuntzakis @@ -277,7 +277,6 @@ sv_attach(parent, self, aux) struct pci_attach_args *pa = aux; pci_chipset_tag_t pc = pa->pa_pc; pci_intr_handle_t ih; - bus_addr_t iobase; bus_size_t iosize; char const *intrstr; u_int32_t dmareg, dmaio; @@ -287,17 +286,12 @@ sv_attach(parent, self, aux) sc->sc_pci_tag = pa->pa_tag; /* Map the enhanced port only */ - if (pci_io_find(pc, pa->pa_tag, SV_ENHANCED_PORTBASE_SLOT, - &iobase, &iosize)) { - printf (": Couldn't find enhanced synth I/O range\n"); + if (pci_mapreg_map(pa, SV_ENHANCED_PORTBASE_SLOT, PCI_MAPREG_TYPE_IO, 0, + &sc->sc_iot, &sc->sc_ioh, NULL, &iosize, 0)) { + printf (": Couldn't map enhanced synth I/O range\n"); return; } - if (bus_space_map(sc->sc_iot, iobase, iosize, 0, &sc->sc_ioh)) { - printf(": can't map i/o space\n"); - return; - } - sc->sc_dmatag = pa->pa_dmat; dmareg = pci_conf_read(pa->pa_pc, pa->pa_tag, SV_DMAA_CONFIG_OFF); diff --git a/sys/dev/pci/wdt.c b/sys/dev/pci/wdt.c index 0f93ddeb3bf..1e261081833 100644 --- a/sys/dev/pci/wdt.c +++ b/sys/dev/pci/wdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wdt.c,v 1.5 2003/08/15 20:32:17 tedu Exp $ */ +/* $OpenBSD: wdt.c,v 1.6 2005/09/11 18:17:08 mickey Exp $ */ /*- * Copyright (c) 1998,1999 Alex Nash @@ -149,17 +149,14 @@ wdtattach (parent, self, aux) { struct wdt_softc *wdt = (struct wdt_softc *)self; struct pci_attach_args *const pa = (struct pci_attach_args *)aux; - int unit; bus_size_t iosize; - bus_addr_t iobase; - - wdt->iot = pa->pa_iot; + int unit; unit = wdt->wdt_dev.dv_unit; /* retrieve the I/O region (BAR2) */ - if (pci_io_find(pa->pa_pc, pa->pa_tag, 0x18, &iobase, - &iosize) != 0) { + if (pci_mapreg_map(pa, 0x18, PCI_MAPREG_TYPE_IO, 0, + &wdt->iot, &wdt->ioh, NULL, &iosize, 0) != 0) { printf("wdt%d: couldn't find PCI I/O region\n", unit); return; } @@ -170,12 +167,6 @@ wdtattach (parent, self, aux) return; } - /* map I/O region */ - if (bus_space_map(pa->pa_iot, iobase, iosize, 0, &wdt->ioh) != 0) { - printf("wdt%d: couldn't map PCI I/O region\n", unit); - return; - } - /* initialize the watchdog timer structure */ wdt->unit = unit; wdt->procs = 0; |