Per-arch user include directories
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 5 Apr 2010 04:56:49 +0000 (21:56 -0700)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 3 Nov 2011 00:35:40 +0000 (17:35 -0700)
Accessible via arch/*.  I don't particularly care how they are arranged
(the way they are, or the way the kernel does it), so long as it's easy
to figure out and not sharing the kernel's files.

GNUmakefile
tests/breakpoint.c
tests/mproctests.c
user/include/arch [new symlink]
user/include/i686/arch.h [new file with mode: 0644]
user/include/sparc/arch.h [new file with mode: 0644]
user/parlib/panic.c

index 796c5c6..8898ba4 100644 (file)
@@ -136,6 +136,7 @@ arch:
 symlinks: error
        ln -fs ../arch/$(ROS_ARCH_DIR) kern/include/arch
        ln -fs arch/$(ROS_ARCH_DIR)/boot kern/boot
+       ln -fs $(ROS_ARCH_DIR) user/include/arch
        @$(MAKE) -j all
 
 # Include Makefrags for subdirectories
@@ -201,6 +202,7 @@ clean:
 realclean: clean
        @rm -f kern/boot
        @rm -f kern/include/arch
+       @rm -f user/include/arch
 
 always:
        @:
index 03793f1..124bc6c 100644 (file)
@@ -1,19 +1,6 @@
 // program to cause a breakpoint trap
 
-// TODO: have arch specific user includes
-#ifdef __i386__
-static __inline void
-breakpoint(void)
-{
-       __asm __volatile("int3");
-}
-#else
-static __inline void
-breakpoint(void)
-{
-       asm volatile ("ta 0x7f");
-}
-#endif
+#include <arch/arch.h>
 
 int main(int argc, char** argv)
 {
index 37a2ded..e08fef5 100644 (file)
@@ -1,40 +1,12 @@
+#include <arch/arch.h>
 #include <parlib.h>
+#include <rassert.h>
 #include <stdlib.h>
 #include <hart.h>
 #include <ros/mman.h>
 #include <ros/resource.h>
 #include <stdio.h>
 
-#ifdef __i386__ // TODO: fix me with per-arch user includes
-static __inline uint64_t
-read_tsc(void)
-{
-       uint64_t tsc;
-       __asm __volatile("rdtsc" : "=A" (tsc));
-       return tsc;
-}
-
-static __inline void
-cpu_relax(void)
-{
-       asm volatile("pause" : : : "memory");
-}
-#else
-static __inline uint64_t
-read_tsc(void)
-{
-       return read_perfctr(0,0);
-}
-
-static __inline void
-cpu_relax(void)
-{
-       int ctr = 8;
-       asm volatile("1: deccc %0; bne 1b; nop" :
-                    "=r"(ctr) : "0"(ctr) : "cc","memory");
-}
-#endif
-
 // ghetto udelay, put in a lib somewhere and export the tsc freq
 void udelay(uint64_t usec, uint64_t tsc_freq)
 {
@@ -108,8 +80,10 @@ int main(int argc, char** argv)
                                retval = hart_request(4);
                                break;
                        default:
-                               retval = hart_request(7);
+                               retval = hart_request(5);
                }
+               if (retval)
+                       panic("failed to allocate cores!");
                printf("Should see me if you want to relocate core0's context "
                        "when moving from RUNNING_S\n");
        }
@@ -119,7 +93,7 @@ int main(int argc, char** argv)
                case TEST_YIELD_OUT_OF_ORDER:
                        udelay(10000000, 1995014570);
                        printf("Core 2 should have yielded, asking for another\n");
-                       retval = hart_request(7);
+                       retval = hart_request(5);
                        break;
                case TEST_YIELD_0_OUT_OF_ORDER:
                        udelay(5000000, 1995014570);
@@ -155,7 +129,7 @@ void hart_entry(void)
                                // Testing getting more while running
                                printf("Asking for more while running:\n");
                                udelay(1000000, 1995014570);
-                               retval = hart_request(7);
+                               retval = hart_request(5);
                                printf("core2's retval: %d\n", retval);
                                break;
                        case TEST_YIELD_OUT_OF_ORDER:
@@ -165,7 +139,7 @@ void hart_entry(void)
                        case TEST_YIELD_0_OUT_OF_ORDER:
                                udelay(7500000, 1995014570);
                                printf("Core 0 should have yielded, asking for another\n");
-                               retval = hart_request(7);
+                               retval = hart_request(5);
                }
        }
        global_tests(vcoreid);
@@ -194,7 +168,7 @@ static void global_tests(uint32_t vcoreid)
                        while(1);
                case TEST_CRAZY_YIELDS:
                        udelay(300000*vcoreid, 1995014570);
-                       hart_request(7);
+                       hart_request(5);
                        sys_yield();
                        printf("should  never see me, unless you slip into *_S\n");
                        break;
diff --git a/user/include/arch b/user/include/arch
new file mode 120000 (symlink)
index 0000000..78efa07
--- /dev/null
@@ -0,0 +1 @@
+i686
\ No newline at end of file
diff --git a/user/include/i686/arch.h b/user/include/i686/arch.h
new file mode 100644 (file)
index 0000000..e2b5386
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef PARLIB_ARCH_H
+#define PARLIB_ARCH_H
+
+#include <ros/common.h>
+
+static __inline void
+breakpoint(void)
+{
+       __asm __volatile("int3");
+}
+
+static __inline uint64_t
+read_tsc(void)
+{
+       uint64_t tsc;
+       __asm __volatile("rdtsc" : "=A" (tsc));
+       return tsc;
+}
+
+static __inline void
+cpu_relax(void)
+{
+       asm volatile("pause" : : : "memory");
+}
+#endif /* PARLIB_ARCH_H */
diff --git a/user/include/sparc/arch.h b/user/include/sparc/arch.h
new file mode 100644 (file)
index 0000000..e70de47
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef PARLIB_ARCH_H
+#define PARLIB_ARCH_H
+
+static __inline void
+breakpoint(void)
+{
+       asm volatile ("ta 0x7f");
+}
+
+static __inline uint64_t
+read_tsc(void)
+{
+       return read_perfctr(0,0);
+}
+
+static __inline void
+cpu_relax(void)
+{
+       int ctr = 8;
+       asm volatile("1: deccc %0; bne 1b; nop" :
+                    "=r"(ctr) : "0"(ctr) : "cc","memory");
+}
+#endif /* PARLIB_ARCH_H */
index 27b5011..1875ce9 100644 (file)
@@ -1,25 +1,9 @@
-
-#include <ros/arch/arch.h>
+#include <arch/arch.h>
 #include <stdio.h>
 #include <stdarg.h>
 
 char *argv0;
 
-// TODO: have arch specific user includes
-#ifdef __i386__
-static __inline void
-breakpoint(void)
-{
-       __asm __volatile("int3");
-}
-#else
-static __inline void
-breakpoint(void)
-{
-       asm volatile ("ta 0x7f");
-}
-#endif
-
 /*
  * Panic is called on unresolvable fatal errors.
  * It prints "panic: <message>", then causes a breakpoint exception,