summaryrefslogtreecommitdiffstats
path: root/src/include/sys
diff options
context:
space:
mode:
authordgilbert <dgilbert@us.ibm.com>2011-06-03 12:54:41 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2011-06-17 12:23:52 -0500
commit609d6810b8bc92dc979f8bbb8e7e7d7b7b5d9490 (patch)
treecd517ec2e10a95638e675b037bb24e2d01296ef4 /src/include/sys
parentf64ba52098e248e62b4ddb14c0a027c21066e9e2 (diff)
downloadtalos-hostboot-609d6810b8bc92dc979f8bbb8e7e7d7b7b5d9490.tar.gz
talos-hostboot-609d6810b8bc92dc979f8bbb8e7e7d7b7b5d9490.zip
Initial futex support
Change-Id: I51a4f1117085ce23c7993c1a38e4124596636726 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/141 Tested-by: Jenkins Server Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com> Reviewed-by: Thi N. Tran <thi@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/include/sys')
-rw-r--r--src/include/sys/mmio.h4
-rw-r--r--src/include/sys/mutex.h20
-rw-r--r--src/include/sys/sync.h89
3 files changed, 91 insertions, 22 deletions
diff --git a/src/include/sys/mmio.h b/src/include/sys/mmio.h
index c36a13821..3536071c8 100644
--- a/src/include/sys/mmio.h
+++ b/src/include/sys/mmio.h
@@ -2,7 +2,7 @@
#define __SYS_MMIO_H
#include <stdint.h>
-#include <sys/mutex.h>
+#include <sys/sync.h>
#ifdef __cplusplus
extern "C"
@@ -38,7 +38,7 @@ int mmio_hmer_write(uint64_t value);
* affinity pin. If the pin is moved the mutex is no longer
* guarenteed for the CPU the task is executing on.
*/
-mutex_t mmio_xscom_mutex();
+mutex_t * mmio_xscom_mutex();
#ifdef __cplusplus
}
diff --git a/src/include/sys/mutex.h b/src/include/sys/mutex.h
deleted file mode 100644
index 3eca65f06..000000000
--- a/src/include/sys/mutex.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __SYS_MUTEX_H
-#define __SYS_MUTEX_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef void* mutex_t;
-
-mutex_t mutex_create();
-int mutex_destroy(mutex_t);
-
-int mutex_lock(mutex_t);
-int mutex_unlock(mutex_t);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/src/include/sys/sync.h b/src/include/sys/sync.h
new file mode 100644
index 000000000..68b570aec
--- /dev/null
+++ b/src/include/sys/sync.h
@@ -0,0 +1,89 @@
+#ifndef SYNC
+#define SYNC
+
+#include <stdint.h>
+
+/**
+ * Mutex object type
+ */
+struct _futex_imp_t
+{
+ uint64_t iv_val;
+};
+
+typedef _futex_imp_t mutex_t;
+
+/**
+ * Barrier object type
+ */
+struct _barrier_imp_t
+{
+ mutex_t iv_mutex;
+ uint64_t iv_event;
+ uint64_t iv_missing;
+ uint64_t iv_count;
+};
+
+typedef _barrier_imp_t barrier_t;
+
+#define MUTEX_INITIALIZER {0}
+
+/**
+ * Initialize a barrier object
+ * @param[out] o_barrier The barrier
+ * @param[in] i_count The number of threads to wait on
+ * @pre an unitiailized barrier object
+ * @post a valid barrier object
+ */
+void barrier_init (barrier_t * o_barrier, uint64_t i_count);
+
+/**
+ * Destroy a barrier
+ * @param[in] i_barrier The barrier
+ */
+void barrier_destroy (barrier_t * i_barrier);
+
+/**
+ * Wait on a barrier
+ * @param[in] i_barrier The barrier
+ * @post this thread will be blocked until the barrier count is reached.
+ */
+void barrier_wait (barrier_t * i_barrier);
+
+/**
+ * Create a mutex and initialize a mutex
+ * @returns a pointer to the mutex
+ */
+mutex_t * mutex_create();
+
+/**
+ * Initialize a mutex object
+ * @param[out] o_mutex the mutex
+ * @pre an uninitialized mutex object
+ * @post a valid mutex object
+ */
+void mutex_init(mutex_t * o_mutex);
+
+/**
+ * Destroy a mutex
+ * @param[in/out] i_mutex The mutex
+ * @pre mutex must have been created with mutex_create()
+ */
+void mutex_destroy(mutex_t *& io_mutex);
+
+/**
+ * Obtain a lock on a mutex
+ * @param[in] i_mutex The mutex
+ * @post returns when this thread has the lock
+ */
+void mutex_lock(mutex_t * i_mutex);
+
+/**
+ * Release a lock on a mutex
+ * @param[in] i_mutex the mutex
+ * @returns non zero on error
+ * @post mutex lock release
+ */
+void mutex_unlock(mutex_t * i_mutex);
+
+#endif
OpenPOWER on IntegriCloud