From owner-svn-src-all@FreeBSD.ORG Mon Nov 11 15:23:35 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id C0753B27; Mon, 11 Nov 2013 15:23:35 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 935702F3C; Mon, 11 Nov 2013 15:23:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rABFNZJP003070; Mon, 11 Nov 2013 15:23:35 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rABFNZHk003069; Mon, 11 Nov 2013 15:23:35 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201311111523.rABFNZHk003069@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 11 Nov 2013 15:23:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r257992 - head/sys/powerpc/ofw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2013 15:23:35 -0000 Author: nwhitehorn Date: Mon Nov 11 15:23:35 2013 New Revision: 257992 URL: http://svnweb.freebsd.org/changeset/base/257992 Log: Allow OF_decode_addr() to also be able to map resources on big-endian devices. To this end, make PCI device detection rely on the device_type field rather than name, as per the standard. Modified: head/sys/powerpc/ofw/ofw_machdep.c Modified: head/sys/powerpc/ofw/ofw_machdep.c ============================================================================== --- head/sys/powerpc/ofw/ofw_machdep.c Mon Nov 11 15:00:33 2013 (r257991) +++ head/sys/powerpc/ofw/ofw_machdep.c Mon Nov 11 15:23:35 2013 (r257992) @@ -627,7 +627,7 @@ OF_getetheraddr(device_t dev, u_char *ad static void OF_get_addr_props(phandle_t node, uint32_t *addrp, uint32_t *sizep, int *pcip) { - char name[16]; + char type[64]; uint32_t addr, size; int pci, res; @@ -639,10 +639,10 @@ OF_get_addr_props(phandle_t node, uint32 size = 1; pci = 0; if (addr == 3 && size == 2) { - res = OF_getprop(node, "name", name, sizeof(name)); + res = OF_getprop(node, "device_type", type, sizeof(type)); if (res != -1) { - name[sizeof(name) - 1] = '\0'; - pci = (strcmp(name, "pci") == 0) ? 1 : 0; + type[sizeof(type) - 1] = '\0'; + pci = (strcmp(type, "pci") == 0) ? 1 : 0; } } if (addrp != NULL) @@ -676,8 +676,13 @@ OF_decode_addr(phandle_t dev, int regno, if (tag == NULL || handle == NULL) return (EINVAL); + /* Assume big-endian unless we find a PCI device */ + *tag = &bs_be_tag; + /* Get the requested register. */ OF_get_addr_props(bridge, &naddr, &nsize, &pci); + if (pci) + *tag = &bs_le_tag; res = OF_getprop(dev, (pci) ? "assigned-addresses" : "reg", cell, sizeof(cell)); if (res == -1) @@ -705,6 +710,8 @@ OF_decode_addr(phandle_t dev, int regno, parent = OF_parent(bridge); while (parent != 0) { OF_get_addr_props(parent, &nbridge, NULL, &pcib); + if (pcib) + *tag = &bs_le_tag; res = OF_getprop(bridge, "ranges", cell, sizeof(cell)); if (res == -1) goto next; @@ -745,7 +752,6 @@ OF_decode_addr(phandle_t dev, int regno, OF_get_addr_props(bridge, &naddr, &nsize, &pci); } - *tag = &bs_le_tag; return (bus_space_map(*tag, addr, size, prefetch ? BUS_SPACE_MAP_PREFETCHABLE : 0, handle)); }