]> git.corax.cc Git - corax/commitdiff
Initialize two tasks at boot time, for testing purposes
authorMatthias Kruk <m@m10k.eu>
Sun, 29 Sep 2019 05:54:13 +0000 (14:54 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 29 Sep 2019 05:54:13 +0000 (14:54 +0900)
kernel/core/main.c

index 09f8cef7aa71b9a4fcdf3c4b49ef3fc0ed45224c..25286764dd37b30c96a410a2897c8c5a44fe180d 100644 (file)
 
 #include <config.h>
 #include <corax/types.h>
+#include <corax/heap.h>
 #include <debug.h>
 #include <arch.h>
+#include <process.h>
 
 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");
     }