1 /******************************************************************************
2 * Copyright (c) 2004, 2008 IBM Corporation
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
10 * IBM Corporation - initial implementation
11 *****************************************************************************/
26 // #define DEBUG(x...) printf(x);
29 #define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
32 #define NULL ((void *)0)
34 #define PARTITION_HEADER_SIZE 16
37 /* exported functions */
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);
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)
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);
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);