Remove empty dummy file "loaders.cache" during uninstall (bug #1766841)
[qemu/ar7.git] / include / hw / nvram / chrp_nvram.h
blobb4f5b2b104579464cac8d8b221d24844abc5659c
1 /*
2 * Common Hardware Reference Platform NVRAM functions.
4 * This code is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #ifndef CHRP_NVRAM_H
19 #define CHRP_NVRAM_H
21 /* OpenBIOS NVRAM partition */
22 typedef struct {
23 uint8_t signature;
24 uint8_t checksum;
25 uint16_t len; /* Big endian, length divided by 16 */
26 char name[12];
27 } ChrpNvramPartHdr;
29 #define CHRP_NVPART_SYSTEM 0x70
30 #define CHRP_NVPART_FREE 0x7f
32 static inline void
33 chrp_nvram_finish_partition(ChrpNvramPartHdr *header, uint32_t size)
35 unsigned int i, sum;
36 uint8_t *tmpptr;
38 /* Length divided by 16 */
39 header->len = cpu_to_be16(size >> 4);
41 /* Checksum */
42 tmpptr = (uint8_t *)header;
43 sum = *tmpptr;
44 for (i = 0; i < 14; i++) {
45 sum += tmpptr[2 + i];
46 sum = (sum + ((sum & 0xff00) >> 8)) & 0xff;
48 header->checksum = sum & 0xff;
51 int chrp_nvram_create_system_partition(uint8_t *data, int min_len);
52 int chrp_nvram_create_free_partition(uint8_t *data, int len);
54 #endif