Merge branch 'master' into proc-work
[akaros.git] / kern / src / testing.c
index 722f7a1..021a06e 100644 (file)
 #include <string.h>
 #include <testing.h>
 #include <trap.h>
-#include <env.h>
+#include <process.h>
 #include <syscall.h>
 
 #define test_vector 0xeb
 
-#if 0
+#ifdef __i386__
 
 void test_ipi_sending(void)
 {
@@ -74,7 +74,7 @@ void test_pic_reception(void)
        while(1);
 }
 
-#endif
+#endif // __i386__
 
 void test_print_info(void)
 {
@@ -228,9 +228,8 @@ checklist_t* the_global_list;
 
 void test_checklist_handler(trapframe_t *tf, void* data)
 {
-       for (int i = 0; i < SMP_BOOT_TIMEOUT; i++);
-       for (int i = 0; i < SMP_BOOT_TIMEOUT; i++);
-       cprintf("down_checklist(%x,%d)\n",the_global_list,core_id());
+       udelay(1000000);
+       cprintf("down_checklist(%x,%d)\n", the_global_list, core_id());
        down_checklist(the_global_list);
 }
 
@@ -269,7 +268,7 @@ void test_checklists(void)
 
 }
 
-atomic_t a = atomic_init(0), b = atomic_init(0), c = atomic_init(0);
+atomic_t a, b, c;
 
 void test_incrementer_handler(trapframe_t *tf, void* data)
 {
@@ -285,6 +284,9 @@ void test_null_handler(trapframe_t *tf, void* data)
 void test_smp_call_functions(void)
 {
        int i;
+       atomic_init(&a, 0);
+       atomic_init(&b, 0);
+       atomic_init(&c, 0);
        handler_wrapper_t *waiter0 = 0, *waiter1 = 0, *waiter2 = 0, *waiter3 = 0,
                          *waiter4 = 0, *waiter5 = 0;
        uint8_t me = core_id();
@@ -385,7 +387,7 @@ void test_smp_call_functions(void)
        printk("Done\n");
 }
 
-#if 0
+#ifdef __i386__
 void test_lapic_status_bit(void)
 {
        register_interrupt_handler(interrupt_handlers, test_vector,
@@ -402,7 +404,7 @@ void test_lapic_status_bit(void)
        printk("IPIs received (should be %d): %d\n", a, NUM_IPI);
        // hopefully that handler never fires again.  leaving it registered for now.
 }
-#endif
+#endif // __i386__
 
 /******************************************************************************/
 /*            Test Measurements: Couples with measurement.c                   */
@@ -536,7 +538,7 @@ void test_run_measurements(uint32_t job_num)
        panic("Error in test setup!!");
 }
 
-#endif
+#endif // __i386__
 
 /************************************************************/
 /* ISR Handler Functions */
@@ -553,7 +555,7 @@ void test_hello_world_handler(trapframe_t *tf, void* data)
        #endif
 
        cprintf("Incoming IRQ, ISR: %d on core %d with tf at 0x%08x\n",
-               trapno, core_id(), tf);
+               trapno, core_id(), tf);
 }
 
 uint32_t print_info_lock = 0;
@@ -563,7 +565,7 @@ void test_print_info_handler(trapframe_t *tf, void* data)
        spin_lock_irqsave(&print_info_lock);
        cprintf("----------------------------\n");
        cprintf("This is Core %d\n", core_id());
-#if 0
+#ifdef __i386__
        cprintf("MTRR_DEF_TYPE = 0x%08x\n", read_msr(IA32_MTRR_DEF_TYPE));
        cprintf("MTRR Phys0 Base = 0x%016llx, Mask = 0x%016llx\n",
                read_msr(0x200), read_msr(0x201));
@@ -581,7 +583,7 @@ void test_print_info_handler(trapframe_t *tf, void* data)
                read_msr(0x20c), read_msr(0x20d));
        cprintf("MTRR Phys7 Base = 0x%016llx, Mask = 0x%016llx\n",
                read_msr(0x20e), read_msr(0x20f));
-#endif
+#endif // __i386__
        cprintf("----------------------------\n");
        spin_unlock_irqsave(&print_info_lock);
 }
@@ -607,7 +609,7 @@ static void test_waiting_handler(trapframe_t *tf, void* data)
        {HANDLER_ATOMIC atomic_dec((atomic_t*)data);}
 }
 
-#if 0
+#ifdef __i386__
 void test_pit(void)
 {
        cprintf("Starting test for PIT now (10s)\n");
@@ -621,11 +623,12 @@ void test_pit(void)
        enable_irq();
        lapic_set_timer(10000000, FALSE);
 
-       atomic_t waiting = atomic_init(1);
+       atomic_t waiting;
+       atomic_init(&waiting, 1);
        register_interrupt_handler(interrupt_handlers, test_vector,
                                   test_waiting_handler, &waiting);
        while(atomic_read(&waiting))
                cpu_relax();
        cprintf("End now\n");
 }
-#endif
+#endif // __i386__