Expand description
The memory “space” as in user space or kernel space
Fields
page_table: PageTable
areas: Vec<MapArea>
The mapped area. Segments are implemented using this mechanism. In other words, they may be considered a subset of MapArea. Yet, other purposes may exist in this struct, such as file mapping.
heap_area_idx: Option<usize>
The pointer to store the heap area in order to ease the heap lookup and allocation/CoW.
Implementations
Getter to the token of current memory space, or “this” page table.
pub fn insert_framed_area(
&mut self,
start_va: VirtAddr,
end_va: VirtAddr,
permission: MapPermission
)
pub fn insert_framed_area(
&mut self,
start_va: VirtAddr,
end_va: VirtAddr,
permission: MapPermission
)
Insert an anonymous segment containing the space between start_va.floor()
to end_va.ceil()
The space is allocated and added to the current MemorySet.
Prerequisite
Assuming no conflicts. In other words, the space is NOT checked for space validity or overlap. It is merely mapped, pushed into the current memory set. Since CoW is implemented, the space is NOT allocated until a page fault is triggered.
pub fn insert_program_area(
&mut self,
start_va: VirtAddr,
end_va: VirtAddr,
permission: MapPermission
) -> Option<MapArea>
pub fn insert_program_area(
&mut self,
start_va: VirtAddr,
end_va: VirtAddr,
permission: MapPermission
) -> Option<MapArea>
Insert an anonymous segment containing the space between start_va.floor()
to end_va.ceil()
The space is allocated and added to the current MemorySet.
Prerequisite
Assuming no conflicts. In other words, the space is NOT checked for space validity or overlap. It is merely mapped, pushed into the current memory set. Since CoW is implemented, the space is NOT allocated until a page fault is triggered.
Warning
if the start_vpn does not match any area’s start_vpn, then nothing is done and return Ok(())
Push a not-yet-mapped map_area into current MemorySet and copy the data into it if any, allocating the needed memory for the map.
Push the map area into the memory set without copying or allocation.
The REAL handler to page fault. Handles all types of page fault:(In regex:) “(Store|Load|Instruction)(Page)?Fault” Checks the permission to decide whether to copy.
Mention that trampoline is not collected by areas.
Can be accessed in user mode.
Create an empty kernel space. Without kernel stacks. (Is it done with .bss?)
Include sections in elf and trampoline and TrapContext and user stack, also returns user_sp and entry point.
Translate the vpn
into its corresponding Some(PageTableEntry)
in the current memory set if exists
None
is returned if nothing is found.