/* * Return a value using CONFIG_SYS_HZ as unit */ ulong get_timer(ulong base) { #if 1 ulong temp = tick_to_time(get_ticks()); // printf("%x %x\n", gd->tbu, gd->tbl); //printf("[get_timer(%lx)]=>temp=%x,temp-base=%lx\n",base,temp,temp-base); return(temp - base); #else return tick_to_time(get_ticks()) - base; #endif }
unsigned long get_timer (unsigned long base) { const unsigned long now = (unsigned long)tick_to_time(get_ticks()); unsigned long result; if (now < base) /* have we over-flowed ? */ { result = (unsigned long)tick_to_time(TMU_MAX_COUNTER) - base; result += now + 1u; } else /* we have not over-flowed */ { result = now - base; } /* return delta (in msec) from 'now' w.r.t. 'base' */ return result; }
ulong get_timer_masked (void) { /* * get_ticks() returns a long long (64 bit), it wraps in * 2^64 / CONFIG_MX27_CLK32 = 2^64 / 2^15 = 2^49 ~ 5 * 10^14 (s) ~ * 5 * 10^9 days... and get_ticks() * CONFIG_SYS_HZ wraps in * 5 * 10^6 days - long enough. */ return tick_to_time(get_ticks()); }
/* * get_timer(base) can be used to check for timeouts or * to measure elasped time relative to an event: * * ulong start_time = get_timer(0) sets start_time to the current * time value. * get_timer(start_time) returns the time elapsed since then. * * The time is used in CONFIG_SYS_HZ units! */ ulong get_timer(ulong base) { unsigned long long ticks, time; ticks = get_ticks(); time = tick_to_time(ticks); return (time - base); }
ulong get_timer_masked(void) { return tick_to_time(get_ticks()); }
/* * get_timer(base) can be used to check for timeouts or * to measure elasped time relative to an event: * * ulong start_time = get_timer(0) sets start_time to the current * time value. * get_timer(start_time) returns the time elapsed since then. * * The time is used in CONFIG_SYS_HZ units! */ ulong get_timer(ulong base) { return tick_to_time(get_ticks()) - base; }
unsigned long get_timer (unsigned long base) { /* return msec */ return tick_to_time(get_ticks()) - base; }
unsigned long __weak notrace timer_get_us(void) { return tick_to_time(get_ticks() * 1000); }
ulong get_timer(ulong base) { /* NOTE: time_to_tick(base) is required to correctly handle rollover! */ return tick_to_time(get_ticks() - time_to_tick(base)); }
ulong get_timer_masked(void) { /* current tick value */ return tick_to_time(get_ticks()); }
/* * timer without interrupts */ ulong get_timer(ulong base) { return tick_to_time(get_ticks() - time_to_tick(base)); }
unsigned long get_timer_masked(void) { return tick_to_time(get_current_tick()); }