2016-10-18 23:46:44 +03:00
|
|
|
#ifndef SUN_NVRAM_H
|
|
|
|
#define SUN_NVRAM_H
|
2007-11-14 22:35:16 +03:00
|
|
|
|
|
|
|
/* Sun IDPROM structure at the end of NVRAM */
|
2009-03-28 19:17:50 +03:00
|
|
|
/* from http://www.squirrel.com/squirrel/sun-nvram-hostid.faq.html */
|
2007-11-14 22:35:16 +03:00
|
|
|
struct Sun_nvram {
|
2009-03-28 19:17:50 +03:00
|
|
|
uint8_t type; /* always 01 */
|
|
|
|
uint8_t machine_id; /* first byte of host id (machine type) */
|
|
|
|
uint8_t macaddr[6]; /* 6 byte ethernet address (first 3 bytes 08, 00, 20) */
|
|
|
|
uint8_t date[4]; /* date of manufacture */
|
|
|
|
uint8_t hostid[3]; /* remaining 3 bytes of host id (serial number) */
|
|
|
|
uint8_t checksum; /* bitwise xor of previous bytes */
|
2007-11-14 22:35:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
Sun_init_header(struct Sun_nvram *header, const uint8_t *macaddr, int machine_id)
|
|
|
|
{
|
|
|
|
uint8_t tmp, *tmpptr;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
header->type = 1;
|
|
|
|
header->machine_id = machine_id & 0xff;
|
|
|
|
memcpy(&header->macaddr, macaddr, 6);
|
2014-02-23 21:08:06 +04:00
|
|
|
memcpy(&header->hostid , &macaddr[3], 3);
|
|
|
|
|
2007-11-14 22:35:16 +03:00
|
|
|
/* Calculate checksum */
|
|
|
|
tmp = 0;
|
|
|
|
tmpptr = (uint8_t *)header;
|
|
|
|
for (i = 0; i < 15; i++)
|
|
|
|
tmp ^= tmpptr[i];
|
|
|
|
|
|
|
|
header->checksum = tmp;
|
|
|
|
}
|
2016-10-18 23:46:44 +03:00
|
|
|
#endif /* SUN_NVRAM_H */
|