|
1 | 1 | use super::{frame_alloc, FrameTracker}; |
2 | 2 | use super::{PTEFlags, PageTable, PageTableEntry}; |
3 | 3 | use super::{PhysAddr, PhysPageNum, VirtAddr, VirtPageNum}; |
4 | | -use super::{StepByOne, VPNRange}; |
| 4 | +use super::{StepByOne, VPNRange, PPNRange}; |
5 | 5 | use crate::config::{MEMORY_END, MMIO, PAGE_SIZE, TRAMPOLINE}; |
6 | 6 | use crate::sync::UPIntrFreeCell; |
7 | 7 | use alloc::collections::BTreeMap; |
@@ -78,6 +78,10 @@ impl MemorySet { |
78 | 78 | } |
79 | 79 | self.areas.push(map_area); |
80 | 80 | } |
| 81 | + pub fn push_noalloc(&mut self, mut map_area: MapArea, ppn_range: PPNRange) { |
| 82 | + map_area.map_noalloc(&mut self.page_table, ppn_range); |
| 83 | + self.areas.push(map_area); |
| 84 | + } |
81 | 85 | /// Mention that trampoline is not collected by areas. |
82 | 86 | fn map_trampoline(&mut self) { |
83 | 87 | self.page_table.map( |
@@ -301,6 +305,14 @@ impl MapArea { |
301 | 305 | self.map_one(page_table, vpn); |
302 | 306 | } |
303 | 307 | } |
| 308 | + pub fn map_noalloc(&mut self, page_table: &mut PageTable,ppn_range:PPNRange) { |
| 309 | + for (vpn,ppn) in core::iter::zip(self.vpn_range,ppn_range) { |
| 310 | + self.data_frames.insert(vpn, FrameTracker::new_nowrite(ppn)); |
| 311 | + let pte_flags = PTEFlags::from_bits(self.map_perm.bits).unwrap(); |
| 312 | + page_table.map(vpn, ppn, pte_flags); |
| 313 | + } |
| 314 | + } |
| 315 | + |
304 | 316 | pub fn unmap(&mut self, page_table: &mut PageTable) { |
305 | 317 | for vpn in self.vpn_range { |
306 | 318 | self.unmap_one(page_table, vpn); |
|
0 commit comments