mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
xous: add Connect syscall
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
ae473b5aa7
commit
646cf9340e
2 changed files with 18 additions and 5 deletions
|
|
@ -46,7 +46,7 @@ pub struct Context {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
/// A struct describing memory that is passed between processes.
|
||||
/// The `buf` value will get translated as necessary.
|
||||
pub struct MemoryMessage {
|
||||
|
|
@ -72,7 +72,7 @@ pub struct MemoryMessage {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
/// A simple scalar message. This is similar to a `move` message.
|
||||
pub struct ScalarMessage {
|
||||
pub id: MessageId,
|
||||
|
|
@ -83,7 +83,7 @@ pub struct ScalarMessage {
|
|||
}
|
||||
|
||||
#[repr(usize)]
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Message {
|
||||
MutableBorrow(MemoryMessage),
|
||||
ImmutableBorrow(MemoryMessage),
|
||||
|
|
|
|||
|
|
@ -143,7 +143,9 @@ pub enum SysCall {
|
|||
/// This process will now wait for an event such as an IRQ or Message.
|
||||
WaitEvent,
|
||||
|
||||
/// This context will now wait for a message with the given server ID
|
||||
/// This context will now wait for a message with the given server ID..
|
||||
/// You can set up a pool by having multiple threads call `WaitMessage`
|
||||
/// with the same SID.
|
||||
WaitMessage(SID),
|
||||
|
||||
/// Stop running the given process.
|
||||
|
|
@ -223,7 +225,7 @@ pub enum SysCall {
|
|||
/// * **ProcessNotChild**: The given process was not a child process, and
|
||||
/// therefore couldn't be resumed.
|
||||
/// * **ProcessTerminated**: The process has crashed.
|
||||
SwitchTo(PID, usize /* thread ID */),
|
||||
SwitchTo(PID, usize /* context ID */),
|
||||
|
||||
/// Create a new Server
|
||||
///
|
||||
|
|
@ -564,6 +566,7 @@ pub enum Result {
|
|||
ResumeProcess,
|
||||
ServerID(SID),
|
||||
ConnectionID(CID),
|
||||
Message(Message),
|
||||
UnknownResult(usize, usize, usize, usize, usize, usize, usize),
|
||||
}
|
||||
|
||||
|
|
@ -655,6 +658,16 @@ pub fn create_server(name: usize) -> core::result::Result<SID, Error> {
|
|||
Err(Error::InternalError)
|
||||
}
|
||||
|
||||
/// Connect to a server with the given SID
|
||||
pub fn connect(server: SID) -> core::result::Result<CID, Error> {
|
||||
let result = rsyscall(SysCall::Connect(server))?;
|
||||
if let Result::ConnectionID(cid) = result {
|
||||
Ok(cid)
|
||||
} else {
|
||||
Err(Error::InternalError)
|
||||
}
|
||||
}
|
||||
|
||||
/// Suspend the current process until a message is received. This thread will
|
||||
/// block until a message is received.
|
||||
///
|
||||
|
|
|
|||
Loading…
Reference in a new issue