Fix some more signed/unsigned errors in the Tock timer driver.

Tock was using non-raw syscalls for set/stop alarm, which is incorrect
as the return value is a u32 and if the high bit is set, Tock
interprets that return value as an error.

There were also some time values declared as isize instead of usize -
this could potentially break things during timer overflow.

Change-Id: I93563d6b8991ff545244f03aab05ad30506c41b5
diff --git a/src/timer.rs b/src/timer.rs
index 0ab76cc..35af9b1 100644
--- a/src/timer.rs
+++ b/src/timer.rs
@@ -6,10 +6,8 @@
 use crate::result::OtherError;
 use crate::result::TockError;
 use crate::result::TockResult;
-use crate::result::EALREADY;
 use crate::syscalls;
 use core::cell::Cell;
-use core::isize;
 use core::marker::PhantomData;
 use core::ops::{Add, AddAssign, Sub};
 
@@ -39,7 +37,7 @@
     fn consume(data: &mut WithCallback<CB>, clock_value: usize, alarm_id: usize, _: usize) {
         (data.callback)(
             ClockValue {
-                num_ticks: clock_value as isize,
+                num_ticks: clock_value as usize,
                 clock_frequency: data.clock_frequency,
             },
             Alarm { alarm_id },
@@ -96,7 +94,7 @@
     pub fn get_current_clock(&self) -> TockResult<ClockValue> {
         Ok(ClockValue {
             num_ticks: unsafe {
-                syscalls::raw::command(DRIVER_NUMBER, command_nr::GET_CLOCK_VALUE, 0, 0)
+                syscalls::raw::command(DRIVER_NUMBER, command_nr::GET_CLOCK_VALUE, 0, 0) as usize
             },
             clock_frequency: self.clock_frequency,
         })
@@ -154,20 +152,20 @@
 
 #[derive(Copy, Clone, Debug)]
 pub struct ClockValue {
-    num_ticks: isize,
+    num_ticks: usize,
     clock_frequency: ClockFrequency,
 }
 
 impl ClockValue {
-    pub fn num_ticks(self) -> isize {
+    pub fn num_ticks(self) -> usize {
         self.num_ticks
     }
 
-    pub fn ms(self) -> isize {
-        if self.num_ticks.abs() < isize::MAX / 1000 {
-            (1000 * self.num_ticks) / self.clock_frequency.hz() as isize
+    pub fn ms(self) -> usize {
+        if self.num_ticks < usize::MAX / 1000 {
+            (1000 * self.num_ticks) / self.clock_frequency.hz()
         } else {
-            1000 * (self.num_ticks / self.clock_frequency.hz() as isize)
+            1000 * (self.num_ticks / self.clock_frequency.hz())
         }
     }
 
@@ -239,8 +237,8 @@
     }
 }
 
-impl Timestamp<isize> {
-    pub fn from_clock_value(value: ClockValue) -> Timestamp<isize> {
+impl Timestamp<usize> {
+    pub fn from_clock_value(value: ClockValue) -> Timestamp<usize> {
         Timestamp { ms: value.ms() }
     }
 }
@@ -500,18 +498,16 @@
     unsafe { Ok(syscalls::raw::command(DRIVER_NUMBER, command_nr::GET_CLOCK_VALUE, 0, 0) as usize) }
 }
 fn set_alarm_at(instant: usize) -> TockResult<()> {
-    syscalls::command(DRIVER_NUMBER, command_nr::SET_ALARM, instant, 0)
-        .map(|_| ())
-        .map_err(|err| err.into())
+    unsafe {
+        syscalls::raw::command(DRIVER_NUMBER, command_nr::SET_ALARM, instant, 0);
+        Ok(())
+    }
 }
 
 fn stop_alarm_at(instant: usize) -> TockResult<()> {
-    match syscalls::command(DRIVER_NUMBER, command_nr::STOP_ALARM, instant, 0) {
-        Ok(_) => Ok(()),
-        Err(error) => match error.return_code {
-            EALREADY => Ok(()),
-            _ => Err(TockError::Command(error)),
-        },
+    unsafe {
+        syscalls::raw::command(DRIVER_NUMBER, command_nr::STOP_ALARM, instant, 0);
+        Ok(())
     }
 }