mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-29 16:13:27 +00:00
Implement a new set of physical page APIs
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
6e1c36965a
commit
cdac59beda
@ -141,13 +141,13 @@ impl DeviceInner {
|
||||
let queue = VirtQueue::new(0, Self::QUEUE_SIZE, transport.as_mut())
|
||||
.expect("create virtqueue failed");
|
||||
let block_requests = {
|
||||
let vm_segment = FrameAllocOptions::new(1).alloc_contiguous().unwrap();
|
||||
DmaStream::map(vm_segment, DmaDirection::Bidirectional, false).unwrap()
|
||||
let segment = FrameAllocOptions::new().alloc_segment(1).unwrap();
|
||||
DmaStream::map(segment.into(), DmaDirection::Bidirectional, false).unwrap()
|
||||
};
|
||||
assert!(Self::QUEUE_SIZE as usize * REQ_SIZE <= block_requests.nbytes());
|
||||
let block_responses = {
|
||||
let vm_segment = FrameAllocOptions::new(1).alloc_contiguous().unwrap();
|
||||
DmaStream::map(vm_segment, DmaDirection::Bidirectional, false).unwrap()
|
||||
let segment = FrameAllocOptions::new().alloc_segment(1).unwrap();
|
||||
DmaStream::map(segment.into(), DmaDirection::Bidirectional, false).unwrap()
|
||||
};
|
||||
assert!(Self::QUEUE_SIZE as usize * RESP_SIZE <= block_responses.nbytes());
|
||||
|
||||
@ -261,11 +261,11 @@ impl DeviceInner {
|
||||
};
|
||||
const MAX_ID_LENGTH: usize = 20;
|
||||
let device_id_stream = {
|
||||
let segment = FrameAllocOptions::new(1)
|
||||
.uninit(true)
|
||||
.alloc_contiguous()
|
||||
let segment = FrameAllocOptions::new()
|
||||
.zeroed(false)
|
||||
.alloc_segment(1)
|
||||
.unwrap();
|
||||
DmaStream::map(segment, DmaDirection::FromDevice, false).unwrap()
|
||||
DmaStream::map(segment.into(), DmaDirection::FromDevice, false).unwrap()
|
||||
};
|
||||
let device_id_slice = DmaStreamSlice::new(&device_id_stream, 0, MAX_ID_LENGTH);
|
||||
let outputs = vec![&device_id_slice, &resp_slice];
|
||||
|
@ -87,13 +87,13 @@ impl ConsoleDevice {
|
||||
SpinLock::new(VirtQueue::new(TRANSMIT0_QUEUE_INDEX, 2, transport.as_mut()).unwrap());
|
||||
|
||||
let send_buffer = {
|
||||
let vm_segment = FrameAllocOptions::new(1).alloc_contiguous().unwrap();
|
||||
DmaStream::map(vm_segment, DmaDirection::ToDevice, false).unwrap()
|
||||
let segment = FrameAllocOptions::new().alloc_segment(1).unwrap();
|
||||
DmaStream::map(segment.into(), DmaDirection::ToDevice, false).unwrap()
|
||||
};
|
||||
|
||||
let receive_buffer = {
|
||||
let vm_segment = FrameAllocOptions::new(1).alloc_contiguous().unwrap();
|
||||
DmaStream::map(vm_segment, DmaDirection::FromDevice, false).unwrap()
|
||||
let segment = FrameAllocOptions::new().alloc_segment(1).unwrap();
|
||||
DmaStream::map(segment.into(), DmaDirection::FromDevice, false).unwrap()
|
||||
};
|
||||
|
||||
let device = Arc::new(Self {
|
||||
|
@ -261,14 +261,14 @@ impl EventTable {
|
||||
fn new(num_events: usize) -> Self {
|
||||
assert!(num_events * mem::size_of::<VirtioInputEvent>() <= PAGE_SIZE);
|
||||
|
||||
let vm_segment = FrameAllocOptions::new(1).alloc_contiguous().unwrap();
|
||||
let segment = FrameAllocOptions::new().alloc_segment(1).unwrap();
|
||||
|
||||
let default_event = VirtioInputEvent::default();
|
||||
let iter = iter::repeat(&default_event).take(EVENT_SIZE);
|
||||
let nr_written = vm_segment.write_vals(0, iter, 0).unwrap();
|
||||
let nr_written = segment.write_vals(0, iter, 0).unwrap();
|
||||
assert_eq!(nr_written, EVENT_SIZE);
|
||||
|
||||
let stream = DmaStream::map(vm_segment, DmaDirection::FromDevice, false).unwrap();
|
||||
let stream = DmaStream::map(segment.into(), DmaDirection::FromDevice, false).unwrap();
|
||||
Self { stream, num_events }
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user