return 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,
+};
gd->env_valid = ENV_VALID;
return 0;
}
+
+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,
+};
err_env_relocate:
set_default_env(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,
+};
#include <fat.h>
#include <mmc.h>
+#ifdef CONFIG_SPL_BUILD
+/* TODO(sjg@chromium.org): Figure out why this is needed */
+# if !defined(CONFIG_TARGET_AM335X_EVM) || defined(CONFIG_SPL_OS_BOOT)
+# define LOADENV
+# endif
+#else
+# define LOADENV
+# if defined(CONFIG_CMD_SAVEENV)
+# define CMD_SAVEENV
+# endif
+#endif
+
char *env_name_spec = "FAT";
env_t *env_ptr;
return 0;
}
-#ifdef CONFIG_CMD_SAVEENV
+#ifdef CMD_SAVEENV
int saveenv(void)
{
env_t env_new;
puts("done\n");
return 0;
}
-#endif /* CONFIG_CMD_SAVEENV */
+#endif /* CMD_SAVEENV */
+#ifdef LOADENV
void env_relocate_spec(void)
{
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
err_env_relocate:
set_default_env(NULL);
}
+#endif /* LOADENV */
+
+U_BOOT_ENV_LOCATION(fat) = {
+ .location = ENVL_FAT,
+ .get_char = env_get_char_spec,
+#ifdef LOADENV
+ .load = env_relocate_spec,
+#endif
+#ifdef CMD_SAVEENV
+ .save = env_save_ptr(saveenv),
+#endif
+ .init = env_init,
+};
DECLARE_GLOBAL_DATA_PTR;
-#if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_FLASH)
-#define CMD_SAVEENV
-#elif defined(CONFIG_ENV_ADDR_REDUND)
-#error CONFIG_ENV_ADDR_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_FLASH
+#ifndef CONFIG_SPL_BUILD
+# if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_FLASH)
+# define CMD_SAVEENV
+# elif defined(CONFIG_ENV_ADDR_REDUND)
+# error CONFIG_ENV_ADDR_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_FLASH
+# endif
#endif
#if defined(CONFIG_ENV_SIZE_REDUND) && \
#error CONFIG_ENV_SIZE_REDUND should not be less then CONFIG_ENV_SIZE
#endif
+/* TODO(sjg@chromium.org): Figure out all these special cases */
+#if (!defined(CONFIG_MICROBLAZE) && !defined(CONFIG_ARCH_ZYNQ) && \
+ !defined(CONFIG_TARGET_MCCMON6) && !defined(CONFIG_TARGET_X600) && \
+ !defined(CONFIG_TARGET_EDMINIV2)) || \
+ !defined(CONFIG_SPL_BUILD)
+#define LOADENV
+#endif
+
+#if !defined(CONFIG_TARGET_X600) || !defined(CONFIG_SPL_BUILD)
+#define INITENV
+#endif
+
char *env_name_spec = "Flash";
#ifdef ENV_IS_EMBEDDED
#ifdef CONFIG_ENV_ADDR_REDUND
+#ifdef INITENV
int env_init(void)
{
int crc1_ok = 0, crc2_ok = 0;
return 0;
}
+#endif
#ifdef CMD_SAVEENV
int saveenv(void)
#else /* ! CONFIG_ENV_ADDR_REDUND */
+#ifdef INITENV
int env_init(void)
{
if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
gd->env_valid = 0;
return 0;
}
+#endif
#ifdef CMD_SAVEENV
int saveenv(void)
env_import((char *)flash_addr, 1);
}
+
+U_BOOT_ENV_LOCATION(flash) = {
+ .location = ENVL_FLASH,
+#ifdef LOADENV
+ .load = env_relocate_spec,
+#endif
+#ifdef CMD_SAVEENV
+ .save = env_save_ptr(saveenv),
+#endif
+#ifdef INITENV
+ .init = env_init,
+#endif
+};
#endif
}
#endif /* CONFIG_ENV_OFFSET_REDUND */
+
+U_BOOT_ENV_LOCATION(mmc) = {
+ .location = ENVL_MMC,
+ .get_char = env_get_char_spec,
+ .load = env_relocate_spec,
+#ifndef CONFIG_SPL_BUILD
+ .save = env_save_ptr(saveenv),
+#endif
+ .init = env_init,
+};
#include <search.h>
#include <errno.h>
-#if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_NAND)
+#if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_NAND) && \
+ !defined(CONFIG_SPL_BUILD)
#define CMD_SAVEENV
#elif defined(CONFIG_ENV_OFFSET_REDUND)
#error CONFIG_ENV_OFFSET_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_NAND
#endif /* ! ENV_IS_EMBEDDED */
}
#endif /* CONFIG_ENV_OFFSET_REDUND */
+
+U_BOOT_ENV_LOCATION(nand) = {
+ .location = ENVL_NAND,
+ .load = env_relocate_spec,
+#if defined(CMD_SAVEENV)
+ .save = env_save_ptr(saveenv),
+#endif
+ .init = env_init,
+};
return 0;
}
+
+U_BOOT_ENV_LOCATION(nowhere) = {
+ .location = ENVL_NOWHERE,
+ .load = env_relocate_spec,
+ .init = env_init,
+};
return 0;
}
+
+U_BOOT_ENV_LOCATION(nvram) = {
+ .location = ENVL_NVRAM,
+#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
+ .get_char = env_get_char_spec,
+#endif
+ .load = env_relocate_spec,
+ .save = env_save_ptr(saveenv),
+ .init = env_init,
+};
return 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,
+};
env_import((char *)env_ptr, 1);
#endif
}
+
+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,
+};
env_import(buf, 1);
}
+
+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,
+};
# define CONFIG_ENV_SPI_MODE CONFIG_SF_DEFAULT_MODE
#endif
+#ifndef CONFIG_SPL_BUILD
+#define CMD_SAVEENV
+#endif
+
#ifdef CONFIG_ENV_OFFSET_REDUND
+#ifdef CMD_SAVEENV
static ulong env_offset = CONFIG_ENV_OFFSET;
static ulong env_new_offset = CONFIG_ENV_OFFSET_REDUND;
+#endif
#define ACTIVE_FLAG 1
#define OBSOLETE_FLAG 0
}
#if defined(CONFIG_ENV_OFFSET_REDUND)
+#ifdef CMD_SAVEENV
int saveenv(void)
{
env_t env_new;
return ret;
}
+#endif /* CMD_SAVEENV */
void env_relocate_spec(void)
{
free(tmp_env2);
}
#else
+#ifdef CMD_SAVEENV
int saveenv(void)
{
u32 saved_size, saved_offset, sector;
return ret;
}
+#endif /* CMD_SAVEENV */
void env_relocate_spec(void)
{
return 0;
}
+
+U_BOOT_ENV_LOCATION(sf) = {
+ .location = ENVL_SPI_FLASH,
+ .get_char = env_get_char_spec,
+ .load = env_relocate_spec,
+#ifdef CMD_SAVEENV
+ .save = env_save_ptr(saveenv),
+#endif
+ .init = env_init,
+};
env_import(buf, 1);
}
#endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */
+
+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,
+};
ENV_REDUND, /* Redundant environment is valid */
};
+enum env_location {
+ ENVL_DATAFLASH,
+ ENVL_EEPROM,
+ ENVL_EXT4,
+ ENVL_FAT,
+ ENVL_FLASH,
+ ENVL_MMC,
+ ENVL_NAND,
+ ENVL_NVRAM,
+ ENVL_ONENAND,
+ ENVL_REMOTE,
+ ENVL_SPI_FLASH,
+ ENVL_UBI,
+ ENVL_NOWHERE,
+
+ ENVL_COUNT,
+ ENVL_UNKNOWN,
+};
+
+struct env_driver {
+ enum env_location location;
+
+ /**
+ * get_char() - Read a character from the environment
+ *
+ * This method is optional. If not provided, a default implementation
+ * will read from gd->env_addr.
+ *
+ * @index: Index of character to read (0=first)
+ * @return character read
+ */
+ unsigned char (*get_char)(int index);
+
+ /**
+ * load() - Load the environment from storage
+ *
+ * This method is optional. If not provided, no environment will be
+ * loaded.
+ */
+ void (*load)(void);
+
+ /**
+ * save() - Save the environment to storage
+ *
+ * This method is required for 'saveenv' to work.
+ *
+ * @return 0 if OK, -ve on error
+ */
+ int (*save)(void);
+
+ /**
+ * init() - Set up the initial pre-relocation environment
+ *
+ * This method is optional.
+ *
+ * @return 0 if OK, -ve on error
+ */
+ int (*init)(void);
+};
+
+/* Declare a new environment location driver */
+#define U_BOOT_ENV_LOCATION(__name) \
+ ll_entry_declare(struct env_driver, __name, env_driver)
+
+#ifdef CONFIG_CMD_SAVEENV
+#define env_save_ptr(x) x
+#else
+#define env_save_ptr(x) NULL
+#endif
+
extern struct hsearch_data env_htab;
/* Function that returns a character from the environment */