MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / create_new_user_pagetable

Function create_new_user_pagetable

kernel/src/memory.rs:183–199  ·  view source on GitHub ↗

Creates a PageTable containing only kernel pages - Copies the kernel pagetables into a new set of tables - Adds the KernelInfo read-only page Returns ------- - A pointer to the PageTable (virtual address in kernel mapped pages) - The physical address which can be written to cr3

()

Source from the content-addressed store, hash-verified

181/// - The physical address which can be written to cr3
182///
183pub fn create_new_user_pagetable() -> (*mut PageTable, u64) {
184 let memory_info = unsafe {MEMORY_INFO.as_mut().unwrap()};
185
186 // Copy kernel pages
187 let (user_page_table_ptr, user_page_table_physaddr) =
188 copy_pagetables(memory_info.kernel_l4_table);
189
190 // Add KernelInfo page
191 let memory_info = unsafe {MEMORY_INFO.as_mut().unwrap()};
192 let mut mapper = unsafe {
193 OffsetPageTable::new(&mut *user_page_table_ptr,
194 memory_info.physical_memory_offset)};
195 _ = kernel_info::add_to_user_table(&mut mapper,
196 &mut memory_info.frame_allocator);
197
198 (user_page_table_ptr, user_page_table_physaddr)
199}
200
201/// Switch to the specified page table
202///

Callers 1

new_user_threadFunction · 0.85

Calls 2

copy_pagetablesFunction · 0.85
add_to_user_tableFunction · 0.85

Tested by

no test coverage detected