Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/next/external/cache/sources/wl/include/bcmnvram.h
Views: 3959
/*1* NVRAM variable manipulation2*3* $Copyright Open Broadcom Corporation$4*5* $Id: bcmnvram.h 401759 2013-05-13 16:08:08Z sudhirbs $6*/78#ifndef _bcmnvram_h_9#define _bcmnvram_h_1011#ifndef _LANGUAGE_ASSEMBLY1213#include <typedefs.h>14#include <bcmdefs.h>1516struct nvram_header {17uint32 magic;18uint32 len;19uint32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */20uint32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */21uint32 config_ncdl; /* ncdl values for memc */22};2324struct nvram_tuple {25char *name;26char *value;27struct nvram_tuple *next;28};2930/*31* Get default value for an NVRAM variable32*/33extern char *nvram_default_get(const char *name);34/*35* validate/restore all per-interface related variables36*/37extern void nvram_validate_all(char *prefix, bool restore);3839/*40* restore specific per-interface variable41*/42extern void nvram_restore_var(char *prefix, char *name);4344/*45* Initialize NVRAM access. May be unnecessary or undefined on certain46* platforms.47*/48extern int nvram_init(void *sih);49extern int nvram_deinit(void *sih);5051#if defined(_CFE_) && defined(BCM_DEVINFO)52extern char *flashdrv_nvram;53extern char *devinfo_flashdrv_nvram;54extern int devinfo_nvram_init(void *sih);55extern int devinfo_nvram_sync(void);56extern void _nvram_hash_select(int idx);57#endif5859/*60* Append a chunk of nvram variables to the global list61*/62extern int nvram_append(void *si, char *vars, uint varsz);6364extern void nvram_get_global_vars(char **varlst, uint *varsz);656667/*68* Check for reset button press for restoring factory defaults.69*/70extern int nvram_reset(void *sih);7172/*73* Disable NVRAM access. May be unnecessary or undefined on certain74* platforms.75*/76extern void nvram_exit(void *sih);7778/*79* Get the value of an NVRAM variable. The pointer returned may be80* invalid after a set.81* @param name name of variable to get82* @return value of variable or NULL if undefined83*/84extern char * nvram_get(const char *name);8586/*87* Read the reset GPIO value from the nvram and set the GPIO88* as input89*/90extern int BCMINITFN(nvram_resetgpio_init)(void *sih);9192/*93* Get the value of an NVRAM variable.94* @param name name of variable to get95* @return value of variable or NUL if undefined96*/97static INLINE char *98nvram_safe_get(const char *name)99{100char *p = nvram_get(name);101return p ? p : "";102}103104/*105* Match an NVRAM variable.106* @param name name of variable to match107* @param match value to compare against value of variable108* @return TRUE if variable is defined and its value is string equal109* to match or FALSE otherwise110*/111static INLINE int112nvram_match(const char *name, const char *match)113{114const char *value = nvram_get(name);115return (value && !strcmp(value, match));116}117118/*119* Inversely match an NVRAM variable.120* @param name name of variable to match121* @param match value to compare against value of variable122* @return TRUE if variable is defined and its value is not string123* equal to invmatch or FALSE otherwise124*/125static INLINE int126nvram_invmatch(const char *name, const char *invmatch)127{128const char *value = nvram_get(name);129return (value && strcmp(value, invmatch));130}131132/*133* Set the value of an NVRAM variable. The name and value strings are134* copied into private storage. Pointers to previously set values135* may become invalid. The new value may be immediately136* retrieved but will not be permanently stored until a commit.137* @param name name of variable to set138* @param value value of variable139* @return 0 on success and errno on failure140*/141extern int nvram_set(const char *name, const char *value);142143/*144* Unset an NVRAM variable. Pointers to previously set values145* remain valid until a set.146* @param name name of variable to unset147* @return 0 on success and errno on failure148* NOTE: use nvram_commit to commit this change to flash.149*/150extern int nvram_unset(const char *name);151152/*153* Commit NVRAM variables to permanent storage. All pointers to values154* may be invalid after a commit.155* NVRAM values are undefined after a commit.156* @param nvram_corrupt true to corrupt nvram, false otherwise.157* @return 0 on success and errno on failure158*/159extern int nvram_commit_internal(bool nvram_corrupt);160161/*162* Commit NVRAM variables to permanent storage. All pointers to values163* may be invalid after a commit.164* NVRAM values are undefined after a commit.165* @return 0 on success and errno on failure166*/167extern int nvram_commit(void);168169/*170* Get all NVRAM variables (format name=value\0 ... \0\0).171* @param buf buffer to store variables172* @param count size of buffer in bytes173* @return 0 on success and errno on failure174*/175extern int nvram_getall(char *nvram_buf, int count);176177/*178* returns the crc value of the nvram179* @param nvh nvram header pointer180*/181uint8 nvram_calc_crc(struct nvram_header * nvh);182183extern int nvram_space;184#endif /* _LANGUAGE_ASSEMBLY */185186/* The NVRAM version number stored as an NVRAM variable */187#define NVRAM_SOFTWARE_VERSION "1"188189#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */190#define NVRAM_CLEAR_MAGIC 0x0191#define NVRAM_INVALID_MAGIC 0xFFFFFFFF192#define NVRAM_VERSION 1193#define NVRAM_HEADER_SIZE 20194/* This definition is for precommit staging, and will be removed */195#define NVRAM_SPACE 0x8000196/* For CFE builds this gets passed in thru the makefile */197#ifndef MAX_NVRAM_SPACE198#define MAX_NVRAM_SPACE 0x10000199#endif200#define DEF_NVRAM_SPACE 0x8000201#define ROM_ENVRAM_SPACE 0x1000202#define NVRAM_LZMA_MAGIC 0x4c5a4d41 /* 'LZMA' */203204#define NVRAM_MAX_VALUE_LEN 255205#define NVRAM_MAX_PARAM_LEN 64206207#define NVRAM_CRC_START_POSITION 9 /* magic, len, crc8 to be skipped */208#define NVRAM_CRC_VER_MASK 0xffffff00 /* for crc_ver_init */209210/* Offsets to embedded nvram area */211#define NVRAM_START_COMPRESSED 0x400212#define NVRAM_START 0x1000213214#define BCM_JUMBO_NVRAM_DELIMIT '\n'215#define BCM_JUMBO_START "Broadcom Jumbo Nvram file"216217#if !defined(BCMDONGLEHOST) && !defined(BCMHIGHSDIO) && defined(BCMTRXV2)218extern char *_vars;219extern uint _varsz;220#endif /* !defined(BCMDONGLEHOST) && !defined(BCMHIGHSDIO) && defined(BCMTRXV2) */221222#if (defined(FAILSAFE_UPGRADE) || defined(CONFIG_FAILSAFE_UPGRADE) || \223defined(__CONFIG_FAILSAFE_UPGRADE_SUPPORT__))224#define IMAGE_SIZE "image_size"225#define BOOTPARTITION "bootpartition"226#define IMAGE_BOOT BOOTPARTITION227#define PARTIALBOOTS "partialboots"228#define MAXPARTIALBOOTS "maxpartialboots"229#define IMAGE_1ST_FLASH_TRX "flash0.trx"230#define IMAGE_1ST_FLASH_OS "flash0.os"231#define IMAGE_2ND_FLASH_TRX "flash0.trx2"232#define IMAGE_2ND_FLASH_OS "flash0.os2"233#define IMAGE_FIRST_OFFSET "image_first_offset"234#define IMAGE_SECOND_OFFSET "image_second_offset"235#define LINUX_FIRST "linux"236#define LINUX_SECOND "linux2"237#endif238239#if (defined(DUAL_IMAGE) || defined(CONFIG_DUAL_IMAGE) || \240defined(__CONFIG_DUAL_IMAGE_FLASH_SUPPORT__))241/* Shared by all: CFE, Linux Kernel, and Ap */242#define IMAGE_BOOT "image_boot"243#define BOOTPARTITION IMAGE_BOOT244/* CFE variables */245#define IMAGE_1ST_FLASH_TRX "flash0.trx"246#define IMAGE_1ST_FLASH_OS "flash0.os"247#define IMAGE_2ND_FLASH_TRX "flash0.trx2"248#define IMAGE_2ND_FLASH_OS "flash0.os2"249#define IMAGE_SIZE "image_size"250251/* CFE and Linux Kernel shared variables */252#define IMAGE_FIRST_OFFSET "image_first_offset"253#define IMAGE_SECOND_OFFSET "image_second_offset"254255/* Linux application variables */256#define LINUX_FIRST "linux"257#define LINUX_SECOND "linux2"258#define POLICY_TOGGLE "toggle"259#define LINUX_PART_TO_FLASH "linux_to_flash"260#define LINUX_FLASH_POLICY "linux_flash_policy"261262#endif /* defined(DUAL_IMAGE||CONFIG_DUAL_IMAGE)||__CONFIG_DUAL_IMAGE_FLASH_SUPPORT__ */263264#endif /* _bcmnvram_h_ */265266267