-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(syscalls): more syscalls and unimplemented handlers
- Loading branch information
1 parent
be79ab5
commit 8cfd538
Showing
3 changed files
with
246 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,67 @@ | ||
use a653rs::bindings::*; | ||
use serde::de::DeserializeOwned; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::SyscallType; | ||
|
||
pub trait Syscall<'params> { | ||
const TY: SyscallType; | ||
const TY: super::SyscallType; | ||
type Params: Serialize + Deserialize<'params>; | ||
type Returns: Serialize + DeserializeOwned; | ||
} | ||
|
||
pub struct SendQueuingMessage; | ||
impl<'msg> Syscall<'msg> for SendQueuingMessage { | ||
const TY: SyscallType = SyscallType::SendQueuingMessage; | ||
type Params = &'msg [u8]; | ||
type Returns = (); | ||
/// `'params` is available as a lifetime for parameter types | ||
macro_rules! define_syscall { | ||
($name:ident: |$params:ty| -> $returns:ty) => { | ||
pub struct $name; | ||
impl<'params> Syscall<'params> for $name { | ||
const TY: super::SyscallType = super::SyscallType::$name; | ||
type Params = $params; | ||
type Returns = $returns; | ||
} | ||
}; | ||
} | ||
|
||
pub struct ReceiveQueuingMessage; | ||
impl<'de> Syscall<'de> for ReceiveQueuingMessage { | ||
const TY: SyscallType = SyscallType::ReceiveQueuingMessage; | ||
type Params = (); | ||
type Returns = Vec<u8>; | ||
macro_rules! define_multiple_syscalls { | ||
($($name:ident: |$params:ty| -> $returns:ty),* $(,)?) => { | ||
$(define_syscall!($name: |$params| -> $returns);)* | ||
} | ||
} | ||
|
||
// ApexPartitionP4 | ||
define_multiple_syscalls!( | ||
GetPartitionStatus: |()| -> ApexPartitionStatus, | ||
SetPartitionMode: |OperatingMode| -> (), | ||
); | ||
|
||
// ApexProcessP4 | ||
define_multiple_syscalls!( | ||
// CreateProcess: |&'params ApexProcessAttribute| -> ProcessId, | ||
Start: |ProcessId| -> (), | ||
); | ||
|
||
// ApexSamplingPortP4 | ||
define_multiple_syscalls!( | ||
CreateSamplingPort: |(SamplingPortName, MessageSize, PortDirection, ApexSystemTime)| -> SamplingPortId, | ||
WriteSamplingMessage: |(SamplingPortId, &'params [ApexByte])| -> (), | ||
ReadSamplingMessage: |SamplingPortId| -> (Validity, Vec<u8>), | ||
); | ||
|
||
// ApexQueuingPortP4 | ||
define_multiple_syscalls!( | ||
CreateQueuingPort: |(QueuingPortName, MessageSize, MessageRange, PortDirection, QueuingDiscipline)| -> QueuingPortId, | ||
SendQueuingMessage: |(QueuingPortId, &'params [ApexByte], ApexSystemTime)| -> (), | ||
ReceiveQueuingMessage: |(QueuingPortId, ApexSystemTime)| -> (QueueOverflow, Vec<u8>), | ||
GetQueuingPortStatus: |QueuingPortId| -> QueuingPortStatus, | ||
ClearQueuingPort: |QueuingPortId| -> (), | ||
); | ||
|
||
// ApexTimeP4 | ||
define_multiple_syscalls!( | ||
PeriodicWait: |()| -> (), | ||
GetTime: |()| -> ApexSystemTime, | ||
); | ||
|
||
// ApexErrorP4 | ||
define_multiple_syscalls!( | ||
ReportApplicationMessage: |&'params [ApexByte]| -> (), | ||
RaiseApplicationError: |(ErrorCode, &'params [ApexByte])| -> (), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters