Removed boot protocol configuring

This commit is contained in:
Zhang Junyang 2023-07-24 15:48:09 +08:00 committed by Tate, Hongliang Tian
parent cad808f05c
commit c6145b450a
4 changed files with 20 additions and 17 deletions

View File

@ -8,7 +8,7 @@ name = "jinux"
path = "kernel/main.rs" path = "kernel/main.rs"
[dependencies] [dependencies]
jinux-frame = { path = "framework/jinux-frame", features = ["multiboot2"] } jinux-frame = { path = "framework/jinux-frame" }
jinux-std = { path = "services/libs/jinux-std" } jinux-std = { path = "services/libs/jinux-std" }
component = { path = "services/libs/comp-sys/component" } component = { path = "services/libs/comp-sys/component" }

View File

@ -27,4 +27,3 @@ acpi = "4.1.1"
aml = "0.16.3" aml = "0.16.3"
[features] [features]
multiboot2 = []

View File

@ -8,10 +8,8 @@
//! than logging since the logger is not initialized here. //! than logging since the logger is not initialized here.
//! //!
#[cfg(feature = "multiboot2")]
pub mod multiboot2; pub mod multiboot2;
#[cfg(feature = "multiboot2")] use self::multiboot2::init_global_boot_statics;
use self::multiboot2::*;
pub mod memory_region; pub mod memory_region;
use self::memory_region::MemoryRegion; use self::memory_region::MemoryRegion;
@ -46,12 +44,7 @@ pub struct BootloaderFramebufferArg {
/// The initialization must be done after the heap is set and before physical /// The initialization must be done after the heap is set and before physical
/// mappings are cancelled. /// mappings are cancelled.
pub fn init() { pub fn init() {
init_bootloader_name(); init_global_boot_statics();
init_kernel_commandline();
init_initramfs();
init_acpi_rsdp();
init_framebuffer_info();
init_memory_regions();
} }
// The public get_* APIs. // The public get_* APIs.

View File

@ -17,7 +17,7 @@ const MULTIBOOT2_ENTRY_MAGIC: u32 = 0x36d76289;
static MB2_INFO: Once<BootInformation> = Once::new(); static MB2_INFO: Once<BootInformation> = Once::new();
pub fn init_bootloader_name() { fn init_bootloader_name() {
BOOTLOADER_NAME.call_once(|| { BOOTLOADER_NAME.call_once(|| {
MB2_INFO MB2_INFO
.get() .get()
@ -30,7 +30,7 @@ pub fn init_bootloader_name() {
}); });
} }
pub fn init_kernel_commandline() { fn init_kernel_commandline() {
KERNEL_COMMANDLINE.call_once(|| { KERNEL_COMMANDLINE.call_once(|| {
MB2_INFO MB2_INFO
.get() .get()
@ -43,7 +43,7 @@ pub fn init_kernel_commandline() {
}); });
} }
pub fn init_initramfs() { fn init_initramfs() {
let mb2_module_tag = MB2_INFO let mb2_module_tag = MB2_INFO
.get() .get()
.unwrap() .unwrap()
@ -61,7 +61,7 @@ pub fn init_initramfs() {
INITRAMFS.call_once(|| unsafe { core::slice::from_raw_parts(base_va as *const u8, length) }); INITRAMFS.call_once(|| unsafe { core::slice::from_raw_parts(base_va as *const u8, length) });
} }
pub fn init_acpi_rsdp() { fn init_acpi_rsdp() {
ACPI_RSDP.call_once(|| { ACPI_RSDP.call_once(|| {
if let Some(v2_tag) = MB2_INFO.get().unwrap().rsdp_v2_tag() { if let Some(v2_tag) = MB2_INFO.get().unwrap().rsdp_v2_tag() {
// check for rsdp v2 // check for rsdp v2
@ -75,7 +75,7 @@ pub fn init_acpi_rsdp() {
}); });
} }
pub fn init_framebuffer_info() { fn init_framebuffer_info() {
let fb_tag = MB2_INFO.get().unwrap().framebuffer_tag().unwrap().unwrap(); let fb_tag = MB2_INFO.get().unwrap().framebuffer_tag().unwrap().unwrap();
FRAMEBUFFER_INFO.call_once(|| BootloaderFramebufferArg { FRAMEBUFFER_INFO.call_once(|| BootloaderFramebufferArg {
address: fb_tag.address() as usize, address: fb_tag.address() as usize,
@ -97,7 +97,7 @@ impl From<MemoryAreaType> for MemoryRegionType {
} }
} }
pub fn init_memory_regions() { fn init_memory_regions() {
// We should later use regions in `regions_unusable` to truncate all // We should later use regions in `regions_unusable` to truncate all
// regions in `regions_usable`. // regions in `regions_usable`.
// The difference is that regions in `regions_usable` could be used by // The difference is that regions in `regions_usable` could be used by
@ -186,6 +186,17 @@ pub fn init_memory_regions() {
}); });
} }
/// Initialize the global boot static varaiables in the boot module to allow
/// other modules to get the boot information.
pub fn init_global_boot_statics() {
init_bootloader_name();
init_kernel_commandline();
init_initramfs();
init_acpi_rsdp();
init_framebuffer_info();
init_memory_regions();
}
// The entry point of kernel code, which should be defined by the package that // The entry point of kernel code, which should be defined by the package that
// uses jinux-frame. // uses jinux-frame.
extern "Rust" { extern "Rust" {