5 /* Open Hack'Ware NVRAM configuration structure */
8 typedef struct ohwcfg_v3_t ohwcfg_v3_t;
10 /* 0x00: structure identifier */
11 uint8_t struct_ident[0x10];
12 /* 0x10: structure version and NVRAM description */
13 uint32_t struct_version;
16 uint16_t nvram_arch_ptr;
17 uint16_t nvram_arch_size;
18 uint16_t nvram_arch_crc;
20 /* 0x20: host architecture */
22 /* 0x30: RAM/ROM description */
33 /* 0x80: Kernel description */
34 uint64_t kernel_image;
36 /* 0x90: Kernel command line */
38 uint64_t cmdline_size;
39 /* 0xA0: Kernel boot image */
40 uint64_t initrd_image;
42 /* 0xB0: NVRAM image */
45 /* 0xC0: graphic configuration */
49 uint16_t graphic_flags;
50 /* 0xC8: CPUs description */
53 uint8_t nboot_devices;
55 /* 0xD0: boot devices */
56 uint8_t boot_devices[0x10];
58 uint8_t pad4[0x1C]; /* 28 */
62 } __attribute__ (( packed ));
64 #define OHW_GF_NOGRAPHICS 0x0001
66 static inline uint16_t
67 OHW_crc_update (uint16_t prev, uint16_t value)
70 uint16_t pd, pd1, pd2;
75 pd2 = ((pd >> 4) & 0x000F) ^ pd1;
76 tmp ^= (pd1 << 3) | (pd1 << 8);
77 tmp ^= pd2 | (pd2 << 7) | (pd2 << 12);
82 static inline uint16_t
83 OHW_compute_crc (ohwcfg_v3_t *header, uint32_t start, uint32_t count)
86 uint16_t crc = 0xFFFF;
87 uint8_t *ptr = (uint8_t *)header;
92 for (i = 0; i != count; i++) {
93 crc = OHW_crc_update(crc, (ptr[start + i] << 8) | ptr[start + i + 1]);
96 crc = OHW_crc_update(crc, ptr[start + i] << 8);
102 /* Sparc32 runtime NVRAM structure for SMP CPU boot */
103 struct sparc_arch_cfg {
111 /* OpenBIOS NVRAM partition */
112 struct OpenBIOS_nvpart_v1 {
115 uint16_t len; // BE, length divided by 16
119 #define OPENBIOS_PART_SYSTEM 0x70
120 #define OPENBIOS_PART_FREE 0x7f
123 OpenBIOS_finish_partition(struct OpenBIOS_nvpart_v1 *header, uint32_t size)
128 // Length divided by 16
129 header->len = cpu_to_be16(size >> 4);
132 tmpptr = (uint8_t *)header;
134 for (i = 0; i < 14; i++) {
135 sum += tmpptr[2 + i];
136 sum = (sum + ((sum & 0xff00) >> 8)) & 0xff;
138 header->checksum = sum & 0xff;
141 static inline uint32_t
142 OpenBIOS_set_var(uint8_t *nvram, uint32_t addr, const unsigned char *str)
146 len = strlen(str) + 1;
147 memcpy(&nvram[addr], str, len);
152 /* Sun IDPROM structure at the end of NVRAM */
162 Sun_init_header(struct Sun_nvram *header, const uint8_t *macaddr, int machine_id)
164 uint8_t tmp, *tmpptr;
168 header->machine_id = machine_id & 0xff;
169 memcpy(&header->macaddr, macaddr, 6);
170 /* Calculate checksum */
172 tmpptr = (uint8_t *)header;
173 for (i = 0; i < 15; i++)
176 header->checksum = tmp;
179 #else /* __ASSEMBLY__ */
181 /* Structure offsets for asm use */
183 /* Open Hack'Ware NVRAM configuration structure */
184 #define OHW_ARCH_PTR 0x18
185 #define OHW_RAM_SIZE 0x38
186 #define OHW_BOOT_CPU 0xC9
188 /* Sparc32 runtime NVRAM structure for SMP CPU boot */
189 #define SPARC_SMP_CTX 0x0
190 #define SPARC_SMP_CTXTBL 0x4
191 #define SPARC_SMP_ENTRY 0x8
192 #define SPARC_SMP_VALID 0xc
194 /* Sun IDPROM structure at the end of NVRAM */
195 #define SPARC_MACHINE_ID 0x1fd9
197 #endif /* __ASSEMBLY__ */
198 #endif /* FIRMWARE_ABI_H */