Refactor the source structure in aster_frame::mm

This commit is contained in:
Zhang Junyang
2024-06-02 11:00:34 +00:00
committed by Tate, Hongliang Tian
parent e8595b95fe
commit 7095b37e7e
38 changed files with 177 additions and 129 deletions

View File

@ -4,7 +4,9 @@ use alloc::{collections::LinkedList, sync::Arc};
use align_ext::AlignExt;
use aster_frame::{
mm::{Daddr, DmaDirection, DmaStream, HasDaddr, VmAllocOptions, VmReader, VmWriter, PAGE_SIZE},
mm::{
Daddr, DmaDirection, DmaStream, FrameAllocOptions, HasDaddr, VmReader, VmWriter, PAGE_SIZE,
},
sync::SpinLock,
};
use pod::Pod;
@ -27,7 +29,7 @@ impl TxBuffer {
} else {
let segment = {
let nframes = (nbytes.align_up(PAGE_SIZE)) / PAGE_SIZE;
VmAllocOptions::new(nframes).alloc_contiguous().unwrap()
FrameAllocOptions::new(nframes).alloc_contiguous().unwrap()
};
DmaStream::map(segment, DmaDirection::ToDevice, false).unwrap()
};

View File

@ -9,7 +9,9 @@ use alloc::{
use core::ops::Range;
use aster_frame::{
mm::{Daddr, DmaDirection, DmaStream, HasDaddr, VmAllocOptions, VmReader, VmWriter, PAGE_SIZE},
mm::{
Daddr, DmaDirection, DmaStream, FrameAllocOptions, HasDaddr, VmReader, VmWriter, PAGE_SIZE,
},
sync::{RwLock, SpinLock},
};
use bitvec::{array::BitArray, prelude::Lsb0};
@ -145,7 +147,7 @@ impl DmaPage {
pool: Weak<DmaPool>,
) -> Result<Self, aster_frame::Error> {
let dma_stream = {
let vm_segment = VmAllocOptions::new(1).alloc_contiguous()?;
let vm_segment = FrameAllocOptions::new(1).alloc_contiguous()?;
DmaStream::map(vm_segment, direction, is_cache_coherent)
.map_err(|_| aster_frame::Error::AccessDenied)?