remote.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 = ENV_VALID;
  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. }
  49. U_BOOT_ENV_LOCATION(remote) = {
  50. .location = ENVL_REMOTE,
  51. .get_char = env_get_char_spec,
  52. .load = env_relocate_spec,
  53. .save = env_save_ptr(saveenv),
  54. .init = env_init,
  55. };