From owner-p4-projects@FreeBSD.ORG Sat Sep 8 16:06:17 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4ED4716A469; Sat, 8 Sep 2007 16:06:17 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0A95316A420 for ; Sat, 8 Sep 2007 16:06:17 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id E91B713C46B for ; Sat, 8 Sep 2007 16:06:16 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l88G6GYN057028 for ; Sat, 8 Sep 2007 16:06:16 GMT (envelope-from gonzo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l88G6GX8057025 for perforce@freebsd.org; Sat, 8 Sep 2007 16:06:16 GMT (envelope-from gonzo@FreeBSD.org) Date: Sat, 8 Sep 2007 16:06:16 GMT Message-Id: <200709081606.l88G6GX8057025@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko To: Perforce Change Reviews Cc: Subject: PERFORCE change 126182 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Sep 2007 16:06:17 -0000 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)); }