lib.rs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #![no_main] // <1>
  2. #![no_std]
  3. #![feature(alloc_error_handler)]
  4. #![feature(asm_goto)]
  5. #![feature(new_zeroed_alloc)]
  6. #![feature(allocator_api)]
  7. #![feature(arbitrary_self_types)]
  8. #![feature(concat_idents)]
  9. #![feature(const_for)]
  10. #![feature(const_size_of_val)]
  11. #![feature(const_trait_impl)]
  12. #![feature(core_intrinsics)]
  13. #![feature(c_variadic)]
  14. #![feature(c_void_variant)]
  15. #![feature(extract_if)]
  16. #![feature(fn_align)]
  17. #![feature(linked_list_retain)]
  18. #![feature(naked_functions)]
  19. #![feature(ptr_internals)]
  20. #![feature(trait_upcasting)]
  21. #![feature(slice_ptr_get)]
  22. #![feature(sync_unsafe_cell)]
  23. #![feature(vec_into_raw_parts)]
  24. #![feature(linkage)]
  25. #![feature(panic_can_unwind)]
  26. #![allow(
  27. static_mut_refs,
  28. non_local_definitions,
  29. internal_features,
  30. non_upper_case_globals
  31. )]
  32. // clippy的配置
  33. #![deny(clippy::all)]
  34. // 取消下面的注释以启用clippy对栈帧大小的检查
  35. // #![deny(clippy::large_stack_frames)]
  36. // #![deny(clippy::large_const_arrays)]
  37. // DragonOS允许在函数中使用return语句(尤其是长函数时,我们推荐这么做)
  38. #![allow(
  39. clippy::macro_metavars_in_unsafe,
  40. clippy::upper_case_acronyms,
  41. clippy::single_char_pattern,
  42. clippy::needless_return,
  43. clippy::needless_pass_by_ref_mut,
  44. clippy::let_and_return,
  45. clippy::bad_bit_mask
  46. )]
  47. #[cfg(test)]
  48. #[macro_use]
  49. extern crate std;
  50. /// 导出x86_64架构相关的代码,命名为arch模块
  51. #[macro_use]
  52. mod arch;
  53. #[macro_use]
  54. mod libs;
  55. #[macro_use]
  56. mod include;
  57. mod bpf;
  58. mod cgroup;
  59. mod debug;
  60. mod driver; // 如果driver依赖了libs,应该在libs后面导出
  61. mod exception;
  62. mod filesystem;
  63. mod init;
  64. mod ipc;
  65. mod misc;
  66. mod mm;
  67. mod net;
  68. mod perf;
  69. mod process;
  70. mod sched;
  71. mod smp;
  72. mod syscall;
  73. mod time;
  74. mod tracepoint;
  75. #[cfg(target_arch = "x86_64")]
  76. mod virt;
  77. #[macro_use]
  78. extern crate alloc;
  79. #[macro_use]
  80. extern crate atomic_enum;
  81. #[macro_use]
  82. extern crate bitflags;
  83. extern crate elf;
  84. #[macro_use]
  85. extern crate lazy_static;
  86. extern crate num;
  87. #[macro_use]
  88. extern crate num_derive;
  89. extern crate smoltcp;
  90. #[macro_use]
  91. extern crate intertrait;
  92. #[cfg(target_arch = "x86_64")]
  93. extern crate x86;
  94. #[macro_use]
  95. extern crate kcmdline_macros;
  96. extern crate klog_types;
  97. extern crate uefi;
  98. extern crate uefi_raw;
  99. #[macro_use]
  100. extern crate wait_queue_macros;
  101. use crate::mm::allocator::kernel_allocator::KernelAllocator;
  102. // 声明全局的分配器
  103. #[cfg_attr(not(test), global_allocator)]
  104. pub static KERNEL_ALLOCATOR: KernelAllocator = KernelAllocator;