mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-08 04:56:43 +00:00
xous-rs: add claim_interrupt wrapper
Rather than calling the raw function, add a wrapper for programs to use. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
7a3e038e6b
commit
9508201db9
2 changed files with 22 additions and 5 deletions
|
|
@ -203,7 +203,7 @@ pub fn handle(call: SysCall) -> xous::Result {
|
|||
mm.unmap_page(page as *mut usize)
|
||||
.expect("unable to unmap page");
|
||||
}
|
||||
xous::Result::ReturnResult
|
||||
xous::Result::Ok
|
||||
}
|
||||
SysCall::SwitchTo(pid, context) => {
|
||||
if context as usize != 0 {
|
||||
|
|
@ -216,7 +216,7 @@ pub fn handle(call: SysCall) -> xous::Result {
|
|||
}
|
||||
SysCall::ClaimInterrupt(no, callback, arg) => {
|
||||
interrupt_claim(no, pid as definitions::PID, callback, arg)
|
||||
.map(|_| xous::Result::ReturnResult)
|
||||
.map(|_| xous::Result::Ok)
|
||||
.unwrap_or_else(|e| xous::Result::Error(e))
|
||||
}
|
||||
SysCall::Yield => {
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ pub struct MemoryRange {
|
|||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Result {
|
||||
ReturnResult,
|
||||
Ok,
|
||||
Error(Error),
|
||||
MemoryAddress(*mut u8),
|
||||
MemoryRange(MemoryRange),
|
||||
|
|
@ -463,7 +463,7 @@ pub fn map_memory(
|
|||
virt: Option<MemoryAddress>,
|
||||
size: usize,
|
||||
flags: MemoryFlags,
|
||||
) -> core::result::Result<crate::MemoryRange, crate::Error> {
|
||||
) -> core::result::Result<MemoryRange, Error> {
|
||||
let result = rsyscall(SysCall::MapMemory(
|
||||
phys.map(|x| x.get()).unwrap_or(0) as *mut usize,
|
||||
virt.map(|x| x.get()).unwrap_or(0) as *mut usize,
|
||||
|
|
@ -473,7 +473,24 @@ pub fn map_memory(
|
|||
if let Result::MemoryRange(range) = result {
|
||||
return Ok(range);
|
||||
}
|
||||
Err(crate::Error::InternalError)
|
||||
Err(Error::InternalError)
|
||||
}
|
||||
|
||||
/// Claim the given interrupt for this process.
|
||||
pub fn claim_interrupt(
|
||||
irq_no: usize,
|
||||
callback: fn(irq_no: usize, arg: *mut usize),
|
||||
arg: *mut usize,
|
||||
) -> core::result::Result<(), Error> {
|
||||
let result = rsyscall(SysCall::ClaimInterrupt(
|
||||
irq_no,
|
||||
callback as *mut usize,
|
||||
arg as *mut usize,
|
||||
))?;
|
||||
if let Result::Ok = result {
|
||||
return Ok(());
|
||||
}
|
||||
Err(Error::InternalError)
|
||||
}
|
||||
|
||||
pub fn rsyscall(call: SysCall) -> SyscallResult {
|
||||
|
|
|
|||
Loading…
Reference in a new issue