initcall.c 899 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2013 The Chromium OS Authors.
  4. */
  5. #include <common.h>
  6. #include <initcall.h>
  7. #include <efi.h>
  8. DECLARE_GLOBAL_DATA_PTR;
  9. int initcall_run_list(const init_fnc_t init_sequence[])
  10. {
  11. const init_fnc_t *init_fnc_ptr;
  12. for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  13. unsigned long reloc_ofs = 0;
  14. int ret;
  15. if (gd->flags & GD_FLG_RELOC)
  16. reloc_ofs = gd->reloc_off;
  17. #ifdef CONFIG_EFI_APP
  18. reloc_ofs = (unsigned long)image_base;
  19. #endif
  20. debug("initcall: %p", (char *)*init_fnc_ptr - reloc_ofs);
  21. if (gd->flags & GD_FLG_RELOC)
  22. debug(" (relocated to %p)\n", (char *)*init_fnc_ptr);
  23. else
  24. debug("\n");
  25. ret = (*init_fnc_ptr)();
  26. if (ret) {
  27. printf("initcall sequence %p failed at call %p (err=%d)\n",
  28. init_sequence,
  29. (char *)*init_fnc_ptr - reloc_ofs, ret);
  30. return -1;
  31. }
  32. }
  33. return 0;
  34. }