OF_NODE_FROM_XREF(9)
π NAME π
okay so this is the manual page for OF_NODE_FROM_XREF(9), and the main characters are OF_node_from_xref and OF_xref_from_node β they convert between kernel phandle and effective phandle π
πΈ SYNOPSIS πΈ
first, include the headers, no skipping:
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
then these two icons:
phandle_t
OF_node_from_xref(phandle_t xref);
phandle_t
OF_xref_from_node(phandle_t node);
π DESCRIPTION π
Some OpenFirmware implementations (FDT, IBM) have this concept of effective phandle or xrefs. Theyβre literally used to cross-reference device tree nodes. For instance, a framebuffer controller may refer to a GPIO controller and pin that controls the backlight. In this example, the GPIO node would have a cell (32-bit integer) property with a reserved name like "phandle" or "linux,phandle" whose value uniquely identifies the node. The actual name depends on the implementation. The framebuffer node would have a property with the name described by device bindings (device-specific set of properties). It can be a cell property or a combined property with one part of it being a cell. The value of the framebuffer nodeβs property would be the same as the value of the GPIO "phandle" property, so it can be said that the framebuffer node refers to the GPIO node. The kernel uses internal logic to assign unique identifiers to the device tree nodes, and these values do not match the values of "phandle" properties. OF_node_from_xref() and OF_xref_from_node() are used to perform conversion between these two kinds of node identifiers.
OF_node_from_xref() returns the kernel phandle for the effective phandle xref. If one cannot be found or the OpenFirmware implementation does not support effective phandles, the function returns the input value. no cap π«Ά
OF_xref_from_node() returns the effective phandle for the kernel phandle node. If one cannot be found or the OpenFirmware implementation does not support effective phandles, the function returns the input value. same energy β¨
π¦ EXAMPLES π¦
hereβs the little code moment:
phandle_t panelnode, panelxref;
char *model;
if (OF_getencprop(node, "lcd-panel", &panelxref) <= 0)
return;
panelnode = OF_node_from_xref(panelxref);
if (OF_getprop_alloc(hdminode, "model", (void **)&model) <= 0)
return;
β SEE ALSO β
π AUTHORS π
This manual page was written by Oleksandr Tymoshenko <gonzo@FreeBSD.org>. iconic π
okay bestie thatβs the whole page β source/version is Debian, dated April 9, 2018, and weβre literally in OF_NODE_FROM_XREF(9) territory β¨π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- π the page's license: BSD-2-Clause
- Copyright (c) 2018 Oleksandr Tymoshenko <gonzo@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms