initcall.c 705 B

1234567891011121314151617181920212223242526272829303132
  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\n", (char *)*init_fnc_ptr - reloc_ofs);
  18. ret = (*init_fnc_ptr)();
  19. if (ret) {
  20. printf("initcall sequence %p failed at call %p (err=%d)\n",
  21. init_sequence,
  22. (char *)*init_fnc_ptr - reloc_ofs, ret);
  23. return -1;
  24. }
  25. }
  26. return 0;
  27. }