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.
17 #ifndef _LANGUAGE_ASSEMBLY
25 uint32 crc_ver_init
; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
26 uint32 config_refresh
; /* 0:15 sdram_config, 16:31 sdram_refresh */
27 uint32 config_ncdl
; /* ncdl values for memc */
33 struct nvram_tuple
*next
;
37 * Get default value for an NVRAM variable
39 extern char *nvram_default_get(const char *name
);
42 * Append a chunk of nvram variables to the global list
44 extern int nvram_append(void *sb
, char *vars
, uint varsz
);
47 * Check for reset button press for restoring factory defaults.
49 extern bool nvram_reset(void *sbh
);
52 * Disable NVRAM access. May be unnecessary or undefined on certain
55 extern void nvram_exit(void *sbh
);
58 * Get the value of an NVRAM variable. The pointer returned may be
59 * invalid after a set.
60 * @param name name of variable to get
61 * @return value of variable or NULL if undefined
63 extern char * nvram_get(const char *name
);
66 * Read the reset GPIO value from the nvram and set the GPIO
69 extern int BCMINITFN(nvram_resetgpio_init
)(void *sbh
);
72 * Get the value of an NVRAM variable.
73 * @param name name of variable to get
74 * @return value of variable or NUL if undefined
76 #define nvram_safe_get(name) (nvram_get(name) ? : "")
79 * Match an NVRAM variable.
80 * @param name name of variable to match
81 * @param match value to compare against value of variable
82 * @return TRUE if variable is defined and its value is string equal
83 * to match or FALSE otherwise
86 nvram_match(char *name
, char *match
) {
87 const char *value
= nvram_get(name
);
88 return (value
&& !strcmp(value
, match
));
92 * Inversely match an NVRAM variable.
93 * @param name name of variable to match
94 * @param match value to compare against value of variable
95 * @return TRUE if variable is defined and its value is not string
96 * equal to invmatch or FALSE otherwise
99 nvram_invmatch(char *name
, char *invmatch
) {
100 const char *value
= nvram_get(name
);
101 return (value
&& strcmp(value
, invmatch
));
105 * Set the value of an NVRAM variable. The name and value strings are
106 * copied into private storage. Pointers to previously set values
107 * may become invalid. The new value may be immediately
108 * retrieved but will not be permanently stored until a commit.
109 * @param name name of variable to set
110 * @param value value of variable
111 * @return 0 on success and errno on failure
113 extern int nvram_set(const char *name
, const char *value
);
116 * Unset an NVRAM variable. Pointers to previously set values
117 * remain valid until a set.
118 * @param name name of variable to unset
119 * @return 0 on success and errno on failure
120 * NOTE: use nvram_commit to commit this change to flash.
122 extern int nvram_unset(const char *name
);
125 * Commit NVRAM variables to permanent storage. All pointers to values
126 * may be invalid after a commit.
127 * NVRAM values are undefined after a commit.
128 * @return 0 on success and errno on failure
130 extern int nvram_commit(void);
133 * Get all NVRAM variables (format name=value\0 ... \0\0).
134 * @param buf buffer to store variables
135 * @param count size of buffer in bytes
136 * @return 0 on success and errno on failure
138 extern int nvram_getall(char *nvram_buf
, int count
);
141 * returns the crc value of the nvram
142 * @param nvh nvram header pointer
144 extern uint8
nvram_calc_crc(struct nvram_header
* nvh
);
146 extern char* getvar(char *vars
, const char *name
);
147 extern int getintvar(char *vars
, const char *name
);
149 #endif /* _LANGUAGE_ASSEMBLY */
151 /* The NVRAM version number stored as an NVRAM variable */
152 #define NVRAM_SOFTWARE_VERSION "1"
154 #define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
155 #define NVRAM_CLEAR_MAGIC 0x0
156 #define NVRAM_INVALID_MAGIC 0xFFFFFFFF
157 #define NVRAM_VERSION 1
158 #define NVRAM_HEADER_SIZE 20
159 #define NVRAM_SPACE 0x8000
161 #define NVRAM_MAX_VALUE_LEN 255
162 #define NVRAM_MAX_PARAM_LEN 64
164 #define NVRAM_CRC_START_POSITION 9 /* magic, len, crc8 to be skipped */
165 #define NVRAM_CRC_VER_MASK 0xffffff00 /* for crc_ver_init */
167 #endif /* _bcmnvram_h_ */
This page took 0.055483 seconds and 5 git commands to generate.