diff options
author | ian <ian@FreeBSD.org> | 2014-05-13 17:59:17 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2014-05-13 17:59:17 +0000 |
commit | 4c1631c2b15b10939521fa505c7995af4409aefb (patch) | |
tree | 5f86e09bcec8a3f59d0156b121390c9d34132344 /sys/dev | |
parent | 7353aa0b49b83071cf7d18e084e64ca1ca0996c7 (diff) | |
download | FreeBSD-src-4c1631c2b15b10939521fa505c7995af4409aefb.zip FreeBSD-src-4c1631c2b15b10939521fa505c7995af4409aefb.tar.gz |
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.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/fdt/fdt_common.c | 4 | ||||
-rw-r--r-- | sys/dev/fdt/fdt_pci.c | 4 | ||||
-rw-r--r-- | sys/dev/fdt/simplebus.c | 8 | ||||
-rw-r--r-- | sys/dev/ofw/ofw_bus_subr.c | 12 | ||||
-rw-r--r-- | sys/dev/ofw/ofw_console.c | 8 | ||||
-rw-r--r-- | sys/dev/ofw/ofw_fdt.c | 14 | ||||
-rw-r--r-- | sys/dev/ofw/ofw_iicbus.c | 11 | ||||
-rw-r--r-- | sys/dev/ofw/openfirm.c | 15 |
8 files changed, 30 insertions, 46 deletions
diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c index 740ccb5..d6401d2 100644 --- a/sys/dev/fdt/fdt_common.c +++ b/sys/dev/fdt/fdt_common.c @@ -523,7 +523,7 @@ fdt_intr_to_rl(phandle_t node, struct resource_list *rl, /* * 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 dev, int *phy_addr, void **phy_sc) 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); diff --git a/sys/dev/fdt/fdt_pci.c b/sys/dev/fdt/fdt_pci.c index bcfe300..fae5f07 100644 --- a/sys/dev/fdt/fdt_pci.c +++ b/sys/dev/fdt/fdt_pci.c @@ -258,7 +258,7 @@ fdt_pci_route_intr(int bus, int slot, int func, int pin, 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, int func, int pin, 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) { diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c index 6efe390..c63cd86 100644 --- a/sys/dev/fdt/simplebus.c +++ b/sys/dev/fdt/simplebus.c @@ -339,8 +339,7 @@ simplebus_get_interrupt_parent(device_t dev) 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 dev) 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; diff --git a/sys/dev/ofw/ofw_bus_subr.c b/sys/dev/ofw/ofw_bus_subr.c index 890e378..26a6759 100644 --- a/sys/dev/ofw/ofw_bus_subr.c +++ b/sys/dev/ofw/ofw_bus_subr.c @@ -229,14 +229,14 @@ ofw_bus_setup_iinfo(phandle_t node, struct ofw_bus_iinfo *ii, int intrsz) 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, struct ofw_bus_iinfo *ii, void *reg, ("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 intrsz, void *regs, int physsz, 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); diff --git a/sys/dev/ofw/ofw_console.c b/sys/dev/ofw/ofw_console.c index 01f86bf..30c1018 100644 --- a/sys/dev/ofw/ofw_console.c +++ b/sys/dev/ofw/ofw_console.c @@ -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; } diff --git a/sys/dev/ofw/ofw_fdt.c b/sys/dev/ofw/ofw_fdt.c index 4191e7e..a4aca3c 100644 --- a/sys/dev/ofw/ofw_fdt.c +++ b/sys/dev/ofw/ofw_fdt.c @@ -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. */ diff --git a/sys/dev/ofw/ofw_iicbus.c b/sys/dev/ofw/ofw_iicbus.c index f6cafb1..965721a 100644 --- a/sys/dev/ofw/ofw_iicbus.c +++ b/sys/dev/ofw/ofw_iicbus.c @@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$"); #include <sys/module.h> #include <sys/mutex.h> -#include <dev/fdt/fdt_common.h> #include <dev/iicbus/iicbus.h> #include <dev/iicbus/iiconf.h> #include <dev/ofw/ofw_bus.h> @@ -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); diff --git a/sys/dev/ofw/openfirm.c b/sys/dev/ofw/openfirm.c index a88b07b..97e6cbf 100644 --- a/sys/dev/ofw/openfirm.c +++ b/sys/dev/ofw/openfirm.c @@ -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, const char *name, int elsz, void **buf) 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, phandle_t xref) 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; |