env_remote.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * (C) Copyright 2011-2012 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. /* #define DEBUG */
  7. #include <common.h>
  8. #include <command.h>
  9. #include <environment.h>
  10. #include <linux/stddef.h>
  11. char *env_name_spec = "Remote";
  12. #ifdef ENV_IS_EMBEDDED
  13. env_t *env_ptr = &environment;
  14. #else /* ! ENV_IS_EMBEDDED */
  15. env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
  16. #endif /* ENV_IS_EMBEDDED */
  17. DECLARE_GLOBAL_DATA_PTR;
  18. #if !defined(CONFIG_ENV_OFFSET)
  19. #define CONFIG_ENV_OFFSET 0
  20. #endif
  21. int env_init(void)
  22. {
  23. if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
  24. gd->env_addr = (ulong)&(env_ptr->data);
  25. gd->env_valid = 1;
  26. return 0;
  27. }
  28. gd->env_addr = (ulong)default_environment;
  29. gd->env_valid = 0;
  30. return 0;
  31. }
  32. #ifdef CONFIG_CMD_SAVEENV
  33. int saveenv(void)
  34. {
  35. #ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
  36. printf("Can not support the 'saveenv' when boot from SRIO or PCIE!\n");
  37. return 1;
  38. #else
  39. return 0;
  40. #endif
  41. }
  42. #endif /* CONFIG_CMD_SAVEENV */
  43. void env_relocate_spec(void)
  44. {
  45. #ifndef ENV_IS_EMBEDDED
  46. env_import((char *)env_ptr, 1);
  47. #endif
  48. }