summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2009-07-23 19:30:43 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2009-07-23 19:30:43 +0000
commit3aa3a7140af850f9a306cf0e49c5f428073747fa (patch)
treee8720d5f6d783e9638ce0292b622c2eabebc6e53
parentc5731045524945a5f5f72d7842dbaeb97ba11158 (diff)
Use pci_mapreg_map() to map ROM.
-rw-r--r--sys/dev/pci/if_gem_pci.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/sys/dev/pci/if_gem_pci.c b/sys/dev/pci/if_gem_pci.c
index ed188600a6d..36be3324560 100644
--- a/sys/dev/pci/if_gem_pci.c
+++ b/sys/dev/pci/if_gem_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gem_pci.c,v 1.29 2009/03/29 21:53:52 sthen Exp $ */
+/* $OpenBSD: if_gem_pci.c,v 1.30 2009/07/23 19:30:42 kettenis Exp $ */
/* $NetBSD: if_gem_pci.c,v 1.1 2001/09/16 00:11:42 eeh Exp $ */
/*
@@ -137,25 +137,20 @@ gem_pci_enaddr(struct gem_softc *sc, struct pci_attach_args *pa)
struct pci_vpd *vpd;
bus_space_handle_t romh;
bus_space_tag_t romt;
- bus_size_t romsize;
+ bus_size_t romsize = 0;
u_int8_t buf[32];
- pcireg_t address, mask;
+ pcireg_t address;
int dataoff, vpdoff;
int rv = -1;
+ if (pci_mapreg_map(pa, PCI_ROM_REG, PCI_MAPREG_TYPE_MEM, 0,
+ &romt, &romh, 0, &romsize, 0))
+ return (-1);
+
address = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_ROM_REG);
- pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_ROM_REG, 0xfffffffe);
- mask = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_ROM_REG);
address |= PCI_ROM_ENABLE;
pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_ROM_REG, address);
- romt = pa->pa_memt;
- romsize = PCI_ROM_SIZE(mask);
- if (bus_space_map(romt, PCI_ROM_ADDR(address), romsize, 0, &romh)) {
- romsize = 0;
- goto fail;
- }
-
bus_space_read_region_1(romt, romh, 0, buf, sizeof(buf));
if (bcmp(buf, gem_promhdr, sizeof(gem_promhdr)))
goto fail;