remote.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. static int env_remote_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. static int env_remote_save(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. static void env_remote_load(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. .load = env_remote_load,
  52. .save = env_save_ptr(env_remote_save),
  53. .init = env_remote_init,
  54. };