lib.rs 2.2 KB

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