init.h 1.5 KB

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