mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
kernel: riscv: mark address_available() as false when shared
When a page is shared, only report an address as being available when we receive a `BadAddress` error when doing the translation. Otherwise, assume it is in use. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
3b85392877
commit
e9a1da25b0
1 changed files with 8 additions and 1 deletions
|
|
@ -597,5 +597,12 @@ pub fn virt_to_phys(virt: usize) -> Result<usize, xous_kernel::Error> {
|
||||||
|
|
||||||
/// Determine whether a virtual address has been mapped
|
/// Determine whether a virtual address has been mapped
|
||||||
pub fn address_available(virt: usize) -> bool {
|
pub fn address_available(virt: usize) -> bool {
|
||||||
virt_to_phys(virt).is_err()
|
if let Err(e) = virt_to_phys(virt) {
|
||||||
|
// If the value is a `BadAddress`, then that means that address is not valid
|
||||||
|
// and is therefore available
|
||||||
|
e == xous_kernel::Error::BadAddress
|
||||||
|
} else {
|
||||||
|
// If the address is not an error, then it is not available and shouldn't be used.
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue