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 2.1KB

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