diff options
author | Thomas Huth <thuth@redhat.com> | 2016-09-09 21:52:02 +0200 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2016-09-14 17:50:40 +1000 |
commit | 91d86c568ebb45f940ce75575ce4d08420638617 (patch) | |
tree | ee9e9206e8405e24323af3db08d32974821d5f65 /slof/helpers.c | |
parent | f4b44f501e220b15ad63873b885c9d150a77b52d (diff) | |
download | SLOF-91d86c568ebb45f940ce75575ce4d08420638617.zip SLOF-91d86c568ebb45f940ce75575ce4d08420638617.tar.gz SLOF-91d86c568ebb45f940ce75575ce4d08420638617.tar.bz2 |
paflof: Provide get_timer() and set_timer() helper functions
They are needed for libnet, too. This implementation uses
SLOF_GetTimer() instead of using the decrementer like it is
done in the net-snk functions.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'slof/helpers.c')
-rw-r--r-- | slof/helpers.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/slof/helpers.c b/slof/helpers.c index 86fd2b6..d074178 100644 --- a/slof/helpers.c +++ b/slof/helpers.c @@ -18,6 +18,7 @@ #include <cpu.h> #include "helpers.h" #include "paflof.h" +#include "../lib/libnet/time.h" /* TODO: Get rid of old timer code */ /** * get msec-timer value @@ -46,6 +47,23 @@ void SLOF_usleep(uint32_t time) forth_eval("us"); } +static unsigned int dest_timer; + +void set_timer(int val) +{ + dest_timer = SLOF_GetTimer() + val; +} + +int get_timer() +{ + return dest_timer - SLOF_GetTimer(); +} + +int get_sec_ticks(void) +{ + return 1000; /* number of ticks in 1 second */ +} + void *SLOF_dma_alloc(long size) { forth_push(size); |