xous-core/services/engine-25519/src/api.rs

61 lines
1.9 KiB
Rust
Raw Normal View History

pub(crate) const SERVER_NAME_ENGINE25519: &str = "_Curve-25519 Accelerator Engine_";
2021-06-23 11:12:43 +00:00
pub(crate) const NUM_REGS: usize = 32;
pub(crate) const BITWIDTH: usize = 256;
pub(crate) const RF_SIZE_IN_U32: usize = NUM_REGS*(BITWIDTH/core::mem::size_of(u32)); // 32 registers, 256 bits/register, divided by 4 bytes per u32
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
pub (crate) struct Job {
2021-06-23 11:12:43 +00:00
/// the SID of the server to which we should return results. Ideally, this is an application-specific server, and not your main loop server.
id: [u32; 4],
/// start location for microcode load
uc_start: u32,
/// length of the microcode to run
uc_len: u32,
/// microcode program
ucode: [u32; 1024],
2021-06-23 11:12:43 +00:00
/// initial register file contents (also contains any arguments to the program)
rf: [u32; RF_SIZE_IN_U32],
/// which register window, if any, to use for the job
window: Option<u8>,
}
2021-06-20 10:42:37 +00:00
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
pub(crate) enum Opcode {
2021-06-23 11:12:43 +00:00
/// Runs a job, if the server is not already occupied
RunJob,
2021-06-20 10:42:37 +00:00
/// a function that can be polled to determine if the block has been currently acquired
2021-06-23 11:12:43 +00:00
IsFree,
/// IRQ handler feedback
EngineDone,
IllegalOpcode,
2021-06-23 11:12:43 +00:00
/// Suspend/resume callback
SuspendResume,
/// exit the server
Quit,
// note that suspend/resume is handled by a secondary thread that can concurrently
// interrupt the main thread and store the state
2021-06-20 10:42:37 +00:00
}
2021-06-23 11:12:43 +00:00
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
pub(crate) enum Return {
Result,
Quit,
}
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
pub(crate) enum JobResult {
/// returns a copy of the entire register file as a result
2021-06-23 11:12:43 +00:00
Result([u32; RF_SIZE_IN_U32]),
Started,
EngineUnavailable,
IllegalOpcodeException,
SuspendError,
2021-06-23 11:12:43 +00:00
}