OPENFIRM(4)
okay bestie, welcome to OPENFIRM(4) β the Open Firmware interface page, and itβs giving βkernel interface but make it fashionβ π
β¨
πΈ NAME πΈ
openfirm β Open Firmware interface. Thatβs the name, thatβs the vibe, but keep reading because the details are the main character. π¦
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <sys/ioctl.h>
#include <dev/ofw/openfirmio.h>
π DESCRIPTION π
okay so the /dev/openfirm device is literally your interface to the Open Firmware device tree. π«Ά This interface is highly stylized. It uses ioctl(2) calls for all operations. Those calls refer to the nodes in the Open Firmware device tree. The nodes are represented by package handles, which are simply integer values describing data areas. Occasionally a package handle of 0 may be used or returned instead, as described below. π
The calls that only take and/or return the package handle of a node use a pointer to a phandle_t for this purpose. The others use a pointer to a struct ofiocdesc descriptor, which has the following definition:
struct ofiocdesc {
phandle_t of_nodeid;
int of_namelen;
const char *of_name;
int of_buflen;
char *of_buf;
};
The of_nodeid member is the package handle of the node that is passed in or returned. Strings are passed in via the of_name member of of_namelen length. The maximum accepted length of of_name is OFIOCMAXNAME. The of_buf member is used to return strings except for the OFIOCSET call where it is also used to pass in a string. In the latter case the maximum accepted length of of_buf is OFIOCMAXVALUE. Generally, of_buf works in a value-result fashion. At entry to the ioctl(2) call, of_buflen is expected to reflect the buffer size. On return, of_buflen is updated to reflect the buffer contents. π
The following ioctl(2) calls are supported:
OFIOCGETOPTNODEβ Uses aphandle_t. Takes nothing and returns the package handle of the/optionsnode.OFIOCGETNEXTβ Uses aphandle_t. Takes the package handle of a node and returns the package handle of the next node in the Open Firmware device tree. The node following the last node has a package handle of0. The node following the node with the package handle of0is the first node.OFIOCGETCHILDβ Uses aphandle_t. Takes the package handle of a node and returns the package handle of the first child of that node. This child may have siblings. These can be determined by usingOFIOCGETNEXT. If the node does not have a child, a package handle of0is returned.OFIOCGETβ Uses astruct ofiocdesc. Takes the package handle of a node and the name of a property. Returns the property value and its length. If no such property is associated with that node, the length of the value is set to-1. If the named property exists but has no value, the length of the value is set to0.OFIOCGETPROPLENβ Uses astruct ofiocdesc. Takes the package handle of a node and the name of a property. Returns the length of the property value. This call is the same asOFIOCGETexcept that only the length of the property value is returned. It can be used to determine whether a node has a particular property or whether a property has a value without the need to provide memory for storing the value.OFIOCSETβ Uses astruct ofiocdesc. Takes the package handle of a node, the name of a property and a property value. Returns the property value and the length that actually have been written. The Open Firmware may choose to truncate the value if it is too long or write a valid value instead if the given value is invalid for the particular property. Therefore the returned value should be checked. The Open Firmware may also completely refuse to write the given value to the property. In this caseEINVALis returned.OFIOCNEXTPROPβ Uses astruct ofiocdesc. Takes the package handle of a node and the name of a property. Returns the name and the length of the next property of the node. If the property referenced by the given name is the last property of the node,ENOENTis returned.OFIOCFINDDEVICEβ Uses astruct ofiocdesc. Takes the name or alias name of a device node. Returns package handle of the node. If no matching node is found,ENOENTis returned.
π FILES π
/dev/openfirmβ Open Firmware interface node
π«Ά DIAGNOSTICS π«Ά
The following may result in rejection of an operation, and yeah bestie, these are the ones to clock:
[EBADF]β The requested operation requires permissions not specified at the call toopen().[EINVAL]β The given package handle is not0and does not correspond to any valid node, or the given package handle is0where0is not allowed.[ENAMETOOLONG]β The given name or value exceeds the maximum allowed length ofOFIOCMAXNAMEandOFIOCMAXVALUEbytes respectively.
π SEE ALSO π
ioctl(2)ofwdump(8)IEEE Std 1275-1994: IEEE Standard for Boot Firmware (Initialization Configuration) Firmware: Core Requirements and Practices", IEEE Standards Organization, ISBN 1-55937-426-8.
π HISTORY π
okay so the openfirm interface first appeared in NetBSD 1.6. The first FreeBSD version to include it was FreeBSD 5.0. History lesson over, slay. π
π AUTHORS π
The openfirm interface was ported to FreeBSD by Thomas Moestl (<tmm@FreeBSD.org>). This manual page was written by Marius Strobl (<marius@FreeBSD.org>) based on the OpenBSD manual page for openprom(4). Give them their flowers. π
π CAVEATS π
Heads up bestie: due to limitations within Open Firmware itself, these functions run at elevated priority and may adversely affect system performance. Thatβs not a vibe, thatβs a real caveat. π
For at least the /options node the property value passed in to the OFIOCSET call has to be null-terminated and the value length passed in has to include the terminating β\0β. However, as with the OFIOCGET call, the returned value length does not include the terminating β\0β. π«Ά
later, bestie π β Debian, January 16, 2021
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 1992, 1993 The Regents of the University of California. All rights reserved
- Copyright (c) 2005 Marius Strobl <marius@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms