2 * NVRAM variable manipulation
4 * Copyright 2007, Broadcom Corporation
7 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
18 #ifndef _LANGUAGE_ASSEMBLY
26 uint32 crc_ver_init
; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
27 uint32 config_refresh
; /* 0:15 sdram_config, 16:31 sdram_refresh */
28 uint32 config_ncdl
; /* ncdl values for memc */
34 struct nvram_tuple
*next
;
38 * Get default value for an NVRAM variable
40 extern char *nvram_default_get(const char *name
);
43 * Append a chunk of nvram variables to the global list
45 extern int nvram_append(void *sb
, char *vars
, uint varsz
);
48 * Check for reset button press for restoring factory defaults.
50 extern bool nvram_reset(void *sbh
);
53 * Disable NVRAM access. May be unnecessary or undefined on certain
56 extern void nvram_exit(void *sbh
);
59 * Get the value of an NVRAM variable. The pointer returned may be
60 * invalid after a set.
61 * @param name name of variable to get
62 * @return value of variable or NULL if undefined
64 extern char * nvram_get(const char *name
);
67 * Read the reset GPIO value from the nvram and set the GPIO
70 extern int BCMINITFN(nvram_resetgpio_init
)(void *sbh
);
73 * Get the value of an NVRAM variable.
74 * @param name name of variable to get
75 * @return value of variable or NUL if undefined
77 #define nvram_safe_get(name) (nvram_get(name) ? : "")
80 * Match an NVRAM variable.
81 * @param name name of variable to match
82 * @param match value to compare against value of variable
83 * @return TRUE if variable is defined and its value is string equal
84 * to match or FALSE otherwise
87 nvram_match(char *name
, char *match
) {
88 const char *value
= nvram_get(name
);
89 return (value
&& !strcmp(value
, match
));
93 * Inversely match an NVRAM variable.
94 * @param name name of variable to match
95 * @param match value to compare against value of variable
96 * @return TRUE if variable is defined and its value is not string
97 * equal to invmatch or FALSE otherwise
100 nvram_invmatch(char *name
, char *invmatch
) {
101 const char *value
= nvram_get(name
);
102 return (value
&& strcmp(value
, invmatch
));
106 * Set the value of an NVRAM variable. The name and value strings are
107 * copied into private storage. Pointers to previously set values
108 * may become invalid. The new value may be immediately
109 * retrieved but will not be permanently stored until a commit.
110 * @param name name of variable to set
111 * @param value value of variable
112 * @return 0 on success and errno on failure
114 extern int nvram_set(const char *name
, const char *value
);
117 * Unset an NVRAM variable. Pointers to previously set values
118 * remain valid until a set.
119 * @param name name of variable to unset
120 * @return 0 on success and errno on failure
121 * NOTE: use nvram_commit to commit this change to flash.
123 extern int nvram_unset(const char *name
);
126 * Commit NVRAM variables to permanent storage. All pointers to values
127 * may be invalid after a commit.
128 * NVRAM values are undefined after a commit.
129 * @return 0 on success and errno on failure
131 extern int nvram_commit(void);
134 * Get all NVRAM variables (format name=value\0 ... \0\0).
135 * @param buf buffer to store variables
136 * @param count size of buffer in bytes
137 * @return 0 on success and errno on failure
139 extern int nvram_getall(char *nvram_buf
, int count
);
142 * returns the crc value of the nvram
143 * @param nvh nvram header pointer
145 extern uint8
nvram_calc_crc(struct nvram_header
* nvh
);
147 extern char* getvar(char *vars
, const char *name
);
148 extern int getintvar(char *vars
, const char *name
);
150 #endif /* _LANGUAGE_ASSEMBLY */
152 /* The NVRAM version number stored as an NVRAM variable */
153 #define NVRAM_SOFTWARE_VERSION "1"
155 #define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
156 #define NVRAM_CLEAR_MAGIC 0x0
157 #define NVRAM_INVALID_MAGIC 0xFFFFFFFF
158 #define NVRAM_VERSION 1
159 #define NVRAM_HEADER_SIZE 20
160 #define NVRAM_SPACE 0x8000
162 #define NVRAM_MAX_VALUE_LEN 255
163 #define NVRAM_MAX_PARAM_LEN 64
165 #define NVRAM_CRC_START_POSITION 9 /* magic, len, crc8 to be skipped */
166 #define NVRAM_CRC_VER_MASK 0xffffff00 /* for crc_ver_init */
168 #endif /* _bcmnvram_h_ */
This page took 0.058864 seconds and 5 git commands to generate.