| 881 |
theseven |
1 |
#include "global.h"
|
|
|
2 |
#include "sys/time.h"
|
|
|
3 |
|
|
|
4 |
static uint32_t sys_time_usec_timer_high = 0;
|
|
|
5 |
static uint32_t sys_time_usec_timer_last_low = 0;
|
|
|
6 |
|
|
|
7 |
void udelay(unsigned int microseconds)
|
|
|
8 |
{
|
|
|
9 |
unsigned int timeout = read_usec_timer() + microseconds + 1;
|
|
|
10 |
while ((int)(read_usec_timer() - timeout) < 0);
|
|
|
11 |
}
|
|
|
12 |
|
|
|
13 |
__attribute__((weak)) int64_t read_usec_timer64()
|
|
|
14 |
{
|
|
|
15 |
uint32_t low = (uint32_t)read_usec_timer();
|
|
|
16 |
if (low < sys_time_usec_timer_last_low) sys_time_usec_timer_high++;
|
|
|
17 |
sys_time_usec_timer_last_low = low;
|
|
|
18 |
int64_t high = ((int64_t)sys_time_usec_timer_high) << 32;
|
|
|
19 |
return high | low;
|
|
|
20 |
}
|