nvram Special File

Purpose

Provides access to platform-specific nonvolatile RAM used for system boot, configuration, and fatal error information. This access is achieved through the machine I/O device driver.

Description

The /dev/nvram character special file provides access to the machine device driver for accessing or modifying machine-specific nonvolatile RAM. The appropriate privilege is required to open the nvram special file. The nvram special file is used by machine-specific configuration programs to store or retrieve configuration and boot information using the nonvolatile RAM or ROM provided on the machine. The nvram special file supports open, close, read, and ioctl operations.

Note: Application programs should not access the nonvolatile RAM. Since nonvolatile RAM is platform-specific, any reliance on its presence and implementation places portability constraints upon the using application. In addition, accessing the nonvolatile RAM may cause loss of system startup and configuration information. Such a loss could require system administrative or maintenance task work to rebuild or recover.

For additional information concerning the use of this special file to access machine-specific nonvolatile RAM, see the "Machine Device Driver" in AIX® Version 7.1 Technical Reference: Kernel and Subsystems, Volume 1.

Usage Considerations

When using subroutines with the nvram special file, consider the following items.

open and close Subroutines

The machine device driver supports the nvram special file as a multiplexed character special file.

A special channel name of base can be used to read the base customize information stored as part of the boot record. The nvram special file must be opened with a channel name of base, as follows:

/dev/nvram/base

The special file /dev/nvram/base can only be opened once. When it is closed for the first time after a boot, the buffer containing the base customize information is free. Subsequent opens return a ENOENT error code.

read, write, and lseek Subroutines

The read subroutine is supported after a successful open of the nvram special file with a channel name of base. The read operation starts transferring data at the location associated with the base customization information and with an offset specified by the offset value associated with the file pointer being used on the subroutine.

On a read subroutine, if the end of the data area is reached before the transfer count is reached, the number of bytes read before the end of the data area was reached is returned. If the read starts after the end of the data area, an error of ENXIO is returned by the driver.

The lseek subroutine can be used to change the starting read offset within the data area associated with the base customization information. The write subroutine is not supported on this channel and results in an error return of ENODEV.

ioctl Subroutine

ioctl commands can be issued to the machine device driver after the /dev/nvram special file has been successfully opened. The IOCINFO parameter returns machine device driver information in the caller's devinfo structure, as pointed to by the arg parameter to the ioctl subroutine. This structure is defined in the /usr/include/sys/devinfo.h file. The device type for this device driver is DD_PSEU.

Error Codes

The following error conditions can be returned when accessing the machine device driver using the nvram special file name:

Item Description
EFAULT A buffer specified by the caller was invalid on a read, write, or ioctl subroutine call.
ENXIO A read operation was attempted past the end of the data area specified by the channel.
ENODEV A write operation was attempted.
ENOMEM A request was made with a user-supplied buffer that is too small for the requested data.

Security

Programs attempting to open the nvram special file require the appropriate privilege.

Files

Item Description
/dev/nvram/base Allows read access to the base customize information stored as part of the boot record.