]> git.ipfire.org Git - thirdparty/u-boot.git/blame - include/initcall.h
usb: kbd: Properly translate up/down arrow keys
[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
47870afa
AG
11#include <common.h>
12#include <initcall.h>
13#include <efi.h>
14
15DECLARE_GLOBAL_DATA_PTR;
16
17static inline int initcall_run_list(const init_fnc_t init_sequence[])
18{
19 const init_fnc_t *init_fnc_ptr;
20
21 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
22 unsigned long reloc_ofs = 0;
23 int ret;
24
25 if (gd->flags & GD_FLG_RELOC)
26 reloc_ofs = gd->reloc_off;
27#ifdef CONFIG_EFI_APP
28 reloc_ofs = (unsigned long)image_base;
29#endif
30 debug("initcall: %p", (char *)*init_fnc_ptr - reloc_ofs);
31 if (gd->flags & GD_FLG_RELOC)
32 debug(" (relocated to %p)\n", (char *)*init_fnc_ptr);
33 else
34 debug("\n");
35 ret = (*init_fnc_ptr)();
36 if (ret) {
37 printf("initcall sequence %p failed at call %p (err=%d)\n",
38 init_sequence,
39 (char *)*init_fnc_ptr - reloc_ofs, ret);
40 return -1;
41 }
42 }
43 return 0;
44}
2d986c0f
SG
45
46#endif