| /* |
| * NVRAM variable manipulation |
| * |
| * $Copyright Open Broadcom Corporation$ |
| * |
| * $Id: bcmnvram.h 428512 2013-10-09 02:12:11Z $ |
| */ |
| |
| #ifndef _bcmnvram_h_ |
| #define _bcmnvram_h_ |
| |
| #ifndef _LANGUAGE_ASSEMBLY |
| |
| #include <typedefs.h> |
| #include <bcmdefs.h> |
| |
| struct nvram_header { |
| uint32 magic; |
| uint32 len; |
| uint32 crc_ver_init; |
| uint32 config_refresh; |
| uint32 config_ncdl; |
| }; |
| |
| struct nvram_tuple { |
| char *name; |
| char *value; |
| struct nvram_tuple *next; |
| }; |
| |
| |
| extern char *nvram_default_get(const char *name); |
| |
| extern void nvram_validate_all(char *prefix, bool restore); |
| |
| |
| extern void nvram_restore_var(char *prefix, char *name); |
| |
| |
| extern int nvram_init(void *sih); |
| extern int nvram_deinit(void *sih); |
| |
| |
| |
| extern int nvram_append(void *si, char *vars, uint varsz); |
| |
| extern void nvram_get_global_vars(char **varlst, uint *varsz); |
| |
| |
| |
| extern int nvram_reset(void *sih); |
| |
| |
| extern void nvram_exit(void *sih); |
| |
| |
| extern char * nvram_get(const char *name); |
| |
| |
| extern int BCMINITFN(nvram_resetgpio_init)(void *sih); |
| |
| |
| static INLINE char * |
| nvram_safe_get(const char *name) |
| { |
| char *p = nvram_get(name); |
| return p ? p : ""; |
| } |
| |
| |
| static INLINE int |
| nvram_match(const char *name, const char *match) |
| { |
| const char *value = nvram_get(name); |
| return (value && !strcmp(value, match)); |
| } |
| |
| |
| static INLINE int |
| nvram_invmatch(const char *name, const char *invmatch) |
| { |
| const char *value = nvram_get(name); |
| return (value && strcmp(value, invmatch)); |
| } |
| |
| |
| extern int nvram_set(const char *name, const char *value); |
| |
| |
| extern int nvram_unset(const char *name); |
| |
| |
| extern int nvram_commit_internal(bool nvram_corrupt); |
| |
| |
| extern int nvram_commit(void); |
| |
| |
| extern int nvram_getall(char *nvram_buf, int count); |
| |
| |
| uint8 nvram_calc_crc(struct nvram_header * nvh); |
| |
| extern int nvram_space; |
| #endif |
| |
| |
| #define NVRAM_SOFTWARE_VERSION "1" |
| |
| #define NVRAM_MAGIC 0x48534C46 |
| #define NVRAM_CLEAR_MAGIC 0x0 |
| #define NVRAM_INVALID_MAGIC 0xFFFFFFFF |
| #define NVRAM_VERSION 1 |
| #define NVRAM_HEADER_SIZE 20 |
| |
| #define NVRAM_SPACE 0x8000 |
| |
| #ifndef MAX_NVRAM_SPACE |
| #define MAX_NVRAM_SPACE 0x10000 |
| #endif |
| #define DEF_NVRAM_SPACE 0x8000 |
| #define ROM_ENVRAM_SPACE 0x1000 |
| #define NVRAM_LZMA_MAGIC 0x4c5a4d41 |
| |
| #define NVRAM_MAX_VALUE_LEN 255 |
| #define NVRAM_MAX_PARAM_LEN 64 |
| |
| #define NVRAM_CRC_START_POSITION 9 |
| #define NVRAM_CRC_VER_MASK 0xffffff00 |
| |
| |
| #define NVRAM_START_COMPRESSED 0x400 |
| #define NVRAM_START 0x1000 |
| |
| #define BCM_JUMBO_NVRAM_DELIMIT '\n' |
| #define BCM_JUMBO_START "Broadcom Jumbo Nvram file" |
| |
| |
| #if (defined(FAILSAFE_UPGRADE) || defined(CONFIG_FAILSAFE_UPGRADE) || \ |
| defined(__CONFIG_FAILSAFE_UPGRADE_SUPPORT__)) |
| #define IMAGE_SIZE "image_size" |
| #define BOOTPARTITION "bootpartition" |
| #define IMAGE_BOOT BOOTPARTITION |
| #define PARTIALBOOTS "partialboots" |
| #define MAXPARTIALBOOTS "maxpartialboots" |
| #define IMAGE_1ST_FLASH_TRX "flash0.trx" |
| #define IMAGE_1ST_FLASH_OS "flash0.os" |
| #define IMAGE_2ND_FLASH_TRX "flash0.trx2" |
| #define IMAGE_2ND_FLASH_OS "flash0.os2" |
| #define IMAGE_FIRST_OFFSET "image_first_offset" |
| #define IMAGE_SECOND_OFFSET "image_second_offset" |
| #define LINUX_FIRST "linux" |
| #define LINUX_SECOND "linux2" |
| #endif |
| |
| #if (defined(DUAL_IMAGE) || defined(CONFIG_DUAL_IMAGE) || \ |
| defined(__CONFIG_DUAL_IMAGE_FLASH_SUPPORT__)) |
| |
| #define IMAGE_BOOT "image_boot" |
| #define BOOTPARTITION IMAGE_BOOT |
| |
| #define IMAGE_1ST_FLASH_TRX "flash0.trx" |
| #define IMAGE_1ST_FLASH_OS "flash0.os" |
| #define IMAGE_2ND_FLASH_TRX "flash0.trx2" |
| #define IMAGE_2ND_FLASH_OS "flash0.os2" |
| #define IMAGE_SIZE "image_size" |
| |
| |
| #define IMAGE_FIRST_OFFSET "image_first_offset" |
| #define IMAGE_SECOND_OFFSET "image_second_offset" |
| |
| |
| #define LINUX_FIRST "linux" |
| #define LINUX_SECOND "linux2" |
| #define POLICY_TOGGLE "toggle" |
| #define LINUX_PART_TO_FLASH "linux_to_flash" |
| #define LINUX_FLASH_POLICY "linux_flash_policy" |
| |
| #endif |
| |
| #endif |