* Check if CRC is valid and (if yes) import the environment.
* Note that "buf" may or may not be aligned.
*/
-int env_import(const char *buf, int check)
+int env_import(const char *buf, int check, int flags)
{
env_t *ep = (env_t *)buf;
}
}
- if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0, 0,
+ if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', flags, 0,
0, NULL)) {
gd->flags |= GD_FLG_ENV_READY;
return 0;
static unsigned char env_flags;
int env_import_redund(const char *buf1, int buf1_read_fail,
- const char *buf2, int buf2_read_fail)
+ const char *buf2, int buf2_read_fail,
+ int flags)
{
int crc1_ok, crc2_ok;
env_t *ep, *tmp_env1, *tmp_env2;
return -EIO;
} else if (!buf1_read_fail && buf2_read_fail) {
gd->env_valid = ENV_VALID;
- return env_import((char *)tmp_env1, 1);
+ return env_import((char *)tmp_env1, 1, flags);
} else if (buf1_read_fail && !buf2_read_fail) {
gd->env_valid = ENV_REDUND;
- return env_import((char *)tmp_env2, 1);
+ return env_import((char *)tmp_env2, 1, flags);
}
crc1_ok = crc32(0, tmp_env1->data, ENV_SIZE) ==
ep = tmp_env2;
env_flags = ep->flags;
- return env_import((char *)ep, 0);
+ return env_import((char *)ep, 0, flags);
}
#endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */
eeprom_bus_read(CONFIG_SYS_DEF_EEPROM_ADDR,
off, (uchar *)buf_env, CONFIG_ENV_SIZE);
- return env_import(buf_env, 1);
+ return env_import(buf_env, 1, H_EXTERNAL);
}
static int env_eeprom_save(void)
goto err_env_relocate;
}
- err = env_import(buf, 1);
+ err = env_import(buf, 1, H_EXTERNAL);
if (!err)
gd->env_valid = ENV_VALID;
goto err_env_relocate;
}
- return env_import(buf, 1);
+ return env_import(buf, 1, H_EXTERNAL);
err_env_relocate:
env_set_default(NULL, 0);
"reading environment; recovered successfully\n\n");
#endif /* CONFIG_ENV_ADDR_REDUND */
- return env_import((char *)flash_addr, 1);
+ return env_import((char *)flash_addr, 1, H_EXTERNAL);
}
#endif /* LOADENV */
read2_fail = read_env(mmc, CONFIG_ENV_SIZE, offset2, tmp_env2);
ret = env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2,
- read2_fail);
+ read2_fail, H_EXTERNAL);
fini:
fini_mmc_for_env(mmc);
goto fini;
}
- ret = env_import(buf, 1);
+ ret = env_import(buf, 1, H_EXTERNAL);
if (!ret) {
ep = (env_t *)buf;
gd->env_addr = (ulong)&ep->data;
read2_fail = readenv(CONFIG_ENV_OFFSET_REDUND, (u_char *) tmp_env2);
ret = env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2,
- read2_fail);
+ read2_fail, H_EXTERNAL);
done:
free(tmp_env1);
return -EIO;
}
- return env_import(buf, 1);
+ return env_import(buf, 1, H_EXTERNAL);
#endif /* ! ENV_IS_EMBEDDED */
return 0;
#else
memcpy(buf, (void *)CONFIG_ENV_ADDR, CONFIG_ENV_SIZE);
#endif
- return env_import(buf, 1);
+ return env_import(buf, 1, H_EXTERNAL);
}
static int env_nvram_save(void)
mtd->writesize = MAX_ONENAND_PAGESIZE;
#endif /* !ENV_IS_EMBEDDED */
- rc = env_import(buf, 1);
+ rc = env_import(buf, 1, H_EXTERNAL);
if (!rc)
gd->env_valid = ENV_VALID;
static int env_remote_load(void)
{
#ifndef ENV_IS_EMBEDDED
- return env_import((char *)env_ptr, 1);
+ return env_import((char *)env_ptr, 1, H_EXTERNAL);
#endif
return 0;
return -EIO;
}
- return env_import(buf, 1);
+ return env_import(buf, 1, H_EXTERNAL);
}
U_BOOT_ENV_LOCATION(sata) = {
CONFIG_ENV_SIZE, tmp_env2);
ret = env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2,
- read2_fail);
+ read2_fail, H_EXTERNAL);
spi_flash_free(env_flash);
env_flash = NULL;
goto err_read;
}
- ret = env_import(buf, 1);
+ ret = env_import(buf, 1, H_EXTERNAL);
if (!ret)
gd->env_valid = ENV_VALID;
CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME_REDUND);
return env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2,
- read2_fail);
+ read2_fail, H_EXTERNAL);
}
#else /* ! CONFIG_SYS_REDUNDAND_ENVIRONMENT */
static int env_ubi_load(void)
return -EIO;
}
- return env_import(buf, 1);
+ return env_import(buf, 1, H_EXTERNAL);
}
#endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */
* @buf: Buffer containing the environment (struct environemnt_s *)
* @check: non-zero to check the CRC at the start of the environment, 0 to
* ignore it
+ * @flags: Flags controlling matching (H_... - see search.h)
* @return 0 if imported successfully, -ENOMSG if the CRC was bad, -EIO if
* something else went wrong
*/
-int env_import(const char *buf, int check);
+int env_import(const char *buf, int check, int flags);
/**
* env_export() - Export the environment to a buffer
* @buf1_read_fail: 0 if buf1 is valid, non-zero if invalid
* @buf2: Second environment (struct environemnt_s *)
* @buf2_read_fail: 0 if buf2 is valid, non-zero if invalid
+ * @flags: Flags controlling matching (H_... - see search.h)
* @return 0 if OK, -EIO if no environment is valid, -ENOMSG if the CRC was bad
*/
int env_import_redund(const char *buf1, int buf1_read_fail,
- const char *buf2, int buf2_read_fail);
+ const char *buf2, int buf2_read_fail,
+ int flags);
/**
* env_get_default() - Look up a variable from the default environment
#define H_PROGRAMMATIC (1 << 9) /* indicate that an import is from env_set() */
#define H_ORIGIN_FLAGS (H_INTERACTIVE | H_PROGRAMMATIC)
#define H_DEFAULT (1 << 10) /* indicate that an import is default env */
+#define H_EXTERNAL (1 << 11) /* indicate that an import is external env */
#endif /* _SEARCH_H_ */