1#![no_std]
8#![cfg_attr(test, no_main)]
9#![feature(custom_test_frameworks)]
10#![feature(abi_x86_interrupt)]
11#![test_runner(crate::test::test_runner)]
12#![reexport_test_harness_main = "test_main"]
13pub mod drivers;
14pub mod fs;
15pub mod graphics;
16pub mod interrupts;
17pub mod libs;
18pub mod memory;
19pub mod output;
20pub mod panic;
21pub mod process;
22pub mod test;
23
24pub mod config {
25 include!(concat!(env!("OUT_DIR"), "/config.rs"));
26}
27
28pub use memory::frame_allocator::{format_bytes, FrameStats, LockedFrameAllocator};
30pub use memory::paging::{
31 get_hhdm_offset, get_memory_stats, init_frame_allocator, init_offset_page_table,
32 print_memory_stats,
33};
34pub use memory::protection::{kernel_flags, user_flags, Protection};
35
36use limine::{
37 modules::InternalModule,
38 request::{FramebufferRequest, MemoryMapRequest, ModuleRequest},
39 BaseRevision,
40};
41
42#[unsafe(link_section = ".requests")]
44#[used]
45pub static BASE_REVISION: BaseRevision = BaseRevision::new();
47
48#[unsafe(link_section = ".requests")]
49#[used]
50pub static FRAMEBUFFER_REQUEST: FramebufferRequest = FramebufferRequest::new();
52
53#[unsafe(link_section = ".requests")]
54#[used]
55pub static MEMORY_MAP_REQUEST: MemoryMapRequest = MemoryMapRequest::new();
56
57#[unsafe(link_section = ".requests")]
58#[used]
59pub static HHDM_REQUEST: limine::request::HhdmRequest = limine::request::HhdmRequest::new();
60
61#[unsafe(link_section = ".requests")]
62#[used]
63pub static MODULE_REQUEST: ModuleRequest = ModuleRequest::new()
64 .with_internal_modules(&[&InternalModule::new().with_path(c"/initrd.cpio")]);
65
66#[macro_export]
82macro_rules! extern_safe {
83 (
84 $(
85 $(#[$meta:meta])*
86 fn $name:ident($($arg:ident: $ty:ty),* $(,)?) -> $ret:ty;
87 )*
88 ) => {
89 unsafe extern "C" {
90 $(
91 $(#[$meta])*
92 fn $name($($arg: $ty),*) -> $ret;
93 )*
94 }
95
96 $(
97 paste::paste! {
98 pub fn [<safe_ $name>]($($arg: $ty),*) -> $ret {
99 unsafe { $name($($arg),*) }
100 }
101 }
102 )*
103 };
104}