A crisper implementation makes profiling a tad easier.

Signed-off-by: Øyvind Harboe <oyvind.har...@zylin.com>
---
 src/helper/time_support.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/helper/time_support.c b/src/helper/time_support.c
index 693528f..4e69c42 100644
--- a/src/helper/time_support.c
+++ b/src/helper/time_support.c
@@ -29,6 +29,9 @@
 
 #include "time_support.h"
 
+#if BUILD_ECOSBOARD == 1
+#include <cyg/kernel/kapi.h>
+#endif
 
 /* calculate difference between two struct timeval values */
 int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval 
*y)
@@ -73,13 +76,26 @@ int timeval_add_time(struct timeval *result, long sec, long 
usec)
        return 0;
 }
 
+/* simple and low overhead fetching of ms counter. Use only
+ * the difference between ms counters returned from this fn.
+ */
 int64_t timeval_ms()
 {
+#if BUILD_ECOSBOARD == 0
        struct timeval now;
        int retval = gettimeofday(&now, NULL);
        if (retval < 0)
                return retval;
        return (int64_t)now.tv_sec * 1000 + now.tv_usec / 1000;
+#else
+       /* Faster/less noisy implementation of getting ms when
+        * profiling
+        */
+       static const int ms_per_tick =
+                       (CYGNUM_HAL_RTC_NUMERATOR / CYGNUM_HAL_RTC_DENOMINATOR) 
/ 1000000;
+       cyg_tick_count_t cur_time = cyg_current_time();
+       return ((int)cur_time) * ms_per_tick;
+#endif
 }
 
 
-- 
1.6.3.3

_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to