You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

init.h 1.9KB

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