Lines Matching +full:a +full:- +full:child +full:- +full:node +full:- +full:property
3 /*-
4 * SPDX-License-Identifier: BSD-4-Clause
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 /*-
50 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
91 phandle_t node; member
105 * xref-phandle-device lookup helper routines.
107 * As soon as we are able to use malloc(), walk the node tree and build a list
108 * of info that cross-references node handles, xref handles, and device_t
109 * instances. This list exists primarily to allow association of a device_t
111 * and node handles. Before malloc() is available we have to recursively search
112 * the node tree each time we want to translate between a node and xref handle.
116 xrefinfo_create(phandle_t node) in xrefinfo_create() argument
119 phandle_t child, xref; in xrefinfo_create() local
122 * Recursively descend from parent, looking for nodes with a property in xrefinfo_create()
124 * such node found create an entry in the xreflist. in xrefinfo_create()
126 for (child = OF_child(node); child != 0; child = OF_peer(child)) { in xrefinfo_create()
127 xrefinfo_create(child); in xrefinfo_create()
128 if (OF_getencprop(child, "phandle", &xref, sizeof(xref)) == in xrefinfo_create()
129 -1 && OF_getencprop(child, "ibm,phandle", &xref, in xrefinfo_create()
130 sizeof(xref)) == -1 && OF_getencprop(child, in xrefinfo_create()
131 "linux,phandle", &xref, sizeof(xref)) == -1) in xrefinfo_create()
134 xi->node = child; in xrefinfo_create()
135 xi->xref = xref; in xrefinfo_create()
163 if ((find_by == FIND_BY_XREF && (phandle_t)key == xi->xref) || in xrefinfo_find()
164 (find_by == FIND_BY_NODE && (phandle_t)key == xi->node) || in xrefinfo_find()
165 (find_by == FIND_BY_DEV && key == (uintptr_t)xi->dev)) { in xrefinfo_find()
175 xrefinfo_add(phandle_t node, phandle_t xref, device_t dev) in xrefinfo_add() argument
180 xi->node = node; in xrefinfo_add()
181 xi->xref = xref; in xrefinfo_add()
182 xi->dev = dev; in xrefinfo_add()
200 * overrides allowing last-set to win.
222 if (ofwp->name && in OF_install()
223 !strcmp(ofwp->name, name) && in OF_install()
242 return (-1); in OF_init()
254 if ((chosen = OF_finddevice("/chosen")) != -1) in OF_init()
256 sizeof(stdout)) == -1) in OF_init()
257 stdout = -1; in OF_init()
290 /* Test to see if a service exists. */
296 return (-1); in OF_test()
310 return (-1); in OF_interpret()
313 if (status == -1) in OF_interpret()
328 /* Return the next sibling of this node or 0. */
330 OF_peer(phandle_t node) in OF_peer() argument
336 return (OFW_PEER(ofw_obj, node)); in OF_peer()
339 /* Return the first child of this node or 0. */
341 OF_child(phandle_t node) in OF_child() argument
347 return (OFW_CHILD(ofw_obj, node)); in OF_child()
350 /* Return the parent of this node or 0. */
352 OF_parent(phandle_t node) in OF_parent() argument
358 return (OFW_PARENT(ofw_obj, node)); in OF_parent()
367 return (-1); in OF_instance_to_package()
372 /* Get the length of a property of a package. */
378 return (-1); in OF_getproplen()
383 /* Check existence of a property of a package. */
391 /* Get the value of a property of a package. */
397 return (-1); in OF_getprop()
403 OF_getencprop(phandle_t node, const char *propname, pcell_t *buf, size_t len) in OF_getencprop() argument
408 KASSERT(len % 4 == 0, ("Need a multiple of 4 bytes")); in OF_getencprop()
410 retval = OF_getprop(node, propname, buf, len); in OF_getencprop()
421 * Recursively search the node and its parent for the given property, working
422 * downward from the node to the device tree root. Returns the value of the
426 OF_searchprop(phandle_t node, const char *propname, void *buf, size_t len) in OF_searchprop() argument
430 for (; node != 0; node = OF_parent(node)) in OF_searchprop()
431 if ((rv = OF_getprop(node, propname, buf, len)) != -1) in OF_searchprop()
433 return (-1); in OF_searchprop()
437 OF_searchencprop(phandle_t node, const char *propname, pcell_t *buf, size_t len) in OF_searchencprop() argument
441 for (; node != 0; node = OF_parent(node)) in OF_searchencprop()
442 if ((rv = OF_getencprop(node, propname, buf, len)) != -1) in OF_searchencprop()
444 return (-1); in OF_searchencprop()
448 * Store the value of a property of a package into newly allocated memory
457 if ((len = OF_getproplen(package, propname)) == -1) in OF_getprop_alloc()
458 return (-1); in OF_getprop_alloc()
462 if (OF_getprop(package, propname, *buf, len) == -1) { in OF_getprop_alloc()
465 return (-1); in OF_getprop_alloc()
472 * Store the value of a property of a package into newly allocated memory
473 * (using the M_OFWPROP malloc pool and M_WAITOK). elsz is the size of a
482 if ((len = OF_getproplen(package, propname)) == -1 || in OF_getprop_alloc_multi()
484 return (-1); in OF_getprop_alloc_multi()
488 if (OF_getprop(package, propname, *buf, len) == -1) { in OF_getprop_alloc_multi()
491 return (-1); in OF_getprop_alloc_multi()
519 if (retval == -1) in OF_getencprop_alloc_multi()
520 return (-1); in OF_getencprop_alloc_multi()
536 /* Get the next property of a package. */
542 return (-1); in OF_nextprop()
547 /* Set the value of a property of a package. */
553 return (-1); in OF_setprop()
558 /* Convert a device specifier to a fully qualified pathname. */
564 return (-1); in OF_canon()
569 /* Return a package handle for the specified device. */
575 return (-1); in OF_finddevice()
586 return (-1); in OF_instance_to_path()
591 /* Return the fully qualified pathname corresponding to a package. */
597 return (-1); in OF_package_to_path()
606 phandle_t child, rxref; in OF_child_xref_phandle() local
609 * Recursively descend from parent, looking for a node with a property in OF_child_xref_phandle()
614 for (child = OF_child(parent); child != 0; child = OF_peer(child)) { in OF_child_xref_phandle()
615 rxref = OF_child_xref_phandle(child, xref); in OF_child_xref_phandle()
616 if (rxref != -1) in OF_child_xref_phandle()
619 if (OF_getencprop(child, "phandle", &rxref, sizeof(rxref)) == in OF_child_xref_phandle()
620 -1 && OF_getencprop(child, "ibm,phandle", &rxref, in OF_child_xref_phandle()
621 sizeof(rxref)) == -1 && OF_getencprop(child, in OF_child_xref_phandle()
622 "linux,phandle", &rxref, sizeof(rxref)) == -1) in OF_child_xref_phandle()
626 return (child); in OF_child_xref_phandle()
629 return (-1); in OF_child_xref_phandle()
636 phandle_t node; in OF_node_from_xref() local
641 return (xi->node); in OF_node_from_xref()
644 if ((node = OF_child_xref_phandle(OF_peer(0), xref)) == -1) in OF_node_from_xref()
646 return (node); in OF_node_from_xref()
650 OF_xref_from_node(phandle_t node) in OF_xref_from_node() argument
656 if ((xi = xrefinfo_find(node, FIND_BY_NODE)) == NULL) in OF_xref_from_node()
657 return (node); in OF_xref_from_node()
658 return (xi->xref); in OF_xref_from_node()
661 if (OF_getencprop(node, "phandle", &xref, sizeof(xref)) == -1 && in OF_xref_from_node()
662 OF_getencprop(node, "ibm,phandle", &xref, sizeof(xref)) == -1 && in OF_xref_from_node()
663 OF_getencprop(node, "linux,phandle", &xref, sizeof(xref)) == -1) in OF_xref_from_node()
664 return (node); in OF_xref_from_node()
676 return (xi->dev); in OF_device_from_xref()
689 return (xi->xref); in OF_xref_from_device()
701 * add a list entry. In theory this can only happen on a system where in OF_device_register_xref()
702 * nodes don't contain phandle properties and xref and node handles are in OF_device_register_xref()
703 * synonymous, so the xref handle is added as the node handle as well. in OF_device_register_xref()
709 xi->dev = dev; in OF_device_register_xref()
725 /* Call the method in the scope of a given instance. */
735 return (-1); in OF_call_method()
755 /* Open an instance for a device. */
783 return (-1); in OF_read()
794 return (-1); in OF_write()
799 /* Seek to a position. */
805 return (-1); in OF_seek()
820 return ((void *)-1); in OF_claim()