Add a note describing the register naming convention in `raw_syscalls.rs` and move the `Syscalls` impl into its own file in preparation for an upcoming PR.
diff --git a/core/platform/src/lib.rs b/core/platform/src/lib.rs
index 699d3da..b269712 100644
--- a/core/platform/src/lib.rs
+++ b/core/platform/src/lib.rs
@@ -12,6 +12,7 @@
mod error_code;
mod raw_syscalls;
mod syscalls;
+mod syscalls_impl;
pub use allows::{AllowReadable, Allowed};
pub use error_code::ErrorCode;
diff --git a/core/platform/src/syscalls.rs b/core/platform/src/syscalls.rs
index fc3207e..8d85380 100644
--- a/core/platform/src/syscalls.rs
+++ b/core/platform/src/syscalls.rs
@@ -1,8 +1,6 @@
// TODO: Implement `libtock_runtime` and `libtock_unittest`, which are
// referenced in the comment on `Syscalls`.
-use crate::raw_syscalls::{RawSyscalls, YieldType};
-
/// `Syscalls` provides safe abstractions over Tock's system calls. It is
/// implemented for `libtock_runtime::TockSyscalls` and
/// `libtock_unittest::FakeSyscalls` (by way of `RawSyscalls`).
@@ -26,30 +24,3 @@
// TODO: Add memop() methods.
}
-
-impl<S: RawSyscalls> Syscalls for S {
- fn yield_wait() {
- Self::raw_yield(YieldType::Wait);
- }
-
- fn yield_no_wait() -> bool {
- Self::raw_yield(YieldType::NoWait) != ReturnType::Failure as usize
- }
-}
-
-// Note: variants are commented out because if they aren't commented out I get a
-// "variant is never constructed" error. When we figure out an error handling
-// design, this type is likely to move into an error handling-related module, at
-// which point we will uncomment the other variants.
-enum ReturnType {
- Failure = 0,
- //FailureWithU32 = 1,
- //FailureWith2U32 = 2,
- //FailureWithU64 = 3,
- //Success = 128,
- //SuccessWithU32 = 129,
- //SuccessWith2U32 = 130,
- //SuccessWithU64 = 131,
- //SuccessWith3U32 = 132,
- //SuccessWithU32AndU64 = 133,
-}
diff --git a/core/platform/src/syscalls_impl.rs b/core/platform/src/syscalls_impl.rs
new file mode 100644
index 0000000..0af15c5
--- /dev/null
+++ b/core/platform/src/syscalls_impl.rs
@@ -0,0 +1,18 @@
+//! Implements `Syscalls` for all types that implement `RawSyscalls`.
+
+use crate::{RawSyscalls, Syscalls, YieldType};
+
+impl<S: RawSyscalls> Syscalls for S {
+ // -------------------------------------------------------------------------
+ // Yield
+ // -------------------------------------------------------------------------
+
+ fn yield_wait() {
+ Self::raw_yield(YieldType::Wait);
+ }
+
+ fn yield_no_wait() -> bool {
+ // TODO: Introduce a return type abstraction so this 0 isn't hardcoded.
+ Self::raw_yield(YieldType::NoWait) != 0
+ }
+}