--- //depot/vendor/freebsd/src/sys/dev/si/si.c +++ //depot/user/jhb/cleanup/sys/dev/si/si.c @@ -301,8 +301,8 @@ } #endif - DPRINT((0, DBG_AUTOBOOT, "si%d: type: %s paddr: %x maddr: %x\n", unit, - sc->sc_typename, sc->sc_paddr, sc->sc_maddr)); + DPRINT((0, DBG_AUTOBOOT, "si%d: type: %s paddr: %lx\n", unit, + sc->sc_typename, rman_get_start(sc->sc_mem_res), sc->sc_maddr)); sc->sc_ports = NULL; /* mark as uninitialised */ @@ -313,9 +313,9 @@ switch (sc->sc_type) { #ifdef DEV_EISA case SIEISA: - outb(sc->sc_iobase + 2, sc->sc_irq << 4); + SI_WRITE_IO(sc, 2, sc->sc_irq << 4); + break; #endif - break; case SIPCI: *(maddr+SIPCIRESET) = 0; break; @@ -361,8 +361,8 @@ case SIEISA: /* modify the download code to tell it that it's on an EISA */ *(maddr + 0x42) = 1; - outb(sc->sc_iobase + 2, (sc->sc_irq << 4) | 4); - (void)inb(sc->sc_iobase + 3); /* reset interrupt */ + SI_WRITE_IO(sc, 2, (sc->sc_irq << 4) | 4); + SI_READ_IO(sc, 3); /* reset interrupt */ break; #endif case SIPCI: @@ -1168,7 +1168,7 @@ case SIEISA: maddr = sc->sc_maddr; ((volatile struct si_reg *)maddr)->int_pending = 0; - (void)inb(sc->sc_iobase + 3); + SI_READ_IO(sc, 3); break; #endif case SIEMPTY: --- //depot/vendor/freebsd/src/sys/dev/si/si_eisa.c +++ //depot/user/jhb/cleanup/sys/dev/si/si_eisa.c @@ -39,9 +39,10 @@ static int si_eisa_probe(device_t dev) { + struct resource *res; u_long iobase; u_long maddr; - int irq; + int irq, rid; if (eisa_get_id(dev) != SIEISADEVID) return ENXIO; @@ -51,11 +52,17 @@ iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + SIEISABASE; eisa_add_iospace(dev, iobase, SIEISAIOSIZE, RESVADDR_NONE); - maddr = (inb(iobase+1) << 24) | (inb(iobase) << 16); + rid = 0; + res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); + if (res == NULL) + return (ENXIO); + + maddr = (bus_read_1(res, 1) << 24) | (bus_read_1(res, 0) << 16); eisa_add_mspace(dev, maddr, SIEISA_MEMSIZE, RESVADDR_NONE); - irq = ((inb(iobase+2) >> 4) & 0xf); + irq = ((bus_read_1(res, 2) >> 4) & 0xf); eisa_add_intr(dev, irq, EISA_TRIGGER_LEVEL); /* XXX shared? */ + bus_release_resource(dev, SYS_RES_IOPORT, rid, res); return (0); } @@ -80,7 +87,6 @@ device_printf(dev, "couldn't allocate ioports\n"); goto fail; } - sc->sc_iobase = rman_get_start(sc->sc_port_res); sc->sc_mem_rid = 0; sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, @@ -89,7 +95,6 @@ device_printf(dev, "couldn't allocate iomemory"); goto fail; } - sc->sc_paddr = (caddr_t)rman_get_start(sc->sc_mem_res); sc->sc_maddr = rman_get_virtual(sc->sc_mem_res); sc->sc_irq_rid = 0; @@ -101,7 +106,7 @@ goto fail; } sc->sc_irq = rman_get_start(sc->sc_irq_res); - error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY, + error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY | INTR_MPSAFE, NULL, si_intr, sc,&ih); if (error) { device_printf(dev, "couldn't activate interrupt"); --- //depot/vendor/freebsd/src/sys/dev/si/si_isa.c +++ //depot/user/jhb/cleanup/sys/dev/si/si_isa.c @@ -45,9 +45,8 @@ struct si_softc *sc; int type; u_int i, ramsize; - volatile unsigned char was, *ux; - volatile unsigned char *maddr; - unsigned char *paddr; + uint8_t was; + unsigned long paddr; int unit; /* No pnp support */ @@ -65,31 +64,29 @@ device_printf(dev, "cannot allocate memory resource\n"); return ENXIO; } - paddr = (caddr_t)rman_get_start(sc->sc_mem_res);/* physical */ - maddr = rman_get_virtual(sc->sc_mem_res); /* in kvm */ + paddr = rman_get_start(sc->sc_mem_res);/* physical */ - DPRINT((0, DBG_AUTOBOOT, "si%d: probe at virtual=0x%x physical=0x%x\n", - unit, maddr, paddr)); + DPRINT((0, DBG_AUTOBOOT, "si%d: probe at physical=0x%lx\n", + unit, paddr)); /* * this is a lie, but it's easier than trying to handle caching * and ram conflicts in the >1M and <16M region. */ - if ((caddr_t)paddr < (caddr_t)0xA0000 || - (caddr_t)paddr >= (caddr_t)0x100000) { - device_printf(dev, "maddr (%p) out of range\n", paddr); + if (paddr < 0xA0000 || paddr >= 0x100000) { + device_printf(dev, "maddr (%#lx) out of range\n", paddr); goto fail; } - if (((uintptr_t)paddr & 0x7fff) != 0) { - device_printf(dev, "maddr (%p) not on 32k boundary\n", paddr); + if ((paddr & 0x7fff) != 0) { + device_printf(dev, "maddr (%#lx) not on 32k boundary\n", paddr); goto fail; } /* Is there anything out there? (0x17 is just an arbitrary number) */ - *maddr = 0x17; - if (*maddr != 0x17) { - device_printf(dev, "0x17 check fail at phys %p\n", paddr); + SI_WRITE_REG(sc, 0, 0x17); + if (SI_READ_REG(sc, 0) != 0x17) { + device_printf(dev, "0x17 check fail at phys %#lx\n", paddr); goto fail; } /* @@ -102,24 +99,24 @@ unsigned char *jet_chk_str = "JET HOST BY KEV#"; for (i = 0; i < strlen(jet_chk_str); i++) - if (jet_chk_str[i] != *(maddr + SIJETIDSTR + 2 * i)) + if (jet_chk_str[i] != SI_READ_REG(sc, SIJETIDSTR + 2 * i)) goto try_mk2; } DPRINT((0, DBG_AUTOBOOT|DBG_FAIL, "si%d: JET first check - 0x%x\n", - unit, (*(maddr+SIJETIDBASE)))); - if (*(maddr+SIJETIDBASE) != (SISPLXID&0xff)) + unit, SI_READ_REG(sc, SIJETIDBASE))); + if (SI_READ_REG(sc, SIJETIDBASE) != (SISPLXID & 0xff)) goto try_mk2; DPRINT((0, DBG_AUTOBOOT|DBG_FAIL, "si%d: JET second check - 0x%x\n", - unit, (*(maddr+SIJETIDBASE+2)))); - if (*(maddr+SIJETIDBASE+2) != ((SISPLXID&0xff00)>>8)) + unit, SI_READ_REG(sc, SIJETIDBASE+2))); + if (SI_READ_REG(sc, SIJETIDBASE + 2) != ((SISPLXID & 0xff00) >> 8)) goto try_mk2; /* It must be a Jet ISA or RIO card */ DPRINT((0, DBG_AUTOBOOT|DBG_FAIL, "si%d: JET id check - 0x%x\n", - unit, (*(maddr+SIUNIQID)))); - if ((*(maddr+SIUNIQID) & 0xf0) != 0x20) + unit, SI_READ_REG(sc, SIUNIQID))); + if ((SI_READ_REG(sc, SIUNIQID) & 0xf0) != 0x20) goto try_mk2; /* It must be a Jet ISA SI/XIO card */ - *(maddr + SIJETCONFIG) = 0; + SI_WRITE_REG(sc, SIJETCONFIG, 0); type = SIJETISA; ramsize = SIJET_RAMSIZE; goto got_card; @@ -130,13 +127,13 @@ * Try for a MK II next (SIHOST2) */ for (i = SIPLSIG; i < SIPLSIG + 8; i++) - if ((*(maddr+i) & 7) != (~(unsigned char)i & 7)) + if ((SI_READ_REG(sc, i) & 7) != (~(unsigned char)i & 7)) goto try_mk1; /* It must be an SIHOST2 */ - *(maddr + SIPLRESET) = 0; - *(maddr + SIPLIRQCLR) = 0; - *(maddr + SIPLIRQSET) = 0x10; + SI_WRITE_REG(sc, SIPLRESET, 0); + SI_WRITE_REG(sc, SIPLIRQCLR, 0); + SI_WRITE_REG(sc, SIPLIRQSET, 0x10); type = SIHOST2; ramsize = SIHOST2_RAMSIZE; goto got_card; @@ -145,15 +142,15 @@ /* * Its not a MK II, so try for a MK I (SIHOST) */ - *(maddr+SIRESET) = 0x0; /* reset the card */ - *(maddr+SIINTCL) = 0x0; /* clear int */ - *(maddr+SIRAM) = 0x17; - if (*(maddr+SIRAM) != (unsigned char)0x17) + SI_WRITE_REG(sc, SIRESET, 0x0); /* reset the card */ + SI_WRITE_REG(sc, SIINTCL, 0x0); /* clear int */ + SI_WRITE_REG(sc, SIRAM, 0x17); + if (SI_READ_REG(sc, SIRAM) != 0x17) goto fail; - *(maddr+0x7ff8) = 0x17; - if (*(maddr+0x7ff8) != (unsigned char)0x17) { - device_printf(dev, "0x17 check fail at phys %p = 0x%x\n", - paddr+0x77f8, *(maddr+0x77f8)); + SI_WRITE_REG(sc, 0x7ff8, 0x17); + if (SI_READ_REG(sc, 0x7ff8) != 0x17) { + device_printf(dev, "0x17 check fail at phys %#lx = 0x%x\n", + paddr+0x77f8, SI_READ_REG(sc, 0x77f8)); goto fail; } @@ -165,27 +162,25 @@ DPRINT((0, DBG_AUTOBOOT, "si%d: found type %d card, try memory test\n", unit, type)); /* Try the acid test */ - ux = maddr + SIRAM; - for (i = 0; i < ramsize; i++, ux++) - *ux = (unsigned char)(i&0xff); - ux = maddr + SIRAM; - for (i = 0; i < ramsize; i++, ux++) { - if ((was = *ux) != (unsigned char)(i&0xff)) { + for (i = 0; i < ramsize; i++) + SI_WRITE_REG(sc, SIRAM + i, i & 0xff); + for (i = 0; i < ramsize; i++) { + was = SI_READ_REG(sc, SIRAM + i); + if (was != (unsigned char)(i & 0xff)) { device_printf(dev, - "memtest fail at phys %p, was %x should be %x\n", + "memtest fail at phys %#lx, was %x should be %x\n", paddr + i, was, i & 0xff); goto fail; } } /* clear out the RAM */ - ux = maddr + SIRAM; for (i = 0; i < ramsize; i++) - *ux++ = 0; - ux = maddr + SIRAM; + SI_WRITE_REG(sc, SIRAM + i, 0); for (i = 0; i < ramsize; i++) { - if ((was = *ux++) != 0) { - device_printf(dev, "clear fail at phys %p, was %x\n", + was = SI_READ_REG(sc, SIRAM + i); + if (was != 0) { + device_printf(dev, "clear fail at phys %#lx, was %x\n", paddr + i, was); goto fail; } @@ -279,7 +274,6 @@ device_printf(dev, "couldn't map memory\n"); goto fail; } - sc->sc_paddr = (caddr_t)rman_get_start(sc->sc_mem_res); sc->sc_maddr = rman_get_virtual(sc->sc_mem_res); sc->sc_irq_rid = 0; @@ -291,7 +285,7 @@ goto fail; } sc->sc_irq = rman_get_start(sc->sc_irq_res); - error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY, + error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY | INTR_MPSAFE, NULL, si_intr, sc, &ih); if (error) { device_printf(dev, "couldn't activate interrupt\n"); --- //depot/vendor/freebsd/src/sys/dev/si/si_pci.c +++ //depot/user/jhb/cleanup/sys/dev/si/si_pci.c @@ -86,7 +86,6 @@ device_printf(dev, "couldn't map memory\n"); goto fail; } - sc->sc_paddr = (caddr_t)rman_get_start(sc->sc_mem_res); sc->sc_maddr = rman_get_virtual(sc->sc_mem_res); sc->sc_irq_rid = 0; @@ -98,7 +97,7 @@ goto fail; } sc->sc_irq = rman_get_start(sc->sc_irq_res); - error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY, + error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY | INTR_MPSAFE, NULL, si_intr, sc, &ih); if (error) { device_printf(dev, "could not activate interrupt\n"); @@ -108,7 +107,6 @@ if (pci_get_devid(dev) == 0x200011cb) { int rid; struct resource *plx_res; - uint32_t *addr; uint32_t oldvalue; /* Perform a PLX control register fixup */ @@ -118,11 +116,10 @@ if (plx_res == NULL) { device_printf(dev, "couldn't map plx registers\n"); } else { - addr = rman_get_virtual(plx_res); - oldvalue = addr[0x50 / 4]; + oldvalue = bus_read_4(plx_res, 0x50); if (oldvalue != 0x18260000) { device_printf(dev, "PLX register 0x50: 0x%08x changed to 0x%08x\n", oldvalue, 0x18260000); - addr[0x50 / 4] = 0x18260000; + bus_write_4(plx_res, 0x50, 0x18260000); } bus_release_resource(dev, SYS_RES_MEMORY, rid, plx_res); } --- //depot/vendor/freebsd/src/sys/dev/si/sivar.h +++ //depot/user/jhb/cleanup/sys/dev/si/sivar.h @@ -45,11 +45,9 @@ struct si_port *sc_ports; /* port structures for this card */ - caddr_t sc_paddr; /* physical addr of iomem */ - caddr_t sc_maddr; /* kvaddr of iomem */ + void *sc_maddr; /* kvaddr of iomem */ int sc_nport; /* # ports on this card */ int sc_irq; /* copy of attach irq */ - int sc_iobase; /* EISA io port address */ struct resource *sc_port_res; struct resource *sc_irq_res; struct resource *sc_mem_res; @@ -59,6 +57,13 @@ int sc_memsize; }; +#define SI_READ_REG(sc, reg) bus_read_1((sc)->sc_mem_res, (reg)) +#define SI_WRITE_REG(sc, reg, val) \ + bus_write_1((sc)->sc_mem_res, (reg), (val)) +#define SI_READ_IO(sc, reg) bus_read_1((sc)->sc_port_res, (reg)) +#define SI_WRITE_IO(sc, reg, val) \ + bus_write_1((sc)->sc_port_res, (reg), (val)) + #endif /* _KERNEL */ #ifdef SI_DEBUG