Skip to main content

roxy_loader_api/
bootinfo.rs

1use crate::framebuffer::Framebuffer;
2
3/// Boot-time data provided by `roxy-loader`.
4///
5/// This is the main value passed to the kernel entry point. It groups together
6/// the information a kernel can use immediately after startup.
7#[derive(Clone, Copy)]
8#[repr(C)]
9pub struct BootInfo {
10    /// Information about the framebuffer that the kernel can draw to.
11    pub framebuffer: Framebuffer,
12}
13
14#[cfg(test)]
15mod tests {
16    use super::BootInfo;
17    use crate::framebuffer::Framebuffer;
18    use core::{
19        mem::{MaybeUninit, align_of, size_of},
20        ptr::addr_of,
21    };
22
23    #[test]
24    fn layout_is_stable() {
25        assert_eq!(size_of::<BootInfo>(), size_of::<Framebuffer>());
26        assert_eq!(align_of::<BootInfo>(), align_of::<Framebuffer>());
27
28        let bootinfo = MaybeUninit::<BootInfo>::uninit();
29        let base = bootinfo.as_ptr();
30
31        unsafe {
32            assert_eq!(addr_of!((*base).framebuffer) as usize - base as usize, 0);
33        }
34    }
35}