xous-rs: implement create_server syscall

The kernel doesn't have this wired up yet, but the syscall works.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-03-14 15:57:58 +08:00
parent c8ccbe27c1
commit 5a1bcf4c21
2 changed files with 13 additions and 4 deletions

View file

@ -10,7 +10,7 @@ pub type MessageSender = usize;
pub type Connection = usize;
/// Server ID
pub type SID = usize;
pub type SID = (usize, usize, usize, usize);
/// Equivalent to a RISC-V Hart ID
pub type CpuID = usize;

View file

@ -1,4 +1,4 @@
use crate::{CpuID, Error, MemoryAddress, PID};
use crate::{CpuID, Error, MemoryAddress, PID, SID};
use num_derive::FromPrimitive;
use num_traits::FromPrimitive;
@ -419,7 +419,7 @@ pub enum Result {
MemoryRange(MemoryRange),
ResumeResult(usize, usize, usize, usize, usize, usize),
ResumeProcess,
ServerID(usize, usize, usize, usize),
ServerID(SID),
UnknownResult(usize, usize, usize, usize, usize, usize, usize),
}
@ -476,7 +476,7 @@ pub fn map_memory(
Err(Error::InternalError)
}
/// Claim the given interrupt for this process.
/// Claim a hardware interrupt for this process.
pub fn claim_interrupt(
irq_no: usize,
callback: fn(irq_no: usize, arg: *mut usize),
@ -493,6 +493,15 @@ pub fn claim_interrupt(
Err(Error::InternalError)
}
/// Create a new server. Returns the new server address.
pub fn create_server() -> core::result::Result<SID, Error> {
let result = rsyscall(SysCall::CreateServer)?;
if let Result::ServerID(sid) = result {
return Ok(sid);
}
Err(Error::InternalError)
}
pub fn rsyscall(call: SysCall) -> SyscallResult {
use core::mem::MaybeUninit;
let mut ret = unsafe { MaybeUninit::uninit().assume_init() };