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.0KB

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