MCPcopy Create free account
hub / github.com/coreboot/coreboot / update_clock

Function update_clock

payloads/libpayload/libc/time.c:52–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50} clock;
51
52static void update_clock(void)
53{
54 u64 delta = timer_raw_value() - clock.ticks;
55 int secs;
56 static uint64_t ticks_per_sec = 0;
57 static uint64_t ticks_per_usec = 0;
58 if (!ticks_per_sec) {
59 ticks_per_sec = timer_hz();
60 ticks_per_usec = timer_hz() / 1000000;
61 }
62
63 clock.ticks += delta;
64
65 secs = (int) (delta / ticks_per_sec);
66 clock.secs += secs;
67 delta -= (secs * ticks_per_sec);
68 clock.usecs += (int)(delta / ticks_per_usec);
69
70 if (clock.usecs > 1000000) {
71 clock.usecs -= 1000000;
72 clock.secs++;
73 }
74}
75
76#if CONFIG(LP_NVRAM)
77

Callers 1

timeFunction · 0.85

Calls 2

timer_raw_valueFunction · 0.50
timer_hzFunction · 0.50

Tested by

no test coverage detected