Skip to main content

roxy_loader_api/
kernel_entry.rs

1/// Defines the entry point used by kernels started with `roxy-loader`.
2///
3/// Use this macro in the crate that contains your kernel entry function.
4/// It connects your function to the startup convention expected by
5/// `roxy-loader`.
6///
7/// # Examples
8///
9/// ```ignore
10/// #![no_std]
11/// #![no_main]
12///
13/// use roxy_loader_api::{bootinfo::BootInfo, kernel_entry};
14///
15/// kernel_entry!(kernel_main);
16///
17/// fn kernel_main(bootinfo: &BootInfo) -> ! {
18///     let _framebuffer = bootinfo.framebuffer;
19///
20///     loop {}
21/// }
22/// ```
23#[macro_export]
24macro_rules! kernel_entry {
25    ($kernel_main:ident) => {
26        #[unsafe(no_mangle)]
27        extern "sysv64" fn _start(bootinfo: *const $crate::bootinfo::BootInfo) -> ! {
28            unsafe {
29                let bootinfo = &*bootinfo;
30                $kernel_main(bootinfo);
31            }
32        }
33    };
34}