Get the previous commit working with gcc
authorZach Anderson <zra@zra-intrepid.(none)>
Fri, 11 Sep 2009 18:36:56 +0000 (11:36 -0700)
committerZach Anderson <zra@zra-intrepid.(none)>
Fri, 11 Sep 2009 18:36:56 +0000 (11:36 -0700)
kern/arch/i386/smp_boot.c
kern/include/env.h
kern/include/process.h
kern/include/ros/ring_buffer.h
kern/src/env.c
kern/src/process.c
kern/src/testing.c

index f1ae7f5..184640f 100644 (file)
@@ -56,7 +56,11 @@ static void init_smp_call_function(void)
 
 /******************************************************************************/
 
+#ifdef __IVY__
 static void smp_mtrr_handler(trapframe_t *tf, barrier_t *data)
+#else
+static void smp_mtrr_handler(trapframe_t *tf, void *data)
+#endif
 {
        setup_default_mtrrs(data);
 }
index 4eb5a4b..bba2269 100644 (file)
@@ -114,6 +114,10 @@ void       env_pop_tf(trapframe_t *tf) __attribute__((noreturn));
 
 
 /* Helper handler for smp_call to dispatch jobs to other cores */
+#ifdef __IVY__
 void run_env_handler(trapframe_t *tf, env_t * data);
+#else
+void run_env_handler(trapframe_t *tf, void * data);
+#endif
 
 #endif // !ROS_KERN_ENV_H
index bdf7738..755d9c4 100644 (file)
@@ -58,10 +58,17 @@ error_t proc_incref(struct proc *SAFE p);
 void proc_decref(struct proc *SAFE p);
 
 /* Active message handlers for process management */
-void __startcore(trapframe_t *tf, uint32_t srcid, uint32_t a0, uint32_t a1,
-                 uint32_t a2);
-void __death(trapframe_t *tf, uint32_t srcid, uint32_t a0, uint32_t a1,
-             uint32_t a2);
+#ifdef __IVY__
+void __startcore(trapframe_t *tf, uint32_t srcid, struct proc *CT(1) a0,
+                 trapframe_t *CT(1) a1, void *SNT a2);
+void __death(trapframe_t *tf, uint32_t srcid, void *SNT a0, void *SNT a1,
+             void *SNT a2);
+#else
+void __startcore(trapframe_t *tf, uint32_t srcid, void * a0, void * a1,
+                 void * a2);
+void __death(trapframe_t *tf, uint32_t srcid, void * a0, void * a1,
+             void * a2);
+#endif
 
 /* Degubbing */
 void print_idlecoremap(void);
index 6c01406..3fac1ec 100644 (file)
@@ -36,6 +36,9 @@
 
 typedef unsigned int RING_IDX;
 
+// zra: smp.c is v. slow to build because these RDn() things cause expressions
+//      to grow exponentially.
+
 /* Round a 32-bit unsigned constant down to the nearest power of two. */
 #define __RD2(_x)  (((_x) & 0x00000002UL) ? 0x2                  : ((_x) & 0x1))
 #define __RD4(_x)  (((_x) & 0x0000000cUL) ? __RD2((_x)>>2)<<2    : __RD2(_x))
@@ -130,8 +133,12 @@ typedef unsigned int RING_IDX;
     RING_IDX rsp_prod, rsp_event;                                       \
     uint8_t  pad[48];
     
+struct rhs_struct {
+       __RING_HEADER()
+};
+
 #define __RING_HEADER_SIZE() \
-    (sizeof(struct {__RING_HEADER()} ))
+    (sizeof(struct rhs_struct))
 
 #define DEFINE_RING_TYPES(__name, __req_t, __rsp_t)                     \
        DEFINE_RING_TYPES_WITH_SIZE(__name, __req_t, __rsp_t,               \
@@ -171,7 +178,6 @@ struct __name##_back_ring {                                             \
 typedef struct __name##_sring __name##_sring_t;                         \
 typedef struct __name##_front_ring __name##_front_ring_t;               \
 typedef struct __name##_back_ring __name##_back_ring_t;                 \
-                                                                        \
 /* This is a dummy function just used to statically assert that         \
  * there are no weird padding issues associated with our sring structs  \
  */                                                                     \
@@ -186,6 +192,7 @@ static void __name##_assert_sring_size() {                              \
                      );                                                    \
 }              
 
+
 /*
  * Macros for manipulating rings.
  * 
index 7b9023a..092f162 100644 (file)
@@ -493,7 +493,11 @@ type SLOCKED(name##_lock) *\
  *
  * Note this is rather old, and meant to run a RUNNABLE_S on a worker core.
  */
+#ifdef __IVY__
 void run_env_handler(trapframe_t *tf, env_t * data)
+#else
+void run_env_handler(trapframe_t *tf, void * data)
+#endif
 {
        assert(data);
        struct work TP(env_t *) job;
@@ -501,13 +505,11 @@ void run_env_handler(trapframe_t *tf, env_t * data)
            TC(&per_cpu_info[core_id()].workqueue);
        // this doesn't work, and making it a TP(env_t) is wrong
        // zra: When you want to use other types, let me know, and I can help
-    // make something that Ivy is happy with. We'll have to use some tagged
-    // unions for the elements of the work queue, and for the args to this
-    // function.
-#ifndef __IVY__
-       job.func = (func_t)proc_run;
-#else
+    // make something that Ivy is happy with. 
+#ifdef __IVY__
        job.func = proc_run;
+#else
+       job.func = (func_t)proc_run;
 #endif
        job.data = data;
        if (enqueue_work(workqueue, &job))
index c8e6365..ed9cd4c 100644 (file)
@@ -148,14 +148,24 @@ void proc_run(struct proc *p)
                        if (p->num_vcores) {
                                // TODO: handle silly state (HSS)
                                // set virtual core 0 to run the main context
-                               send_active_msg_sync(p->vcoremap[0], __startcore, (uint32_t)p,
-                                                    (uint32_t)&p->env_tf, 0);
+#ifdef __IVY__
+                               send_active_msg_sync(p->vcoremap[0], __startcore, p,
+                                                    &p->env_tf, (void *SNT)0);
+#else
+                               send_active_msg_sync(p->vcoremap[0], (void *)__startcore,
+                                                    (void *)p, (void *)&p->env_tf, 0);
+#endif
                                /* handle the others.  note the sync message will spin until
                                 * there is a free active message slot, which could lock up the
                                 * system.  think about this. (TODO) */
                                for (int i = 1; i < p->num_vcores; i++)
+#ifdef __IVY__
                                        send_active_msg_sync(p->vcoremap[i], __startcore,
-                                                            (uint32_t)p, 0, i);
+                                                            p, (trapframe_t *CT(1))NULL, (void *SNT)i);
+#else
+                                       send_active_msg_sync(p->vcoremap[i], (void *)__startcore,
+                                                            (void *)p, (void *)0, (void *)i);
+#endif
                        }
                        /* There a subtle (attempted) race avoidance here.  proc_startcore
                         * can handle a death message, but we can't have the startcore come
@@ -292,7 +302,8 @@ void proc_destroy(struct proc *p)
                                current = NULL;
                        }
                        #endif
-                       send_active_msg_sync(p->vcoremap[0], __death, 0, 0, 0);
+                       send_active_msg_sync(p->vcoremap[0], __death, (void *SNT)0,
+                                            (void *SNT)0, (void *SNT)0);
                        #if 0
                        /* right now, RUNNING_S only runs on a mgmt core (0), not cores
                         * managed by the idlecoremap.  so don't do this yet. */
