Compare commits

...

1 Commits

Author SHA1 Message Date
Runji Wang d004ae2ac2 vmo: recover simple version VMO-paged 2021-04-04 23:20:11 +08:00
4 changed files with 106 additions and 958 deletions

View File

@ -184,12 +184,20 @@ impl PhysFrame {
#[linkage = "weak"]
#[export_name = "hal_frame_alloc_contiguous"]
pub fn alloc_contiguous_base(_size: usize, _align_log2: usize) -> Option<PhysAddr> {
fn alloc_contiguous_base(_size: usize, _align_log2: usize) -> Option<PhysAddr> {
unimplemented!()
}
pub fn alloc_contiguous(size: usize, align_log2: usize) -> Vec<Self> {
pub fn alloc_zeroed() -> Option<Self> {
Self::alloc().map(|f| {
pmem_zero(f.addr(), PAGE_SIZE);
f
})
}
pub fn alloc_contiguous_zeroed(size: usize, align_log2: usize) -> Vec<Self> {
PhysFrame::alloc_contiguous_base(size, align_log2).map_or(Vec::new(), |base| {
pmem_zero(base, size * PAGE_SIZE);
(0..size)
.map(|i| PhysFrame {
paddr: base + i * PAGE_SIZE,

View File

@ -32,6 +32,13 @@ pub mod defs {
WriteCombining = 3,
}
}
impl Default for CachePolicy {
fn default() -> Self {
CachePolicy::Cached
}
}
pub const CACHE_POLICY_MASK: u32 = 3;
pub type PhysAddr = usize;

View File

@ -880,32 +880,6 @@ impl VmMapping {
}
}
/// Remove WRITE flag from the mappings for Copy-on-Write.
pub(super) fn range_change(&self, offset: usize, len: usize, op: RangeChangeOp) {
let inner = self.inner.try_lock();
// If we are already locked, we are handling page fault/map range
// In this case we can just ignore the operation since we will update the mapping later
if let Some(inner) = inner {
let start = offset.max(inner.vmo_offset);
let end = (inner.vmo_offset + inner.size / PAGE_SIZE).min(offset + len);
if !(start..end).is_empty() {
let mut pg_table = self.page_table.lock();
for i in (start - inner.vmo_offset)..(end - inner.vmo_offset) {
match op {
RangeChangeOp::RemoveWrite => {
let mut new_flag = inner.flags[i];
new_flag.remove(MMUFlags::WRITE);
pg_table
.protect(inner.addr + i * PAGE_SIZE, new_flag)
.unwrap()
}
RangeChangeOp::Unmap => pg_table.unmap(inner.addr + i * PAGE_SIZE).unwrap(),
}
}
}
}
}
/// Handle page fault happened on this VmMapping.
pub(crate) fn handle_page_fault(&self, vaddr: VirtAddr, access_flags: MMUFlags) -> ZxResult {
let vaddr = round_down_pages(vaddr);

File diff suppressed because it is too large Load Diff