mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-25 02:46:23 +04:00
use frame_alloc_more in VirtioHal
This commit is contained in:
parent
31b1ba428a
commit
fa2d574c3b
@ -1,6 +1,6 @@
|
||||
use crate::mm::{
|
||||
frame_alloc, frame_dealloc, kernel_token, FrameTracker, PageTable, PhysAddr, PhysPageNum,
|
||||
StepByOne, VirtAddr,
|
||||
StepByOne, VirtAddr, frame_alloc_more,
|
||||
};
|
||||
use crate::sync::UPIntrFreeCell;
|
||||
use alloc::vec::Vec;
|
||||
@ -16,15 +16,9 @@ pub struct VirtioHal;
|
||||
|
||||
impl Hal for VirtioHal {
|
||||
fn dma_alloc(pages: usize) -> usize {
|
||||
let mut ppn_base = PhysPageNum(0);
|
||||
for i in 0..pages {
|
||||
let frame = frame_alloc().unwrap();
|
||||
if i == 0 {
|
||||
ppn_base = frame.ppn;
|
||||
}
|
||||
assert_eq!(frame.ppn.0, ppn_base.0 + i);
|
||||
QUEUE_FRAMES.exclusive_access().push(frame);
|
||||
}
|
||||
let trakcers = frame_alloc_more(pages);
|
||||
let ppn_base = trakcers.as_ref().unwrap().last().unwrap().ppn;
|
||||
QUEUE_FRAMES.exclusive_access().append(&mut trakcers.unwrap());
|
||||
let pa: PhysAddr = ppn_base.into();
|
||||
pa.0
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ mod page_table;
|
||||
|
||||
use address::VPNRange;
|
||||
pub use address::{PhysAddr, PhysPageNum, StepByOne, VirtAddr, VirtPageNum};
|
||||
pub use frame_allocator::{frame_alloc, frame_dealloc, FrameTracker};
|
||||
pub use frame_allocator::{frame_alloc, frame_alloc_more, frame_dealloc, FrameTracker};
|
||||
pub use memory_set::remap_test;
|
||||
pub use memory_set::{kernel_token, MapPermission, MemorySet, KERNEL_SPACE};
|
||||
use page_table::PTEFlags;
|
||||
|
Loading…
Reference in New Issue
Block a user