initcall.c 667 B

123456789101112131415161718192021222324252627282930
  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. if (gd->flags & GD_FLG_RELOC)
  15. reloc_ofs = gd->reloc_off;
  16. debug("initcall: %p\n", (char *)*init_fnc_ptr - reloc_ofs);
  17. if ((*init_fnc_ptr)()) {
  18. printf("initcall sequence %p failed at call %p\n",
  19. init_sequence,
  20. (char *)*init_fnc_ptr - reloc_ofs);
  21. return -1;
  22. }
  23. }
  24. return 0;
  25. }