nowhere.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_valid = ENV_INVALID;
  23. return 0;
  24. }
  25. static int env_nowhere_load(void)
  26. {
  27. /*
  28. * For SPL, setting env_valid = ENV_INVALID is enough, as env_get()
  29. * searches default_environment array in that case.
  30. * For U-Boot proper, import the default environment to allow reload.
  31. */
  32. if (!IS_ENABLED(CONFIG_SPL_BUILD))
  33. env_set_default(NULL, 0);
  34. gd->env_valid = ENV_INVALID;
  35. return 0;
  36. }
  37. U_BOOT_ENV_LOCATION(nowhere) = {
  38. .location = ENVL_NOWHERE,
  39. .init = env_nowhere_init,
  40. .load = env_nowhere_load,
  41. ENV_NAME("nowhere")
  42. };