2020-03-10 04:04:17 +00:00
|
|
|
use core::num::NonZeroUsize;
|
|
|
|
|
|
|
|
|
|
pub type MemoryAddress = NonZeroUsize;
|
|
|
|
|
pub type MemorySize = NonZeroUsize;
|
|
|
|
|
pub type StackPointer = usize;
|
|
|
|
|
pub type MessageId = usize;
|
|
|
|
|
|
|
|
|
|
pub type PID = u8;
|
|
|
|
|
pub type MessageSender = usize;
|
|
|
|
|
pub type Connection = usize;
|
|
|
|
|
|
|
|
|
|
/// Server ID
|
2020-03-14 07:57:58 +00:00
|
|
|
pub type SID = (usize, usize, usize, usize);
|
2020-03-10 04:04:17 +00:00
|
|
|
|
2020-03-17 05:00:06 +00:00
|
|
|
/// Connection ID
|
|
|
|
|
pub type CID = usize;
|
|
|
|
|
|
2020-03-10 04:04:17 +00:00
|
|
|
/// Equivalent to a RISC-V Hart ID
|
|
|
|
|
pub type CpuID = usize;
|
|
|
|
|
|
2020-03-17 02:27:03 +00:00
|
|
|
#[repr(usize)]
|
2020-03-10 04:04:17 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
|
pub enum Error {
|
|
|
|
|
NoError = 0,
|
|
|
|
|
BadAlignment = 1,
|
|
|
|
|
BadAddress = 2,
|
|
|
|
|
OutOfMemory = 3,
|
|
|
|
|
MemoryInUse = 4,
|
|
|
|
|
InterruptNotFound = 5,
|
|
|
|
|
InterruptInUse = 6,
|
|
|
|
|
InvalidString = 7,
|
|
|
|
|
ServerExists = 8,
|
|
|
|
|
ServerNotFound = 9,
|
|
|
|
|
ProcessNotFound = 10,
|
|
|
|
|
ProcessNotChild = 11,
|
|
|
|
|
ProcessTerminated = 12,
|
|
|
|
|
Timeout = 13,
|
2020-03-13 12:33:08 +00:00
|
|
|
InternalError = 14,
|
|
|
|
|
UnhandledSyscall = 15,
|
2020-03-10 04:04:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[repr(C)]
|
|
|
|
|
pub struct Context {
|
|
|
|
|
stack: StackPointer,
|
|
|
|
|
pid: PID,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[repr(C)]
|
2020-03-17 05:00:06 +00:00
|
|
|
#[derive(Debug)]
|
2020-03-10 04:04:17 +00:00
|
|
|
pub struct MemoryMessage {
|
2020-03-17 05:00:06 +00:00
|
|
|
pub id: MessageId,
|
|
|
|
|
pub in_buf: Option<MemoryAddress>,
|
|
|
|
|
pub in_buf_size: Option<MemorySize>,
|
|
|
|
|
pub out_buf: Option<MemoryAddress>,
|
|
|
|
|
pub out_buf_size: Option<MemorySize>,
|
2020-03-10 04:04:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[repr(C)]
|
2020-03-17 05:00:06 +00:00
|
|
|
#[derive(Debug)]
|
2020-03-10 04:04:17 +00:00
|
|
|
pub struct ScalarMessage {
|
2020-03-17 05:00:06 +00:00
|
|
|
pub id: MessageId,
|
|
|
|
|
pub arg1: usize,
|
|
|
|
|
pub arg2: usize,
|
|
|
|
|
pub arg3: usize,
|
|
|
|
|
pub arg4: usize,
|
2020-03-10 04:04:17 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-17 02:27:03 +00:00
|
|
|
#[repr(usize)]
|
2020-03-17 05:00:06 +00:00
|
|
|
#[derive(Debug)]
|
2020-03-10 04:04:17 +00:00
|
|
|
pub enum Message {
|
|
|
|
|
Memory(MemoryMessage),
|
|
|
|
|
Scalar(ScalarMessage),
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-17 02:27:03 +00:00
|
|
|
#[repr(C)]
|
2020-03-17 05:00:06 +00:00
|
|
|
#[derive(Debug)]
|
2020-03-17 02:27:03 +00:00
|
|
|
pub struct MessageEnvelope {
|
2020-03-10 04:04:17 +00:00
|
|
|
sender: MessageSender,
|
|
|
|
|
message: Message,
|
|
|
|
|
}
|