mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-29 04:13:24 +00:00
Recognize kernel memory regions in the Linux boot path
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
d4b6eea97d
commit
487e0cdd15
@ -5,7 +5,9 @@ use spin::Once;
|
||||
use crate::{
|
||||
boot::{
|
||||
kcmdline::KCmdlineArg,
|
||||
memory_region::{non_overlapping_regions_from, MemoryRegion, MemoryRegionType},
|
||||
memory_region::{
|
||||
non_overlapping_regions_from, MemoryRegion, MemoryRegionType,
|
||||
},
|
||||
BootloaderAcpiArg, BootloaderFramebufferArg,
|
||||
},
|
||||
config::PHYS_OFFSET,
|
||||
|
@ -6,7 +6,9 @@ use multiboot2::{BootInformation, BootInformationHeader, MemoryAreaType};
|
||||
|
||||
use crate::boot::{
|
||||
kcmdline::KCmdlineArg,
|
||||
memory_region::{non_overlapping_regions_from, MemoryRegion, MemoryRegionType},
|
||||
memory_region::{
|
||||
non_overlapping_regions_from, MemoryRegion, MemoryRegionType,
|
||||
},
|
||||
BootloaderAcpiArg, BootloaderFramebufferArg,
|
||||
};
|
||||
use spin::Once;
|
||||
|
@ -56,7 +56,7 @@ fn init_tsc_mode() {
|
||||
fn determine_tsc_freq_via_pit() -> u64 {
|
||||
let mut irq = IrqLine::alloc_specific(super::TIMER_IRQ_NUM.load(Ordering::Relaxed)).unwrap();
|
||||
irq.on_active(pit_callback);
|
||||
let mut io_apic = IO_APIC.get().unwrap().get(0).unwrap().lock();
|
||||
let mut io_apic = IO_APIC.get().unwrap().first().unwrap().lock();
|
||||
debug_assert_eq!(io_apic.interrupt_base(), 0);
|
||||
io_apic.enable(2, irq.clone()).unwrap();
|
||||
drop(io_apic);
|
||||
@ -87,7 +87,7 @@ fn determine_tsc_freq_via_pit() -> u64 {
|
||||
IN_TIME += 1;
|
||||
return;
|
||||
}
|
||||
let mut io_apic = IO_APIC.get().unwrap().get(0).unwrap().lock();
|
||||
let mut io_apic = IO_APIC.get().unwrap().first().unwrap().lock();
|
||||
io_apic.disable(2).unwrap();
|
||||
drop(io_apic);
|
||||
let tsc_count = _rdtsc();
|
||||
|
@ -84,9 +84,12 @@ pub(crate) fn init(regions: &[MemoryRegion]) {
|
||||
let mut allocator = FrameAllocator::<32>::new();
|
||||
for region in regions.iter() {
|
||||
if region.typ() == MemoryRegionType::Usable {
|
||||
// Make the memory region page-aligned
|
||||
// Make the memory region page-aligned, and skip if it is too small.
|
||||
let start = region.base().align_up(PAGE_SIZE) / PAGE_SIZE;
|
||||
let end = (region.base() + region.len()).align_down(PAGE_SIZE) / PAGE_SIZE;
|
||||
if end <= start {
|
||||
continue;
|
||||
}
|
||||
allocator.add_frame(start, end);
|
||||
info!(
|
||||
"Found usable region, start:{:x}, end:{:x}",
|
||||
|
Reference in New Issue
Block a user