init.h 1.6 KB

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