use frame_alloc_more in VirtioHal
This commit is contained in:
parent
4ce5f89c9c
commit
1a2838d670
2 changed files with 5 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
||||||
use crate::mm::{
|
use crate::mm::{
|
||||||
frame_alloc, frame_dealloc, kernel_token, FrameTracker, PageTable, PhysAddr, PhysPageNum,
|
frame_alloc, frame_dealloc, kernel_token, FrameTracker, PageTable, PhysAddr, PhysPageNum,
|
||||||
StepByOne, VirtAddr,
|
StepByOne, VirtAddr, frame_alloc_more,
|
||||||
};
|
};
|
||||||
use crate::sync::UPIntrFreeCell;
|
use crate::sync::UPIntrFreeCell;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
@ -16,15 +16,9 @@ pub struct VirtioHal;
|
||||||
|
|
||||||
impl Hal for VirtioHal {
|
impl Hal for VirtioHal {
|
||||||
fn dma_alloc(pages: usize) -> usize {
|
fn dma_alloc(pages: usize) -> usize {
|
||||||
let mut ppn_base = PhysPageNum(0);
|
let trakcers = frame_alloc_more(pages);
|
||||||
for i in 0..pages {
|
let ppn_base = trakcers.as_ref().unwrap().last().unwrap().ppn;
|
||||||
let frame = frame_alloc().unwrap();
|
QUEUE_FRAMES.exclusive_access().append(&mut trakcers.unwrap());
|
||||||
if i == 0 {
|
|
||||||
ppn_base = frame.ppn;
|
|
||||||
}
|
|
||||||
assert_eq!(frame.ppn.0, ppn_base.0 + i);
|
|
||||||
QUEUE_FRAMES.exclusive_access().push(frame);
|
|
||||||
}
|
|
||||||
let pa: PhysAddr = ppn_base.into();
|
let pa: PhysAddr = ppn_base.into();
|
||||||
pa.0
|
pa.0
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ mod page_table;
|
||||||
|
|
||||||
pub use address::VPNRange;
|
pub use address::VPNRange;
|
||||||
pub use address::{PhysAddr, PhysPageNum, StepByOne, VirtAddr, VirtPageNum};
|
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::remap_test;
|
||||||
pub use memory_set::{kernel_token, MapArea, MapPermission, MapType, MemorySet, KERNEL_SPACE};
|
pub use memory_set::{kernel_token, MapArea, MapPermission, MapType, MemorySet, KERNEL_SPACE};
|
||||||
use page_table::PTEFlags;
|
use page_table::PTEFlags;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue