char *env_name_spec = "dataflash";
-uchar env_get_char_spec(int index)
+static unsigned char env_dataflash_get_char(int index)
{
uchar c;
return c;
}
-void env_relocate_spec(void)
+static void env_dataflash_load(void)
{
ulong crc, new = 0;
unsigned off;
#error No support for redundant environment on dataflash yet!
#endif
-int saveenv(void)
+static int env_dataflash_save(void)
{
env_t env_new;
int ret;
* We are still running from ROM, so data use is limited.
* Use a (moderately small) buffer on the stack
*/
-int env_init(void)
+int env_dataflash_init(void)
{
/* use default */
gd->env_addr = (ulong)&default_environment[0];
U_BOOT_ENV_LOCATION(dataflash) = {
.location = ENVL_DATAFLASH,
- .get_char = env_get_char_spec,
- .load = env_relocate_spec,
- .save = env_save_ptr(saveenv),
- .init = env_init,
+ .get_char = env_dataflash_get_char,
+ .load = env_dataflash_load,
+ .save = env_save_ptr(env_dataflash_save),
+ .init = env_dataflash_init,
};
return rcode;
}
-uchar env_get_char_spec(int index)
+static uchar env_eeprom_get_char(int index)
{
uchar c;
unsigned int off = CONFIG_ENV_OFFSET;
return c;
}
-void env_relocate_spec(void)
+static void env_eeprom_load(void)
{
char buf_env[CONFIG_ENV_SIZE];
unsigned int off = CONFIG_ENV_OFFSET;
env_import(buf_env, 1);
}
-int saveenv(void)
+static int env_eeprom_save(void)
{
env_t env_new;
int rc;
* We are still running from ROM, so data use is limited.
* Use a (moderately small) buffer on the stack
*/
-int env_init(void)
+static int env_eeprom_init(void)
{
gd->env_addr = (ulong)&default_environment[0];
gd->env_valid = ENV_VALID;
U_BOOT_ENV_LOCATION(eeprom) = {
.location = ENVL_EEPROM,
- .get_char = env_get_char_spec,
- .load = env_relocate_spec,
- .save = env_save_ptr(saveenv),
- .init = env_init,
+ .get_char = env_eeprom_get_char,
+ .load = env_eeprom_load,
+ .save = env_save_ptr(env_eeprom_save),
+ .init = env_eeprom_init,
};
return 0;
}
+
+unsigned char env_get_char_spec(int index)
+{
+ return *(uchar *)(gd->env_addr + index);
+}
+
+void env_relocate_spec(void)
+{
+ env_load();
+}
+
+int saveenv(void)
+{
+ return env_save();
+}
+
+int env_init(void)
+{
+ return env_init_new();
+}
DECLARE_GLOBAL_DATA_PTR;
-int env_init(void)
+static int env_ext4_init(void)
{
/* use default */
gd->env_addr = (ulong)&default_environment[0];
}
#ifdef CONFIG_CMD_SAVEENV
-int saveenv(void)
+static int env_ext4_save(void)
{
env_t env_new;
struct blk_desc *dev_desc = NULL;
}
#endif /* CONFIG_CMD_SAVEENV */
-void env_relocate_spec(void)
+static void env_ext4_load(void)
{
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
struct blk_desc *dev_desc = NULL;
U_BOOT_ENV_LOCATION(ext4) = {
.location = ENVL_EXT4,
- .get_char = env_get_char_spec,
- .load = env_relocate_spec,
- .save = env_save_ptr(saveenv),
- .init = env_init,
+ .load = env_ext4_load,
+ .save = env_save_ptr(env_ext4_save),
+ .init = env_ext4_init,
};
DECLARE_GLOBAL_DATA_PTR;
-int env_init(void)
+static int env_fat_init(void)
{
/* use default */
gd->env_addr = (ulong)&default_environment[0];
}
#ifdef CMD_SAVEENV
-int saveenv(void)
+static int env_fat_save(void)
{
env_t env_new;
struct blk_desc *dev_desc = NULL;
#endif /* CMD_SAVEENV */
#ifdef LOADENV
-void env_relocate_spec(void)
+static void env_fat_load(void)
{
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
struct blk_desc *dev_desc = NULL;
U_BOOT_ENV_LOCATION(fat) = {
.location = ENVL_FAT,
- .get_char = env_get_char_spec,
#ifdef LOADENV
- .load = env_relocate_spec,
+ .load = env_fat_load,
#endif
#ifdef CMD_SAVEENV
- .save = env_save_ptr(saveenv),
+ .save = env_save_ptr(env_fat_save),
#endif
- .init = env_init,
+ .init = env_fat_init,
};
#ifdef ENV_IS_EMBEDDED
env_t *env_ptr = &environment;
-static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
+static __maybe_unused env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
#else /* ! ENV_IS_EMBEDDED */
env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
-static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
+static __maybe_unused env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
#endif /* ENV_IS_EMBEDDED */
-#if defined(CMD_SAVEENV) || defined(CONFIG_ENV_ADDR_REDUND)
/* CONFIG_ENV_ADDR is supposed to be on sector boundary */
-static ulong end_addr = CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1;
-#endif
+static ulong __maybe_unused end_addr =
+ CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1;
#ifdef CONFIG_ENV_ADDR_REDUND
-static env_t *flash_addr_new = (env_t *)CONFIG_ENV_ADDR_REDUND;
+
+static env_t __maybe_unused *flash_addr_new = (env_t *)CONFIG_ENV_ADDR_REDUND;
/* CONFIG_ENV_ADDR_REDUND is supposed to be on sector boundary */
-static ulong end_addr_new = CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1;
+static ulong __maybe_unused end_addr_new =
+ CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1;
#endif /* CONFIG_ENV_ADDR_REDUND */
-
#ifdef CONFIG_ENV_ADDR_REDUND
#ifdef INITENV
-int env_init(void)
+static int env_flash_init(void)
{
int crc1_ok = 0, crc2_ok = 0;
#endif
#ifdef CMD_SAVEENV
-int saveenv(void)
+static int env_flash_save(void)
{
env_t env_new;
char *saved_data = NULL;
#else /* ! CONFIG_ENV_ADDR_REDUND */
#ifdef INITENV
-int env_init(void)
+static int env_flash_init(void)
{
if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
gd->env_addr = (ulong)&(env_ptr->data);
#endif
#ifdef CMD_SAVEENV
-int saveenv(void)
+static int env_flash_save(void)
{
env_t env_new;
int rc = 1;
#endif /* CONFIG_ENV_ADDR_REDUND */
-void env_relocate_spec(void)
+#ifdef LOADENV
+static void env_flash_load(void)
{
#ifdef CONFIG_ENV_ADDR_REDUND
if (gd->env_addr != (ulong)&(flash_addr->data)) {
env_import((char *)flash_addr, 1);
}
+#endif /* LOADENV */
U_BOOT_ENV_LOCATION(flash) = {
.location = ENVL_FLASH,
#ifdef LOADENV
- .load = env_relocate_spec,
+ .load = env_flash_load,
#endif
#ifdef CMD_SAVEENV
- .save = env_save_ptr(saveenv),
+ .save = env_save_ptr(env_flash_save),
#endif
#ifdef INITENV
- .init = env_init,
+ .init = env_flash_init,
#endif
};
return CONFIG_SYS_MMC_ENV_DEV;
}
-int env_init(void)
+static int env_mmc_init(void)
{
/* use default */
gd->env_addr = (ulong)&default_environment[0];
#endif
}
-#ifdef CONFIG_CMD_SAVEENV
+#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_SPL_BUILD)
static inline int write_env(struct mmc *mmc, unsigned long size,
unsigned long offset, const void *buffer)
{
return (n == blk_cnt) ? 0 : -1;
}
-int saveenv(void)
+static int env_mmc_save(void)
{
ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
int dev = mmc_get_env_dev();
fini_mmc_for_env(mmc);
return ret;
}
-#endif /* CONFIG_CMD_SAVEENV */
+#endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */
static inline int read_env(struct mmc *mmc, unsigned long size,
unsigned long offset, const void *buffer)
}
#ifdef CONFIG_ENV_OFFSET_REDUND
-void env_relocate_spec(void)
+static void env_mmc_load(void)
{
#if !defined(ENV_IS_EMBEDDED)
struct mmc *mmc;
#endif
}
#else /* ! CONFIG_ENV_OFFSET_REDUND */
-void env_relocate_spec(void)
+static void env_mmc_load(void)
{
#if !defined(ENV_IS_EMBEDDED)
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
U_BOOT_ENV_LOCATION(mmc) = {
.location = ENVL_MMC,
- .get_char = env_get_char_spec,
- .load = env_relocate_spec,
+ .load = env_mmc_load,
#ifndef CONFIG_SPL_BUILD
- .save = env_save_ptr(saveenv),
+ .save = env_save_ptr(env_mmc_save),
#endif
- .init = env_init,
+ .init = env_mmc_init,
};
* This way the SPL loads not only the U-Boot image from NAND but
* also the environment.
*/
-int env_init(void)
+static int env_nand_init(void)
{
#if defined(ENV_IS_EMBEDDED) || defined(CONFIG_NAND_ENV_DST)
int crc1_ok = 0, crc2_ok = 0;
return ret;
}
-int saveenv(void)
+static int env_nand_save(void)
{
int ret = 0;
ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
#endif
#ifdef CONFIG_ENV_OFFSET_REDUND
-void env_relocate_spec(void)
+static void env_nand_load(void)
{
#if !defined(ENV_IS_EMBEDDED)
int read1_fail = 0, read2_fail = 0;
* device i.e., nand_dev_desc + 0. This is also the behaviour using
* the new NAND code.
*/
-void env_relocate_spec(void)
+static void env_nand_load(void)
{
#if !defined(ENV_IS_EMBEDDED)
int ret;
U_BOOT_ENV_LOCATION(nand) = {
.location = ENVL_NAND,
- .load = env_relocate_spec,
+ .load = env_nand_load,
#if defined(CMD_SAVEENV)
- .save = env_save_ptr(saveenv),
+ .save = env_save_ptr(env_nand_save),
#endif
- .init = env_init,
+ .init = env_nand_init,
};
env_t *env_ptr;
-void env_relocate_spec(void)
+static void env_nowhere_load(void)
{
}
*
* We are still running from ROM, so data use is limited
*/
-int env_init(void)
+static int env_nowhere_init(void)
{
gd->env_addr = (ulong)&default_environment[0];
gd->env_valid = 0;
U_BOOT_ENV_LOCATION(nowhere) = {
.location = ENVL_NOWHERE,
- .load = env_relocate_spec,
- .init = env_init,
+ .load = env_nowhere_load,
+ .init = env_nowhere_init,
};
char *env_name_spec = "NVRAM";
#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
-uchar env_get_char_spec(int index)
+static uchar env_nvram_get_char(int index)
{
uchar c;
}
#endif
-void env_relocate_spec(void)
+static void env_nvram_load(void)
{
char buf[CONFIG_ENV_SIZE];
env_import(buf, 1);
}
-int saveenv(void)
+static int env_nvram_save(void)
{
env_t env_new;
int rcode = 0;
*
* We are still running from ROM, so data use is limited
*/
-int env_init(void)
+static int env_nvram_init(void)
{
#if defined(CONFIG_SYS_NVRAM_ACCESS_ROUTINE)
ulong crc;
U_BOOT_ENV_LOCATION(nvram) = {
.location = ENVL_NVRAM,
#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
- .get_char = env_get_char_spec,
+ .get_char = env_nvram_get_char,
#endif
- .load = env_relocate_spec,
- .save = env_save_ptr(saveenv),
- .init = env_init,
+ .load = env_nvram_load,
+ .save = env_save_ptr(env_nvram_save),
+ .init = env_nvram_init,
};
DECLARE_GLOBAL_DATA_PTR;
-void env_relocate_spec(void)
+static void env_onenand_load(void)
{
struct mtd_info *mtd = &onenand_mtd;
#ifdef CONFIG_ENV_ADDR_FLEX
gd->env_valid = ENV_VALID;
}
-int saveenv(void)
+static int env_onenand_save(void)
{
env_t env_new;
int ret;
return 0;
}
-int env_init(void)
+static int env_onenand_init(void)
{
/* use default */
gd->env_addr = (ulong)&default_environment[0];
U_BOOT_ENV_LOCATION(onenand) = {
.location = ENVL_ONENAND,
- .get_char = env_get_char_spec,
- .load = env_relocate_spec,
- .save = env_save_ptr(saveenv),
- .init = env_init,
+ .load = env_onenand_load,
+ .save = env_save_ptr(env_onenand_save),
+ .init = env_onenand_init,
};
#define CONFIG_ENV_OFFSET 0
#endif
-int env_init(void)
+static int env_remote_init(void)
{
if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
gd->env_addr = (ulong)&(env_ptr->data);
}
#ifdef CONFIG_CMD_SAVEENV
-int saveenv(void)
+static int env_remote_save(void)
{
#ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
printf("Can not support the 'saveenv' when boot from SRIO or PCIE!\n");
}
#endif /* CONFIG_CMD_SAVEENV */
-void env_relocate_spec(void)
+static void env_remote_load(void)
{
#ifndef ENV_IS_EMBEDDED
env_import((char *)env_ptr, 1);
U_BOOT_ENV_LOCATION(remote) = {
.location = ENVL_REMOTE,
- .get_char = env_get_char_spec,
- .load = env_relocate_spec,
- .save = env_save_ptr(saveenv),
- .init = env_init,
+ .load = env_remote_load,
+ .save = env_save_ptr(env_remote_save),
+ .init = env_remote_init,
};
return CONFIG_SYS_SATA_ENV_DEV;
}
-int env_init(void)
+static int env_sata_init(void)
{
/* use default */
gd->env_addr = (ulong)&default_environment[0];
return (n == blk_cnt) ? 0 : -1;
}
-int saveenv(void)
+static int env_sata_save(void)
{
ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
struct blk_desc *sata = NULL;
return (n == blk_cnt) ? 0 : -1;
}
-void env_relocate_spec(void)
+static void env_sata_load(void)
{
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
struct blk_desc *sata = NULL;
U_BOOT_ENV_LOCATION(sata) = {
.location = ENVL_ESATA,
- .get_char = env_get_char_spec,
- .load = env_relocate_spec,
- .save = env_save_ptr(saveenv),
- .init = env_init,
+ .load = env_sata_load,
+ .save = env_save_ptr(env_sata_save),
+ .init = env_sata_init,
};
#if defined(CONFIG_ENV_OFFSET_REDUND)
#ifdef CMD_SAVEENV
-int saveenv(void)
+static int env_sf_save(void)
{
env_t env_new;
char *saved_buffer = NULL, flag = OBSOLETE_FLAG;
}
#endif /* CMD_SAVEENV */
-void env_relocate_spec(void)
+static void env_sf_load(void)
{
int ret;
int crc1_ok = 0, crc2_ok = 0;
}
#else
#ifdef CMD_SAVEENV
-int saveenv(void)
+static int env_sf_save(void)
{
u32 saved_size, saved_offset, sector;
char *saved_buffer = NULL;
}
#endif /* CMD_SAVEENV */
-void env_relocate_spec(void)
+static void env_sf_load(void)
{
int ret;
char *buf = NULL;
}
#endif
-int env_init(void)
+static int env_sf_init(void)
{
/* SPI flash isn't usable before relocation */
gd->env_addr = (ulong)&default_environment[0];
U_BOOT_ENV_LOCATION(sf) = {
.location = ENVL_SPI_FLASH,
- .get_char = env_get_char_spec,
- .load = env_relocate_spec,
+ .load = env_sf_load,
#ifdef CMD_SAVEENV
- .save = env_save_ptr(saveenv),
+ .save = env_save_ptr(env_sf_save),
#endif
- .init = env_init,
+ .init = env_sf_init,
};
DECLARE_GLOBAL_DATA_PTR;
-int env_init(void)
+static int env_ubi_init(void)
{
/* use default */
gd->env_addr = (ulong)&default_environment[0];
#ifdef CONFIG_CMD_SAVEENV
#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
-int saveenv(void)
+static int env_ubi_save(void)
{
ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
int ret;
return 0;
}
#else /* ! CONFIG_SYS_REDUNDAND_ENVIRONMENT */
-int saveenv(void)
+static int env_ubi_save(void)
{
ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
int ret;
#endif /* CONFIG_CMD_SAVEENV */
#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
-void env_relocate_spec(void)
+static void env_ubi_load(void)
{
ALLOC_CACHE_ALIGN_BUFFER(char, env1_buf, CONFIG_ENV_SIZE);
ALLOC_CACHE_ALIGN_BUFFER(char, env2_buf, CONFIG_ENV_SIZE);
env_import_redund((char *)tmp_env1, (char *)tmp_env2);
}
#else /* ! CONFIG_SYS_REDUNDAND_ENVIRONMENT */
-void env_relocate_spec(void)
+static void env_ubi_load(void)
{
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
U_BOOT_ENV_LOCATION(ubi) = {
.location = ENVL_UBI,
- .get_char = env_get_char_spec,
- .load = env_relocate_spec,
- .save = env_save_ptr(saveenv),
- .init = env_init,
+ .load = env_ubi_load,
+ .save = env_save_ptr(env_ubi_save),
+ .init = env_ubi_init,
};