nowhere.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 <linux/stddef.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. /*
  16. * Because we only ever have the default environment available we must mark
  17. * it as invalid.
  18. */
  19. static int env_nowhere_init(void)
  20. {
  21. gd->env_addr = (ulong)&default_environment[0];
  22. gd->env_valid = ENV_INVALID;
  23. return 0;
  24. }
  25. static int env_nowhere_load(void)
  26. {
  27. /*
  28. * for SPL, set env_valid = ENV_INVALID is enougth as env_get_char()
  29. * return the default env if env_get is used
  30. * and SPL don't used env_import to reduce its size
  31. * For U-Boot proper, import the default environment to allow reload.
  32. */
  33. if (!IS_ENABLED(CONFIG_SPL_BUILD))
  34. env_set_default(NULL, 0);
  35. gd->env_valid = ENV_INVALID;
  36. return 0;
  37. }
  38. U_BOOT_ENV_LOCATION(nowhere) = {
  39. .location = ENVL_NOWHERE,
  40. .init = env_nowhere_init,
  41. .load = env_nowhere_load,
  42. ENV_NAME("nowhere")
  43. };