Technical data

SunOS 5.5 Devices openprom(7D)
Get the peer node of the given node. The root node is the peer of zero.
After changing nodes, property lookups apply to that node. The driver
’remembers’ what node you are in.
/
static int
peer(int nodeid, int fd)
{
Oppbuf oppbuf;
struct openpromio opp = &(oppbuf.opp);
int ip = (int )(opp->oprom_array);
(void) memset(oppbuf.buf, 0, BUFSZ);
opp->oprom_size = MAXVALSZ;
ip = nodeid;
if (ioctl(fd, OPROMNEXT, opp) < 0) {
perror("OPROMNEXT");
exit(1);
}
return ((int )opp->oprom_array);
}
int
main(void)
{
Oppbuf oppbuf;
struct openpromio opp = &(oppbuf.opp);
int fd;
if ((fd = open(promdev, O_RDONLY)) < 0) {
fprintf(stderr, "Cannot open openprom device0);
exit(1);
}
/
Get and print the value of the root node ’name’ property
/
(void) peer(0, fd); /Navigate to the root node /
(void) memset(oppbuf.buf, 0, BUFSZ);
opp->oprom_size = MAXVALSZ;
(void) strcpy(opp->oprom_array, "name");
if (ioctl(fd, OPROMGETPROP, opp) < 0) {
perror("OPROMGETPROP");
exit(1);
modified 18 Aug 1995 7D-237