From: Matthias Kruk Date: Sun, 29 Sep 2019 05:54:13 +0000 (+0900) Subject: Initialize two tasks at boot time, for testing purposes X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=302e3ab9b8cf5b0c7f76d4cd9ffca0e797ec08b0;p=corax Initialize two tasks at boot time, for testing purposes --- diff --git a/kernel/core/main.c b/kernel/core/main.c index 09f8cef..2528676 100644 --- a/kernel/core/main.c +++ b/kernel/core/main.c @@ -18,11 +18,14 @@ #include #include +#include #include #include +#include void cpu_debug(void); int arch_init(void*); +void sched_tick(void); void _print_mptbl(void *tbl) { @@ -74,6 +77,15 @@ void _print_mptbl(void *tbl) return; } +static void _idle(void) +{ + while(1) { + asm volatile("hlt"); + } + + return; +} + int corax(void *mb_info, u32_t magic) { dbg_printf("Corax 0.1 - As the Crow flies\n"); @@ -148,12 +160,43 @@ int corax(void *mb_info, u32_t magic) } } */ +#if 0 + void *ptr; + + ptr = kmalloc(1024 * 1024); + + dbg_printf("Allocated 1024KB @ %p\n", ptr); + + kfree(ptr); +#endif + dbg_printf("Switching pstate\n"); p = cpu_set_pstate(1); dbg_printf("Entered P-state %u. (0x%x)\n", p & 0xffff, p); dbg_printf("Initialisation complete. Nothing to do.\n"); + process_t *proc; + process_t *proc2; + u32_t err; + + err = process_create(&proc, 0, (void*)_idle); + + if(err < 0) { + dbg_printf("process_create() = 0x%x\n", err); + } + + /* enqueue a second process */ + err = process_create(&proc2, 0, (void*)_idle); + + if(err < 0) { + dbg_printf("process_create() = 0x%x\n", err); + } + + sched_tick(); + + dbg_printf("This should not get printed\n"); + while(1) { asm volatile("hlt"); }