lib.rs 2.2 KB

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