Files
Arquivotheca.SunOS-4.1.4/sys/boot/lib/promlib/prom_idprom.c
seta75D ff309bfe1c Init
2021-10-11 18:37:13 -03:00

55 lines
1.1 KiB
C

/* @(#)prom_idprom.c 1.1 94/10/31 SMI" */
/*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*/
#include <promcommon.h>
#include <mon/idprom.h>
/*
* Get idprom property from root node, return to callers buffer.
* Returns idprom format byte.
*/
#define rootnode() prom_nextnode((dnode_t)0)
#define NO_FORMAT ((char)(IDFORM_1 - 1))
static int idpromlength;
static struct idprom idprombuf;
extern dnode_t prom_nextnode();
char
prom_getidprom(addr, size)
caddr_t addr;
int size;
{
int length;
dnode_t rootid;
if (idpromlength == 0) {
if ((rootid = rootnode()) == OBP_BADNODE) {
prom_printf("prom_getidprom: can't get root node!\n");
return (NO_FORMAT);
}
length = prom_getproplen(rootid, OBP_IDPROM);
if (length == -1) {
prom_printf("Missing idprom property.\n");
return (NO_FORMAT);
}
if (length > sizeof (idprombuf)) {
prom_printf("prom_getidprom: property size <%d> too large!\n",
length);
return (NO_FORMAT);
}
(void)prom_getprop(rootid, OBP_IDPROM, (char *)(&idprombuf));
idpromlength = length;
}
bcopy((char *)(&idprombuf), addr, (u_int) size);
return (*addr);
}