summaryrefslogtreecommitdiffstats
path: root/src/include/kernel
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2010-10-04 17:48:47 -0500
committerPatrick Williams <iawillia@us.ibm.com>2010-10-04 17:48:47 -0500
commit3e9ed72a3b6442eaebadf26294e448862c3a4400 (patch)
treef3745143af3f1f87d99f3dec1256549195bf7fe1 /src/include/kernel
parent706838262ce47efeb8f983920a218460b81f2dc3 (diff)
downloadtalos-hostboot-3e9ed72a3b6442eaebadf26294e448862c3a4400.tar.gz
talos-hostboot-3e9ed72a3b6442eaebadf26294e448862c3a4400.zip
Add nanosleep syscall.
Diffstat (limited to 'src/include/kernel')
-rw-r--r--src/include/kernel/ppcarch.H8
-rw-r--r--src/include/kernel/syscalls.H2
-rw-r--r--src/include/kernel/timemgr.H43
3 files changed, 48 insertions, 5 deletions
diff --git a/src/include/kernel/ppcarch.H b/src/include/kernel/ppcarch.H
index 91ee138a2..3d34bf888 100644
--- a/src/include/kernel/ppcarch.H
+++ b/src/include/kernel/ppcarch.H
@@ -74,6 +74,14 @@ inline uint64_t ppc_getDAR()
return dar;
}
+__attribute__((always_inline))
+inline uint64_t ppc_getTB()
+{
+ register uint64_t tb = 0;
+ asm volatile("mfspr %0, 268" : "=r" (tb));
+ return tb;
+}
+
#endif
diff --git a/src/include/kernel/syscalls.H b/src/include/kernel/syscalls.H
index a33a0cef7..330db6922 100644
--- a/src/include/kernel/syscalls.H
+++ b/src/include/kernel/syscalls.H
@@ -28,6 +28,8 @@ namespace Systemcalls
MMIO_MAP,
MMIO_UNMAP,
+ TIME_NANOSLEEP,
+
SYSCALL_MAX
};
};
diff --git a/src/include/kernel/timemgr.H b/src/include/kernel/timemgr.H
index 58381263f..78de82216 100644
--- a/src/include/kernel/timemgr.H
+++ b/src/include/kernel/timemgr.H
@@ -2,25 +2,58 @@
#define __KERNEL_TIMEMGR_H
#include <kernel/types.h>
+#include <kernel/ppcarch.H>
+
+#include <util/locked/pqueue.H>
+#include <kernel/spinlock.H>
+
+class Scheduler;
+
+struct _TimeManager_Delay_t
+{
+ _TimeManager_Delay_t * next;
+ _TimeManager_Delay_t * prev;
+ uint64_t key;
+ task_t* task;
+};
class TimeManager
{
public:
+ enum
+ {
+ TIMESLICE_PER_SEC = 1000,
+ };
+
static void init();
static uint64_t getTimeSliceCount()
{
- return iv_timeSlice;
+ return iv_timebaseFreq / TIMESLICE_PER_SEC;
};
+ static uint64_t getCurrentTimeBase()
+ {
+ return ppc_getTB();
+ };
+
+ static uint64_t convertSecToTicks(uint64_t i_sec, uint64_t i_nsec);
+
+ static void delayTask(task_t* t, uint64_t i_sec, uint64_t i_nsec);
+ static void checkReleaseTasks(Scheduler* s);
+
protected:
- TimeManager() {};
+ TimeManager() :
+ iv_taskList() {};
~TimeManager() {};
private:
void _init();
-
-
- static uint64_t iv_timeSlice;
+ void _delayTask(task_t* t, uint64_t i_sec, uint64_t i_nsec);
+ void _checkReleaseTasks(Scheduler* s);
+
+ Util::Locked::PQueue<_TimeManager_Delay_t, uint64_t,
+ true, Spinlock> iv_taskList;
+ static uint64_t iv_timebaseFreq;
};
#endif
OpenPOWER on IntegriCloud