Skip to content

Commit

Permalink
feat: try SO bit
Browse files Browse the repository at this point in the history
Signed-off-by: YdrMaster <[email protected]>
  • Loading branch information
YdrMaster committed Oct 10, 2022
1 parent ae914ce commit 7a8bc0c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions kernel-hal/src/bare/arch/riscv/drivers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ impl IoMapper for IoMapperImpl {
let flags = MMUFlags::READ
| MMUFlags::WRITE
| MMUFlags::HUGE_PAGE
| MMUFlags::DEVICE
| MMUFlags::from_bits_truncate(CachePolicy::UncachedDevice as usize);
if let Err(err) = pt.map_cont(vaddr, size, paddr, flags) {
warn!(
Expand Down
38 changes: 22 additions & 16 deletions kernel-hal/src/bare/arch/riscv/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,20 @@ hal_fn_impl! {
bitflags::bitflags! {
/// Possible flags for a page table entry.
struct PTF: usize {
const VALID = 1 << 0;
const READABLE = 1 << 1;
const WRITABLE = 1 << 2;
const EXECUTABLE = 1 << 3;
const USER = 1 << 4;
const GLOBAL = 1 << 5;
const ACCESSED = 1 << 6;
const DIRTY = 1 << 7;
const RESERVED1 = 1 << 8;
const RESERVED2 = 1 << 9;
const CACHEABLE = 1 << 62;
const VALID = 1 << 0;
const READABLE = 1 << 1;
const WRITABLE = 1 << 2;
const EXECUTABLE = 1 << 3;
const USER = 1 << 4;
const GLOBAL = 1 << 5;
const ACCESSED = 1 << 6;
const DIRTY = 1 << 7;
const RESERVED1 = 1 << 8;
const RESERVED2 = 1 << 9;
#[cfg(feature = "thead-maee")]
const CACHEABLE = 1 << 62;
#[cfg(feature = "thead-maee")]
const STRONG_ORDER = 1 << 63;
}
}

Expand All @@ -163,15 +166,14 @@ impl From<MMUFlags> for PTF {
return PTF::empty();
}
let mut flags = PTF::VALID;
if f.contains(MMUFlags::READ) {
flags |= PTF::READABLE;
if f.contains(MMUFlags::WRITE) {
flags |= PTF::READABLE | PTF::WRITABLE;
#[cfg(feature = "thead-maee")]
{
flags |= PTF::CACHEABLE;
}
}
if f.contains(MMUFlags::WRITE) {
flags |= PTF::READABLE | PTF::WRITABLE;
} else if f.contains(MMUFlags::READ) {
flags |= PTF::READABLE;
#[cfg(feature = "thead-maee")]
{
flags |= PTF::CACHEABLE;
Expand All @@ -183,6 +185,10 @@ impl From<MMUFlags> for PTF {
if f.contains(MMUFlags::USER) {
flags |= PTF::USER;
}
#[cfg(feature = "thead-maee")]
if f.contains(MMUFlags::DEVICE) {
flags |= PTF::STRONG_ORDER;
}
flags
}
}
Expand Down

0 comments on commit 7a8bc0c

Please sign in to comment.