Thomas Heijligen has uploaded this change for review.

View Change

libpayload: Outsource delay function into own header

For libflashrom we need the delay functions but when including the whole
libpayload.h it has conflicting symbols.

Change-Id: I6e4a669b8ba25836fb870d74c200985c1bfdb387
Signed-off-by: Thomas Heijligen <src@posteo.de>
---
M payloads/libpayload/include/libpayload.h
A payloads/libpayload/include/libpayload/delay.h
M payloads/libpayload/include/stddef.h
3 files changed, 71 insertions(+), 49 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/39/70139/1
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index 1587118..221be46 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -68,6 +68,7 @@
#include <sysinfo.h>
#include <pci.h>
#include <archive.h>
+#include <libpayload/delay.h>

#define BIT(x) (1ul << (x))

@@ -510,54 +511,12 @@

/* Timer functions. */
/* Defined by each architecture. */
-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. */

/**
- * 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
* This interface provides a simple implementation of the standard readline()
* and getline() functions. They read a line of input from the console.
diff --git a/payloads/libpayload/include/libpayload/delay.h b/payloads/libpayload/include/libpayload/delay.h
new file mode 100644
index 0000000..96d029c
--- /dev/null
+++ b/payloads/libpayload/include/libpayload/delay.h
@@ -0,0 +1,57 @@
+#ifndef LIBPAYLOAD_DELAY_H
+#define LIBPAYLOAD_DELAY_H
+
+#include <stdint.h>
+
+#define NSECS_PER_SEC 1000000000
+#define USECS_PER_SEC 1000000
+#define MSECS_PER_SEC 1000
+#define NSECS_PER_MSEC (NSECS_PER_SEC / MSECS_PER_SEC)
+#define NSECS_PER_USEC (NSECS_PER_SEC / USECS_PER_SEC)
+#define USECS_PER_MSEC (USECS_PER_SEC / MSECS_PER_SEC)
+
+unsigned int get_cpu_speed(void);
+
+void arch_ndelay(uint64_t 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);
+}
+
+#endif /* LIBPAYLOAD_DELAY_H */
diff --git a/payloads/libpayload/include/stddef.h b/payloads/libpayload/include/stddef.h
index 9003ac9..81aaa17 100644
--- a/payloads/libpayload/include/stddef.h
+++ b/payloads/libpayload/include/stddef.h
@@ -26,11 +26,4 @@
typedef __SIZE_TYPE__ ssize_t;
#undef unsigned

-#define NSECS_PER_SEC 1000000000
-#define USECS_PER_SEC 1000000
-#define MSECS_PER_SEC 1000
-#define NSECS_PER_MSEC (NSECS_PER_SEC / MSECS_PER_SEC)
-#define NSECS_PER_USEC (NSECS_PER_SEC / USECS_PER_SEC)
-#define USECS_PER_MSEC (USECS_PER_SEC / MSECS_PER_SEC)
-
#endif

To view, visit change 70139. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I6e4a669b8ba25836fb870d74c200985c1bfdb387
Gerrit-Change-Number: 70139
Gerrit-PatchSet: 1
Gerrit-Owner: Thomas Heijligen <src@posteo.de>
Gerrit-MessageType: newchange