@@ -13,10 +13,9 @@ use free_list::{FreeList, PageLayout, PageRange};
1313use hermit_sync:: SpinMutex ;
1414use memory_addresses:: { PhysAddr , VirtAddr } ;
1515
16- use crate :: arch;
1716#[ cfg( target_arch = "x86_64" ) ]
1817use crate :: arch:: mm:: paging:: PageTableEntryFlagsExt ;
19- use crate :: arch:: mm:: paging:: { BasePageSize , PageSize , PageTableEntryFlags } ;
18+ use crate :: arch:: mm:: paging:: { self , BasePageSize , PageSize , PageTableEntryFlags } ;
2019use crate :: mm:: { FrameAlloc , PageAlloc , PageRangeAllocator } ;
2120
2221bitflags ! {
@@ -67,7 +66,7 @@ pub extern "C" fn sys_mmap(size: usize, prot_flags: MemoryProtection, ret: &mut
6766 flags. execute_disable ( ) ;
6867 }
6968
70- arch :: mm :: paging:: map :: < BasePageSize > ( virtual_address, physical_address, count, flags) ;
69+ paging:: map :: < BasePageSize > ( virtual_address, physical_address, count, flags) ;
7170
7271 * ret = virtual_address. as_mut_ptr ( ) ;
7372
@@ -86,11 +85,8 @@ pub extern "C" fn sys_munmap(ptr: *mut u8, size: usize) -> i32 {
8685 return 0 ;
8786 }
8887
89- if let Some ( physical_address) = arch:: mm:: paging:: virtual_to_physical ( virtual_address) {
90- arch:: mm:: paging:: unmap :: < BasePageSize > (
91- virtual_address,
92- size / BasePageSize :: SIZE as usize ,
93- ) ;
88+ if let Some ( physical_address) = paging:: virtual_to_physical ( virtual_address) {
89+ paging:: unmap :: < BasePageSize > ( virtual_address, size / BasePageSize :: SIZE as usize ) ;
9490 debug ! ( "Unmapping {virtual_address:X} ({size}) -> {physical_address:X}" ) ;
9591
9692 let frame_range =
@@ -127,14 +123,14 @@ pub extern "C" fn sys_mprotect(ptr: *mut u8, size: usize, prot_flags: MemoryProt
127123 let virtual_address = VirtAddr :: from_ptr ( ptr) ;
128124
129125 debug ! ( "Mprotect {virtual_address:X} ({size}) -> {prot_flags:?})" ) ;
130- if let Some ( physical_address) = arch :: mm :: paging:: virtual_to_physical ( virtual_address) {
131- arch :: mm :: paging:: map :: < BasePageSize > ( virtual_address, physical_address, count, flags) ;
126+ if let Some ( physical_address) = paging:: virtual_to_physical ( virtual_address) {
127+ paging:: map :: < BasePageSize > ( virtual_address, physical_address, count, flags) ;
132128 0
133129 } else {
134130 let frame_layout = PageLayout :: from_size ( size) . unwrap ( ) ;
135131 let frame_range = FrameAlloc :: allocate ( frame_layout) . unwrap ( ) ;
136132 let physical_address = PhysAddr :: from ( frame_range. start ( ) ) ;
137- arch :: mm :: paging:: map :: < BasePageSize > ( virtual_address, physical_address, count, flags) ;
133+ paging:: map :: < BasePageSize > ( virtual_address, physical_address, count, flags) ;
138134 0
139135 }
140136}
0 commit comments