summaryrefslogtreecommitdiff
path: root/payloads/libpayload/include/libpayload.h
diff options
context:
space:
mode:
authorRaul E Rangel <rrangel@chromium.org>2018-08-20 12:47:19 -0600
committerMartin Roth <martinroth@google.com>2018-09-12 14:15:18 +0000
commitd63627fb846b6621be87348b1653a5f37070e12f (patch)
tree2547e1bf937bc9bbf128d5b2f1836e407c0e928b /payloads/libpayload/include/libpayload.h
parent24ae85c3ffb48c72f67a514dcb843c1de54e5416 (diff)
downloadcoreboot-d63627fb846b6621be87348b1653a5f37070e12f.tar.xz
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 <rrangel@chromium.org> Reviewed-on: https://review.coreboot.org/28243 Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Richard Spiegel <richard.spiegel@silverbackltd.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'payloads/libpayload/include/libpayload.h')
-rw-r--r--payloads/libpayload/include/libpayload.h45
1 files changed, 41 insertions, 4 deletions
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index 359bd0e4ce..c2510b7373 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -464,11 +464,48 @@ unsigned int get_cpu_speed(void);
uint64_t timer_hz(void);
uint64_t timer_raw_value(void);
uint64_t timer_us(uint64_t base);
+void arch_ndelay(uint64_t n);
/* Generic. */
-void ndelay(unsigned int n);
-void udelay(unsigned int n);
-void mdelay(unsigned int n);
-void delay(unsigned int n);
+
+/**
+ * Delay for a specified number of nanoseconds.
+ *
+ * @param ns Number of nanoseconds to delay for.
+ */
+static inline void ndelay(unsigned int ns)
+{
+ arch_ndelay((uint64_t)ns);
+}
+
+/**
+ * Delay for a specified number of microseconds.
+ *
+ * @param us Number of microseconds to delay for.
+ */
+static inline void udelay(unsigned int us)
+{
+ arch_ndelay((uint64_t)us * NSECS_PER_USEC);
+}
+
+/**
+ * Delay for a specified number of milliseconds.
+ *
+ * @param ms Number of milliseconds to delay for.
+ */
+static inline void mdelay(unsigned int ms)
+{
+ arch_ndelay((uint64_t)ms * NSECS_PER_MSEC);
+}
+
+/**
+ * Delay for a specified number of seconds.
+ *
+ * @param s Number of seconds to delay for.
+ */
+static inline void delay(unsigned int s)
+{
+ arch_ndelay((uint64_t)s * NSECS_PER_SEC);
+}
/**
* @defgroup readline Readline functions