Date: Sat, 8 Sep 2007 16:06:16 GMT From: Oleksandr Tymoshenko <gonzo@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 126182 for review Message-ID: <200709081606.l88G6GX8057025@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=126182 Change 126182 by gonzo@gonzo_jeeves on 2007/09/08 16:06:11 o Fix resource handling - map physical address to KSEG1 during activation. Affected files ... .. //depot/projects/mips2/src/sys/mips/mips32/idt/idtpci.c#3 edit Differences ... ==== //depot/projects/mips2/src/sys/mips/mips32/idt/idtpci.c#3 (text+ko) ==== @@ -113,7 +113,6 @@ struct idtpci_softc { device_t sc_dev; - bus_space_tag_t sc_st; int sc_busno; struct rman sc_mem_rman; @@ -217,18 +216,17 @@ sc->sc_io_rman.rm_descr = "IDTPCI I/O Ports"; if (rman_init(&sc->sc_io_rman) != 0 || rman_manage_region(&sc->sc_io_rman, - MIPS_PHYS_TO_KSEG1(IDT_PCIMEM3_BASE), - MIPS_PHYS_TO_KSEG1(IDT_PCIMEM3_BASE + IDT_PCIMEM3_SIZE - 1)) != 0) { + IDT_PCIMEM3_BASE, IDT_PCIMEM3_BASE + IDT_PCIMEM3_SIZE - 1) != 0) { panic("idtpci_attach: failed to set up I/O rman"); } /* Use KSEG1 to access PCI memory for it is uncached */ - sc->sc_mem = MIPS_PHYS_TO_KSEG1(IDT_PCIMEM1_BASE); + sc->sc_mem = 0; sc->sc_mem_rman.rm_type = RMAN_ARRAY; sc->sc_mem_rman.rm_descr = "IDTPCI PCI Memory"; if (rman_init(&sc->sc_mem_rman) != 0 || rman_manage_region(&sc->sc_mem_rman, - sc->sc_mem, sc->sc_mem + IDT_PCIMEM1_SIZE) != 0) { + IDT_PCIMEM1_BASE, IDT_PCIMEM1_BASE + IDT_PCIMEM1_SIZE) != 0) { panic("idtpci_attach: failed to set up memory rman"); } @@ -440,6 +438,7 @@ struct resource *rv = NULL; struct rman *rm; bus_space_handle_t bh = 0; + void *vaddr; switch (type) { case SYS_RES_IRQ: @@ -447,11 +446,9 @@ break; case SYS_RES_MEMORY: rm = &sc->sc_mem_rman; - bh = sc->sc_mem; break; case SYS_RES_IOPORT: rm = &sc->sc_io_rman; - bh = sc->sc_io; break; default: return (NULL); @@ -460,19 +457,23 @@ rv = rman_reserve_resource(rm, start, end, count, flags, child); if (rv == NULL) return (NULL); + + if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) { + vaddr = + (void *)MIPS_PHYS_TO_KSEG1((intptr_t)rman_get_start(rv)); + rman_set_virtual(rv, vaddr); + rman_set_bushandle(rv, (bus_space_handle_t)vaddr); + } + rman_set_rid(rv, *rid); - if (type != SYS_RES_IRQ) { - bh += (rman_get_start(rv)); + + if (flags & RF_ACTIVE) { + if (bus_activate_resource(child, type, *rid, rv)) { + rman_release_resource(rv); + return (NULL); + } + } - rman_set_bustag(rv, sc->sc_st); - rman_set_bushandle(rv, bh); - if (flags & RF_ACTIVE) { - if (bus_activate_resource(child, type, *rid, rv)) { - rman_release_resource(rv); - return (NULL); - } - } - } return (rv); } @@ -480,16 +481,10 @@ idtpci_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { - bus_space_handle_t p; - int error; - - if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) { - error = bus_space_map(rman_get_bustag(r), - rman_get_bushandle(r), rman_get_size(r), 0, &p); - if (error) - return (error); - rman_set_bushandle(r, p); + if (type == SYS_RES_IRQ) { + /* TODO:enable interrupt here? */ } + return (rman_activate_resource(r)); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200709081606.l88G6GX8057025>