mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
xous: add UnmapMemory syscall
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
abce9eb0c1
commit
4be5f4031b
1 changed files with 31 additions and 0 deletions
|
|
@ -79,6 +79,12 @@ pub enum SysCall {
|
||||||
MemoryFlags, /* flags */
|
MemoryFlags, /* flags */
|
||||||
),
|
),
|
||||||
|
|
||||||
|
/// Release the memory back to the operating system.
|
||||||
|
///
|
||||||
|
/// # Errors
|
||||||
|
///
|
||||||
|
UnmapMemory(*mut usize /* virt */, usize /* region size */),
|
||||||
|
|
||||||
/// Sets the offset and size of a given memory region. This call may only
|
/// Sets the offset and size of a given memory region. This call may only
|
||||||
/// be made by processes that have not yet started, or processes that have a
|
/// be made by processes that have not yet started, or processes that have a
|
||||||
/// PPID of 1. Care must be taken to ensure this region doesn't run into
|
/// PPID of 1. Care must be taken to ensure this region doesn't run into
|
||||||
|
|
@ -306,6 +312,7 @@ enum SysCallNumber {
|
||||||
SendMessage = 16,
|
SendMessage = 16,
|
||||||
Connect = 17,
|
Connect = 17,
|
||||||
SpawnThread = 18,
|
SpawnThread = 18,
|
||||||
|
UnmapMemory = 19,
|
||||||
Invalid,
|
Invalid,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -330,6 +337,16 @@ impl SysCall {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
],
|
],
|
||||||
|
SysCall::UnmapMemory(a1, a2) => [
|
||||||
|
SysCallNumber::UnmapMemory as usize,
|
||||||
|
a1 as usize,
|
||||||
|
a2,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
],
|
||||||
SysCall::Yield => [SysCallNumber::Yield as usize, 0, 0, 0, 0, 0, 0, 0],
|
SysCall::Yield => [SysCallNumber::Yield as usize, 0, 0, 0, 0, 0, 0, 0],
|
||||||
SysCall::WaitEvent => [SysCallNumber::WaitEvent as usize, 0, 0, 0, 0, 0, 0, 0],
|
SysCall::WaitEvent => [SysCallNumber::WaitEvent as usize, 0, 0, 0, 0, 0, 0, 0],
|
||||||
SysCall::ReceiveMessage(sid) => [
|
SysCall::ReceiveMessage(sid) => [
|
||||||
|
|
@ -513,6 +530,7 @@ impl SysCall {
|
||||||
a3,
|
a3,
|
||||||
MemoryFlags::from_bits(a4).ok_or(InvalidSyscall {})?,
|
MemoryFlags::from_bits(a4).ok_or(InvalidSyscall {})?,
|
||||||
),
|
),
|
||||||
|
Some(SysCallNumber::UnmapMemory) => SysCall::UnmapMemory(a1 as *mut usize, a2),
|
||||||
Some(SysCallNumber::Yield) => SysCall::Yield,
|
Some(SysCallNumber::Yield) => SysCall::Yield,
|
||||||
Some(SysCallNumber::WaitEvent) => SysCall::WaitEvent,
|
Some(SysCallNumber::WaitEvent) => SysCall::WaitEvent,
|
||||||
Some(SysCallNumber::ReceiveMessage) => SysCall::ReceiveMessage((a1, a2, a3, a4)),
|
Some(SysCallNumber::ReceiveMessage) => SysCall::ReceiveMessage((a1, a2, a3, a4)),
|
||||||
|
|
@ -676,6 +694,19 @@ pub fn map_memory(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Map the given physical address to the given virtual address.
|
||||||
|
/// The `size` field must be page-aligned.
|
||||||
|
pub fn unmap_memory(virt: MemoryAddress, size: usize) -> core::result::Result<(), Error> {
|
||||||
|
let result = rsyscall(SysCall::UnmapMemory(virt.get() as *mut usize, size))?;
|
||||||
|
if let Result::Ok = result {
|
||||||
|
Ok(())
|
||||||
|
} else if let Result::Error(e) = result {
|
||||||
|
Err(e)
|
||||||
|
} else {
|
||||||
|
Err(Error::InternalError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Claim a hardware interrupt for this process.
|
/// Claim a hardware interrupt for this process.
|
||||||
pub fn claim_interrupt(
|
pub fn claim_interrupt(
|
||||||
irq_no: usize,
|
irq_no: usize,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue