File tree Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ impl Write for Writer {
32
32
#[ panic_handler]
33
33
#[ cfg( not( test) ) ]
34
34
pub fn panic ( info : & core:: panic:: PanicInfo ) -> ! {
35
- let _ = writeln ! ( Writer , "\n PANIC: {}" , info ) ;
35
+ let _ = writeln ! ( Writer , "\n PANIC: {info}" ) ;
36
36
37
37
loop {
38
38
unsafe {
Original file line number Diff line number Diff line change @@ -61,7 +61,8 @@ pub fn enter_long_mode_and_jump_to_stage_4(info: &mut BiosInfo) {
61
61
// enter endless loop in case 4th stage returns
62
62
"2:" ,
63
63
"jmp 2b" ,
64
- out( "eax" ) _
64
+ out( "eax" ) _,
65
+ options( noreturn) ,
65
66
) ;
66
67
}
67
68
}
Original file line number Diff line number Diff line change @@ -15,14 +15,13 @@ fn create_mappings() {
15
15
let l4 = unsafe { LEVEL_4 . get_mut ( ) } ;
16
16
let l3 = unsafe { LEVEL_3 . get_mut ( ) } ;
17
17
let l2s = unsafe { LEVEL_2 . get_mut ( ) } ;
18
- let common_flags = 0b11 ;
18
+ let common_flags = 0b11 ; // PRESENT | WRITEABLE
19
19
l4. entries [ 0 ] = ( l3 as * mut PageTable as u64 ) | common_flags;
20
- for i in 0 ..l2s. len ( ) {
21
- let l2 = & mut l2s[ i] ;
20
+ for ( i, l2) in l2s. iter_mut ( ) . enumerate ( ) {
22
21
l3. entries [ i] = ( l2 as * mut PageTable as u64 ) | common_flags;
23
22
let offset = u64:: try_from ( i) . unwrap ( ) * 1024 * 1024 * 1024 ;
24
- for j in 0 .. 512 {
25
- l2 . entries [ j ] =
23
+ for ( j , entry ) in l2 . entries . iter_mut ( ) . enumerate ( ) {
24
+ * entry =
26
25
( offset + u64:: try_from ( j) . unwrap ( ) * ( 2 * 1024 * 1024 ) ) | common_flags | ( 1 << 7 ) ;
27
26
}
28
27
}
Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ fn create_page_tables(frame_allocator: &mut impl FrameAllocator<Size4KiB>) -> Pa
153
153
let ( kernel_page_table, kernel_level_4_frame) = {
154
154
// get an unused frame for new level 4 page table
155
155
let frame: PhysFrame = frame_allocator. allocate_frame ( ) . expect ( "no unused frames" ) ;
156
- log:: info!( "New page table at: {:#?}" , & frame ) ;
156
+ log:: info!( "New page table at: {frame :#?}" ) ;
157
157
// get the corresponding virtual address
158
158
let addr = phys_offset + frame. start_address ( ) . as_u64 ( ) ;
159
159
// initialize a new page table
@@ -215,7 +215,7 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
215
215
. get ( )
216
216
. map ( |l| l. force_unlock ( ) )
217
217
} ;
218
- log:: error!( "{}" , info ) ;
218
+ log:: error!( "{info}" ) ;
219
219
loop {
220
220
unsafe { core:: arch:: asm!( "cli; hlt" ) } ;
221
221
}
You can’t perform that action at this time.
0 commit comments