remote.c 1.2 KB

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