From 79b5932c4eea229fca427bc93ba491ffecef10f5 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Fri, 9 Nov 2012 21:35:49 +0100 Subject: 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. --- kern/kernel.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'kern/kernel.c') 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 #include +#include +#include +#include #include -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 */ } -- cgit v1.2.3