nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]
[qemu.git] / include / hw / nvram / openbios_firmware_abi.h
blob27ce9f4a536d6cdb2e62cc6e65bd4b07b18d935b
1 #ifndef OPENBIOS_FIRMWARE_ABI_H
2 #define OPENBIOS_FIRMWARE_ABI_H
4 /* Sun IDPROM structure at the end of NVRAM */
5 /* from http://www.squirrel.com/squirrel/sun-nvram-hostid.faq.html */
6 struct Sun_nvram {
7 uint8_t type; /* always 01 */
8 uint8_t machine_id; /* first byte of host id (machine type) */
9 uint8_t macaddr[6]; /* 6 byte ethernet address (first 3 bytes 08, 00, 20) */
10 uint8_t date[4]; /* date of manufacture */
11 uint8_t hostid[3]; /* remaining 3 bytes of host id (serial number) */
12 uint8_t checksum; /* bitwise xor of previous bytes */
15 static inline void
16 Sun_init_header(struct Sun_nvram *header, const uint8_t *macaddr, int machine_id)
18 uint8_t tmp, *tmpptr;
19 unsigned int i;
21 header->type = 1;
22 header->machine_id = machine_id & 0xff;
23 memcpy(&header->macaddr, macaddr, 6);
24 memcpy(&header->hostid , &macaddr[3], 3);
26 /* Calculate checksum */
27 tmp = 0;
28 tmpptr = (uint8_t *)header;
29 for (i = 0; i < 15; i++)
30 tmp ^= tmpptr[i];
32 header->checksum = tmp;
34 #endif /* OPENBIOS_FIRMWARE_ABI_H */