NVRAM(4) | Kernel Interfaces Manual (PReP) | NVRAM(4)

# NAME

nvram — PReP nvram interface

# SYNOPSIS

#include <machine/nvram.h>

# DESCRIPTION

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.

# FILES

/dev/nvram

# ERRORS

The following may result in rejection of an operation:

[EINVAL]
  The given variable name does not exist; or the buffer set up to retrieve values from the nvram was not large enough to hold the result.

# SEE ALSO

ioctl(2)

PowerPC Reference Platform Specification Version 1.1, Section 5.5

# BUGS

Due to limitations within the nvram itself, these functions run at elevated priority and may adversely affect system performance.

PNVIOCSET is not currently supported, making the nvram driver read-only at this time.

March 1, 2007 | NetBSD 6.0