mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-18 12:06:43 +00:00
Fix boot documentations and comments
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
0ab7fcc408
commit
b5e04ea5ad
@ -6,8 +6,8 @@ use alloc::{vec, vec::Vec};
|
||||
|
||||
use crate::config::PAGE_SIZE;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||
/// The type of initial memory regions that are needed for the kernel.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||
pub enum MemoryRegionType {
|
||||
/// Maybe points to an unplugged DIMM module. It's bad anyway.
|
||||
BadMemory = 0,
|
||||
@ -27,9 +27,9 @@ pub enum MemoryRegionType {
|
||||
Usable = 7,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||
/// The information of initial memory regions that are needed by the kernel.
|
||||
/// The sections are **not** guaranteed to not overlap. The region must be page aligned.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||
pub struct MemoryRegion {
|
||||
base: usize,
|
||||
len: usize,
|
||||
@ -43,12 +43,15 @@ impl MemoryRegion {
|
||||
let aligned_end;
|
||||
match typ {
|
||||
MemoryRegionType::Usable | MemoryRegionType::Reclaimable => {
|
||||
// Align shrinked.
|
||||
// Align shrinked. These regions may be used by the frame allocator.
|
||||
aligned_base = base.align_up(PAGE_SIZE);
|
||||
aligned_end = (base + len).align_down(PAGE_SIZE);
|
||||
}
|
||||
_ => {
|
||||
// Align bloated.
|
||||
// We can align other regions in a bloated manner since we do not
|
||||
// use MemoryRegion as a way to deliver objects. They are just
|
||||
// markers of untouchable memory areas or areas that need special
|
||||
// treatments.
|
||||
aligned_base = base.align_down(PAGE_SIZE);
|
||||
aligned_end = (base + len).align_up(PAGE_SIZE);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
//! The boot module defines the entrypoints of Jinux and the corresponding
|
||||
//! headers for different bootloaders.
|
||||
//!
|
||||
//! We currently support Multiboot2 and the Limine Boot Protocol. The
|
||||
//! support for Linux boot protocol is on its way.
|
||||
//! We currently support Multiboot2. The support for Linux Boot Protocol is
|
||||
//! on its way.
|
||||
//!
|
||||
//! In this module, we use println! to print information on screen rather
|
||||
//! than logging since the logger is not initialized here.
|
||||
@ -19,10 +19,10 @@ pub use memory_region::*;
|
||||
use alloc::{string::String, vec::Vec};
|
||||
use spin::Once;
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
/// 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.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum BootloaderAcpiArg {
|
||||
/// Physical address of the RSDP.
|
||||
Rsdp(usize),
|
||||
@ -32,8 +32,8 @@ pub enum BootloaderAcpiArg {
|
||||
Xsdt(usize),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
/// The framebuffer arguments.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct BootloaderFramebufferArg {
|
||||
pub address: usize,
|
||||
pub width: usize,
|
||||
|
@ -182,12 +182,14 @@ pub fn init_memory_regions() {
|
||||
MEMORY_REGIONS.call_once(|| regions_unusable);
|
||||
}
|
||||
|
||||
/// The entry point of kernel code, which should be defined by the package that
|
||||
/// uses jinux-frame.
|
||||
extern "Rust" {
|
||||
fn jinux_main() -> !;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
/// The entry point of Rust code called by inline asm.
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn __multiboot2_entry(boot_magic: u32, boot_params: u64) -> ! {
|
||||
assert_eq!(boot_magic, MULTIBOOT2_ENTRY_MAGIC);
|
||||
MB2_INFO.call_once(|| unsafe {
|
||||
|
Reference in New Issue
Block a user