1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/// Do not modify the discriminants in this structure. They are used in `libstd` directly.
#[repr(usize)]
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
pub enum Opcode {
    /// Get the elapsed time in milliseconds
    ElapsedMs = 0,

    /// Sleep for the specified numer of milliseconds
    SleepMs = 1,

    /// Recalculate the sleep time
    RecalculateSleep = 2,

    /// Suspend/resume callback
    SuspendResume = 3,

    /// force a WDT update
    PingWdt = 4,

    /// Return the version string of Xous. We bury it here because this is a small, lightweight server we can rebuild on every run.
    GetVersion = 5,

    /// Lock the given Mutex, blocking if it is already locked.
    ///
    /// # Arguments
    ///
    /// *arg1*: An integer of some sort, such as the address of the Mutex
    LockMutex = 6,

    /// Unlock the given Mutex
    ///
    /// # Arguments
    ///
    /// *arg1*: An integer of some sort, such as the address of the Mutex
    UnlockMutex = 7,

    /// Wait for a given condition to be signalled
    ///
    /// # Arguments
    ///
    /// *arg1*: An integer of some sort, such as the address of the Condvar
    /// *arg2*: The number of milliseconds to wait, or 0 to wait forever
    WaitForCondition = 8,

    /// Notify a condition
    ///
    /// # Arguments
    ///
    /// *arg1*: An integer of some sort, such as the address of the Condvar
    /// *arg2*: The number of conditions to notify
    NotifyCondition = 9,

    /// Free a Mutex
    ///
    /// This call will free a Mutex that was previously Locked or Unlocked.
    /// Doing so causes the Mutex to be unlocked.
    ///
    /// # Arguments
    ///
    /// *arg1*: The integer that matches the Mutex value
    FreeMutex = 10,

    /// Free a Condition
    ///
    /// This call will free a Condition that was previously waited upon. All
    /// pending threads will be forgotten.
    ///
    /// # Arguments
    ///
    /// *arg1*: The integer that matches the Condition value
    FreeCondition = 11,

    /// Invalid call -- an error occurred decoding the opcode
    InvalidCall = u32::MAX as usize,
}

#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
pub struct VersionString {
    pub version: xous_ipc::String<512>,
}