]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
c8a311d9 SG |
2 | /* |
3 | * Copyright (c) 2011 The Chromium OS Authors. | |
c8a311d9 SG |
4 | */ |
5 | ||
2d986c0f SG |
6 | #ifndef __INITCALL_H |
7 | #define __INITCALL_H | |
8 | ||
c8a311d9 SG |
9 | typedef int (*init_fnc_t)(void); |
10 | ||
f7ae49fc | 11 | #include <log.h> |
e6f6f9e6 SG |
12 | #ifdef CONFIG_EFI_APP |
13 | #include <efi.h> | |
14 | #endif | |
401d1c4f | 15 | #include <asm/global_data.h> |
e6f6f9e6 | 16 | |
315f60d7 SG |
17 | /* |
18 | * To enable debugging. add #define DEBUG at the top of the including file. | |
19 | * | |
20 | * To find a symbol, use grep on u-boot.map | |
21 | */ | |
47870afa AG |
22 | static inline int initcall_run_list(const init_fnc_t init_sequence[]) |
23 | { | |
24 | const init_fnc_t *init_fnc_ptr; | |
25 | ||
26 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { | |
27 | unsigned long reloc_ofs = 0; | |
28 | int ret; | |
29 | ||
001d1885 SG |
30 | /* |
31 | * Sandbox is relocated by the OS, so symbols always appear at | |
32 | * the relocated address. | |
33 | */ | |
34 | if (IS_ENABLED(CONFIG_SANDBOX) || (gd->flags & GD_FLG_RELOC)) | |
47870afa AG |
35 | reloc_ofs = gd->reloc_off; |
36 | #ifdef CONFIG_EFI_APP | |
37 | reloc_ofs = (unsigned long)image_base; | |
38 | #endif | |
001d1885 | 39 | if (reloc_ofs) |
fa840f13 OP |
40 | debug("initcall: %p (relocated to %p)\n", |
41 | (char *)*init_fnc_ptr - reloc_ofs, | |
42 | (char *)*init_fnc_ptr); | |
47870afa | 43 | else |
fa840f13 OP |
44 | debug("initcall: %p\n", (char *)*init_fnc_ptr - reloc_ofs); |
45 | ||
47870afa AG |
46 | ret = (*init_fnc_ptr)(); |
47 | if (ret) { | |
48 | printf("initcall sequence %p failed at call %p (err=%d)\n", | |
49 | init_sequence, | |
50 | (char *)*init_fnc_ptr - reloc_ofs, ret); | |
51 | return -1; | |
52 | } | |
53 | } | |
54 | return 0; | |
55 | } | |
2d986c0f SG |
56 | |
57 | #endif |