|
|
1.1 root 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:
64: /* envvar.c */
65: char *get_env(partition_t part, char *envvar);
66: int add_env(partition_t part, char *envvar, char *value);
67: int del_env(partition_t part, char *envvar);
68: int set_env(partition_t part, char *envvar, char *value);
69:
70: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.