summaryrefslogtreecommitdiff
path: root/kern/kernel.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2012-11-09 21:35:49 +0100
committerRichard Braun <rbraun@sceen.net>2012-11-09 21:40:52 +0100
commit79b5932c4eea229fca427bc93ba491ffecef10f5 (patch)
treebf1165e7fa7c2f6232fd8c1e8b6c148b329b42f7 /kern/kernel.c
parentc8ba9280fafe518ada8a6d2a545d6afa2b2dbe23 (diff)
Implement preliminary thread context
Three new modules are added : - kern/task: Tasks are thread groups and resource containers for their threads. - kern/thread: The well known scheduling unit. - x86/tcb: The architecture specific thread control block. The kernel currently loads a single thread context on the main processor.
Diffstat (limited to 'kern/kernel.c')
-rw-r--r--kern/kernel.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/kern/kernel.c b/kern/kernel.c
index 52217876..7c83d8d1 100644
--- a/kern/kernel.c
+++ b/kern/kernel.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Richard Braun.
+ * Copyright (c) 2011, 2012 Richard Braun.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,15 +17,39 @@
#include <kern/init.h>
#include <kern/kernel.h>
+#include <kern/panic.h>
+#include <kern/task.h>
+#include <kern/thread.h>
#include <machine/cpu.h>
-void __init
-kernel_main(void)
+static void __init
+kernel_setup(void *arg)
{
+ (void)arg;
+
+ cpu_mp_setup();
+
cpu_intr_enable();
for (;;)
cpu_idle();
+}
+
+void __init
+kernel_main(void)
+{
+ struct thread *thread;
+ int error;
+
+ task_setup();
+ thread_setup();
+
+ error = thread_create(&thread, "core", kernel_task, kernel_setup, NULL);
+
+ if (error)
+ panic("kernel: unable to create kernel thread");
+
+ thread_load(thread);
/* Never reached */
}