init.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #define arch_init(fn) \
  29. void *__initcall1_##fn __attribute__ ((__section__ (".initcalls.arch"))) = fn;
  30. #define kernel_init(fn) \
  31. void *__initcall2_##fn __attribute__ ((__section__ (".initcalls.kernel"))) = fn;
  32. #define __init __attribute__((__section__(".init.text")))
  33. #define ARRAYSIZE(arr) (sizeof(arr) / sizeof(arr[0]))
  34. #endif
  35. #endif