qemu

FORK: QEMU emulator
git clone https://git.neptards.moe/neptards/qemu.git
Log | Files | Refs | Submodules | LICENSE

sun_nvram.h (1044B)


      1 #ifndef SUN_NVRAM_H
      2 #define SUN_NVRAM_H
      3 
      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 */
     13 };
     14 
     15 static inline void
     16 Sun_init_header(struct Sun_nvram *header, const uint8_t *macaddr, int machine_id)
     17 {
     18     uint8_t tmp, *tmpptr;
     19     unsigned int i;
     20 
     21     header->type = 1;
     22     header->machine_id = machine_id & 0xff;
     23     memcpy(&header->macaddr, macaddr, 6);
     24     memcpy(&header->hostid , &macaddr[3], 3);
     25 
     26     /* Calculate checksum */
     27     tmp = 0;
     28     tmpptr = (uint8_t *)header;
     29     for (i = 0; i < 15; i++)
     30         tmp ^= tmpptr[i];
     31 
     32     header->checksum = tmp;
     33 }
     34 #endif /* SUN_NVRAM_H */