Add user attribute to pages
This commit is contained in:
parent
39cb3e7414
commit
f362616fdc
@ -3,6 +3,7 @@ unsafe fn load_cr3(value: usize) {
|
||||
}
|
||||
|
||||
const PAGE_HUGE: u64 = 1 << 7;
|
||||
const PAGE_USER: u64 = 1 << 2;
|
||||
const PAGE_WRITE: u64 = 1 << 1;
|
||||
const PAGE_PRESENT: u64 = 1 << 0;
|
||||
|
||||
@ -13,18 +14,18 @@ static mut TABLES: [u64; 512 * 6] = [0; 512 * 6];
|
||||
unsafe fn setup_tables() {
|
||||
for i in 0 .. 512 * 4 {
|
||||
// pd[i] = 2MiB block
|
||||
TABLES[i + 512 * 2] = (i << 21) as u64 | PAGE_HUGE | PAGE_WRITE | PAGE_PRESENT;
|
||||
TABLES[i + 512 * 2] = (i << 21) as u64 | PAGE_HUGE | PAGE_WRITE | PAGE_PRESENT | PAGE_USER;
|
||||
}
|
||||
|
||||
for i in 0 .. 4 {
|
||||
// pdpt[i] = pd_i
|
||||
TABLES[512 + i] = (&TABLES[i * 512 + 512 * 2]) as *const _ as u64 | PAGE_WRITE | PAGE_PRESENT;
|
||||
TABLES[512 + i] = (&TABLES[i * 512 + 512 * 2]) as *const _ as u64 | PAGE_WRITE | PAGE_PRESENT | PAGE_USER;
|
||||
}
|
||||
|
||||
// pml4[0] = PRESENT | pdpt
|
||||
TABLES[0] = (&TABLES[512]) as *const _ as u64 | PAGE_WRITE | PAGE_PRESENT;
|
||||
TABLES[0] = (&TABLES[512]) as *const _ as u64 | PAGE_WRITE | PAGE_PRESENT | PAGE_USER;
|
||||
// pml4[510] = PRESENT | pdpt
|
||||
TABLES[510] = (&TABLES[512]) as *const _ as u64 | PAGE_WRITE | PAGE_PRESENT;
|
||||
TABLES[510] = (&TABLES[512]) as *const _ as u64 | PAGE_WRITE | PAGE_PRESENT | PAGE_USER;
|
||||
}
|
||||
|
||||
pub fn setup_upper() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user