summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2010-06-02 17:45:11 -0500
committerPatrick Williams <iawillia@us.ibm.com>2010-06-02 17:45:11 -0500
commit2cc0de1f136026f13ca6de363d9e57831c6ba10b (patch)
tree5653bf1244af8c97e63745536bf5ca887d06ea36 /src/include
parent5235cd52014205f358f1a295c5228091e1847efb (diff)
downloadtalos-hostboot-2cc0de1f136026f13ca6de363d9e57831c6ba10b.tar.gz
talos-hostboot-2cc0de1f136026f13ca6de363d9e57831c6ba10b.zip
Initial cpu / task structs.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/kernel/cpu.H16
-rw-r--r--src/include/kernel/cpumgr.H32
-rw-r--r--src/include/kernel/scheduler.H26
-rw-r--r--src/include/kernel/task.H25
-rw-r--r--src/include/kernel/taskmgr.H31
-rw-r--r--src/include/kernel/types.h12
6 files changed, 142 insertions, 0 deletions
diff --git a/src/include/kernel/cpu.H b/src/include/kernel/cpu.H
new file mode 100644
index 000000000..6dd513b2c
--- /dev/null
+++ b/src/include/kernel/cpu.H
@@ -0,0 +1,16 @@
+#ifndef __KERNEL_CPU_H
+#define __KERNEL_CPU_H
+
+#include <kernel/types.h>
+
+class Scheduler;
+
+struct cpu_t
+{
+ cpuid_t cpu;
+
+ Scheduler* scheduler;
+ void* kernel_stack;
+};
+
+#endif
diff --git a/src/include/kernel/cpumgr.H b/src/include/kernel/cpumgr.H
new file mode 100644
index 000000000..06ca8dbc1
--- /dev/null
+++ b/src/include/kernel/cpumgr.H
@@ -0,0 +1,32 @@
+#ifndef __KERNEL_CPUMGR_H
+#define __KERNEL_CPUMGR_H
+
+#include <kernel/types.h>
+
+class CpuManager
+{
+ public:
+ enum { MAXCPUS = 8 };
+
+ /** @fn getCurrentCPU
+ * Returns a pointer to the current CPU structure by using the
+ * task structure in SPRG3.
+ */
+ cpu_t* getCurrentCPU();
+
+ static void init();
+
+ protected:
+ CpuManager();
+ ~CpuManager() {};
+
+ /** @fn startCPU
+ * Starts the requested CPU. Default of -1 implies current CPU.
+ */
+ void startCPU(ssize_t i = -1);
+
+ private:
+ cpu_t* iv_cpus[MAXCPUS];
+};
+
+#endif
diff --git a/src/include/kernel/scheduler.H b/src/include/kernel/scheduler.H
new file mode 100644
index 000000000..06c3adcee
--- /dev/null
+++ b/src/include/kernel/scheduler.H
@@ -0,0 +1,26 @@
+#ifndef __KERNEL_SCHEDULER_H
+#define __KERNEL_SCHEDULER_H
+
+#include <kernel/types.h>
+#include <util/lockfree/stack.H>
+
+class Scheduler
+{
+ public:
+ friend class CpuManager;
+
+ protected:
+ Scheduler() : iv_direction(false) {};
+ ~Scheduler() {};
+
+ void setIdleTask(task_t* t) { iv_idleTask = t; };
+ task_t* getIdleTask() { return iv_idleTask; };
+
+ private:
+ bool iv_direction;
+ Util::Lockfree::Stack<task_t> iv_taskList[2];
+
+ task_t* iv_idleTask;
+};
+
+#endif
diff --git a/src/include/kernel/task.H b/src/include/kernel/task.H
new file mode 100644
index 000000000..c2ae51de1
--- /dev/null
+++ b/src/include/kernel/task.H
@@ -0,0 +1,25 @@
+#ifndef __KERNEL_TASK_H
+#define __KERNEL_TASK_H
+
+#include <kernel/types.h>
+
+struct context_t
+{
+ void* stack_ptr;
+ void* nip;
+ uint64_t gprs[32];
+ uint64_t lr;
+ uint64_t ctr;
+ uint64_t xer;
+};
+
+struct task_t
+{
+ cpu_t* cpu;
+ context_t context;
+
+ tid_t tid;
+ task_t* next;
+};
+
+#endif
diff --git a/src/include/kernel/taskmgr.H b/src/include/kernel/taskmgr.H
new file mode 100644
index 000000000..7f23c8821
--- /dev/null
+++ b/src/include/kernel/taskmgr.H
@@ -0,0 +1,31 @@
+#ifndef __KERNEL_TASKMGR_H
+#define __KENREL_TASKMGR_H
+
+#include <kernel/types.h>
+
+class TaskManager
+{
+ public:
+ static task_t* getCurrentTask();
+
+ typedef void(*task_fn_t)();
+
+ friend class CpuManager;
+ protected:
+ TaskManager();
+ ~TaskManager() {};
+
+ static task_t* createIdleTask();
+ static task_t* createTask(task_fn_t);
+
+ private:
+ tid_t getNextTid();
+
+ tid_t iv_nextTid;
+
+ static void idleTaskLoop();
+ task_t* _createIdleTask();
+ task_t* _createTask(task_fn_t, bool);
+};
+
+#endif
diff --git a/src/include/kernel/types.h b/src/include/kernel/types.h
new file mode 100644
index 000000000..c994308c2
--- /dev/null
+++ b/src/include/kernel/types.h
@@ -0,0 +1,12 @@
+#ifndef __KERNEL_TYPES_H
+#define __KNERLE_TYPES_H
+
+#include <stdint.h>
+
+typedef uint64_t tid_t;
+struct task_t;
+
+typedef uint64_t cpuid_t;
+struct cpu_t;
+
+#endif
OpenPOWER on IntegriCloud