VFS: mounts KFS, shell functions
[akaros.git] / kern / src / manager.c
index 86614f5..2cfeea5 100644 (file)
@@ -31,6 +31,8 @@
 #include <colored_caches.h>
 #include <string.h>
 #include <pmap.h>
+#include <ros/timer.h>
+#include <ros/arch/membar.h>
 
 /*
  * Currently, if you leave this function by way of proc_run (process_workqueue
@@ -51,12 +53,46 @@ void manager(void)
        MANAGER_FUNC(DEVELOPER_NAME)();
 }
 
+/* Helper macro for quickly running something out of KFS.  Pass it a string and
+ * a proc pointer. */
+#define quick_proc_run(x, p)                                                     \
+       (p) = kfs_proc_create(kfs_lookup_path((x)));                                 \
+       spin_lock(&(p)->proc_lock);                                                  \
+       __proc_set_state((p), PROC_RUNNABLE_S);                                      \
+       spin_unlock(&(p)->proc_lock);                                                \
+       proc_run((p));                                                               \
+       proc_decref((p), 1);
+
+#define quick_proc_create(x, p)                                                  \
+       (p) = kfs_proc_create(kfs_lookup_path((x)));                                 \
+       spin_lock(&(p)->proc_lock);                                                  \
+       __proc_set_state((p), PROC_RUNNABLE_S);                                      \
+       spin_unlock(&(p)->proc_lock);
+
+#define quick_proc_color_run(x, p, c)                                            \
+       (p) = kfs_proc_create(kfs_lookup_path((x)));                                 \
+       spin_lock(&(p)->proc_lock);                                                  \
+       __proc_set_state((p), PROC_RUNNABLE_S);                                      \
+       spin_unlock(&(p)->proc_lock);                                                \
+       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));                                                               \
+       proc_decref((p), 1);
+
+#define quick_proc_color_create(x, p, c)                                         \
+       (p) = kfs_proc_create(kfs_lookup_path((x)));                                 \
+       spin_lock(&(p)->proc_lock);                                                  \
+       __proc_set_state((p), PROC_RUNNABLE_S);                                      \
+       spin_unlock(&(p)->proc_lock);                                                \
+       p->cache_colors_map = cache_colors_map_alloc();                              \
+       for (int i = 0; i < (c); i++)                                                \
+               cache_color_alloc(llc_cache, p->cache_colors_map);
+
 void manager_brho(void)
 {
        static uint8_t RACY progress = 0;
-
-       static struct proc *envs[256];
-       static struct proc *p ;
+       static struct proc *p;
 
        // for testing taking cores, check in case 1 for usage
        uint32_t corelist[MAX_NUM_CPUS];
@@ -64,16 +100,11 @@ void manager_brho(void)
 
        switch (progress++) {
                case 0:
-                       // TODO: need to store the pid for future manager runs, not the *p
-                       //p = kfs_proc_create(kfs_lookup_path("pthread_test"));
-                       p = kfs_proc_create(kfs_lookup_path("mhello"));
-                       // being proper and all:
-                       spin_lock(&p->proc_lock);
-                       __proc_set_state(p, PROC_RUNNABLE_S);
-                       // normal single-cored way
-                       spin_unlock(&p->proc_lock);
-                       proc_run(p);
-                       proc_decref(p, 1);
+                       monitor(0);
+                       /* 124 is half of the available boxboro colors (with the kernel
+                        * getting 8) */
+                       //quick_proc_color_run("msr_dumb_while", p, 124);
+                       quick_proc_run("mhello", p);
                        #if 0
                        // this is how you can transition to a parallel process manually
                        // make sure you don't proc run first
@@ -86,7 +117,6 @@ void manager_brho(void)
                        #endif
                        break;
                case 1:
-                       //monitor(0);
                        #if 0
                        udelay(10000000);
                        // this is a ghetto way to test restarting an _M
@@ -134,6 +164,7 @@ void manager_brho(void)
                        schedule();
        }
        panic("If you see me, then you probably screwed up");
+       monitor(0);
 
        /*
        printk("Servicing syscalls from Core 0:\n\n");
@@ -211,7 +242,6 @@ void manager_pearce()
 
 }
 
-
 #ifdef __sparc_v8__
 
 static char*