From c6145b450ae81abc668dff2e19281cd10094e3b5 Mon Sep 17 00:00:00 2001 From: Zhang Junyang Date: Mon, 24 Jul 2023 15:48:09 +0800 Subject: [PATCH] Removed boot protocol configuring --- Cargo.toml | 2 +- framework/jinux-frame/Cargo.toml | 1 - .../jinux-frame/src/arch/x86/boot/mod.rs | 11 ++------- .../src/arch/x86/boot/multiboot2/mod.rs | 23 ++++++++++++++----- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1b989eea..f4d626f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ name = "jinux" path = "kernel/main.rs" [dependencies] -jinux-frame = { path = "framework/jinux-frame", features = ["multiboot2"] } +jinux-frame = { path = "framework/jinux-frame" } jinux-std = { path = "services/libs/jinux-std" } component = { path = "services/libs/comp-sys/component" } diff --git a/framework/jinux-frame/Cargo.toml b/framework/jinux-frame/Cargo.toml index df8ad4e3..0ec788b1 100644 --- a/framework/jinux-frame/Cargo.toml +++ b/framework/jinux-frame/Cargo.toml @@ -27,4 +27,3 @@ acpi = "4.1.1" aml = "0.16.3" [features] -multiboot2 = [] diff --git a/framework/jinux-frame/src/arch/x86/boot/mod.rs b/framework/jinux-frame/src/arch/x86/boot/mod.rs index 28cdb716..0ce0e2af 100644 --- a/framework/jinux-frame/src/arch/x86/boot/mod.rs +++ b/framework/jinux-frame/src/arch/x86/boot/mod.rs @@ -8,10 +8,8 @@ //! than logging since the logger is not initialized here. //! -#[cfg(feature = "multiboot2")] pub mod multiboot2; -#[cfg(feature = "multiboot2")] -use self::multiboot2::*; +use self::multiboot2::init_global_boot_statics; pub mod memory_region; 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 /// mappings are cancelled. pub fn init() { - init_bootloader_name(); - init_kernel_commandline(); - init_initramfs(); - init_acpi_rsdp(); - init_framebuffer_info(); - init_memory_regions(); + init_global_boot_statics(); } // The public get_* APIs. diff --git a/framework/jinux-frame/src/arch/x86/boot/multiboot2/mod.rs b/framework/jinux-frame/src/arch/x86/boot/multiboot2/mod.rs index 916fa2cf..d8f3239c 100644 --- a/framework/jinux-frame/src/arch/x86/boot/multiboot2/mod.rs +++ b/framework/jinux-frame/src/arch/x86/boot/multiboot2/mod.rs @@ -17,7 +17,7 @@ const MULTIBOOT2_ENTRY_MAGIC: u32 = 0x36d76289; static MB2_INFO: Once = Once::new(); -pub fn init_bootloader_name() { +fn init_bootloader_name() { BOOTLOADER_NAME.call_once(|| { MB2_INFO .get() @@ -30,7 +30,7 @@ pub fn init_bootloader_name() { }); } -pub fn init_kernel_commandline() { +fn init_kernel_commandline() { KERNEL_COMMANDLINE.call_once(|| { MB2_INFO .get() @@ -43,7 +43,7 @@ pub fn init_kernel_commandline() { }); } -pub fn init_initramfs() { +fn init_initramfs() { let mb2_module_tag = MB2_INFO .get() .unwrap() @@ -61,7 +61,7 @@ pub fn init_initramfs() { 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(|| { if let Some(v2_tag) = MB2_INFO.get().unwrap().rsdp_v2_tag() { // 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(); FRAMEBUFFER_INFO.call_once(|| BootloaderFramebufferArg { address: fb_tag.address() as usize, @@ -97,7 +97,7 @@ impl From for MemoryRegionType { } } -pub fn init_memory_regions() { +fn init_memory_regions() { // We should later use regions in `regions_unusable` to truncate all // regions in `regions_usable`. // 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 // uses jinux-frame. extern "Rust" {