2018-05-07 05:58:06 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2013-03-05 22:39:40 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 The Chromium OS Authors.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <initcall.h>
|
2015-07-31 23:31:38 +08:00
|
|
|
#include <efi.h>
|
2013-03-05 22:39:40 +08:00
|
|
|
|
2014-05-20 20:01:43 +08:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
int initcall_run_list(const init_fnc_t init_sequence[])
|
2013-03-05 22:39:40 +08:00
|
|
|
{
|
2014-05-20 20:01:43 +08:00
|
|
|
const init_fnc_t *init_fnc_ptr;
|
2013-03-05 22:39:40 +08:00
|
|
|
|
|
|
|
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
|
2014-05-20 20:01:43 +08:00
|
|
|
unsigned long reloc_ofs = 0;
|
2014-10-02 09:57:22 +08:00
|
|
|
int ret;
|
2014-05-20 20:01:43 +08:00
|
|
|
|
|
|
|
if (gd->flags & GD_FLG_RELOC)
|
|
|
|
reloc_ofs = gd->reloc_off;
|
2015-07-31 23:31:38 +08:00
|
|
|
#ifdef CONFIG_EFI_APP
|
|
|
|
reloc_ofs = (unsigned long)image_base;
|
|
|
|
#endif
|
2014-12-28 06:35:57 +08:00
|
|
|
debug("initcall: %p", (char *)*init_fnc_ptr - reloc_ofs);
|
|
|
|
if (gd->flags & GD_FLG_RELOC)
|
|
|
|
debug(" (relocated to %p)\n", (char *)*init_fnc_ptr);
|
|
|
|
else
|
|
|
|
debug("\n");
|
2014-10-02 09:57:22 +08:00
|
|
|
ret = (*init_fnc_ptr)();
|
|
|
|
if (ret) {
|
|
|
|
printf("initcall sequence %p failed at call %p (err=%d)\n",
|
2014-05-20 20:01:43 +08:00
|
|
|
init_sequence,
|
2014-10-02 09:57:22 +08:00
|
|
|
(char *)*init_fnc_ptr - reloc_ofs, ret);
|
2013-03-05 22:39:40 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|