diff --git a/sys/dev/pccard/card_if.m b/sys/dev/pccard/card_if.m index f3813ee91198..7952b8620614 100644 --- a/sys/dev/pccard/card_if.m +++ b/sys/dev/pccard/card_if.m @@ -64,7 +64,6 @@ METHOD int set_memory_offset { device_t child; int rid; u_int32_t cardaddr; - u_int32_t *offsetp; } METHOD int get_memory_offset { diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c index 6bbbd123741d..efa170ee03b9 100644 --- a/sys/dev/pccard/pccard.c +++ b/sys/dev/pccard/pccard.c @@ -391,6 +391,8 @@ pccard_function_enable(struct pccard_function *pf) struct pccard_function *tmp; int reg; device_t dev = pf->sc->dev; + uint32_t addr; + if (pf->cfe == NULL) { DEVPRVERBOSE((dev, "No config entry could be allocated.\n")); return ENOMEM; @@ -442,12 +444,16 @@ pccard_function_enable(struct pccard_function *pf) &pf->ccr_rid, 0, ~0, 1 << 10, RF_ACTIVE); if (!pf->ccr_res) goto bad; - DEVPRINTF((dev, "ccr_res == %lx-%lx, base=%lx\n", rman_get_start(pf->ccr_res), rman_get_end(pf->ccr_res), pf->ccr_base)); + DEVPRINTF((dev, "ccr_res == %lx-%lx, base=%lx\n", + rman_get_start(pf->ccr_res), rman_get_end(pf->ccr_res), + pf->ccr_base)); CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, pf->ccr_rid, PCCARD_A_MEM_ATTR); CARD_SET_MEMORY_OFFSET(device_get_parent(dev), dev, - pf->ccr_rid, pf->ccr_base, - &pf->pf_ccr_offset); + pf->ccr_rid, pf->ccr_base); + CARD_GET_MEMORY_OFFSET(device_get_parent(dev), dev, + pf->ccr_rid, &addr); + pf->pf_ccr_offset = pf->ccr_base - addr; pf->pf_ccrt = rman_get_bustag(pf->ccr_res); pf->pf_ccrh = rman_get_bushandle(pf->ccr_res); pf->pf_ccr_realsize = 1; @@ -835,11 +841,11 @@ pccard_set_res_flags(device_t dev, device_t child, int type, int rid, static int pccard_set_memory_offset(device_t dev, device_t child, int rid, - u_int32_t offset, u_int32_t *offsetp) + u_int32_t offset) { return CARD_SET_MEMORY_OFFSET(device_get_parent(dev), child, rid, - offset, offsetp); + offset); } static int diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c index e39e956eccdf..caa22fd74a3a 100644 --- a/sys/dev/pccbb/pccbb.c +++ b/sys/dev/pccbb/pccbb.c @@ -242,7 +242,7 @@ static int pccbb_pcic_release_resource(device_t self, device_t child, int type, static int pccbb_pcic_set_res_flags(device_t self, device_t child, int type, int rid, u_int32_t flags); static int pccbb_pcic_set_memory_offset(device_t self, device_t child, int rid, - u_int32_t offset, u_int32_t *offsetp); + u_int32_t offset); static int pccbb_power_enable_socket(device_t self, device_t child); static void pccbb_power_disable_socket(device_t self, device_t child); static int pccbb_activate_resource(device_t self, device_t child, int type, @@ -1706,7 +1706,7 @@ pccbb_pcic_set_res_flags(device_t self, device_t child, int type, int rid, static int pccbb_pcic_set_memory_offset(device_t self, device_t child, int rid, - u_int32_t cardaddr, u_int32_t *offsetp) + u_int32_t cardaddr) { struct pccbb_softc *sc = device_get_softc(self); int win; @@ -1726,11 +1726,11 @@ pccbb_pcic_set_memory_offset(device_t self, device_t child, int rid, return 1; } - *offsetp = cardaddr % PCIC_MEM_PAGESIZE; - cardaddr -= *offsetp; - sc->mem[win].realsize = sc->mem[win].size + *offsetp + PCIC_MEM_PAGESIZE - 1; - sc->mem[win].realsize = sc->mem[win].realsize - - (sc->mem[win].realsize % PCIC_MEM_PAGESIZE); + /* Fixup size since cardaddr must align to PCIC_MEM_PAGESIZE */ + /* XXX This should be a marco XXX */ + sc->mem[win].realsize = (sc->mem[win].size + + (cardaddr & (PCIC_MEM_PAGESIZE - 1))) & ~(PCIC_MEM_PAGESIZE - 1); + cardaddr &= ~(PCIC_MEM_PAGESIZE - 1); sc->mem[win].offset = cardaddr - sc->mem[win].addr; pccbb_pcic_do_mem_map(sc, win);