From owner-svn-src-all@FreeBSD.ORG Tue May 13 17:59:20 2014 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 ESMTPS id 6EE441B6; Tue, 13 May 2014 17:59:20 +0000 (UTC) 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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5A6632F8F; Tue, 13 May 2014 17:59:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4DHxKNd008727; Tue, 13 May 2014 17:59:20 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4DHxIqw008713; Tue, 13 May 2014 17:59:18 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201405131759.s4DHxIqw008713@svn.freebsd.org> From: Ian Lepore Date: Tue, 13 May 2014 17:59:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r265967 - in stable/10/sys: arm/mv dev/fdt dev/ofw powerpc/powerpc X-SVN-Group: stable-10 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.18 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: Tue, 13 May 2014 17:59:20 -0000 Author: ian Date: Tue May 13 17:59:17 2014 New Revision: 265967 URL: http://svnweb.freebsd.org/changeset/base/265967 Log: MFC r256932, r256938, r256966, r256953, r256967, r256969, r257015: Add a new function (OF_getencprop()) that undoes the transformation applied by encode-int. Specifically, it takes a set of 32-bit cell values and changes them to host byte order. Most non-string instances of OF_getprop() should be using this function, which is a no-op on big-endian platforms. Use the new function all over the place. Modified: stable/10/sys/arm/mv/gpio.c stable/10/sys/dev/fdt/fdt_common.c stable/10/sys/dev/fdt/fdt_pci.c stable/10/sys/dev/fdt/simplebus.c stable/10/sys/dev/ofw/ofw_bus_subr.c stable/10/sys/dev/ofw/ofw_console.c stable/10/sys/dev/ofw/ofw_fdt.c stable/10/sys/dev/ofw/ofw_iicbus.c stable/10/sys/dev/ofw/openfirm.c stable/10/sys/powerpc/powerpc/nexus.c Modified: stable/10/sys/arm/mv/gpio.c ============================================================================== --- stable/10/sys/arm/mv/gpio.c Tue May 13 17:51:15 2014 (r265966) +++ stable/10/sys/arm/mv/gpio.c Tue May 13 17:59:17 2014 (r265967) @@ -605,7 +605,6 @@ int platform_gpio_init(void) { phandle_t child, parent, root, ctrl; - ihandle_t ctrl_ihandle; pcell_t gpios[MAX_PINS_PER_NODE * GPIOS_PROP_CELLS]; struct gpio_ctrl_entry *e; int len, rv; @@ -639,9 +638,7 @@ platform_gpio_init(void) * contain a ref. to a node defining GPIO * controller. */ - ctrl_ihandle = (ihandle_t)gpios[0]; - ctrl_ihandle = fdt32_to_cpu(ctrl_ihandle); - ctrl = OF_instance_to_package(ctrl_ihandle); + ctrl = OF_xref_phandle(fdt32_to_cpu(gpios[0])); if (fdt_is_compatible(ctrl, e->compat)) /* Call a handler. */ Modified: stable/10/sys/dev/fdt/fdt_common.c ============================================================================== --- stable/10/sys/dev/fdt/fdt_common.c Tue May 13 17:51:15 2014 (r265966) +++ stable/10/sys/dev/fdt/fdt_common.c Tue May 13 17:59:17 2014 (r265967) @@ -523,7 +523,7 @@ fdt_intr_to_rl(phandle_t node, struct re /* * Find #interrupt-cells of the interrupt domain. */ - if (OF_getprop(node, "interrupt-parent", &iph, sizeof(iph)) <= 0) { + if (OF_getencprop(node, "interrupt-parent", &iph, sizeof(iph)) <= 0) { debugf("no intr-parent phandle\n"); intr_par = OF_parent(node); } else { @@ -583,7 +583,7 @@ fdt_get_phyaddr(phandle_t node, device_t uint32_t i; device_t parent, child; - if (OF_getprop(node, "phy-handle", (void *)&phy_handle, + if (OF_getencprop(node, "phy-handle", (void *)&phy_handle, sizeof(phy_handle)) <= 0) return (ENXIO); Modified: stable/10/sys/dev/fdt/fdt_pci.c ============================================================================== --- stable/10/sys/dev/fdt/fdt_pci.c Tue May 13 17:51:15 2014 (r265966) +++ stable/10/sys/dev/fdt/fdt_pci.c Tue May 13 17:59:17 2014 (r265967) @@ -258,7 +258,7 @@ fdt_pci_route_intr(int bus, int slot, in struct fdt_pci_intr *intr_info, int *interrupt) { pcell_t child_spec[4], masked[4]; - ihandle_t iph; + phandle_t iph; pcell_t intr_par; pcell_t *map_ptr; uint32_t addr; @@ -283,7 +283,7 @@ fdt_pci_route_intr(int bus, int slot, in i = 0; while (i < map_len) { iph = fdt32_to_cpu(map_ptr[par_idx]); - intr_par = OF_instance_to_package(iph); + intr_par = OF_xref_phandle(iph); err = fdt_addr_cells(intr_par, &par_addr_cells); if (err != 0) { Modified: stable/10/sys/dev/fdt/simplebus.c ============================================================================== --- stable/10/sys/dev/fdt/simplebus.c Tue May 13 17:51:15 2014 (r265966) +++ stable/10/sys/dev/fdt/simplebus.c Tue May 13 17:59:17 2014 (r265967) @@ -339,8 +339,7 @@ simplebus_get_interrupt_parent(device_t struct simplebus_devinfo *di; struct fdt_ic *ic; device_t ip; - ihandle_t iph; - phandle_t ph; + phandle_t ph, iph; ip = NULL; @@ -348,10 +347,9 @@ simplebus_get_interrupt_parent(device_t if (di == NULL) return (NULL); - if (OF_getprop(di->di_ofw.obd_node, "interrupt-parent", &iph, + if (OF_getencprop(di->di_ofw.obd_node, "interrupt-parent", &iph, sizeof(iph)) > 0) { - iph = fdt32_to_cpu(iph); - ph = OF_instance_to_package(iph); + ph = OF_xref_phandle(iph); SLIST_FOREACH(ic, &fdt_ic_list_head, fdt_ics) { if (ic->iph == ph) { ip = ic->dev; Modified: stable/10/sys/dev/ofw/ofw_bus_subr.c ============================================================================== --- stable/10/sys/dev/ofw/ofw_bus_subr.c Tue May 13 17:51:15 2014 (r265966) +++ stable/10/sys/dev/ofw/ofw_bus_subr.c Tue May 13 17:59:17 2014 (r265967) @@ -229,14 +229,14 @@ ofw_bus_setup_iinfo(phandle_t node, stru pcell_t addrc; int msksz; - if (OF_getprop(node, "#address-cells", &addrc, sizeof(addrc)) == -1) + if (OF_getencprop(node, "#address-cells", &addrc, sizeof(addrc)) == -1) addrc = 2; ii->opi_addrc = addrc * sizeof(pcell_t); - ii->opi_imapsz = OF_getprop_alloc(node, "interrupt-map", 1, + ii->opi_imapsz = OF_getencprop_alloc(node, "interrupt-map", 1, (void **)&ii->opi_imap); if (ii->opi_imapsz > 0) { - msksz = OF_getprop_alloc(node, "interrupt-map-mask", 1, + msksz = OF_getencprop_alloc(node, "interrupt-map-mask", 1, (void **)&ii->opi_imapmsk); /* * Failure to get the mask is ignored; a full mask is used @@ -261,7 +261,7 @@ ofw_bus_lookup_imap(phandle_t node, stru ("ofw_bus_lookup_imap: register size too small: %d < %d", regsz, ii->opi_addrc)); if (node != -1) { - rv = OF_getprop(node, "reg", reg, regsz); + rv = OF_getencprop(node, "reg", reg, regsz); if (rv < regsz) panic("ofw_bus_lookup_imap: cannot get reg property"); } @@ -316,8 +316,8 @@ ofw_bus_search_intrmap(void *intr, int i i = imapsz; while (i > 0) { bcopy(mptr + physsz + intrsz, &parent, sizeof(parent)); - if (OF_searchprop(OF_xref_phandle(parent), "#interrupt-cells", - &pintrsz, sizeof(pintrsz)) == -1) + if (OF_searchencprop(OF_xref_phandle(parent), + "#interrupt-cells", &pintrsz, sizeof(pintrsz)) == -1) pintrsz = 1; /* default */ pintrsz *= sizeof(pcell_t); Modified: stable/10/sys/dev/ofw/ofw_console.c ============================================================================== --- stable/10/sys/dev/ofw/ofw_console.c Tue May 13 17:51:15 2014 (r265966) +++ stable/10/sys/dev/ofw/ofw_console.c Tue May 13 17:59:17 2014 (r265967) @@ -106,8 +106,8 @@ cn_drvinit(void *unused) SYSINIT(cndev, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE, cn_drvinit, NULL); -static int stdin; -static int stdout; +static pcell_t stdin; +static pcell_t stdout; static int ofwtty_open(struct tty *tp) @@ -170,12 +170,12 @@ ofw_cnprobe(struct consdev *cp) return; } - if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1) { + if (OF_getencprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1) { cp->cn_pri = CN_DEAD; return; } - if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) { + if (OF_getencprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) { cp->cn_pri = CN_DEAD; return; } Modified: stable/10/sys/dev/ofw/ofw_fdt.c ============================================================================== --- stable/10/sys/dev/ofw/ofw_fdt.c Tue May 13 17:51:15 2014 (r265966) +++ stable/10/sys/dev/ofw/ofw_fdt.c Tue May 13 17:59:17 2014 (r265967) @@ -226,20 +226,8 @@ ofw_fdt_parent(ofw_t ofw, phandle_t node static phandle_t ofw_fdt_instance_to_package(ofw_t ofw, ihandle_t instance) { - int offset; - - /* - * Note: FDT does not have the notion of instances, but we somewhat - * abuse the semantics and let treat as 'instance' the internal - * 'phandle' prop, so that ofw I/F consumers have a uniform way of - * translation between internal representation (which appear in some - * contexts as property values) and effective phandles. - */ - offset = fdt_node_offset_by_phandle(fdtp, instance); - if (offset < 0) - return (-1); - return (fdt_offset_phandle(offset)); + return (-1); } /* Get the length of a property of a package. */ Modified: stable/10/sys/dev/ofw/ofw_iicbus.c ============================================================================== --- stable/10/sys/dev/ofw/ofw_iicbus.c Tue May 13 17:51:15 2014 (r265966) +++ stable/10/sys/dev/ofw/ofw_iicbus.c Tue May 13 17:59:17 2014 (r265967) @@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include @@ -104,7 +103,6 @@ ofw_iicbus_attach(device_t dev) phandle_t child; pcell_t paddr; device_t childdev; - uint32_t addr; sc->dev = dev; mtx_init(&sc->lock, "iicbus", NULL, MTX_DEF); @@ -123,11 +121,12 @@ ofw_iicbus_attach(device_t dev) * property, then try the reg property. It moves around * on different systems. */ - if (OF_getprop(child, "i2c-address", &paddr, sizeof(paddr)) == -1) - if (OF_getprop(child, "reg", &paddr, sizeof(paddr)) == -1) + if (OF_getencprop(child, "i2c-address", &paddr, + sizeof(paddr)) == -1) + if (OF_getencprop(child, "reg", &paddr, + sizeof(paddr)) == -1) continue; - addr = fdt32_to_cpu(paddr); /* * Now set up the I2C and OFW bus layer devinfo and add it * to the bus. @@ -136,7 +135,7 @@ ofw_iicbus_attach(device_t dev) M_NOWAIT | M_ZERO); if (dinfo == NULL) continue; - dinfo->opd_dinfo.addr = addr; + dinfo->opd_dinfo.addr = paddr; if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) != 0) { free(dinfo, M_DEVBUF); Modified: stable/10/sys/dev/ofw/openfirm.c ============================================================================== --- stable/10/sys/dev/ofw/openfirm.c Tue May 13 17:51:15 2014 (r265966) +++ stable/10/sys/dev/ofw/openfirm.c Tue May 13 17:59:17 2014 (r265967) @@ -135,7 +135,8 @@ OF_init(void *cookie) rv = OFW_INIT(ofw_obj, cookie); if ((chosen = OF_finddevice("/chosen")) != -1) - if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) + if (OF_getencprop(chosen, "stdout", &stdout, + sizeof(stdout)) == -1) stdout = -1; return (rv); @@ -354,11 +355,9 @@ OF_getencprop_alloc(phandle_t package, c pcell_t *cell; int i; - KASSERT(elsz % 4 == 0, ("Need a multiple of 4 bytes")); - retval = OF_getprop_alloc(package, name, elsz, buf); - if (retval == -1) - return (retval); + if (retval == -1 || retval*elsz % 4 != 0) + return (-1); cell = *buf; for (i = 0; i < retval*elsz/4; i++) @@ -450,9 +449,9 @@ OF_child_xref_phandle(phandle_t parent, if (rxref != -1) return (rxref); - if (OF_getprop(child, "phandle", &rxref, sizeof(rxref)) == -1 && - OF_getprop(child, "ibm,phandle", &rxref, - sizeof(rxref)) == -1 && OF_getprop(child, + if (OF_getencprop(child, "phandle", &rxref, sizeof(rxref)) == + -1 && OF_getencprop(child, "ibm,phandle", &rxref, + sizeof(rxref)) == -1 && OF_getencprop(child, "linux,phandle", &rxref, sizeof(rxref)) == -1) continue; Modified: stable/10/sys/powerpc/powerpc/nexus.c ============================================================================== --- stable/10/sys/powerpc/powerpc/nexus.c Tue May 13 17:51:15 2014 (r265966) +++ stable/10/sys/powerpc/powerpc/nexus.c Tue May 13 17:59:17 2014 (r265967) @@ -248,9 +248,9 @@ nexus_attach(device_t dev) * Some important numbers */ sc->acells = 2; - OF_getprop(node, "#address-cells", &sc->acells, sizeof(sc->acells)); + OF_getencprop(node, "#address-cells", &sc->acells, sizeof(sc->acells)); sc->scells = 1; - OF_getprop(node, "#size-cells", &sc->scells, sizeof(sc->scells)); + OF_getencprop(node, "#size-cells", &sc->scells, sizeof(sc->scells)); /* * Now walk the OFW tree and attach top-level devices. @@ -564,7 +564,7 @@ nexus_setup_dinfo(device_t dev, phandle_ } resource_list_init(&ndi->ndi_rl); - nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)®); + nreg = OF_getencprop_alloc(node, "reg", sizeof(*reg), (void **)®); if (nreg == -1) nreg = 0; if (nreg % (sc->acells + sc->scells) != 0) { @@ -591,7 +591,7 @@ nexus_setup_dinfo(device_t dev, phandle_ } free(reg, M_OFWPROP); - nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intr), + nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr), (void **)&intr); if (nintr > 0) { iparent = 0;