diff --git a/common/clock.c b/common/clock.c index 9c7c1ba..2dae9ff 100644 --- a/common/clock.c +++ b/common/clock.c @@ -29,6 +29,12 @@ static struct clocksource *current_clock; static uint64_t time_ns; +/* + * The first timestamp when the clocksource is registered. + * Useful for measuring the time spent in barebox. + */ +uint64_t time_beginning; + /** * get_time_ns - get current timestamp in nanoseconds */ @@ -180,5 +186,7 @@ int init_clock(struct clocksource *cs) { current_clock = cs; + time_beginning = get_time_ns(); + return 0; } diff --git a/include/clock.h b/include/clock.h index a169790..691befc 100644 --- a/include/clock.h +++ b/include/clock.h @@ -43,6 +43,8 @@ #define MSECOND ((uint64_t)(1000 * 1000)) #define USECOND ((uint64_t)(1000)) +extern uint64_t time_beginning; + /* * Convenience wrapper to implement a typical polling loop with * timeout. returns 0 if the condition became true within the