proka_bootloader/lib.rs
1//! This crate provides the struct, enums about the Proka
2//! bootloader, including the boot information, and so on.
3//!
4//! # About proka bootloader
5//! Well, this bootloader is for Proka Kernel, which will obey
6//! its standard. For more information, see <url>.
7
8#![no_std]
9#![no_main]
10
11#[cfg(feature = "loader_main")]
12pub mod loader_main;
13pub mod output;
14pub mod memory;
15use self::output::Framebuffer;
16use self::memory::MemoryMap;
17
18/// This struct is the boot information struct, which provides
19/// the basic information, *memory map*, and so on.
20#[repr(C)]
21#[derive(Debug, Clone, PartialEq, Eq)]
22pub struct BootInfo {
23 /// The boot mode, see the [`BootMode`] enum.
24 boot_mode: BootMode,
25 memmap: MemoryMap,
26 framebuffer: Framebuffer,
27
28}
29
30impl BootInfo {
31 /// Initialize a new boot info object.
32 ///
33 /// Note: this object will be initialized by loader
34 /// automatically, so if you are a kernel developer, do
35 /// not use this method, because you needn't and unusable.
36 #[cfg(feature = "loader_main")]
37 pub fn new(boot_mode: BootMode, memmap: MemoryMap, fb: Framebuffer) -> Self {
38 Self {
39 boot_mode,
40 memmap,
41 framebuffer: fb
42 }
43 }
44
45 /// Get the boot mode.
46 pub const fn boot_mode(&self) -> &BootMode {
47 &self.boot_mode
48 }
49
50 /// Get the framebuffer info.
51 pub const fn framebuffer(&self) -> &Framebuffer {
52 &self.framebuffer
53 }
54
55 /// Get the memory map.
56 pub const fn memory(&self) -> &MemoryMap {
57 &self.memmap
58 }
59}
60
61/// This is the boot mode, only support 2 modes, which are legacy(BIOS) and UEFI.
62#[repr(C)]
63#[derive(Debug, Clone, Copy, PartialEq, Eq)]
64pub enum BootMode {
65 /// The Legacy boot mode, also called BIOS boot mode.
66 ///
67 /// This mode is for older machine, and we needs implement
68 /// lots of things in it.
69 Legacy,
70
71 /// The UEFI boot mode, which is the newer mode. Lots of
72 /// new machines uses it.
73 ///
74 /// Also, some machine only support it (such as mine awa).
75 Uefi,
76}