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.c 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**************************************************************************
  2. * call_{init,reset,exit}_fns ()
  3. *
  4. * Call the various initialisation and exit functions. We use a
  5. * function table so that we don't end up dragging in an object just
  6. * because we call its initialisation function.
  7. **************************************************************************
  8. */
  9. #include "init.h"
  10. static struct init_fn init_fns[0] __table_start(init_fn);
  11. static struct init_fn init_fns_end[0] __table_end(init_fn);
  12. void call_init_fns ( void ) {
  13. struct init_fn *init_fn;
  14. for ( init_fn = init_fns; init_fn < init_fns_end ; init_fn++ ) {
  15. if ( init_fn->init )
  16. init_fn->init ();
  17. }
  18. }
  19. void call_reset_fns ( void ) {
  20. struct init_fn *init_fn;
  21. for ( init_fn = init_fns; init_fn < init_fns_end ; init_fn++ ) {
  22. if ( init_fn->reset )
  23. init_fn->reset ();
  24. }
  25. }
  26. void call_exit_fns ( void ) {
  27. struct init_fn *init_fn;
  28. /*
  29. * Exit functions are called in reverse order to
  30. * initialisation functions.
  31. */
  32. for ( init_fn = init_fns_end - 1; init_fn >= init_fns ; init_fn-- ) {
  33. if ( init_fn->exit )
  34. init_fn->exit ();
  35. }
  36. }