virtio-blk worked.
This commit is contained in:
parent
2d34cab989
commit
eca5ee2eb7
12 changed files with 145 additions and 11 deletions
|
@ -3,15 +3,19 @@ use super::PageTableEntry;
|
|||
use core::fmt::{self, Debug, Formatter};
|
||||
|
||||
/// Definitions
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
|
||||
pub struct PhysAddr(pub usize);
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
|
||||
pub struct VirtAddr(pub usize);
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
|
||||
pub struct PhysPageNum(pub usize);
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
|
||||
pub struct VirtPageNum(pub usize);
|
||||
|
||||
|
@ -144,6 +148,11 @@ impl StepByOne for VirtPageNum {
|
|||
self.0 += 1;
|
||||
}
|
||||
}
|
||||
impl StepByOne for PhysPageNum {
|
||||
fn step(&mut self) {
|
||||
self.0 += 1;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct SimpleRange<T> where
|
||||
|
|
|
@ -108,7 +108,7 @@ pub fn frame_alloc() -> Option<FrameTracker> {
|
|||
.map(|ppn| FrameTracker::new(ppn))
|
||||
}
|
||||
|
||||
fn frame_dealloc(ppn: PhysPageNum) {
|
||||
pub fn frame_dealloc(ppn: PhysPageNum) {
|
||||
FRAME_ALLOCATOR
|
||||
.lock()
|
||||
.dealloc(ppn);
|
||||
|
|
|
@ -13,7 +13,8 @@ use crate::config::{
|
|||
PAGE_SIZE,
|
||||
TRAMPOLINE,
|
||||
TRAP_CONTEXT,
|
||||
USER_STACK_SIZE
|
||||
USER_STACK_SIZE,
|
||||
MMIO,
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
@ -126,6 +127,15 @@ impl MemorySet {
|
|||
MapType::Identical,
|
||||
MapPermission::R | MapPermission::W,
|
||||
), None);
|
||||
println!("mapping memory-mapped registers");
|
||||
for pair in MMIO {
|
||||
memory_set.push(MapArea::new(
|
||||
(*pair).0.into(),
|
||||
((*pair).0 + (*pair).1).into(),
|
||||
MapType::Identical,
|
||||
MapPermission::R | MapPermission::W,
|
||||
), None);
|
||||
}
|
||||
memory_set
|
||||
}
|
||||
/// Include sections in elf and trampoline and TrapContext and user stack,
|
||||
|
|
|
@ -5,9 +5,9 @@ mod page_table;
|
|||
mod memory_set;
|
||||
|
||||
use page_table::{PageTable, PTEFlags};
|
||||
use address::{VPNRange, StepByOne};
|
||||
pub use address::{PhysAddr, VirtAddr, PhysPageNum, VirtPageNum};
|
||||
pub use frame_allocator::{FrameTracker, frame_alloc};
|
||||
use address::VPNRange;
|
||||
pub use address::{PhysAddr, VirtAddr, PhysPageNum, VirtPageNum, StepByOne};
|
||||
pub use frame_allocator::{FrameTracker, frame_alloc, frame_dealloc,};
|
||||
pub use page_table::{
|
||||
PageTableEntry,
|
||||
translated_byte_buffer,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue