remote.c 1.2 KB

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