From deb5c972c2240a3e1f05c940ddb9b9bdf9ac550b Mon Sep 17 00:00:00 2001 From: Stephen Marz Date: Wed, 9 Oct 2019 21:36:54 -0400 Subject: [PATCH] Make id_map_range easier to read --- risc_v/ch3/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/risc_v/ch3/src/lib.rs b/risc_v/ch3/src/lib.rs index 4c56d01..a7c7371 100755 --- a/risc_v/ch3/src/lib.rs +++ b/risc_v/ch3/src/lib.rs @@ -97,11 +97,12 @@ pub fn id_map_range(root: &mut page::Table, end: usize, bits: i64) { + let start_aligned = start & !(page::PAGE_SIZE - 1); let num_pages = (page::align_val(end, 12) - - (start & !(page::PAGE_SIZE - 1))) + - start_aligned) / page::PAGE_SIZE; for i in 0..num_pages { - let m = (start & !(page::PAGE_SIZE - 1)) + (i << 12); + let m = start_aligned + (i << 12); page::map(root, m, m, bits); } }