1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//! # Proka Bootloader - The bootloader of ProkaOS
//!
//! [](https://www.rust-lang.org/)
//! [](https://opensource.org/license/gpl-3.0)
//! [](https://github.com/RainSTR-Studio/proka-bootloader/stargazers)
//! [](https://github.com/RainSTR-Studio/proka-bootloader/issues)
//! [](https://github.com/RainSTR-Studio/proka-bootloader/pulls)
//! [](https://prokadoc.pages.dev/)
//!
//!**Copyright (C) 2026 RainSTR Studio. All rights reserved.**
//!
//!---
//!
//! ## Introduction
//! This crate provides the struct, enums about the Proka
//! bootloader, including the boot information, and so on.
//!
//! # Example
//! Here's an example to use this crateb
//!
//! ```rust
//! #![no_std]
//! #![no_main]
//! #![feature(custom_test_frameworks)]
//! #![test_runner(self::test_runner)]
//! #![reexport_test_harness_main = "test_main"]
//!
//! use proka_bootloader::BootInfo;
//! use core::panic::PanicInfo;
//!
//! // Panic handler
//! #[panic_handler]
//! pub fn panic(_: &PanicInfo) -> ! {
//! loop {}
//! }
//! #[unsafe(no_mangle)]
//! #[unsafe(link_section = ".text")]
//! pub extern "C" fn kernel_main() -> ! {
//! let info = proka_bootloader::get_bootinfo();
//! let framebuffer = info.framebuffer();
//! unsafe {
//! let ptr = framebuffer.address() as *mut u8;
//! for i in 0..500 {
//! let offset = framebuffer.pitch() * i + i * framebuffer.bpp();
//! ptr.add(offset as usize).cast::<u32>().write(0x00FFFFFF);
//! }
//! }
//! loop {}
//! }
//! // Test runner
//! #[cfg(test)]
//! fn test_runner(tests: &[&'static dyn Fn()]) {
//! for test in tests {
//! test();
//! }
//! }
//! ```
//!
//! //! # LICENSE
//! This crate is under license [GPL-v3](https://github.com/RainSTR-Studio/proka-exec/blob/main/LICENSE),
//! and you must follow its rules.
//!
//! See [LICENSE](https://github.com/RainSTR-Studio/proka-exec/blob/main/LICENSE) file for more details.
//!
//! ## MSRV
//! This crate's MSRV is `1.85.0` stable.
use MemoryMap;
use Framebuffer;
/// This struct is the boot information struct, which provides
/// the basic information, *memory map*, and so on.
/// This is the boot mode, only support 2 modes, which are legacy(BIOS) and UEFI.
/// Get the bootinfo.
///
/// The BootInfo is pre-copied & fixed at the dedicated constant physical address
/// 0x10000 by UEFI boot stage, never modified nor released in kernel lifetime.
///
/// # Safety
/// Caller must ensure **before invoking**:
/// 1. Address `0x10000` is allocated & filled with valid initialized BootInfo;
/// 2. This range is reserved, never overwritten/freed by kernel/UEFI;
/// 3. No mutable aliasing exists for this memory region.
///
/// These steps are already guaranteed by the bootloader, so invocation is generally safe
/// in normal kernel runtime.
///
/// # Returns
/// - `&'static BootInfo`: immutable static reference to the pre-filled BootInfo
pub const