@@ -308,7 +319,8 @@ void proc_destroy(struct proc *p)
                         * within proc_destroy */
                        spin_lock(&idle_lock);
                        for (int i = 0; i < p->num_vcores; i++) {
-                               send_active_msg_sync(p->vcoremap[i], __death, 0, 0, 0);
+                               send_active_msg_sync(p->vcoremap[i], __death, (void *SNT)0,
+                                                    (void *SNT)0, (void *SNT)0);
                                // give the pcore back to the idlecoremap
                                assert(num_idlecores < num_cpus); // sanity
                                idlecoremap[num_idlecores++] = p->vcoremap[i];
@@ -411,13 +423,18 @@ void proc_decref(struct proc *p)
 
 /* Active message handler to start a process's context on this core.  Tightly
  * coupled with proc_run() */
-void __startcore(trapframe_t *tf, uint32_t srcid, uint32_t a0, uint32_t a1,
-                 uint32_t a2)
+#ifdef __IVY__
+void __startcore(trapframe_t *tf, uint32_t srcid, struct proc *CT(1) a0,
+                 trapframe_t *CT(1) a1, void *SNT a2)
+#else
+void __startcore(trapframe_t *tf, uint32_t srcid, void * a0, void * a1,
+                 void * a2)
+#endif
 {
        uint32_t coreid = core_id();
-       struct proc *p_to_run = (struct proc *SAFE) TC(a0);
+       struct proc *p_to_run = (struct proc *CT(1))a0;
        trapframe_t local_tf;
-       trapframe_t *tf_to_pop = (trapframe_t *SAFE) TC(a1);
+       trapframe_t *tf_to_pop = (trapframe_t *CT(1))a1;
 
        printk("Startcore on core %d\n", coreid);
        assert(p_to_run);
@@ -427,7 +444,7 @@ void __startcore(trapframe_t *tf, uint32_t srcid, uint32_t a0, uint32_t a1,
                memset(tf_to_pop, 0, sizeof(*tf_to_pop));
                proc_init_trapframe(tf_to_pop);
                // Note the init_tf sets tf_to_pop->tf_esp = USTACKTOP;
-               proc_set_tfcoreid(tf_to_pop, a2);
+               proc_set_tfcoreid(tf_to_pop, (uint32_t)a2);
                proc_set_program_counter(tf_to_pop, p_to_run->env_entry);
        }
        proc_startcore(p_to_run, tf_to_pop);
@@ -437,8 +454,8 @@ void __startcore(trapframe_t *tf, uint32_t srcid, uint32_t a0, uint32_t a1,
  * to idle.  Note this leaves no trace of what was running.
  * It's okay if death comes to a core that's already idling and has no current.
  * It could happen if a process decref'd before proc_startcore could incref. */
-void __death(trapframe_t *tf, uint32_t srcid, uint32_t a0, uint32_t a1,
-             uint32_t a2)
+void __death(trapframe_t *tf, uint32_t srcid, void *SNT a0, void *SNT a1,
+             void *SNT a2)
 {
        /* If we are currently running an address space on our core, we need a known
         * good pgdir before releasing the old one.  This is currently the major
index 0c4693b..1c369b2 100644 (file)
@@ -343,7 +343,11 @@ void test_checklists(void)
 
 atomic_t a, b, c;
 
+#ifdef __IVY__
 void test_incrementer_handler(trapframe_t *tf, atomic_t *data)
+#else
+void test_incrementer_handler(trapframe_t *tf, void *data)
+#endif
 {
        assert(data);
        atomic_inc(data);
@@ -677,7 +681,11 @@ void test_barrier_handler(trapframe_t *tf, void* data)
        //cprintf("Round 4: Core %d\n", core_id());
 }
 
+#ifdef __IVY__
 static void test_waiting_handler(trapframe_t *tf, atomic_t *data)
+#else
+static void test_waiting_handler(trapframe_t *tf, void *data)
+#endif
 {
        atomic_dec(data);
 }
@@ -716,8 +724,13 @@ void test_circ_buffer(void)
        return;
 }
 
+#ifdef __IVY__
 void test_am_handler(trapframe_t* tf, uint32_t srcid, uint32_t a0, uint32_t a1,
                      uint32_t a2)
+#else
+void test_am_handler(trapframe_t* tf, uint32_t srcid, void * a0, void * a1,
+                     void * a2)
+#endif
 {
        printk("Received AM on core %d from core %d: arg0= 0x%08x, arg1 = "
               "0x%08x, arg2 = 0x%08x\n", core_id(), srcid, a0, a1, a2);
@@ -730,13 +743,25 @@ void test_active_messages(void)
        // messages work.
        printk("sending NUM_ACTIVE_MESSAGES to core 1, sending (#,deadbeef,0)\n");
        for (int i = 0; i < NUM_ACTIVE_MESSAGES; i++)
+#ifdef __IVY__
                while (send_active_message(1, test_am_handler, i, 0xdeadbeef, 0))
                        cpu_relax();
+#else
+               while (send_active_message(1, test_am_handler, (void *)i,
+                                          (void *)0xdeadbeef, (void *)0))
+                       cpu_relax();
+#endif
        udelay(5000000);
        printk("sending 2*NUM_ACTIVE_MESSAGES to core 1, sending (#,cafebabe,0)\n");
        for (int i = 0; i < 2*NUM_ACTIVE_MESSAGES; i++)
-               while (send_active_message(1, test_am_handler, i, 0xcafebabe, 0))
+#ifdef __IVY__
+               while (send_active_message(1, test_am_handler, i, 0xdeadbeef, 0))
                        cpu_relax();
+#else
+               while (send_active_message(1, test_am_handler, (void *)i,
+                                          (void *)0xdeadbeef, (void *)0))
+                       cpu_relax();
+#endif
        udelay(5000000);
        return;
 }