iPXE
|
00001 #ifndef _IPXE_INIT_H 00002 #define _IPXE_INIT_H 00003 00004 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); 00005 00006 #include <ipxe/tables.h> 00007 00008 /** 00009 * An initialisation function 00010 * 00011 * Initialisation functions are called exactly once, as part of the 00012 * call to initialise(). 00013 */ 00014 struct init_fn { 00015 void ( * initialise ) ( void ); 00016 }; 00017 00018 /** Initialisation function table */ 00019 #define INIT_FNS __table ( struct init_fn, "init_fns" ) 00020 00021 /** Declare an initialisation functon */ 00022 #define __init_fn( init_order ) __table_entry ( INIT_FNS, init_order ) 00023 00024 /** @defgroup initfn_order Initialisation function ordering 00025 * @{ 00026 */ 00027 00028 #define INIT_EARLY 01 /**< Early initialisation */ 00029 #define INIT_CONSOLE 02 /**< Console initialisation */ 00030 #define INIT_NORMAL 03 /**< Normal initialisation */ 00031 #define INIT_LATE 04 /**< Late initialisation */ 00032 00033 /** @} */ 00034 00035 /** 00036 * A startup/shutdown function 00037 * 00038 * Startup and shutdown functions may be called multiple times, as 00039 * part of the calls to startup() and shutdown(). 00040 */ 00041 struct startup_fn { 00042 const char *name; 00043 void ( * startup ) ( void ); 00044 void ( * shutdown ) ( int booting ); 00045 }; 00046 00047 /** Startup/shutdown function table */ 00048 #define STARTUP_FNS __table ( struct startup_fn, "startup_fns" ) 00049 00050 /** Declare a startup/shutdown function */ 00051 #define __startup_fn( startup_order ) \ 00052 __table_entry ( STARTUP_FNS, startup_order ) 00053 00054 /** @defgroup startfn_order Startup/shutdown function ordering 00055 * 00056 * Shutdown functions are called in the reverse order to startup 00057 * functions. 00058 * 00059 * @{ 00060 */ 00061 00062 #define STARTUP_EARLY 01 /**< Early startup */ 00063 #define STARTUP_NORMAL 02 /**< Normal startup */ 00064 #define STARTUP_LATE 03 /**< Late startup */ 00065 00066 /** @} */ 00067 00068 extern void initialise ( void ); 00069 extern void startup ( void ); 00070 extern void shutdown ( int booting ); 00071 00072 /** 00073 * Shut down system for OS boot 00074 * 00075 */ 00076 static inline void shutdown_boot ( void ) { 00077 shutdown ( 1 ); 00078 } 00079 00080 /** 00081 * Shut down system for exit back to firmware 00082 * 00083 */ 00084 static inline void shutdown_exit ( void ) { 00085 shutdown ( 0 ); 00086 } 00087 00088 #endif /* _IPXE_INIT_H */