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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef _GPXE_INIT_H
  2. #define _GPXE_INIT_H
  3. #include <gpxe/tables.h>
  4. /*
  5. * In order to avoid having objects dragged in just because main()
  6. * calls their initialisation function, we allow each object to
  7. * specify that it has a function that must be called to initialise
  8. * that object. The function call_init_fns() will call all the
  9. * included objects' initialisation functions.
  10. *
  11. * Objects that require initialisation should include init.h and
  12. * register the initialisation function using INIT_FN().
  13. *
  14. * Objects may register up to three functions: init, reset and exit.
  15. * init gets called only once, at the point that Etherboot is
  16. * initialised (before the call to main()). reset gets called between
  17. * each boot attempt. exit gets called only once, just before the
  18. * loaded OS starts up (or just before Etherboot exits, if it exits,
  19. * or when the PXE NBP calls UNDI_SHUTDOWN, if it's a PXE NBP).
  20. *
  21. * The syntax is:
  22. * INIT_FN ( init_order, init_function, reset_function, exit_function );
  23. * where init_order is an ordering taken from the list below. Any
  24. * function may be left as NULL.
  25. */
  26. /* An entry in the initialisation function table */
  27. struct init_fn {
  28. void ( *init ) ( void );
  29. void ( *reset ) ( void );
  30. void ( *exit ) ( void );
  31. };
  32. /* Use double digits to avoid problems with "10" < "9" on alphabetic sort */
  33. #define INIT_CONSOLE 02
  34. #define INIT_CPU 03
  35. #define INIT_TIMERS 04
  36. #define INIT_LOADBUF 08
  37. #define INIT_PCMCIA 09
  38. #define INIT_RPC 11
  39. #define INIT_PROCESS 12
  40. /* Macro for creating an initialisation function table entry */
  41. #define INIT_FN( init_order, init_func, reset_func, exit_func ) \
  42. struct init_fn PREFIX_OBJECT(init_fn__) \
  43. __table ( struct init_fn, init_fn, init_order ) = { \
  44. .init = init_func, \
  45. .reset = reset_func, \
  46. .exit = exit_func, \
  47. };
  48. /* Function prototypes */
  49. void call_init_fns ( void );
  50. void call_reset_fns ( void );
  51. void call_exit_fns ( void );
  52. #endif /* _GPXE_INIT_H */