Skip to content

Commit bee20ac

Browse files
phil-oppFreax13
andauthored
Apply suggestions from code review
Co-authored-by: Tom Dohrmann <[email protected]>
1 parent b00bf34 commit bee20ac

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

bios/stage-2/src/screen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl Write for Writer {
3232
#[panic_handler]
3333
#[cfg(not(test))]
3434
pub fn panic(info: &core::panic::PanicInfo) -> ! {
35-
let _ = writeln!(Writer, "\nPANIC: {}", info);
35+
let _ = writeln!(Writer, "\nPANIC: {info}");
3636

3737
loop {
3838
unsafe {

bios/stage-3/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ pub fn enter_long_mode_and_jump_to_stage_4(info: &mut BiosInfo) {
6161
// enter endless loop in case 4th stage returns
6262
"2:",
6363
"jmp 2b",
64-
out("eax") _
64+
out("eax") _,
65+
options(noreturn),
6566
);
6667
}
6768
}

bios/stage-3/src/paging.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ fn create_mappings() {
1515
let l4 = unsafe { LEVEL_4.get_mut() };
1616
let l3 = unsafe { LEVEL_3.get_mut() };
1717
let l2s = unsafe { LEVEL_2.get_mut() };
18-
let common_flags = 0b11;
18+
let common_flags = 0b11; // PRESENT | WRITEABLE
1919
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() {
2221
l3.entries[i] = (l2 as *mut PageTable as u64) | common_flags;
2322
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 =
2625
(offset + u64::try_from(j).unwrap() * (2 * 1024 * 1024)) | common_flags | (1 << 7);
2726
}
2827
}

bios/stage-4/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn create_page_tables(frame_allocator: &mut impl FrameAllocator<Size4KiB>) -> Pa
153153
let (kernel_page_table, kernel_level_4_frame) = {
154154
// get an unused frame for new level 4 page table
155155
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:#?}");
157157
// get the corresponding virtual address
158158
let addr = phys_offset + frame.start_address().as_u64();
159159
// initialize a new page table
@@ -215,7 +215,7 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
215215
.get()
216216
.map(|l| l.force_unlock())
217217
};
218-
log::error!("{}", info);
218+
log::error!("{info}");
219219
loop {
220220
unsafe { core::arch::asm!("cli; hlt") };
221221
}

0 commit comments

Comments
 (0)