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.
92 phandle_t node; member
106 * xref-phandle-device lookup helper routines.
108 * As soon as we are able to use malloc(), walk the node tree and build a list
109 * of info that cross-references node handles, xref handles, and device_t
110 * instances. This list exists primarily to allow association of a device_t
112 * and node handles. Before malloc() is available we have to recursively search
113 * the node tree each time we want to translate between a node and xref handle.
117 xrefinfo_create(phandle_t node) in xrefinfo_create() argument
120 phandle_t child, xref; in xrefinfo_create() local
123 * Recursively descend from parent, looking for nodes with a property in xrefinfo_create()
125 * such node found create an entry in the xreflist. in xrefinfo_create()
127 for (child = OF_child(node); child != 0; child = OF_peer(child)) { in xrefinfo_create()
128 xrefinfo_create(child); in xrefinfo_create()
129 if (OF_getencprop(child, "phandle", &xref, sizeof(xref)) == in xrefinfo_create()
130 -1 && OF_getencprop(child, "ibm,phandle", &xref, in xrefinfo_create()
131 sizeof(xref)) == -1 && OF_getencprop(child, in xrefinfo_create()
132 "linux,phandle", &xref, sizeof(xref)) == -1) in xrefinfo_create()
135 xi->node = child; in xrefinfo_create()
136 xi->xref = xref; in xrefinfo_create()
164 if ((find_by == FIND_BY_XREF && (phandle_t)key == xi->xref) || in xrefinfo_find()
165 (find_by == FIND_BY_NODE && (phandle_t)key == xi->node) || in xrefinfo_find()
166 (find_by == FIND_BY_DEV && key == (uintptr_t)xi->dev)) { in xrefinfo_find()
176 xrefinfo_add(phandle_t node, phandle_t xref, device_t dev) in xrefinfo_add() argument
181 xi->node = node; in xrefinfo_add()
182 xi->xref = xref; in xrefinfo_add()
183 xi->dev = dev; in xrefinfo_add()
192 * overrides allowing last-set to win.
214 if (ofwp->name && in OF_install()
215 !strcmp(ofwp->name, name) && in OF_install()
234 return (-1); in OF_init()
246 if ((chosen = OF_finddevice("/chosen")) != -1) in OF_init()
248 sizeof(stdout)) == -1) in OF_init()
249 stdout = -1; in OF_init()
282 /* Test to see if a service exists. */
288 return (-1); in OF_test()
302 return (-1); in OF_interpret()
305 if (status == -1) in OF_interpret()
320 /* Return the next sibling of this node or 0. */
322 OF_peer(phandle_t node) in OF_peer() argument
328 return (OFW_PEER(ofw_obj, node)); in OF_peer()
331 /* Return the first child of this node or 0. */
333 OF_child(phandle_t node) in OF_child() argument
339 return (OFW_CHILD(ofw_obj, node)); in OF_child()
342 /* Return the parent of this node or 0. */
344 OF_parent(phandle_t node) in OF_parent() argument
350 return (OFW_PARENT(ofw_obj, node)); in OF_parent()
359 return (-1); in OF_instance_to_package()
364 /* Get the length of a property of a package. */
370 return (-1); in OF_getproplen()
375 /* Check existence of a property of a package. */
383 /* Get the value of a property of a package. */
389 return (-1); in OF_getprop()
395 OF_getencprop(phandle_t node, const char *propname, pcell_t *buf, size_t len) in OF_getencprop() argument
400 KASSERT(len % 4 == 0, ("Need a multiple of 4 bytes")); in OF_getencprop()
402 retval = OF_getprop(node, propname, buf, len); in OF_getencprop()
413 * Recursively search the node and its parent for the given property, working
414 * downward from the node to the device tree root. Returns the value of the
418 OF_searchprop(phandle_t node, const char *propname, void *buf, size_t len) in OF_searchprop() argument
422 for (; node != 0; node = OF_parent(node)) in OF_searchprop()
423 if ((rv = OF_getprop(node, propname, buf, len)) != -1) in OF_searchprop()
425 return (-1); in OF_searchprop()
429 OF_searchencprop(phandle_t node, const char *propname, pcell_t *buf, size_t len) in OF_searchencprop() argument
433 for (; node != 0; node = OF_parent(node)) in OF_searchencprop()
434 if ((rv = OF_getencprop(node, propname, buf, len)) != -1) in OF_searchencprop()
436 return (-1); in OF_searchencprop()
440 * Store the value of a property of a package into newly allocated memory
449 if ((len = OF_getproplen(package, propname)) == -1) in OF_getprop_alloc()
450 return (-1); in OF_getprop_alloc()
454 if (OF_getprop(package, propname, *buf, len) == -1) { in OF_getprop_alloc()
457 return (-1); in OF_getprop_alloc()
464 * Store the value of a property of a package into newly allocated memory
465 * (using the M_OFWPROP malloc pool and M_WAITOK). elsz is the size of a
474 if ((len = OF_getproplen(package, propname)) == -1 || in OF_getprop_alloc_multi()
476 return (-1); in OF_getprop_alloc_multi()
480 if (OF_getprop(package, propname, *buf, len) == -1) { in OF_getprop_alloc_multi()
483 return (-1); in OF_getprop_alloc_multi()
511 if (retval == -1) in OF_getencprop_alloc_multi()
512 return (-1); in OF_getencprop_alloc_multi()
528 /* Get the next property of a package. */
534 return (-1); in OF_nextprop()
539 /* Set the value of a property of a package. */
545 return (-1); in OF_setprop()
550 /* Convert a device specifier to a fully qualified pathname. */
556 return (-1); in OF_canon()
561 /* Return a package handle for the specified device. */
567 return (-1); in OF_finddevice()
578 return (-1); in OF_instance_to_path()
583 /* Return the fully qualified pathname corresponding to a package. */
589 return (-1); in OF_package_to_path()
598 phandle_t child, rxref; in OF_child_xref_phandle() local
601 * Recursively descend from parent, looking for a node with a property in OF_child_xref_phandle()
606 for (child = OF_child(parent); child != 0; child = OF_peer(child)) { in OF_child_xref_phandle()
607 rxref = OF_child_xref_phandle(child, xref); in OF_child_xref_phandle()
608 if (rxref != -1) in OF_child_xref_phandle()
611 if (OF_getencprop(child, "phandle", &rxref, sizeof(rxref)) == in OF_child_xref_phandle()
612 -1 && OF_getencprop(child, "ibm,phandle", &rxref, in OF_child_xref_phandle()
613 sizeof(rxref)) == -1 && OF_getencprop(child, in OF_child_xref_phandle()
614 "linux,phandle", &rxref, sizeof(rxref)) == -1) in OF_child_xref_phandle()
618 return (child); in OF_child_xref_phandle()
621 return (-1); in OF_child_xref_phandle()
628 phandle_t node; in OF_node_from_xref() local
633 return (xi->node); in OF_node_from_xref()
636 if ((node = OF_child_xref_phandle(OF_peer(0), xref)) == -1) in OF_node_from_xref()
638 return (node); in OF_node_from_xref()
642 OF_xref_from_node(phandle_t node) in OF_xref_from_node() argument
648 if ((xi = xrefinfo_find(node, FIND_BY_NODE)) == NULL) in OF_xref_from_node()
649 return (node); in OF_xref_from_node()
650 return (xi->xref); in OF_xref_from_node()
653 if (OF_getencprop(node, "phandle", &xref, sizeof(xref)) == -1 && in OF_xref_from_node()
654 OF_getencprop(node, "ibm,phandle", &xref, sizeof(xref)) == -1 && in OF_xref_from_node()
655 OF_getencprop(node, "linux,phandle", &xref, sizeof(xref)) == -1) in OF_xref_from_node()
656 return (node); in OF_xref_from_node()
668 return (xi->dev); in OF_device_from_xref()
681 return (xi->xref); in OF_xref_from_device()
693 * add a list entry. In theory this can only happen on a system where in OF_device_register_xref()
694 * nodes don't contain phandle properties and xref and node handles are in OF_device_register_xref()
695 * synonymous, so the xref handle is added as the node handle as well. in OF_device_register_xref()
701 xi->dev = dev; in OF_device_register_xref()
707 /* Call the method in the scope of a given instance. */
717 return (-1); in OF_call_method()
737 /* Open an instance for a device. */
765 return (-1); in OF_read()
776 return (-1); in OF_write()
781 /* Seek to a position. */
787 return (-1); in OF_seek()
802 return ((void *)-1); in OF_claim()