]> git.ipfire.org Git - thirdparty/u-boot.git/blame - include/initcall.h
efi_loader: device path for virtio block devices
[thirdparty/u-boot.git] / include / initcall.h
CommitLineData
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
9typedef int (*init_fnc_t)(void);
10
f7ae49fc 11#include <log.h>
e6f6f9e6
SG
12#ifdef CONFIG_EFI_APP
13#include <efi.h>
14#endif
15
315f60d7
SG
16/*
17 * To enable debugging. add #define DEBUG at the top of the including file.
18 *
19 * To find a symbol, use grep on u-boot.map
20 */
47870afa
AG
21static inline int initcall_run_list(const init_fnc_t init_sequence[])
22{
23 const init_fnc_t *init_fnc_ptr;
24
25 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
26 unsigned long reloc_ofs = 0;
27 int ret;
28
001d1885
SG
29 /*
30 * Sandbox is relocated by the OS, so symbols always appear at
31 * the relocated address.
32 */
33 if (IS_ENABLED(CONFIG_SANDBOX) || (gd->flags & GD_FLG_RELOC))
47870afa
AG
34 reloc_ofs = gd->reloc_off;
35#ifdef CONFIG_EFI_APP
36 reloc_ofs = (unsigned long)image_base;
37#endif
001d1885 38 if (reloc_ofs)
fa840f13
OP
39 debug("initcall: %p (relocated to %p)\n",
40 (char *)*init_fnc_ptr - reloc_ofs,
41 (char *)*init_fnc_ptr);
47870afa 42 else
fa840f13
OP
43 debug("initcall: %p\n", (char *)*init_fnc_ptr - reloc_ofs);
44
47870afa
AG
45 ret = (*init_fnc_ptr)();
46 if (ret) {
47 printf("initcall sequence %p failed at call %p (err=%d)\n",
48 init_sequence,
49 (char *)*init_fnc_ptr - reloc_ofs, ret);
50 return -1;
51 }
52 }
53 return 0;
54}
2d986c0f
SG
55
56#endif