4 #include "stddef.h" /* for NULL */
5 #include <gpxe/tables.h>
8 * In order to avoid having objects dragged in just because main()
9 * calls their initialisation function, we allow each object to
10 * specify that it has a function that must be called to initialise
11 * that object. The function call_init_fns() will call all the
12 * included objects' initialisation functions.
14 * Objects that require initialisation should include init.h and
15 * register the initialisation function using INIT_FN().
17 * Objects may register up to three functions: init, reset and exit.
18 * init gets called only once, at the point that Etherboot is
19 * initialised (before the call to main()). reset gets called between
20 * each boot attempt. exit gets called only once, just before the
21 * loaded OS starts up (or just before Etherboot exits, if it exits,
22 * or when the PXE NBP calls UNDI_SHUTDOWN, if it's a PXE NBP).
25 * INIT_FN ( init_order, init_function, reset_function, exit_function );
26 * where init_order is an ordering taken from the list below. Any
27 * function may be left as NULL.
30 /* An entry in the initialisation function table */
33 void ( *init ) ( void );
34 void ( *reset ) ( void );
35 void ( *exit ) ( void );
38 /* Use double digits to avoid problems with "10" < "9" on alphabetic sort */
40 #define INIT_CONSOLE 02
42 #define INIT_TIMERS 04
43 #define INIT_PCIBIOS 05
44 #define INIT_MEMSIZES 06
45 #define INIT_RELOCATE 07
46 #define INIT_LOADBUF 08
47 #define INIT_PCMCIA 09
51 /* Macro for creating an initialisation function table entry */
52 #define INIT_FN( init_order, init_func, reset_func, exit_func ) \
53 struct init_fn PREFIX_OBJECT(init_fn__) \
54 __table ( init_fn, init_order ) = { \
56 .reset = reset_func, \
60 /* Function prototypes */
62 void call_init_fns ( void );
63 void call_reset_fns ( void );
64 void call_exit_fns ( void );