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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. const char *name;
  34. void ( * startup ) ( void );
  35. void ( * shutdown ) ( int booting );
  36. };
  37. /** Startup/shutdown function table */
  38. #define STARTUP_FNS __table ( struct startup_fn, "startup_fns" )
  39. /** Declare a startup/shutdown function */
  40. #define __startup_fn( startup_order ) \
  41. __table_entry ( STARTUP_FNS, startup_order )
  42. /** @defgroup startfn_order Startup/shutdown function ordering
  43. *
  44. * Shutdown functions are called in the reverse order to startup
  45. * functions.
  46. *
  47. * @{
  48. */
  49. #define STARTUP_EARLY 01 /**< Early startup */
  50. #define STARTUP_NORMAL 02 /**< Normal startup */
  51. #define STARTUP_LATE 03 /**< Late startup */
  52. /** @} */
  53. extern void initialise ( void );
  54. extern void startup ( void );
  55. extern void shutdown ( int booting );
  56. /**
  57. * Shut down system for OS boot
  58. *
  59. */
  60. static inline void shutdown_boot ( void ) {
  61. shutdown ( 1 );
  62. }
  63. /**
  64. * Shut down system for exit back to firmware
  65. *
  66. */
  67. static inline void shutdown_exit ( void ) {
  68. shutdown ( 0 );
  69. }
  70. #endif /* _IPXE_INIT_H */