mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +00:00
xous-rs: add "device" memory flag
This commit is contained in:
parent
e2d34d364c
commit
0f420b7b63
1 changed files with 7 additions and 2 deletions
|
|
@ -7,6 +7,8 @@ pub struct MemoryFlags {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MemoryFlags {
|
impl MemoryFlags {
|
||||||
|
const FLAGS_ALL: usize = 0b111111;
|
||||||
|
|
||||||
/// Free this memory
|
/// Free this memory
|
||||||
pub const FREE: Self = Self { bits: 0b0000_0000 };
|
pub const FREE: Self = Self { bits: 0b0000_0000 };
|
||||||
|
|
||||||
|
|
@ -24,12 +26,15 @@ impl MemoryFlags {
|
||||||
/// Allow the CPU to execute from this page.
|
/// Allow the CPU to execute from this page.
|
||||||
pub const X: Self = Self { bits: 0b0000_1000 };
|
pub const X: Self = Self { bits: 0b0000_1000 };
|
||||||
|
|
||||||
|
/// Marks the page as the 'device' page for on-chip peripherals.
|
||||||
|
pub const DEV: Self = Self { bits: 0b0001_0000 };
|
||||||
|
|
||||||
pub fn bits(&self) -> usize {
|
pub fn bits(&self) -> usize {
|
||||||
self.bits
|
self.bits
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_bits(raw: usize) -> Option<MemoryFlags> {
|
pub fn from_bits(raw: usize) -> Option<MemoryFlags> {
|
||||||
if raw > 16 {
|
if raw > Self::FLAGS_ALL {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(MemoryFlags { bits: raw })
|
Some(MemoryFlags { bits: raw })
|
||||||
|
|
@ -45,7 +50,7 @@ impl MemoryFlags {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all() -> MemoryFlags {
|
pub fn all() -> MemoryFlags {
|
||||||
MemoryFlags { bits: 15 }
|
MemoryFlags { bits: Self::FLAGS_ALL }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue