iPXE
init.h
Go to the documentation of this file.
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         void ( * startup ) ( void );
00043         void ( * shutdown ) ( int booting );
00044 };
00045 
00046 /** Startup/shutdown function table */
00047 #define STARTUP_FNS __table ( struct startup_fn, "startup_fns" )
00048 
00049 /** Declare a startup/shutdown function */
00050 #define __startup_fn( startup_order ) \
00051         __table_entry ( STARTUP_FNS, startup_order )
00052 
00053 /** @defgroup startfn_order Startup/shutdown function ordering
00054  *
00055  * Shutdown functions are called in the reverse order to startup
00056  * functions.
00057  *
00058  * @{
00059  */
00060 
00061 #define STARTUP_EARLY   01      /**< Early startup */
00062 #define STARTUP_NORMAL  02      /**< Normal startup */
00063 #define STARTUP_LATE    03      /**< Late startup */
00064 
00065 /** @} */
00066 
00067 extern void initialise ( void );
00068 extern void startup ( void );
00069 extern void shutdown ( int booting );
00070 
00071 /**
00072  * Shut down system for OS boot
00073  *
00074  */
00075 static inline void shutdown_boot ( void ) {
00076         shutdown ( 1 );
00077 }
00078 
00079 /**
00080  * Shut down system for exit back to firmware
00081  *
00082  */
00083 static inline void shutdown_exit ( void ) {
00084         shutdown ( 0 );
00085 }
00086 
00087 #endif /* _IPXE_INIT_H */