init.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* include/kernel/init.h
  2. *
  3. * This file is part of evx.
  4. *
  5. * evx is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * evx is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with evx. If not, see <https://www.gnu.org/licenses/>
  17. */
  18. #ifndef __INIT_H
  19. #define __INIT_H
  20. #ifndef __ASSEMBLER__
  21. #include <sys/types.h>
  22. #ifndef NULL
  23. #define NULL ((void *) 0)
  24. #endif
  25. /* defines in kernel.lds */
  26. extern void *_init_call_arch, *_init_call_kernel, *_init_call_modules;
  27. extern void *_einit_call_arch, *_einit_call_kernel, *_einit_call_modules;
  28. /* never use this directly. use kernel_end instead of it */
  29. extern int _end __attribute__ ((__section__(".end")));
  30. extern void *kernel_end;
  31. #define STATE_INIT_CALLS 1
  32. #define STATE_READY 2
  33. extern int init_state;
  34. #define arch_init(fn) \
  35. void *__initcall1_##fn __attribute__ ((__section__ (".initcalls.arch"))) = fn;
  36. #define kernel_init(fn) \
  37. void *__initcall2_##fn __attribute__ ((__section__ (".initcalls.kernel"))) = fn;
  38. #define __init __attribute__((__section__(".init.text")))
  39. #define __init_data __attribute__((__section__(".init.data")))
  40. #define ARRAYSIZE(arr) (sizeof(arr) / sizeof(arr[0]))
  41. #endif
  42. #endif