initcall.c 815 B

123456789101112131415161718192021222324252627282930313233343536
  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. 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. debug("initcall: %p", (char *)*init_fnc_ptr - reloc_ofs);
  18. if (gd->flags & GD_FLG_RELOC)
  19. debug(" (relocated to %p)\n", (char *)*init_fnc_ptr);
  20. else
  21. debug("\n");
  22. ret = (*init_fnc_ptr)();
  23. if (ret) {
  24. printf("initcall sequence %p failed at call %p (err=%d)\n",
  25. init_sequence,
  26. (char *)*init_fnc_ptr - reloc_ofs, ret);
  27. return -1;
  28. }
  29. }
  30. return 0;
  31. }