mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-17 12:47:16 +00:00
Clean up the frame buffer state in ostd::mm
This commit is contained in:
parent
8b2ca77804
commit
9a79ecbcbe
@ -16,7 +16,7 @@ use core::{
|
||||
use component::{init_component, ComponentInitError};
|
||||
use font8x8::UnicodeFonts;
|
||||
use ostd::{
|
||||
boot,
|
||||
boot::{self, memory_region::MemoryRegionType, memory_regions},
|
||||
io_mem::IoMem,
|
||||
mm::{VmIo, PAGE_SIZE},
|
||||
sync::SpinLock,
|
||||
@ -39,8 +39,10 @@ pub(crate) fn init() {
|
||||
let mut writer = {
|
||||
let framebuffer = boot::framebuffer_arg();
|
||||
let mut size = 0;
|
||||
for i in ostd::mm::FRAMEBUFFER_REGIONS.get().unwrap().iter() {
|
||||
size = i.len();
|
||||
for region in memory_regions() {
|
||||
if region.typ() == MemoryRegionType::Framebuffer {
|
||||
size = region.len();
|
||||
}
|
||||
}
|
||||
|
||||
let page_size = size / PAGE_SIZE;
|
||||
|
@ -86,7 +86,7 @@ pub unsafe fn init() {
|
||||
|
||||
mm::page::allocator::init();
|
||||
mm::kspace::init_kernel_page_table(mm::init_page_meta());
|
||||
mm::misc_init();
|
||||
mm::dma::init();
|
||||
|
||||
// SAFETY: This function is called only once in the entire system.
|
||||
unsafe { trap::softirq::init() };
|
||||
|
@ -53,9 +53,12 @@ use super::{
|
||||
},
|
||||
page_prop::{CachePolicy, PageFlags, PageProperty, PrivilegedPageFlags},
|
||||
page_table::{KernelMode, PageTable},
|
||||
MemoryRegionType, Paddr, PagingConstsTrait, Vaddr, PAGE_SIZE,
|
||||
Paddr, PagingConstsTrait, Vaddr, PAGE_SIZE,
|
||||
};
|
||||
use crate::{
|
||||
arch::mm::{PageTableEntry, PagingConsts},
|
||||
boot::memory_region::MemoryRegionType,
|
||||
};
|
||||
use crate::arch::mm::{PageTableEntry, PagingConsts};
|
||||
|
||||
/// The shortest supported address width is 39 bits. And the literal
|
||||
/// values are written for 48 bits address width. Adjust the values
|
||||
|
@ -20,11 +20,8 @@ pub(crate) mod page_table;
|
||||
pub mod stat;
|
||||
pub mod vm_space;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::{fmt::Debug, ops::Range};
|
||||
|
||||
use spin::Once;
|
||||
|
||||
pub use self::{
|
||||
dma::{Daddr, DmaCoherent, DmaDirection, DmaStream, DmaStreamSlice, HasDaddr},
|
||||
frame::{options::FrameAllocOptions, Frame, Segment},
|
||||
@ -39,10 +36,7 @@ pub(crate) use self::{
|
||||
kspace::paddr_to_vaddr, page::meta::init as init_page_meta, page_prop::PrivilegedPageFlags,
|
||||
page_table::PageTable,
|
||||
};
|
||||
use crate::{
|
||||
arch::mm::PagingConsts,
|
||||
boot::memory_region::{MemoryRegion, MemoryRegionType},
|
||||
};
|
||||
use crate::arch::mm::PagingConsts;
|
||||
|
||||
/// The level of a page table node or a frame.
|
||||
pub type PagingLevel = u8;
|
||||
@ -119,18 +113,3 @@ pub trait HasPaddr {
|
||||
pub const fn is_page_aligned(p: usize) -> bool {
|
||||
(p & (PAGE_SIZE - 1)) == 0
|
||||
}
|
||||
|
||||
/// Memory regions used for frame buffer.
|
||||
pub static FRAMEBUFFER_REGIONS: Once<Vec<MemoryRegion>> = Once::new();
|
||||
|
||||
pub(crate) fn misc_init() {
|
||||
dma::init();
|
||||
|
||||
let mut framebuffer_regions = Vec::new();
|
||||
for i in crate::boot::memory_regions() {
|
||||
if i.typ() == MemoryRegionType::Framebuffer {
|
||||
framebuffer_regions.push(*i);
|
||||
}
|
||||
}
|
||||
FRAMEBUFFER_REGIONS.call_once(|| framebuffer_regions);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user