From 5a1bcf4c2120b30b38d5f006083295c44fa98e3e Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Sat, 14 Mar 2020 15:57:58 +0800 Subject: [PATCH] xous-rs: implement `create_server` syscall The kernel doesn't have this wired up yet, but the syscall works. Signed-off-by: Sean Cross --- xous-rs/src/definitions.rs | 2 +- xous-rs/src/syscall.rs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/xous-rs/src/definitions.rs b/xous-rs/src/definitions.rs index eabf60d66..47875ebdf 100644 --- a/xous-rs/src/definitions.rs +++ b/xous-rs/src/definitions.rs @@ -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; diff --git a/xous-rs/src/syscall.rs b/xous-rs/src/syscall.rs index 58928a220..b620ec4f9 100644 --- a/xous-rs/src/syscall.rs +++ b/xous-rs/src/syscall.rs @@ -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 { + 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() };