Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ openprom(7) — SunOS 5.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

devinfo(1M)

eeprom(1M)

mem(7)

monitor(1M)

openprom(7)

NAME

openprom − PROM monitor configuration interface

SYNOPSIS

#include <sys/fcntl.h>
#include <sys/types.h>
#include <sundev/openpromio.h>
open("/dev/openprom", mode);

DESCRIPTION

The internal encoding of the configuration information stored in EEPROM or NVRAM varies from model to model, and on some systems the encoding is “hidden” by the firmware.  The openprom driver provides a consistent interface that allows a user or program to inspect and modify that configuration, using ioctl(2) requests.  These requests are defined in <sundev/openpromio.h>:

struct openpromio {
        u_int   oprom_size;/∗ real size of following array ∗/
        char    oprom_array[1];/∗ For property names and values ∗/
/∗ NB: Adjacent, Null terminated ∗/
};
#define OPROMMAXPARAM   1024      /∗ max size of array ∗/
 /∗
 ∗ Note that all OPROM ioctl codes are type void. Since the amount
 ∗ of data copied in/out may (and does) vary, the openprom driver
 ∗ handles the copyin/copyout itself.
 ∗/
#define OPROMGETOPT_IO(O, 1)
#define OPROMSETOPT_IO(O, 2)
#define OPROMNXTOPT_IO(O, 3)
#define OPROMSETOPT2_IO(O, 4) /∗ preferred OPROMSETOPT ∗/
#define OPROMNEXT_IO(O, 5) /∗ interface to raw config_ops ∗/
#define OPROMCHILD_IO(O, 6) /∗ interface to raw config_ops ∗/
#define OPROMGETPROP_IO(O, 7) /∗ interface to raw config_ops ∗/
#define OPROMNXTPROP_IO(O, 8) /∗ interface to raw config_ops ∗/

For all ioctl() requests, the third parameter is a pointer to a ‘struct openpromio’.  All property names and values are null-terminated strings; the value of a numeric option is its ASCII representation. 

IOCTLS

The OPROMGETOPT ioctl takes the null-terminated name of a property in the oprom_array and returns its null-terminated value (overlaying its name).  oprom_size should be set to the size of oprom_array; on return it will contain the size of the returned value. If the named property does not exist, or if there is not enough space to hold its value, then oprom_size will be set to zero.  See BUGS below. 

The OPROMSETOPT ioctl takes two adjacent strings in oprom_array; the null-terminated property name followed by the null-terminated value.

The OPROMNXTOPT ioctl is used to retrieve properties sequentially.  The null-terminated name of a property is placed into oprom_array and on return it is replaced with the null-terminated name of the next property in the sequence, with oprom_size set to its length.  A null string on input means return the name of the first property; an oprom_size of zero on output means there are no more properties. 

The OPROMNXT, OPROMCHILD, OPROMGETPROP, and OPROMNXTPROP ioctls provide an interface to the raw config_ops operations in the PROM monitor. One can use them to traverse the system device tree; see devinfo(1M). 

ERRORS

EINVAL The size value was invalid, or (for OPROMSETOPT) the property does not exist. 

ENOMEM The kernel could not allocate space to copy the user’s structure

FILES

/dev/openprom PROM monitor configuration interface

SEE ALSO

devinfo(1M), eeprom(1M), mem(7), monitor(1M)

BUGS

There should be separate return values for non-existent properties as opposed to not enough space for the value. 

An attempt to set a property to an illegal value results in the PROM setting it to some legal value, with no error being returned.  An OPROMGETOPT should be performed after an OPROMSETOPT to verify that the set worked. 

The driver should be more consistent in its treatment of errors and edge conditions. 

SunOS 5.1  —  Last change: 4 Sep 1991

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026