nowhere.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2000-2010
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. *
  6. * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  7. * Andreas Heppel <aheppel@sysgo.de>
  8. */
  9. #include <common.h>
  10. #include <command.h>
  11. #include <env.h>
  12. #include <env_internal.h>
  13. #include <asm/global_data.h>
  14. #include <linux/stddef.h>
  15. DECLARE_GLOBAL_DATA_PTR;
  16. /*
  17. * Because we only ever have the default environment available we must mark
  18. * it as invalid.
  19. */
  20. static int env_nowhere_init(void)
  21. {
  22. gd->env_addr = (ulong)&default_environment[0];
  23. gd->env_valid = ENV_INVALID;
  24. return 0;
  25. }
  26. static int env_nowhere_load(void)
  27. {
  28. /*
  29. * for SPL, set env_valid = ENV_INVALID is enough as env_get_char()
  30. * return the default env if env_get is used
  31. * and SPL don't used env_import to reduce its size
  32. * For U-Boot proper, import the default environment to allow reload.
  33. */
  34. if (!IS_ENABLED(CONFIG_SPL_BUILD))
  35. env_set_default(NULL, 0);
  36. gd->env_valid = ENV_INVALID;
  37. return 0;
  38. }
  39. U_BOOT_ENV_LOCATION(nowhere) = {
  40. .location = ENVL_NOWHERE,
  41. .init = env_nowhere_init,
  42. .load = env_nowhere_load,
  43. ENV_NAME("nowhere")
  44. };