[SLOF] [PATCH 04/11] paflof: Provide get_timer() and set_timer() helper functions
Thomas Huth
thuth at redhat.com
Sat Sep 10 05:52:02 AEST 2016
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 at redhat.com>
---
lib/libnet/time.h | 6 ++++++
slof/helpers.c | 18 ++++++++++++++++++
2 files changed, 24 insertions(+)
create mode 100644 lib/libnet/time.h
diff --git a/lib/libnet/time.h b/lib/libnet/time.h
new file mode 100644
index 0000000..fcd5cd5
--- /dev/null
+++ b/lib/libnet/time.h
@@ -0,0 +1,6 @@
+
+extern void set_timer(int);
+extern int get_timer(void);
+extern int get_sec_ticks(void);
+
+#define TICKS_SEC get_sec_ticks()
diff --git a/slof/helpers.c b/slof/helpers.c
index 3f411b9..eab334d 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);
--
1.8.3.1
More information about the SLOF
mailing list