timer: Move structures about
authorAlan Cox <alan@linux.intel.com>
Sat, 27 Dec 2014 21:38:56 +0000 (21:38 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 27 Dec 2014 21:38:56 +0000 (21:38 +0000)
All the clock bits are now in the cpu struct together. This also lets us
flip the 6809 clock/mini union the right way up for big endian

Kernel/cpu-6502/cpu.h
Kernel/cpu-6809/cpu.h
Kernel/cpu-z80/cpu.h
Kernel/include/kernel.h
Kernel/timer.c

index eb39e67..ffce123 100644 (file)
@@ -24,11 +24,22 @@ extern size_t strlen(const char *);
 
 #define staticfast     static
 
+/* User's structure for times() system call */
+typedef unsigned long clock_t;
+
 typedef struct {
   uint32_t low;
   uint32_t high;
 } time_t;
 
+typedef union {            /* this structure is endian dependent */
+    clock_t  full;         /* 32-bit count of ticks since boot */
+    union {
+      uint16_t low;         /* 16-bit count of ticks since boot */
+      uint16_t high;
+    } h;
+} ticks_t;
+
 /* We don't yet have bank attributes and banking for Z80 */
 #define CODE1
 #define CODE2
index 4d676ac..7470550 100644 (file)
@@ -27,12 +27,23 @@ extern uint16_t swab(uint16_t);
    non-reentrant functions static */
 #define staticfast     auto
 
-/* FIXME: should be 64bits - need to add helpers and struct variants */
+/* User's structure for times() system call */
+typedef unsigned long clock_t;
+
 typedef struct {
    uint32_t low;
    uint32_t high;
 } time_t;
 
+typedef union {            /* this structure is endian dependent */
+    clock_t  full;         /* 32-bit count of ticks since boot */
+    union {
+      uint16_t high;
+      uint16_t low;         /* 16-bit count of ticks since boot */
+    } h;
+} ticks_t;
+
+
 #define cpu_to_le16(x) swab(x)
 #define le16_to_cpu(x) swab(x)
 
index a669a4a..183376a 100644 (file)
@@ -31,12 +31,23 @@ extern int16_t strlen(const char *p);
 
 #define        staticfast      static
 
+/* User's structure for times() system call */
+typedef unsigned long clock_t;
+
 /* Must match native ordering of long long */
 typedef struct {
        uint32_t low;
        uint32_t high;
 } time_t;
 
+typedef union {            /* this structure is endian dependent */
+    clock_t  full;         /* 32-bit count of ticks since boot */
+    union {
+      uint16_t low;         /* 16-bit count of ticks since boot */
+      uint16_t high;
+    } h;
+} ticks_t;
+
 /* We don't yet have bank attributes and banking for Z80 */
 #define CODE1
 #define CODE2
index c0be366..ba68911 100644 (file)
@@ -70,9 +70,6 @@ typedef struct s_queue {
     int   q_wakeup;  /* Threshold for waking up processes waiting on queue */
 } queue_t;
 
-/* User's structure for times() system call */
-typedef unsigned long clock_t;
-
 struct tms {
        clock_t  tms_utime;
        clock_t  tms_stime;
index f80708c..e9b8a3c 100644 (file)
@@ -3,23 +3,27 @@
 #include <timer.h>
 #include <printf.h>
 
-/* WRS: simple timer functions */
+/* WRS: simple timer functions
+
+   These use a 16bit "miniticks" to keep the generated code nice
+*/
+
 timer_t set_timer_duration(uint16_t duration)
 {
-    timer_t a;
+       timer_t a;
        if (duration & 0x8000) {
                kprintf("bad timer duration 0x%x\n", duration);
        }
-    /* obvious code is return (miniticks+duration), however we have to do */
-    /* it this longwinded way or sdcc doesn't load miniticks atomically */
-    a = ticks.mini;
-    a += duration;
-    return a;
+       /* obvious code is return (miniticks+duration), however we have to do */
+       /* it this longwinded way or sdcc doesn't load miniticks atomically */
+       a = ticks.h.low;
+       a += duration;
+       return a;
 }
 
 bool timer_expired(timer_t timer_val)
 {
-       return ((timer_val - ticks.mini) & 0x8000);
+       return ((timer_val - ticks.h.low) & 0x8000);
 }
 
 /*-----------------------------------------------------------*/