summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2010-06-07 14:41:20 -0500
committerPatrick Williams <iawillia@us.ibm.com>2010-06-07 14:41:20 -0500
commit546a015f74fab0c4e359cf97f289ff26d6481844 (patch)
treebd2643a5d512af932090fb09748aea8aa8f61521 /src
parentcd86583d084a4227dbf6a7cca2934eaad2b060d1 (diff)
downloadtalos-hostboot-546a015f74fab0c4e359cf97f289ff26d6481844.tar.gz
talos-hostboot-546a015f74fab0c4e359cf97f289ff26d6481844.zip
Create init process, fix scheduler bugs.
Diffstat (limited to 'src')
-rw-r--r--src/include/kernel/scheduler.H4
-rw-r--r--src/include/kernel/taskmgr.H5
-rw-r--r--src/kernel/cpumgr.C2
-rw-r--r--src/kernel/kernel.C17
-rw-r--r--src/kernel/scheduler.C6
-rw-r--r--src/kernel/taskmgr.C2
-rw-r--r--src/makefile2
-rw-r--r--src/sys/init/init_main.C8
-rw-r--r--src/sys/init/makefile10
-rw-r--r--src/sys/makefile12
10 files changed, 59 insertions, 9 deletions
diff --git a/src/include/kernel/scheduler.H b/src/include/kernel/scheduler.H
index 93854ac3b..31cdde70e 100644
--- a/src/include/kernel/scheduler.H
+++ b/src/include/kernel/scheduler.H
@@ -15,7 +15,8 @@ class Scheduler
void setNextRunnable();
protected:
- Scheduler() : iv_direction(false) {};
+ Scheduler(cpu_t* cpu) :
+ iv_direction(false), iv_idleTask(NULL), iv_cpu(cpu) {};
~Scheduler() {};
void setIdleTask(task_t* t) { iv_idleTask = t; };
@@ -26,6 +27,7 @@ class Scheduler
Util::Lockfree::Stack<task_t> iv_taskList[2];
task_t* iv_idleTask;
+ cpu_t* iv_cpu;
};
#endif
diff --git a/src/include/kernel/taskmgr.H b/src/include/kernel/taskmgr.H
index fbaf94f8a..34267324c 100644
--- a/src/include/kernel/taskmgr.H
+++ b/src/include/kernel/taskmgr.H
@@ -9,9 +9,10 @@ class TaskManager
static task_t* getCurrentTask();
static void setCurrentTask(task_t* t);
- typedef void(*task_fn_t)();
+ typedef void(*task_fn_t)(void*);
friend class CpuManager;
+ friend class Kernel;
protected:
TaskManager();
~TaskManager() {};
@@ -24,7 +25,7 @@ class TaskManager
tid_t iv_nextTid;
- static void idleTaskLoop();
+ static void idleTaskLoop(void*);
task_t* _createIdleTask();
task_t* _createTask(task_fn_t, void*, bool);
};
diff --git a/src/kernel/cpumgr.C b/src/kernel/cpumgr.C
index 6855bfc1e..d43b28ca8 100644
--- a/src/kernel/cpumgr.C
+++ b/src/kernel/cpumgr.C
@@ -45,7 +45,7 @@ void CpuManager::startCPU(ssize_t i)
// Initialize CPU.
cpu->cpu = i;
- cpu->scheduler = new Scheduler();
+ cpu->scheduler = new Scheduler(cpu);
cpu->kernel_stack =
(void*) (((uint64_t)PageManager::allocatePage(4)) + 16320);
diff --git a/src/kernel/kernel.C b/src/kernel/kernel.C
index 148ffe0bf..b071d9999 100644
--- a/src/kernel/kernel.C
+++ b/src/kernel/kernel.C
@@ -4,10 +4,15 @@
#include <kernel/heapmgr.H>
#include <kernel/cpumgr.H>
#include <util/singleton.H>
+#include <kernel/cpu.H>
+#include <kernel/task.H>
+#include <kernel/scheduler.H>
+#include <kernel/taskmgr.H>
#include <stdlib.h>
extern "C" void kernel_dispatch_task();
+extern void init_main(void* unused);
class Kernel
{
@@ -15,6 +20,7 @@ class Kernel
void cppBootstrap();
void memBootstrap();
void cpuBootstrap();
+ void inittaskBootstrap();
protected:
Kernel() {};
@@ -29,8 +35,9 @@ int main()
kernel.memBootstrap();
kernel.cpuBootstrap();
- kernel_dispatch_task();
+ kernel.inittaskBootstrap();
+ kernel_dispatch_task(); // no return.
while(1);
return 0;
}
@@ -59,3 +66,11 @@ void Kernel::cpuBootstrap()
CpuManager::init();
}
+void Kernel::inittaskBootstrap()
+{
+ task_t * t = TaskManager::createTask(&init_main, NULL);
+ t->cpu = CpuManager::getCurrentCPU();
+ TaskManager::setCurrentTask(t);
+
+}
+
diff --git a/src/kernel/scheduler.C b/src/kernel/scheduler.C
index 1df91b9eb..b96dd7c7b 100644
--- a/src/kernel/scheduler.C
+++ b/src/kernel/scheduler.C
@@ -5,7 +5,9 @@
void Scheduler::addTask(task_t* t)
{
if (iv_idleTask != t)
+ {
iv_taskList[iv_direction ? 0 : 1].push(t);
+ }
}
void Scheduler::returnRunnable()
@@ -22,7 +24,7 @@ void Scheduler::setNextRunnable()
if (NULL == t)
{
- iv_taskList[direction ? 0 : 1].pop();
+ t = iv_taskList[direction ? 0 : 1].pop();
__sync_bool_compare_and_swap(&iv_direction, direction, !direction);
}
@@ -30,6 +32,6 @@ void Scheduler::setNextRunnable()
{
t = iv_idleTask;
}
-
+
TaskManager::setCurrentTask(t);
}
diff --git a/src/kernel/taskmgr.C b/src/kernel/taskmgr.C
index 5917abfeb..fabb70cde 100644
--- a/src/kernel/taskmgr.C
+++ b/src/kernel/taskmgr.C
@@ -3,7 +3,7 @@
#include <kernel/task.H>
#include <kernel/pagemgr.H>
-void TaskManager::idleTaskLoop()
+void TaskManager::idleTaskLoop(void* unused)
{
while(1)
{
diff --git a/src/makefile b/src/makefile
index e0265b92e..022348601 100644
--- a/src/makefile
+++ b/src/makefile
@@ -2,7 +2,7 @@ IMGDIR = ../img
OBJDIR = ../obj
include ../config.mk
-SUBDIRS = kernel.d lib.d libc++.d
+SUBDIRS = kernel.d lib.d libc++.d sys.d
IMAGES += ${IMGDIR}/kernel.elf
IMAGES += ${IMGDIR}/kernel.bin
diff --git a/src/sys/init/init_main.C b/src/sys/init/init_main.C
new file mode 100644
index 000000000..99a7cfe0b
--- /dev/null
+++ b/src/sys/init/init_main.C
@@ -0,0 +1,8 @@
+#include <kernel/console.H> // TODO : Remove this.
+
+void init_main(void* unused)
+{
+ printk("Starting init!\n");
+
+ while(1);
+}
diff --git a/src/sys/init/makefile b/src/sys/init/makefile
new file mode 100644
index 000000000..4a1ecf48b
--- /dev/null
+++ b/src/sys/init/makefile
@@ -0,0 +1,10 @@
+OBJDIR = ../../../obj
+include ../../../config.mk
+
+OBJS = init_main.o
+OBJECTS = $(addprefix ${OBJDIR}/, ${OBJS})
+
+all: ${OBJECTS}
+
+clean:
+ (rm -f ${OBJECTS} )
diff --git a/src/sys/makefile b/src/sys/makefile
new file mode 100644
index 000000000..5a553e1d2
--- /dev/null
+++ b/src/sys/makefile
@@ -0,0 +1,12 @@
+IMGDIR = ../../img
+OBJDIR = ../../obj
+include ../../config.mk
+
+SUBDIRS = init.d
+IMAGES += ${IMGDIR}/kernel.elf
+IMAGES += ${IMGDIR}/kernel.bin
+
+all: ${SUBDIRS}
+
+clean: $(patsubst %.d,%.clean, ${SUBDIRS})
+ (rm -f ${IMAGES} )
OpenPOWER on IntegriCloud