-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
201 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1 @@ | ||
use hal_core::{ | ||
mm::{self, PageAlloc, PageMap}, | ||
AddressRange, Error, | ||
}; | ||
|
||
pub mod pgt48; | ||
|
||
use pgt48::PageTable; | ||
|
||
pub type EntryType = usize; | ||
|
||
pub const PAGE_SIZE: usize = PageTable::PAGE_SIZE; | ||
|
||
use core::cell::OnceCell; | ||
|
||
static mut GPT: OnceCell<&'static mut PageTable> = OnceCell::new(); | ||
|
||
pub fn is_pagetable_installed() -> bool { | ||
unsafe { GPT.get_mut().is_some() } | ||
} | ||
|
||
pub fn prefill_pagetable( | ||
r: impl Iterator<Item = AddressRange>, | ||
rw: impl Iterator<Item = AddressRange>, | ||
rwx: impl Iterator<Item = AddressRange>, | ||
pre_allocated: impl Iterator<Item = AddressRange>, | ||
allocator: &impl PageAlloc, | ||
) -> Result<(), Error> { | ||
let pt = hal_core::mm::prefill_pagetable::<PageTable>(r, rw, rwx, pre_allocated, allocator)?; | ||
|
||
// TODO: put into into the hal_core::Error | ||
unsafe { | ||
if GPT.set(pt).is_err() { | ||
panic!("GPT is already set ?"); | ||
} | ||
}; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn align_up(addr: usize) -> usize { | ||
mm::align_up(addr, PAGE_SIZE) | ||
} | ||
|
||
pub fn align_down(addr: usize) -> usize { | ||
mm::align_down(addr, PAGE_SIZE) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ hal_core = { path = "../hal_core" } | |
modular-bitfield = "0.11" | ||
sbi = "0.2.0" | ||
riscv = "0.10" | ||
log = "0.4" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.