1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2011 The Chromium OS Authors.
9 typedef int (*init_fnc_t)(void);
15 #include <asm/global_data.h>
18 * To enable debugging. add #define DEBUG at the top of the including file.
20 * To find a symbol, use grep on u-boot.map
22 static inline int initcall_run_list(const init_fnc_t init_sequence[])
24 const init_fnc_t *init_fnc_ptr;
26 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
27 unsigned long reloc_ofs = 0;
31 * Sandbox is relocated by the OS, so symbols always appear at
32 * the relocated address.
34 if (IS_ENABLED(CONFIG_SANDBOX) || (gd->flags & GD_FLG_RELOC))
35 reloc_ofs = gd->reloc_off;
37 reloc_ofs = (unsigned long)image_base;
40 debug("initcall: %p (relocated to %p)\n",
41 (char *)*init_fnc_ptr - reloc_ofs,
42 (char *)*init_fnc_ptr);
44 debug("initcall: %p\n", (char *)*init_fnc_ptr - reloc_ofs);
46 ret = (*init_fnc_ptr)();
48 printf("initcall sequence %p failed at call %p (err=%d)\n",
50 (char *)*init_fnc_ptr - reloc_ofs, ret);