init_i.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2017 Richard Braun.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef KERN_INIT_I_H
  18. #define KERN_INIT_I_H
  19. #include <stdalign.h>
  20. #include <stdbool.h>
  21. #include <stddef.h>
  22. #include <kern/slist_types.h>
  23. #include <kern/macros.h>
  24. #define __initop __section(QUOTE(INIT_OPS_SECTION))
  25. #define INIT_OP_STATE_UNLINKED 0
  26. #define INIT_OP_STATE_PENDING 1
  27. #define INIT_OP_STATE_COMPLETE 2
  28. struct init_op {
  29. alignas(INIT_OP_ALIGN) struct slist_node list_node;
  30. struct slist_node stack_node;
  31. const char *name;
  32. init_op_fn_t fn;
  33. struct init_op_dep *deps;
  34. int error;
  35. unsigned char state;
  36. unsigned char nr_deps;
  37. unsigned char nr_parents;
  38. };
  39. struct init_op_dep {
  40. struct init_op *op;
  41. bool required;
  42. };
  43. #define __INIT_OP_DEPS(fn) fn ## _init_op_deps
  44. #define INIT_OP_DEPS(fn) __INIT_OP_DEPS(fn)
  45. #define __INIT_OP(fn) fn ## _init_op
  46. #define INIT_OP(fn) __INIT_OP(fn)
  47. #endif /* KERN_INIT_I_H */