Home | History | Annotate | Download | only in gpxe
      1 #ifndef _GPXE_INIT_H
      2 #define _GPXE_INIT_H
      3 
      4 FILE_LICENCE ( GPL2_OR_LATER );
      5 
      6 #include <gpxe/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 	void ( * initialise ) ( void );
     16 };
     17 
     18 /** Initialisation function table */
     19 #define INIT_FNS __table ( struct init_fn, "init_fns" )
     20 
     21 /** Declare an initialisation functon */
     22 #define __init_fn( init_order ) __table_entry ( INIT_FNS, init_order )
     23 
     24 /** @defgroup initfn_order Initialisation function ordering
     25  * @{
     26  */
     27 
     28 #define INIT_EARLY	01	/**< Early initialisation */
     29 #define INIT_SERIAL	02	/**< Serial driver initialisation */
     30 #define	INIT_CONSOLE	03	/**< Console initialisation */
     31 #define INIT_NORMAL	04	/**< Normal initialisation */
     32 
     33 /** @} */
     34 
     35 /** Shutdown flags */
     36 enum shutdown_flags {
     37 	/** Shutdown is in order to exit (return to gPXE's caller) */
     38 	SHUTDOWN_EXIT = 0x0001,
     39 	/** Shutdown is in order to boot an OS */
     40 	SHUTDOWN_BOOT = 0x0002,
     41 	/** Do not remove devices */
     42 	SHUTDOWN_KEEP_DEVICES = 0x0004,
     43 };
     44 
     45 /**
     46  * A startup/shutdown function
     47  *
     48  * Startup and shutdown functions may be called multiple times, as
     49  * part of the calls to startup() and shutdown().
     50  */
     51 struct startup_fn {
     52 	void ( * startup ) ( void );
     53 	void ( * shutdown ) ( int flags );
     54 };
     55 
     56 /** Startup/shutdown function table */
     57 #define STARTUP_FNS __table ( struct startup_fn, "startup_fns" )
     58 
     59 /** Declare a startup/shutdown function */
     60 #define __startup_fn( startup_order ) \
     61 	__table_entry ( STARTUP_FNS, startup_order )
     62 
     63 /** @defgroup startfn_order Startup/shutdown function ordering
     64  *
     65  * Shutdown functions are called in the reverse order to startup
     66  * functions.
     67  *
     68  * @{
     69  */
     70 
     71 #define STARTUP_EARLY	01	/**< Early startup */
     72 #define STARTUP_NORMAL	02	/**< Normal startup */
     73 #define STARTUP_LATE	03	/**< Late startup */
     74 
     75 /** @} */
     76 
     77 extern void initialise ( void );
     78 extern void startup ( void );
     79 extern void shutdown ( int flags );
     80 
     81 #endif /* _GPXE_INIT_H */
     82