module.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* include/kernel/module.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 __MODULE_H
  19. #define __MODULE_H
  20. #ifndef __ASSEMBLER__
  21. #include <sys/types.h>
  22. struct modfuncs {
  23. /* point to blk/chr/net operations */
  24. void *ops;
  25. struct modfuncs *next;
  26. };
  27. struct kmodule {
  28. char *mod_name;
  29. /* this module compiled inside kernel */
  30. #define MODTYPE_KINSIDE 0x0001
  31. #define MODTYPE_GPL 0x0002
  32. #define MODTYPE_BLKDRV 0x0004
  33. #define MODTYPE_CHRDRV 0x0008
  34. #define MODTYPE_NETDRV 0x0010
  35. #define MODTYPE_KPATCH 0x0020
  36. #define MODTYPE_FS 0x0040
  37. /* there is a panic (or oops) caused by this module */
  38. #define MODTYPE_CAUSED_PANIC 0x0080
  39. __uint16_t mod_type;
  40. /* reference count of this module. */
  41. __uint32_t mod_refer;
  42. struct modfuncs *mod_funcs;
  43. /* the uid of the installer of this module */
  44. __uid_t installer_uid;
  45. };
  46. #define module_init(fn) \
  47. void *__initcall_##fn __attribute__ ((__section__ (".initcalls.modules"))) = fn; \
  48. #endif
  49. #endif