iPXE
init.h
Go to the documentation of this file.
1 #ifndef _IPXE_INIT_H
2 #define _IPXE_INIT_H
3 
4 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
5 
6 #include <ipxe/tables.h>
7 
8 /**
9  * An initialisation function
10  *
11  * Initialisation functions are called exactly once, as part of the
12  * call to initialise().
13  */
14 struct init_fn {
15  const char *name;
16  void ( * initialise ) ( void );
17 };
18 
19 /** Initialisation function table */
20 #define INIT_FNS __table ( struct init_fn, "init_fns" )
21 
22 /** Declare an initialisation functon */
23 #define __init_fn( init_order ) __table_entry ( INIT_FNS, init_order )
24 
25 /** @defgroup initfn_order Initialisation function ordering
26  * @{
27  */
28 
29 #define INIT_EARLY 01 /**< Early initialisation */
30 #define INIT_CONSOLE 02 /**< Console initialisation */
31 #define INIT_NORMAL 03 /**< Normal initialisation */
32 #define INIT_LATE 04 /**< Late initialisation */
33 
34 /** @} */
35 
36 /**
37  * A startup/shutdown function
38  *
39  * Startup and shutdown functions may be called multiple times, as
40  * part of the calls to startup() and shutdown().
41  */
42 struct startup_fn {
43  const char *name;
44  void ( * startup ) ( void );
45  void ( * shutdown ) ( int booting );
46 };
47 
48 /** Startup/shutdown function table */
49 #define STARTUP_FNS __table ( struct startup_fn, "startup_fns" )
50 
51 /** Declare a startup/shutdown function */
52 #define __startup_fn( startup_order ) \
53  __table_entry ( STARTUP_FNS, startup_order )
54 
55 /** @defgroup startfn_order Startup/shutdown function ordering
56  *
57  * Shutdown functions are called in the reverse order to startup
58  * functions.
59  *
60  * @{
61  */
62 
63 #define STARTUP_EARLY 01 /**< Early startup */
64 #define STARTUP_NORMAL 02 /**< Normal startup */
65 #define STARTUP_LATE 03 /**< Late startup */
66 
67 /** @} */
68 
69 extern void initialise ( void );
70 extern void startup ( void );
71 extern void shutdown ( int booting );
72 
73 /**
74  * Shut down system for OS boot
75  *
76  */
77 static inline void shutdown_boot ( void ) {
78  shutdown ( 1 );
79 }
80 
81 /**
82  * Shut down system for exit back to firmware
83  *
84  */
85 static inline void shutdown_exit ( void ) {
86  shutdown ( 0 );
87 }
88 
89 #endif /* _IPXE_INIT_H */
void initialise(void)
Initialise iPXE.
Definition: init.c:52
void(* initialise)(void)
Definition: init.h:16
const char * name
Definition: init.h:43
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void shutdown(int booting)
Shut down iPXE.
Definition: init.c:100
A startup/shutdown function.
Definition: init.h:42
An initialisation function.
Definition: init.h:14
const char * name
Definition: init.h:15
static void shutdown_exit(void)
Shut down system for exit back to firmware.
Definition: init.h:85
void(* startup)(void)
Definition: init.h:44
void(* shutdown)(int booting)
Definition: init.h:45
Linker tables.
void startup(void)
Start up iPXE.
Definition: init.c:69
static void shutdown_boot(void)
Shut down system for OS boot.
Definition: init.h:77