libosmo_emb: Implement _gettimeofday() on simplistic 'jiffies' counter.

We simply use the SysTick timer to count at 1KHz and fill a 64bit jiffies
conunter.  This counter is then used to fill tv_sec and tv_usec in the
gettimeofday() implementation.

NOTE: tv_sec will not indicate the seconds since the epoch (Jan 01,
1970), but rather since system startup.  For the existign users,
particularly osmo_timer, this doesn't matter.

Change-Id: I9dbbb730996bde1e7039f790d76d7243739a8419
diff --git a/sysmoOCTSIM/libosmo_emb.c b/sysmoOCTSIM/libosmo_emb.c
index 887887d..b100560 100644
--- a/sysmoOCTSIM/libosmo_emb.c
+++ b/sysmoOCTSIM/libosmo_emb.c
@@ -14,15 +14,21 @@
  ***********************************************************************/
 
 #include <sys/time.h>
+#include "driver_init.h"
 
-/* FIXME: Implement it bsed on jiffies and/or RTC! */
-int _gettimeofday(struct timeval *tv, void *tz)
+volatile uint64_t jiffies;
+
+void SysTick_Handler(void)
 {
-	tv->tv_sec = 0;
-	tv->tv_usec = 0;
-	return 0;
+	jiffies++;
 }
 
+int _gettimeofday(struct timeval *tv, void *tz)
+{
+	tv->tv_sec = jiffies / 1000;
+	tv->tv_usec = (jiffies % 1000) * 1000;
+	return 0;
+}
 
 /***********************************************************************
  * Logging
@@ -124,4 +130,7 @@
 	stderr_target = log_target_create_stderr_raw();
 	log_add_target(stderr_target);
 	log_set_all_filter(stderr_target, 1);
+
+	/* timer */
+	SysTick_Config(SystemCoreClock / 1000);
 }