|
|
1.1 ! root 1: /* ! 2: * @(#)idprom.c 1.1 86/02/03 Copyright (c) 1983 by Sun Microsystems, Inc. ! 3: */ ! 4: ! 5: #include <machine/idprom.h> ! 6: ! 7: /* ! 8: * Read the ID prom and check it. ! 9: * Arguments are a format number and an address to store prom contents at. ! 10: * ! 11: * Result is format number if prom has the right format and good checksum. ! 12: * Result is -1 if prom has the right format and bad checksum. ! 13: * Result is prom's format if prom has the wrong format. ! 14: * ! 15: * If the PROM is in the wrong format, the addressed area is not changed. ! 16: * ! 17: * This routine must know the size, and checksum algorithm, of each format. ! 18: * (Currently there's only one.) ! 19: */ ! 20: ! 21: int ! 22: idprom(format, idp) ! 23: unsigned char format; ! 24: register struct idprom *idp; ! 25: { ! 26: unsigned char *cp, sum=0, promform; ! 27: short i; ! 28: ! 29: getidprom(&promform, 1); /* Get format byte */ ! 30: if (format != promform) ! 31: return promform; ! 32: getidprom((unsigned char *)idp, sizeof(*idp)); /* The whole thing */ ! 33: cp = (unsigned char *)idp; ! 34: for (i=0; i<16; i++) ! 35: sum ^= *cp++; ! 36: if (sum != 0) ! 37: return -1; ! 38: return promform; ! 39: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.