initcall.c 902 B

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