Fix multiple issues in the initproc path

This commit is contained in:
Zhang Junyang
2023-08-03 11:05:06 +08:00
committed by Tate, Hongliang Tian
parent 4a33020b4f
commit acfbc7efdc
6 changed files with 53 additions and 91 deletions

View File

@ -2,8 +2,6 @@
//! from the bootloader to the rest of the framework.
//!
use crate::arch::boot::init_boot_args;
pub mod kcmdline;
use kcmdline::KCmdlineArg;
@ -13,6 +11,8 @@ use self::memory_region::MemoryRegion;
use alloc::{string::String, vec::Vec};
use spin::Once;
/// ACPI information from the bootloader.
///
/// The boot crate can choose either providing the raw RSDP physical address or
/// providing the RSDT/XSDT physical address after parsing RSDP.
/// This is because bootloaders differ in such behaviors.
@ -36,40 +36,39 @@ pub struct BootloaderFramebufferArg {
pub bpp: usize,
}
// Use a macro to simplify coding.
macro_rules! define_global_static_boot_arguments {
( $( $lower:ident, $upper:ident, $typ:ty; )* ) => {
// Define statics and corresponding public get APIs.
// Define statics and corresponding public getter APIs.
$(
static $upper: Once<$typ> = Once::new();
/// Macro generated public get API.
/// Macro generated public getter API.
pub fn $lower() -> &'static $typ {
$upper.get().unwrap()
}
)*
// Produce a init function call. The init function must
// be defined in the `arch::boot` module conforming to this
// definition.
fn arch_init_boot_args() {
init_boot_args( $( &$upper, )* );
crate::arch::boot::init_boot_args( $( &$upper, )* );
}
};
}
// Define a series of static variable definitions and its APIs. The names in
// each line are:
// 1. The lowercase name of the variable, also the name of the get API;
// 2. the uppercase name of the variable;
// 3. the type of the variable.
// Define a series of static variables and their getter APIs.
define_global_static_boot_arguments!(
bootloader_name, BOOTLOADER_NAME, String;
kernel_cmdline, KERNEL_CMDLINE, KCmdlineArg;
initramfs, INITRAMFS, &'static [u8];
acpi_arg, ACPI_ARG, BootloaderAcpiArg;
framebuffer_arg, FRAMEBUFFER_ARG, BootloaderFramebufferArg;
memory_regions, MEMORY_REGIONS, Vec<MemoryRegion>;
// Getter Names | Static Variables | Variable Types
bootloader_name, BOOTLOADER_NAME, String;
kernel_cmdline, KERNEL_CMDLINE, KCmdlineArg;
initramfs, INITRAMFS, &'static [u8];
acpi_arg, ACPI_ARG, BootloaderAcpiArg;
framebuffer_arg, FRAMEBUFFER_ARG, BootloaderFramebufferArg;
memory_regions, MEMORY_REGIONS, Vec<MemoryRegion>;
);
/// The initialization method of the boot module.
///
/// After initializing the boot module, the get functions could be called.
/// The initialization must be done after the heap is set and before physical
/// mappings are cancelled.