From d63627fb846b6621be87348b1653a5f37070e12f Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Mon, 20 Aug 2018 12:47:19 -0600 Subject: libpayload/libc/time: Add an arch_ndelay() Replace _delay with an arch_ndelay(). This way each arch can setup their own delay mechanism. BUG=b:109749762 TEST=Verified delay's still work on grunt. Change-Id: I552eb30984f9c21e92dffc9d7b36873e9e2e4ac5 Signed-off-by: Raul E Rangel Reviewed-on: https://review.coreboot.org/28243 Reviewed-by: Martin Roth Reviewed-by: Richard Spiegel Tested-by: build bot (Jenkins) --- payloads/libpayload/libc/time.c | 44 +++-------------------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) (limited to 'payloads/libpayload/libc') diff --git a/payloads/libpayload/libc/time.c b/payloads/libpayload/libc/time.c index 46306bb1ba..f8913466dc 100644 --- a/payloads/libpayload/libc/time.c +++ b/payloads/libpayload/libc/time.c @@ -158,52 +158,14 @@ int gettimeofday(struct timeval *tv, void *tz) return 0; } -static inline void _delay(uint64_t delta) +__attribute__((weak)) +void arch_ndelay(uint64_t ns) { + uint64_t delta = ns * timer_hz() / NSECS_PER_SEC; uint64_t start = timer_raw_value(); while (timer_raw_value() - start < delta) ; } -/** - * Delay for a specified number of nanoseconds. - * - * @param n Number of nanoseconds to delay for. - */ -void ndelay(unsigned int n) -{ - _delay((uint64_t)n * timer_hz() / 1000000000); -} - -/** - * Delay for a specified number of microseconds. - * - * @param n Number of microseconds to delay for. - */ -void udelay(unsigned int n) -{ - _delay((uint64_t)n * timer_hz() / 1000000); -} - -/** - * Delay for a specified number of milliseconds. - * - * @param m Number of milliseconds to delay for. - */ -void mdelay(unsigned int m) -{ - _delay((uint64_t)m * timer_hz() / 1000); -} - -/** - * Delay for a specified number of seconds. - * - * @param s Number of seconds to delay for. - */ -void delay(unsigned int s) -{ - _delay((uint64_t)s * timer_hz()); -} - u64 timer_us(u64 base) { static u64 hz; -- cgit v1.2.3