forked from AbleOS/holey-bytes
redone page size thing
This commit is contained in:
parent
a08e0172c9
commit
965a6a2c19
|
@ -206,9 +206,9 @@ impl Iterator for PageSplitter {
|
||||||
ptr as *mut u8,
|
ptr as *mut u8,
|
||||||
perm,
|
perm,
|
||||||
match lvl {
|
match lvl {
|
||||||
0 => 4096,
|
0 => PageSize::Size4K,
|
||||||
1 => 1024_usize.pow(2) * 2,
|
1 => PageSize::Size2M,
|
||||||
2 => 1024_usize.pow(3),
|
2 => PageSize::Size1G,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
},
|
},
|
||||||
self.addr as usize & ((1 << (lvl * 9 + 12)) - 1),
|
self.addr as usize & ((1 << (lvl * 9 + 12)) - 1),
|
||||||
|
@ -220,9 +220,9 @@ impl Iterator for PageSplitter {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
let avail = (size - offset).clamp(0, self.size);
|
let avail = (size as usize - offset).clamp(0, self.size);
|
||||||
self.addr += size as u64;
|
self.addr += size as u64;
|
||||||
self.size = self.size.saturating_sub(size);
|
self.size = self.size.saturating_sub(size as _);
|
||||||
Some(PageSplitResult {
|
Some(PageSplitResult {
|
||||||
ptr: unsafe { base.add(offset) },
|
ptr: unsafe { base.add(offset) },
|
||||||
size: avail,
|
size: avail,
|
||||||
|
@ -230,3 +230,10 @@ impl Iterator for PageSplitter {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
|
pub enum PageSize {
|
||||||
|
Size4K = 4096,
|
||||||
|
Size2M = 1024 * 1024 * 2,
|
||||||
|
Size1G = 1024 * 1024 * 1024,
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue