remote.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #include <u-boot/crc.h>
  11. #ifdef ENV_IS_EMBEDDED
  12. env_t *env_ptr = &environment;
  13. #else /* ! ENV_IS_EMBEDDED */
  14. env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
  15. #endif /* ENV_IS_EMBEDDED */
  16. DECLARE_GLOBAL_DATA_PTR;
  17. static int env_remote_init(void)
  18. {
  19. if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
  20. gd->env_addr = (ulong)&(env_ptr->data);
  21. gd->env_valid = ENV_VALID;
  22. return 0;
  23. }
  24. return -ENOENT;
  25. }
  26. #ifdef CONFIG_CMD_SAVEENV
  27. static int env_remote_save(void)
  28. {
  29. #ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
  30. printf("Can not support the 'saveenv' when boot from SRIO or PCIE!\n");
  31. return 1;
  32. #else
  33. return 0;
  34. #endif
  35. }
  36. #endif /* CONFIG_CMD_SAVEENV */
  37. static int env_remote_load(void)
  38. {
  39. #ifndef ENV_IS_EMBEDDED
  40. return env_import((char *)env_ptr, 1);
  41. #endif
  42. return 0;
  43. }
  44. U_BOOT_ENV_LOCATION(remote) = {
  45. .location = ENVL_REMOTE,
  46. ENV_NAME("Remote")
  47. .load = env_remote_load,
  48. .save = env_save_ptr(env_remote_save),
  49. .init = env_remote_init,
  50. };