#include <kernel.h>
-#include <timer.h>
#include <kdata.h>
#include <printf.h>
#include <kernel.h>
#include <kdata.h>
#include <printf.h>
-#include <timer.h>
/* N_open is given a string containing a path name in user space,
* and returns an inode table pointer. If it returns NULL, the file
extern uint16_t runticks; /* Number of ticks current process has been swapped in */
extern time_t tod; /* Time of day */
-extern clock_t ticks; /* Cumulative tick counter, in minutes and ticks */
+extern clock_t ticks; /* 32-bit count of ticks since boot */
+extern uint16_t miniticks; /* 16-bit count of ticks since boot */
extern uint8_t *swapbase; /* Used by device driver for swapping */
extern unsigned swapcnt;
#define __TIMER_DOT_H__
#include <stdbool.h>
+#include <kdata.h>
#include <kernel.h>
typedef uint16_t timer_t;
-extern timer_t system_timer; /* counts up at TICKSPERSEC, wraps to zero */
-timer_t set_timer_duration(uint16_t duration); /* good for up to approx 0x8000 ticks */
+#define set_timer_ms(msec) (set_timer_duration(((msec * TICKSPERSEC) / 1000U) == 0 ? 1 : ((msec * TICKSPERSEC) / 1000U)))
+#define set_timer_sec(sec) (set_timer_duration(sec * TICKSPERSEC))
+timer_t set_timer_duration(uint16_t duration); /* good for up to 32K ticks */
bool timer_expired(timer_t timer_val);
#endif
#include <kernel.h>
#include <kdata.h>
#include <printf.h>
-#include <timer.h>
/* Writei (and readi) need more i/o error handling */
void readi(inoptr ino, uint8_t flag)
char bootline[2];
uint16_t ramsize, procmem, maxproc, nproc, nready;
uint16_t runticks;
-uint16_t system_tick_counter;
bool inint;
uint8_t root_dev = DEFAULT_ROOT;
uint8_t ticks_this_dsecond;
inoptr root;
uint16_t waitno;
time_t tod; // time of day
-clock_t ticks; // system tick counter
+clock_t ticks; // 32-bit system tick counter
+uint16_t miniticks; // 16-bit system tick counter
int16_t acct_fh = -1; /* Accounting file handle */
.globl unix_syscall_entry
.globl _chksigs
.globl null_handler
- .globl _system_tick_counter
.globl unix_syscall_entry
.globl dispatch_process_signal
.globl _doexec
push ix
push iy
- ld hl, (_system_tick_counter)
- inc hl
- ld (_system_tick_counter), hl
-
; Some platforms (MSX for example) have devices we *must*
; service irrespective of kernel state in order to shut them
; up. This code must be in common and use small amounts of stack
#undef DEBUGREALLYHARD /* turn on getproc dumping */
#include <kernel.h>
-#include <timer.h>
#include <kdata.h>
#include <printf.h>
#include <version.h>
#include <kdata.h>
#include <printf.h>
-#include <timer.h>
/*
* Logic for select
*/
#include <kernel.h>
-#include <timer.h>
#include <kdata.h>
#include <printf.h>
#include <kernel.h>
-#include <timer.h>
#include <kdata.h>
#include <printf.h>
#include <kernel.h>
#include <version.h>
-#include <timer.h>
#include <kdata.h>
#include <printf.h>
#include <tty.h>
*/
#include <kernel.h>
-#include <timer.h>
#include <kdata.h>
#include <printf.h>
#include <version.h>
#include <kdata.h>
#include <printf.h>
-#include <timer.h>
static void close_on_exec(void)
{
#include <version.h>
#include <kdata.h>
#include <printf.h>
-#include <timer.h>
void updoff(void)
{
#include <version.h>
#include <kdata.h>
#include <printf.h>
-#include <timer.h>
/*
* File system related calls that are not continually used (so
#include <version.h>
#include <kdata.h>
#include <printf.h>
-#include <timer.h>
/*
* More obscure syscalls that it might be useful to pull out of the main
#include <kernel.h>
#include <kdata.h>
#include <printf.h>
-#include <timer.h>
#undef DEBUG
#include <timer.h>
#include <printf.h>
-/* the interrupt handler increments this after every timer interrupt */
-uint16_t system_timer;
-
-/* WRS: timer functions */
+/* WRS: simple timer functions */
timer_t set_timer_duration(uint16_t duration)
{
+ timer_t a;
if (duration & 0x8000) {
kprintf("bad timer duration 0x%x\n", duration);
}
- return (system_timer + duration);
+ /* obvious code is return (miniticks+duration), however we have to do */
+ /* it this longwinded way or sdcc doesn't load miniticks atomically */
+ a = miniticks;
+ a += duration;
+ return a;
}
bool timer_expired(timer_t timer_val)
{
- if ((timer_val - system_timer) > 0x7fff)
- return true;
- return false;
+ return ((timer_val - miniticks) & 0x8000);
}
/*-----------------------------------------------------------*/