The file
/dev/nvram is an interface to the PReP NVRAM, including the Global Environment Area. This interface is highly stylized; ioctls are used for all operations. These ioctls refer to individual variables in the Global Environment Area and their values.
The calls that take and/or return a variable use a pointer to an
int variable for this purpose; others use a pointer to an
struct pnviocdesc descriptor, which contains a variable and two counted strings. The first string comprises the fields
pnv_namelen (an
int) and
pnv_name (a
char *), giving the name of a field. The second string comprises the fields
pnv_buflen and
pnv_buf, used analogously. These two counted strings work in a “value-result” fashion. At entry to the ioctl, the counts are expected to reflect the buffer size; on return, the counts are updated to reflect the buffer contents.
The following ioctls are supported:
PNVIOCGETNEXTNAME
Takes a variable name and returns the name of the following variable. If a NULL is passed as the variable name, the first variable name will be returned. If the last variable is given as an argument, the ioctl will return EINVAL.
PNVIOCGET
Fills in the value of the named property for the given variable. If no such property is associated with that variable, the value length is set to -1. If the named property exists but has no value, the value length is set to 0.
PNVIOCSET
Writes the given value under the given name.
PNVIOCGETNUMGE
Returns the number of variables in the Global Environment Area.