remote.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 void env_remote_load(void)
  41. {
  42. #ifndef ENV_IS_EMBEDDED
  43. env_import((char *)env_ptr, 1);
  44. #endif
  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. };