Contained Within
Find More Documentation
Featured Support Resources
| Download this book in PDF
NAME
- envm - EISA NVRAM support
AVAILABILITY
- x86
DESCRIPTION
- The EISA NVRAM is analogous to the CMOS RAM on an AT -type machine, but is much more complete. It describes the hardware environment in great detail on a slot-by-slot basis. The information is placed in the NVRAM by the EISA Configuration Utility supplied with the machine. EISA NVRAM support offers access to this data for drivers and user applications. User-level access is through the device /dev/eisarom. An application must open the device and issue ioctl calls to gather the required data. Drivers or other kernel code must call the driver routines directly to gather their data.
Determination of Bus Type for Drivers
- For a driver to determine whether or not it is running on an EISA machine, it should do the following:
-
-
#include <sys/eisarom.h>
extern int envm_check ();/* Returns -1 if not an EISA machine. * /
-
if (envm_check () != -1)
-
-
{
/* It's an EISA machine. * /
}
else
{
/* It's not. * /
}
Determination of Bus Type for
- For an application to determine whether or not it is running on an EISA machine, it should do the following:
Applications
-
-
#include <sys/fcntl.h>
extern int open();
-
if (open("/dev/eisarom", O_RDONLY) != -1) /* It's an EISA machine. * /
-
-
{
/* It's an EISA machine. * /
}
else
{
/* It's not. * /
}
Data Gathering for Drivers
- To read data from the NVRAM, a driver should use the following template. eisa_nvm () returns the number of bytes placed in ``data'':
-
-
#include <sys/eisarom.h>
#include <sys/nvm.h>
extern int eisa_nvm ();
-
int
-
-
eisa_nvm (data, key_mask, [key1, key2, . . . key(n)])
-
char * data;
-
-
KEY_MASK key_mask;
{
}
Data Gathering for Applications
- To read data from the NVRAM, an application should do the following:
-
-
#include <fcntl.h>
#include <sys/eisarom.h>
#include <sys/nvm.h>
-
char * data;
-
-
int length = (20* 1024);
eisanvm nvm;/* See "eisarom.h". * /
int fd;
-
/* The "ioctl" function will transform the arguments in "data" to a
-
-
stack frame that can be passed in to "eisa_nvm". * /
-
if ((fd = open("/dev/eisarom", O_RDONLY)) != -1)
-
-
{
/* We're on an EISA machine. * /
data = (char * )malloc(length);
nvm.data = data;
/* This sets up the "key" arguments for the "ioctl" function. * /
- * ((int* )nvm.data)++= key_mask;
-
-
* ((int* )nvm.data)++= key1;
* ((int* )nvm.data)++= key2;
-
if (ioctl(fd, EISA_CMOS_QUERY, &nvm) != -1)
-
-
{
/* Call was successful. * /
/* If length is 0, no records matched all keys. * /
/* Length is in nvm.length. * /
/* Data is pointed to by nvm.data. * /
/* Data consists of 0 or more slot records, each * /
/* followed by 1 or more function records * /
-
/* (see "nvm.h"). * /
-
-
}
else
{
/* Fatal error. * /
}
}
else
{
/* Not an EISA machine or no "envm" driver installed. * /
}
Masks and Keys
- This section deals with the values for the key_mask and keys fields in the call to eisa_nvm (). The key_mask field determines which fields are checked during the search in eisa_nvm (). The number of keys passed to eisa_nvm () must be the same as the number of items specified in key_mask. The key arguments must be in the order shown below. See nvm.h for the slot and function record format. Arguments may be omitted, but the ordering must be maintained. The key argument ordering is:
- slot function (board_id mask) revision checksum type sub-type
- Correct values for the key fields may be obtained from the documentation accompanying the machine.
EXAMPLES
- To copy all slot and function records into buffer:
-
-
bytes = eisa_nvm(buffer, 0);
To copy the record for slot 0 and all its function records into buffer:
bytes = eisa_nvm(buffer, SLOT, 0);
To copy any or all slot and function records that pertain to the board type DISCO into
buffer:
bytes = eisa_nvm(buffer, TYPE, DISCO );
To copy any or all slot and function records that pertain to the board ID xx40110e and the
type COM into buffer:
bytes = eisa_nvm(buffer, BOARD_ID | TYPE, 0x0140110e, 0xffffff, "COM");
To copy any or all slot and function records that pertain to the board ID 0140110e, the
checksum 0x ABCD ,and the type ASY into buffer:
bytes = eisa_nvm(buffer, BOARD_ID | CHECKSUM | TYPE, 0x0140110e, 0xffffffff,
0xABCD, "ASY");
|
|