Skip to content

Commit eddf194

Browse files
MivikAsakuraMizu
authored andcommitted
feat: add remap
1 parent ac7d1c8 commit eddf194

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

page_table_multiarch/src/bits64.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,26 @@ impl<M: PagingMetaData, PTE: GenericPTE, H: PagingHandler> PageTable64<M, PTE, H
100100
Ok((size, TlbFlush::new(vaddr)))
101101
}
102102

103+
/// Remap the mapping starts with `vaddr`, updates both the physical address
104+
/// and flags.
105+
///
106+
/// Returns the page size of the mapping.
107+
///
108+
/// Returns [`Err(PagingError::NotMapped)`](PagingError::NotMapped) if the
109+
/// intermediate level tables of the mapping is not present.
110+
pub fn remap(
111+
&mut self,
112+
vaddr: M::VirtAddr,
113+
paddr: PhysAddr,
114+
flags: MappingFlags,
115+
) -> PagingResult<PageSize> {
116+
let (entry, size) = self.get_entry_mut(vaddr)?;
117+
entry.set_paddr(paddr);
118+
entry.set_flags(flags, size.is_huge());
119+
M::flush_tlb(Some(vaddr));
120+
Ok(size)
121+
}
122+
103123
/// Updates the flags of the mapping starts with `vaddr`.
104124
///
105125
/// Returns the page size of the mapping.

0 commit comments

Comments
 (0)