remote.c 1.2 KB

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