@@ -22,7 +22,9 @@ pub struct FrameAlloc;
2222
2323impl PageRangeAllocator for FrameAlloc {
2424 unsafe fn init ( ) {
25- init ( ) ;
25+ unsafe {
26+ init ( ) ;
27+ }
2628 }
2729
2830 fn allocate ( layout : PageLayout ) -> Result < PageRange , AllocError > {
@@ -99,7 +101,7 @@ pub unsafe fn map_frame_range(frame_range: PageRange) {
99101 }
100102}
101103
102- fn detect_from_fdt ( ) -> Result < ( ) , ( ) > {
104+ unsafe fn detect_from_fdt ( ) -> Result < ( ) , ( ) > {
103105 let fdt = env:: fdt ( ) . ok_or ( ( ) ) ?;
104106
105107 let all_regions = fdt
@@ -198,7 +200,7 @@ impl PageRangeExt for PageRange {
198200}
199201
200202#[ cfg( any( target_arch = "aarch64" , target_arch = "riscv64" ) ) ]
201- fn detect_from_limits ( ) -> Result < ( ) , ( ) > {
203+ unsafe fn detect_from_limits ( ) -> Result < ( ) , ( ) > {
202204 let limit = crate :: arch:: kernel:: get_limit ( ) ;
203205 if limit == 0 {
204206 return Err ( ( ) ) ;
@@ -220,19 +222,19 @@ fn detect_from_limits() -> Result<(), ()> {
220222 Ok ( ( ) )
221223}
222224
223- fn init ( ) {
225+ unsafe fn init ( ) {
224226 if env:: is_uefi ( ) && DeviceAlloc . phys_offset ( ) != VirtAddr :: zero ( ) {
225227 let start = DeviceAlloc . phys_offset ( ) ;
226228 let count = DeviceAlloc . phys_offset ( ) . as_u64 ( ) / HugePageSize :: SIZE ;
227229 let count = usize:: try_from ( count) . unwrap ( ) ;
228230 paging:: unmap :: < HugePageSize > ( start, count) ;
229231 }
230232
231- if let Err ( _err) = detect_from_fdt ( ) {
233+ if let Err ( _err) = unsafe { detect_from_fdt ( ) } {
232234 cfg_if:: cfg_if! {
233235 if #[ cfg( any( target_arch = "aarch64" , target_arch = "riscv64" ) ) ] {
234236 error!( "Could not detect physical memory from FDT" ) ;
235- detect_from_limits( ) . unwrap( ) ;
237+ unsafe { detect_from_limits( ) . unwrap( ) ; }
236238 } else {
237239 panic!( "Could not detect physical memory from FDT" ) ;
238240 }
0 commit comments