Blame view

lib/initcall.c 902 Bytes
c8a311d9d   Simon Glass   Introduce a basic...
1
2
3
  /*
   * Copyright (c) 2013 The Chromium OS Authors.
   *
1a4596601   Wolfgang Denk   Add GPL-2.0+ SPDX...
4
   * SPDX-License-Identifier:	GPL-2.0+
c8a311d9d   Simon Glass   Introduce a basic...
5
6
7
8
   */
  
  #include <common.h>
  #include <initcall.h>
f134ed7df   Simon Glass   efi: Display the ...
9
  #include <efi.h>
c8a311d9d   Simon Glass   Introduce a basic...
10

2f43f8546   Simon Glass   initcall: Improve...
11
12
13
  DECLARE_GLOBAL_DATA_PTR;
  
  int initcall_run_list(const init_fnc_t init_sequence[])
c8a311d9d   Simon Glass   Introduce a basic...
14
  {
2f43f8546   Simon Glass   initcall: Improve...
15
  	const init_fnc_t *init_fnc_ptr;
c8a311d9d   Simon Glass   Introduce a basic...
16
17
  
  	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
2f43f8546   Simon Glass   initcall: Improve...
18
  		unsigned long reloc_ofs = 0;
aacc6c5d1   Simon Glass   initcall: Display...
19
  		int ret;
2f43f8546   Simon Glass   initcall: Improve...
20
21
22
  
  		if (gd->flags & GD_FLG_RELOC)
  			reloc_ofs = gd->reloc_off;
f134ed7df   Simon Glass   efi: Display the ...
23
24
25
  #ifdef CONFIG_EFI_APP
  		reloc_ofs = (unsigned long)image_base;
  #endif
e38d1cb28   Alexey Brodkin   initcall: add exp...
26
27
28
29
30
31
32
  		debug("initcall: %p", (char *)*init_fnc_ptr - reloc_ofs);
  		if (gd->flags & GD_FLG_RELOC)
  			debug(" (relocated to %p)
  ", (char *)*init_fnc_ptr);
  		else
  			debug("
  ");
aacc6c5d1   Simon Glass   initcall: Display...
33
34
35
36
  		ret = (*init_fnc_ptr)();
  		if (ret) {
  			printf("initcall sequence %p failed at call %p (err=%d)
  ",
2f43f8546   Simon Glass   initcall: Improve...
37
  			       init_sequence,
aacc6c5d1   Simon Glass   initcall: Display...
38
  			       (char *)*init_fnc_ptr - reloc_ofs, ret);
c8a311d9d   Simon Glass   Introduce a basic...
39
40
41
42
43
  			return -1;
  		}
  	}
  	return 0;
  }