forked from rcore-os/zCore
Compare commits
1 Commits
master
...
simple-vmo
| Author | SHA1 | Date |
|---|---|---|
|
|
d004ae2ac2 |
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
Loading…
Reference in New Issue