mirror of
https://github.com/sgmarz/osblog.git
synced 2024-11-24 02:16:19 +04:00
Removed unsafe for id_map_range, added comments
This commit is contained in:
parent
037e7044ac
commit
d81c619e60
@ -87,14 +87,15 @@ extern "C"
|
||||
static KERNEL_STACK: usize;
|
||||
static mut KERNEL_TABLE: usize;
|
||||
}
|
||||
/// Identity map range
|
||||
/// Takes a contiguous allocation of memory and maps it using PAGE_SIZE
|
||||
/// This assumes that start <= end
|
||||
pub fn id_map_range(root: &mut page::Table, start: usize, end: usize, bits: i64) {
|
||||
unsafe {
|
||||
let num_pages = (page::align_val(end, 12) - (start & !(page::PAGE_SIZE-1))) / page::PAGE_SIZE;
|
||||
for i in 0..num_pages {
|
||||
let m = (start & !(page::PAGE_SIZE-1)) + (i << 12);
|
||||
page::map(root, m, m, bits);
|
||||
}
|
||||
}
|
||||
}
|
||||
// ///////////////////////////////////
|
||||
// / ENTRY POINT
|
||||
@ -114,9 +115,9 @@ fn kinit() -> usize {
|
||||
let root_ptr = kmem::get_page_table();
|
||||
let root_u = root_ptr as usize;
|
||||
let mut root = unsafe { root_ptr.as_mut().unwrap() };
|
||||
let t = kmem::get_head() as usize;
|
||||
let kheap_head = kmem::get_head() as usize;
|
||||
let total_pages = kmem::get_num_allocations();
|
||||
id_map_range(&mut root, t, t + (total_pages << 12), page::EntryBits::ReadWrite.val());
|
||||
id_map_range(&mut root, kheap_head, kheap_head + (total_pages << 12), page::EntryBits::ReadWrite.val());
|
||||
unsafe {
|
||||
// Map executable section
|
||||
id_map_range(&mut root, TEXT_START, TEXT_END, page::EntryBits::ReadExecute.val());
|
||||
|
Loading…
Reference in New Issue
Block a user