Revision ec0503b4
b/hw/nvram/mac_nvram.c | ||
---|---|---|
23 | 23 |
* THE SOFTWARE. |
24 | 24 |
*/ |
25 | 25 |
#include "hw/hw.h" |
26 |
#include "hw/sparc/firmware_abi.h"
|
|
26 |
#include "hw/nvram/openbios_firmware_abi.h"
|
|
27 | 27 |
#include "sysemu/sysemu.h" |
28 | 28 |
#include "hw/ppc/mac.h" |
29 | 29 |
|
b/hw/sparc/sun4m.c | ||
---|---|---|
30 | 30 |
#include "sysemu/sysemu.h" |
31 | 31 |
#include "net/net.h" |
32 | 32 |
#include "hw/boards.h" |
33 |
#include "hw/sparc/firmware_abi.h"
|
|
33 |
#include "hw/nvram/openbios_firmware_abi.h"
|
|
34 | 34 |
#include "hw/scsi/esp.h" |
35 | 35 |
#include "hw/i386/pc.h" |
36 | 36 |
#include "hw/isa/isa.h" |
b/hw/sparc64/sun4u.c | ||
---|---|---|
32 | 32 |
#include "qemu/timer.h" |
33 | 33 |
#include "sysemu/sysemu.h" |
34 | 34 |
#include "hw/boards.h" |
35 |
#include "hw/sparc/firmware_abi.h"
|
|
35 |
#include "hw/nvram/openbios_firmware_abi.h"
|
|
36 | 36 |
#include "hw/nvram/fw_cfg.h" |
37 | 37 |
#include "hw/sysbus.h" |
38 | 38 |
#include "hw/ide.h" |
b/include/hw/nvram/openbios_firmware_abi.h | ||
---|---|---|
1 |
#ifndef FIRMWARE_ABI_H |
|
2 |
#define FIRMWARE_ABI_H |
|
3 |
|
|
4 |
/* OpenBIOS NVRAM partition */ |
|
5 |
struct OpenBIOS_nvpart_v1 { |
|
6 |
uint8_t signature; |
|
7 |
uint8_t checksum; |
|
8 |
uint16_t len; // BE, length divided by 16 |
|
9 |
char name[12]; |
|
10 |
}; |
|
11 |
|
|
12 |
#define OPENBIOS_PART_SYSTEM 0x70 |
|
13 |
#define OPENBIOS_PART_FREE 0x7f |
|
14 |
|
|
15 |
static inline void |
|
16 |
OpenBIOS_finish_partition(struct OpenBIOS_nvpart_v1 *header, uint32_t size) |
|
17 |
{ |
|
18 |
unsigned int i, sum; |
|
19 |
uint8_t *tmpptr; |
|
20 |
|
|
21 |
// Length divided by 16 |
|
22 |
header->len = cpu_to_be16(size >> 4); |
|
23 |
|
|
24 |
// Checksum |
|
25 |
tmpptr = (uint8_t *)header; |
|
26 |
sum = *tmpptr; |
|
27 |
for (i = 0; i < 14; i++) { |
|
28 |
sum += tmpptr[2 + i]; |
|
29 |
sum = (sum + ((sum & 0xff00) >> 8)) & 0xff; |
|
30 |
} |
|
31 |
header->checksum = sum & 0xff; |
|
32 |
} |
|
33 |
|
|
34 |
static inline uint32_t |
|
35 |
OpenBIOS_set_var(uint8_t *nvram, uint32_t addr, const char *str) |
|
36 |
{ |
|
37 |
uint32_t len; |
|
38 |
|
|
39 |
len = strlen(str) + 1; |
|
40 |
memcpy(&nvram[addr], str, len); |
|
41 |
|
|
42 |
return addr + len; |
|
43 |
} |
|
44 |
|
|
45 |
/* Sun IDPROM structure at the end of NVRAM */ |
|
46 |
/* from http://www.squirrel.com/squirrel/sun-nvram-hostid.faq.html */ |
|
47 |
struct Sun_nvram { |
|
48 |
uint8_t type; /* always 01 */ |
|
49 |
uint8_t machine_id; /* first byte of host id (machine type) */ |
|
50 |
uint8_t macaddr[6]; /* 6 byte ethernet address (first 3 bytes 08, 00, 20) */ |
|
51 |
uint8_t date[4]; /* date of manufacture */ |
|
52 |
uint8_t hostid[3]; /* remaining 3 bytes of host id (serial number) */ |
|
53 |
uint8_t checksum; /* bitwise xor of previous bytes */ |
|
54 |
}; |
|
55 |
|
|
56 |
static inline void |
|
57 |
Sun_init_header(struct Sun_nvram *header, const uint8_t *macaddr, int machine_id) |
|
58 |
{ |
|
59 |
uint8_t tmp, *tmpptr; |
|
60 |
unsigned int i; |
|
61 |
|
|
62 |
header->type = 1; |
|
63 |
header->machine_id = machine_id & 0xff; |
|
64 |
memcpy(&header->macaddr, macaddr, 6); |
|
65 |
/* Calculate checksum */ |
|
66 |
tmp = 0; |
|
67 |
tmpptr = (uint8_t *)header; |
|
68 |
for (i = 0; i < 15; i++) |
|
69 |
tmp ^= tmpptr[i]; |
|
70 |
|
|
71 |
header->checksum = tmp; |
|
72 |
} |
|
73 |
#endif /* FIRMWARE_ABI_H */ |
/dev/null | ||
---|---|---|
1 |
#ifndef FIRMWARE_ABI_H |
|
2 |
#define FIRMWARE_ABI_H |
|
3 |
|
|
4 |
/* OpenBIOS NVRAM partition */ |
|
5 |
struct OpenBIOS_nvpart_v1 { |
|
6 |
uint8_t signature; |
|
7 |
uint8_t checksum; |
|
8 |
uint16_t len; // BE, length divided by 16 |
|
9 |
char name[12]; |
|
10 |
}; |
|
11 |
|
|
12 |
#define OPENBIOS_PART_SYSTEM 0x70 |
|
13 |
#define OPENBIOS_PART_FREE 0x7f |
|
14 |
|
|
15 |
static inline void |
|
16 |
OpenBIOS_finish_partition(struct OpenBIOS_nvpart_v1 *header, uint32_t size) |
|
17 |
{ |
|
18 |
unsigned int i, sum; |
|
19 |
uint8_t *tmpptr; |
|
20 |
|
|
21 |
// Length divided by 16 |
|
22 |
header->len = cpu_to_be16(size >> 4); |
|
23 |
|
|
24 |
// Checksum |
|
25 |
tmpptr = (uint8_t *)header; |
|
26 |
sum = *tmpptr; |
|
27 |
for (i = 0; i < 14; i++) { |
|
28 |
sum += tmpptr[2 + i]; |
|
29 |
sum = (sum + ((sum & 0xff00) >> 8)) & 0xff; |
|
30 |
} |
|
31 |
header->checksum = sum & 0xff; |
|
32 |
} |
|
33 |
|
|
34 |
static inline uint32_t |
|
35 |
OpenBIOS_set_var(uint8_t *nvram, uint32_t addr, const char *str) |
|
36 |
{ |
|
37 |
uint32_t len; |
|
38 |
|
|
39 |
len = strlen(str) + 1; |
|
40 |
memcpy(&nvram[addr], str, len); |
|
41 |
|
|
42 |
return addr + len; |
|
43 |
} |
|
44 |
|
|
45 |
/* Sun IDPROM structure at the end of NVRAM */ |
|
46 |
/* from http://www.squirrel.com/squirrel/sun-nvram-hostid.faq.html */ |
|
47 |
struct Sun_nvram { |
|
48 |
uint8_t type; /* always 01 */ |
|
49 |
uint8_t machine_id; /* first byte of host id (machine type) */ |
|
50 |
uint8_t macaddr[6]; /* 6 byte ethernet address (first 3 bytes 08, 00, 20) */ |
|
51 |
uint8_t date[4]; /* date of manufacture */ |
|
52 |
uint8_t hostid[3]; /* remaining 3 bytes of host id (serial number) */ |
|
53 |
uint8_t checksum; /* bitwise xor of previous bytes */ |
|
54 |
}; |
|
55 |
|
|
56 |
static inline void |
|
57 |
Sun_init_header(struct Sun_nvram *header, const uint8_t *macaddr, int machine_id) |
|
58 |
{ |
|
59 |
uint8_t tmp, *tmpptr; |
|
60 |
unsigned int i; |
|
61 |
|
|
62 |
header->type = 1; |
|
63 |
header->machine_id = machine_id & 0xff; |
|
64 |
memcpy(&header->macaddr, macaddr, 6); |
|
65 |
/* Calculate checksum */ |
|
66 |
tmp = 0; |
|
67 |
tmpptr = (uint8_t *)header; |
|
68 |
for (i = 0; i < 15; i++) |
|
69 |
tmp ^= tmpptr[i]; |
|
70 |
|
|
71 |
header->checksum = tmp; |
|
72 |
} |
|
73 |
#endif /* FIRMWARE_ABI_H */ |
Also available in: Unified diff