summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown2008-10-13 00:34:45 +0200
committerMichael Brown2008-10-13 00:36:53 +0200
commitc0835339d06716b133aa653847023742a967f188 (patch)
tree25f22e63175c7919c8de678f5a5f1513bed516c8 /src/include
parent[monojob] Allow for extremely slow system timers (diff)
downloadipxe-c0835339d06716b133aa653847023742a967f188.tar.gz
ipxe-c0835339d06716b133aa653847023742a967f188.tar.xz
ipxe-c0835339d06716b133aa653847023742a967f188.zip
[nap] Formalise the CPU sleeping API
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gpxe/nap.h54
-rw-r--r--src/include/gpxe/null_nap.h21
2 files changed, 75 insertions, 0 deletions
diff --git a/src/include/gpxe/nap.h b/src/include/gpxe/nap.h
new file mode 100644
index 000000000..f9ae3cf43
--- /dev/null
+++ b/src/include/gpxe/nap.h
@@ -0,0 +1,54 @@
+#ifndef _GPXE_NAP_H
+#define _GPXE_NAP_H
+
+/** @file
+ *
+ * CPU sleeping
+ *
+ */
+
+#include <gpxe/api.h>
+#include <config/nap.h>
+
+/**
+ * Calculate static inline CPU sleeping API function name
+ *
+ * @v _prefix Subsystem prefix
+ * @v _api_func API function
+ * @ret _subsys_func Subsystem API function
+ */
+#define NAP_INLINE( _subsys, _api_func ) \
+ SINGLE_API_INLINE ( NAP_PREFIX_ ## _subsys, _api_func )
+
+/**
+ * Provide an CPU sleeping API implementation
+ *
+ * @v _prefix Subsystem prefix
+ * @v _api_func API function
+ * @v _func Implementing function
+ */
+#define PROVIDE_NAP( _subsys, _api_func, _func ) \
+ PROVIDE_SINGLE_API ( NAP_PREFIX_ ## _subsys, _api_func, _func )
+
+/**
+ * Provide a static inline CPU sleeping API implementation
+ *
+ * @v _prefix Subsystem prefix
+ * @v _api_func API function
+ */
+#define PROVIDE_NAP_INLINE( _subsys, _api_func ) \
+ PROVIDE_SINGLE_API_INLINE ( NAP_PREFIX_ ## _subsys, _api_func )
+
+/* Include all architecture-independent I/O API headers */
+#include <gpxe/null_nap.h>
+
+/* Include all architecture-dependent I/O API headers */
+#include <bits/nap.h>
+
+/**
+ * Sleep until next CPU interrupt
+ *
+ */
+void cpu_nap ( void );
+
+#endif /* _GPXE_NAP_H */
diff --git a/src/include/gpxe/null_nap.h b/src/include/gpxe/null_nap.h
new file mode 100644
index 000000000..6dd0cda3e
--- /dev/null
+++ b/src/include/gpxe/null_nap.h
@@ -0,0 +1,21 @@
+#ifndef _GPXE_NULL_NAP_H
+#define _GPXE_NULL_NAP_H
+
+/** @file
+ *
+ * Null CPU sleeping
+ *
+ */
+
+#ifdef NAP_NULL
+#define NAP_PREFIX_null
+#else
+#define NAP_PREFIX_null __null_
+#endif
+
+static inline __always_inline void
+NAP_INLINE ( null, cpu_nap ) ( void ) {
+ /* Do nothing */
+}
+
+#endif /* _GPXE_NULL_NAP_H */