#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
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)
#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
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;
#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);
}
/*-----------------------------------------------------------*/