Ksched is interrupt driven
[akaros.git] / kern / src / manager.c
index cdf4e78..04304b4 100644 (file)
 #include <testing.h>
 #include <kfs.h>
 #include <stdio.h>
-#include <timing.h>
-#include <resource.h>
+#include <time.h>
 #include <monitor.h>
 #include <colored_caches.h>
 #include <string.h>
 #include <pmap.h>
-#include <ros/timer.h>
+#include <arch/console.h>
+#include <ros/time.h>
 #include <ros/arch/membar.h>
 
 /*
@@ -66,8 +66,8 @@ char *p_envp[] = {"LD_LIBRARY_PATH=/lib", 0};
        spin_lock(&(p)->proc_lock);                                                  \
        __proc_set_state((p), PROC_RUNNABLE_S);                                      \
        spin_unlock(&(p)->proc_lock);                                                \
-       proc_run((p));                                                               \
-       kref_put(&(p)->kref);
+       proc_run_s((p));                                                             \
+       proc_decref((p));
 
 #define quick_proc_create(x, p, f)                                               \
        (f) = do_file_open((x), 0, 0);                                               \
@@ -91,8 +91,8 @@ char *p_envp[] = {"LD_LIBRARY_PATH=/lib", 0};
        p->cache_colors_map = cache_colors_map_alloc();                              \
        for (int i = 0; i < (c); i++)                                                \
                cache_color_alloc(llc_cache, p->cache_colors_map);                       \
-       proc_run((p));                                                               \
-       kref_put(&(p)->kref);
+       proc_run_s((p));                                                             \
+       proc_decref((p));
 
 #define quick_proc_color_create(x, p, c, f)                                      \
        (f) = do_file_open((x), 0, 0);                                               \
@@ -109,16 +109,44 @@ char *p_envp[] = {"LD_LIBRARY_PATH=/lib", 0};
 
 void manager_brho(void)
 {
-       static uint8_t RACY progress = 0;
-       static struct proc *p;
-       struct file *temp_f;
+       static bool first = TRUE;
+       struct per_cpu_info *pcpui = &per_cpu_info[core_id()];
+
+       if (first) {    
+               printk("*** Hit shift-g to get into the monitor. ***\n");
+               first = FALSE;
+       }
+       while (1) {
+               enable_irq();
+               /* one time keyboard / serial check for some magic, then monitor */
+               if (cons_getc() == 'G') {
+                       printk("Heard the call of the giraffe!\n");
+                       monitor(0);
+               }
+               process_routine_kmsg(0);
+               /* would like to idle here, but without reset stacks, people will run
+                * off the kstack.  so just idle if we have an owning proc (which we
+                * should then 'restart'). */
+               if (pcpui->owning_proc)
+                       smp_idle();
+       }
+       /* whatever we do in the manager, keep in mind that we need to not do
+        * anything too soon (like make processes), since we'll drop in here during
+        * boot if the boot sequence required any I/O (like EXT2), and we need to
+        * PRKM() */
+       assert(0);
 
+#if 0 /* ancient tests below: (keeping around til we ditch the manager) */
        // for testing taking cores, check in case 1 for usage
        uint32_t corelist[MAX_NUM_CPUS];
        uint32_t num = 3;
+       struct file *temp_f;
+       static struct proc *p;
 
+       static uint8_t RACY progress = 0;       /* this will wrap around. */
        switch (progress++) {
                case 0:
+                       printk("Top of the manager to ya!\n");
                        /* 124 is half of the available boxboro colors (with the kernel
                         * getting 8) */
                        //quick_proc_color_run("msr_dumb_while", p, 124, temp_f);
@@ -163,6 +191,7 @@ void manager_brho(void)
                        envs[0] = kfs_proc_create(kfs_lookup_path("roslib_hello"));
                        __proc_set_state(envs[0], PROC_RUNNABLE_S);
                        proc_run(envs[0]);
+                       warn("DEPRECATED");
                        break;
                        #endif
                case 2:
@@ -192,6 +221,7 @@ void manager_brho(void)
        }
        */
        return;
+#endif
 }
 
 void manager_klueska()
@@ -204,63 +234,36 @@ void manager_klueska()
                panic("what do you want to do?");
                //envs[0] = kfs_proc_create(kfs_lookup_path("fillmeup"));
                __proc_set_state(envs[0], PROC_RUNNABLE_S);
-               proc_run(envs[0]);
+               proc_run_s(envs[0]);
+               warn("DEPRECATED");
        }
        schedule();
 
        panic("DON'T PANIC");
 }
 
-struct elf_info
-{
-       long entry;
-       long phdr;
-       int phnum;
-       int dynamic;
-       char interp[256];
-};
-
 void manager_waterman()
 {
-       static int init = 0;
-       if(!init)
-       {
-               warn("Old file creation might not work");
-               init = 1;
-               struct proc *p;
-               proc_alloc(&p, 0);
-
-               char* argv[] = {"/bin/sh","-l",0};
-               char* envp[] = {"LD_LIBRARY_PATH=/lib",0};
-               procinfo_pack_args(p->procinfo,argv,envp);
-
-               struct file* f = file_open("/bin/busybox",0,0);
-               assert(f != NULL);
-               assert(load_elf(p,f) == 0);
-               file_decref(f);
-
-               __proc_set_state(p, PROC_RUNNABLE_S);
-               proc_run(p);
-       }
        schedule();
+       monitor(0);
+       assert(0);
 }
 
-void manager_pearce()
+void manager_yuzhu()
 {
-       static struct proc *envs[256];
-       static volatile uint8_t progress = 0;
+       
+       static uint8_t RACY progress = 0;
+       static struct proc *p;
 
-       if (progress == 0) {
-               progress++;
-               panic("what do you want to do?");
-               //envs[0] = kfs_proc_create(kfs_lookup_path("parlib_httpserver_integrated"));
-               //envs[0] = kfs_proc_create(kfs_lookup_path("parlib_lock_test"));
-               __proc_set_state(envs[0], PROC_RUNNABLE_S);
-               proc_run(envs[0]);
-       }
-       schedule();
+       // for testing taking cores, check in case 1 for usage
+       uint32_t corelist[MAX_NUM_CPUS];
+       uint32_t num = 3;
 
-       panic("DON'T PANIC");
+       //create_server(init_num_cores, loop);
+
+       monitor(0);
+
+       // quick_proc_run("hello", p);
 
 }