Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / lib / libnvram / nvram.h
1 /******************************************************************************
2  * Copyright (c) 2004, 2008 IBM Corporation
3  * All rights reserved.
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12
13 #ifndef __NVRAM_H
14 #define __NVRAM_H 1
15
16 /* data structures */
17
18 typedef struct {
19         unsigned long addr;
20         long len;
21 } partition_t;
22
23 /* macros */
24
25 #define DEBUG(x...)
26 // #define DEBUG(x...) printf(x);
27
28 #ifndef ALIGN
29 #define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
30 #endif
31
32 #define NULL ((void *)0)
33
34 #define PARTITION_HEADER_SIZE 16
35
36
37 /* exported functions */
38
39 #define nvram_access_proto(type,name)                   \
40         type nvram_read_##name(unsigned int offset);            \
41         void nvram_write_##name(unsigned int offset, type data);
42
43 nvram_access_proto(uint8_t,  byte)
44 nvram_access_proto(uint16_t, word)
45 nvram_access_proto(uint32_t, dword)
46 nvram_access_proto(uint64_t, qword)
47
48 /* nvram.c */
49
50 char *get_nvram_buffer(int len);
51 void free_nvram_buffer(char *buffer);
52 int nvramlog_printf(const char* fmt, ...);
53 partition_t get_partition(unsigned int type, char *name);
54 void erase_nvram(int offset, int len);
55 int wipe_partition(partition_t partition, int header_only);
56 partition_t new_nvram_partition(int type, char *name, int len);
57 int increase_nvram_partition_size(partition_t partition, int newsize);
58 int clear_nvram_partition(partition_t part);
59 int delete_nvram_partition(partition_t part);
60 void reset_nvram(void);
61 void wipe_nvram(void);
62 void nvram_debug(void);
63 void nvram_init(uint32_t store_token, uint32_t fetch_token,
64                 long nv_size, void* nvram_addr);
65 unsigned int get_nvram_size(void);
66
67 /* envvar.c */
68 char *get_env(partition_t part, char *envvar);
69 int add_env(partition_t part, char *envvar, char *value);
70 int del_env(partition_t part, char *envvar);
71 int set_env(partition_t part, char *envvar, char *value);
72
73 #endif