T118: libbarrelfish: Refactor architecture specific debug syscalls. Move common debug...
authorMoritz Hoffmann <moritz.hoffmann@inf.ethz.ch>
Mon, 15 Jun 2015 11:24:57 +0000 (13:24 +0200)
committerMoritz Hoffmann <moritz.hoffmann@inf.ethz.ch>
Tue, 16 Jun 2015 11:37:41 +0000 (13:37 +0200)
Signed-off-by: Moritz Hoffmann <moritz.hoffmann@inf.ethz.ch>

lib/barrelfish/Hakefile
lib/barrelfish/arch/arm/sys_debug.c
lib/barrelfish/arch/x86/sys_debug.c [new file with mode: 0644]
lib/barrelfish/arch/x86_32/sys_debug.c
lib/barrelfish/arch/x86_64/sys_debug.c
lib/barrelfish/sys_debug.c [new file with mode: 0644]
lib/barrelfish/syscalls.c

index 34dc33d..950344b 100644 (file)
@@ -27,7 +27,7 @@
                       "slot_alloc/single_slot_alloc.c", "slot_alloc/multi_slot_alloc.c",
                       "slot_alloc/slot_alloc.c", "slot_alloc/range_slot_alloc.c",
                       "bulk_transfer.c", "trace.c", "resource_ctrl.c", "coreset.c",
-                      "inthandler.c", "deferred.c", "syscalls.c"
+                      "inthandler.c", "deferred.c", "syscalls.c", "sys_debug.c"
                     ]
 
       idc_srcs = concat $ map getsrcs $ optInterconnectDrivers $ options arch
                               "target/x86/pmap_x86.c",
                               "vspace/arch/x86_32/layout.c" , "vspace/memobj_pinned.c" ,
                               "vspace/pinned.c", "vspace/memobj_anon.c",
-                              "arch/x86/perfmon.c", "arch/x86/tls.c"]
+                              "arch/x86/perfmon.c", "arch/x86/tls.c",
+                              "arch/x86/sys_debug.c"]
       archfam_srcs "x86_64"  = [ "arch/x86_64/debug.c", "arch/x86_64/dispatch.c" ,
                                  "arch/x86_64/syscalls.c", "arch/x86_64/sys_debug.c",
                                  "arch/x86_64/ldt.c",
                                  "target/x86_64/pmap_target.c", "target/x86/pmap_x86.c",
                                  "vspace/arch/x86_64/layout.c",
                                  "vspace/memobj_pinned.c", "vspace/pinned.c", "vspace/memobj_anon.c",
-                                 "arch/x86/perfmon.c", "arch/x86/tls.c"]
+                                 "arch/x86/perfmon.c", "arch/x86/tls.c",
+                                 "arch/x86/sys_debug.c"]
       archfam_srcs "k1om"   = [ "arch/x86_64/debug.c", "arch/x86_64/dispatch.c" ,
                                  "arch/x86_64/syscalls.c", "arch/x86_64/sys_debug.c",
                                  "arch/x86_64/ldt.c",
                                  "target/x86_64/pmap_target.c", "target/x86/pmap_x86.c",
                                  "vspace/arch/x86_64/layout.c",
                                  "vspace/memobj_pinned.c", "vspace/pinned.c", "vspace/memobj_anon.c",
-                                 "arch/x86/perfmon.c", "arch/x86/tls.c"]
+                                 "arch/x86/perfmon.c", "arch/x86/tls.c",
+                                 "arch/x86/sys_debug.c"]
       archfam_srcs "arm"     = [ "arch/arm/debug.c", "arch/arm/dispatch.c",
                                  "arch/arm/pmap_arch.c", "arch/arm/sys_debug.c",
                                  "arch/arm/syscalls.c", "vspace/memobj_pinned.c" ,
                                  "vspace/pinned.c", "vspace/memobj_anon.c",
-                                 "vspace/arch/arm/layout.c" ]
+                                 "vspace/arch/arm/layout.c",
+                                 "arch/arm/sys_debug.c"]
       archfam_srcs _         = []
 
       -- sources specific to the architecture
                       "slot_alloc/single_slot_alloc.c", "slot_alloc/multi_slot_alloc.c",
                       "slot_alloc/slot_alloc.c", "slot_alloc/range_slot_alloc.c",
                       "bulk_transfer.c", "trace.c", "resource_ctrl.c", "coreset.c",
-                      "inthandler.c", "deferred.c", "syscalls.c"
+                      "inthandler.c", "deferred.c", "syscalls.c", "sys_debug.c"
                     ]
 
       idc_srcs = concat $ map getsrcs $ optInterconnectDrivers $ options arch
                               "target/x86/pmap_x86.c",
                               "vspace/arch/x86_32/layout.c" , "vspace/memobj_pinned.c" ,
                               "vspace/pinned.c", "vspace/memobj_anon.c",
-                              "arch/x86/perfmon.c", "arch/x86/tls.c"]
+                              "arch/x86/perfmon.c", "arch/x86/tls.c",
+                              "arch/x86/sys_debug.c"]
       archfam_srcs "x86_64"  = [ "arch/x86_64/debug.c", "arch/x86_64/dispatch.c" ,
                                  "arch/x86_64/syscalls.c", "arch/x86_64/sys_debug.c",
                                  "arch/x86_64/ldt.c",
                                  "target/x86_64/pmap_target.c", "target/x86/pmap_x86.c",
                                  "vspace/arch/x86_64/layout.c",
                                  "vspace/memobj_pinned.c", "vspace/pinned.c", "vspace/memobj_anon.c",
-                                 "arch/x86/perfmon.c", "arch/x86/tls.c"]
+                                 "arch/x86/perfmon.c", "arch/x86/tls.c",
+                                 "arch/x86/sys_debug.c"]
       archfam_srcs "arm"     = [ "arch/arm/debug.c", "arch/arm/dispatch.c",
                                  "arch/arm/pmap_arch.c", "arch/arm/sys_debug.c",
                                  "arch/arm/syscalls.c", "vspace/memobj_pinned.c" ,
                                  "vspace/pinned.c", "vspace/memobj_anon.c",
-                                 "vspace/arch/arm/layout.c" ]
+                                 "vspace/arch/arm/layout.c",
+                                 "arch/arm/sys_debug.c"]
       archfam_srcs _         = []
 
       -- sources specific to the architecture
index 8ecea07..8a56aae 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * \file
- * \brief Debug system calls, user-side
+ * \brief Debug system calls, specific for arm, user-side
  */
 
 /*
 #include <stdio.h>
 #include <inttypes.h>
 
-errval_t sys_nop(void)
-{
-    return syscall1(SYSCALL_NOP).error;
-}
-
-errval_t sys_reboot(void)
-{
-    return syscall1(SYSCALL_REBOOT).error;
-}
-
-errval_t sys_debug_context_counter_reset(void)
-{
-    return syscall2(SYSCALL_DEBUG, DEBUG_CONTEXT_COUNTER_RESET).error;
-}
-
-errval_t sys_debug_context_counter_read(uint64_t *ret)
-{
-    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_CONTEXT_COUNTER_READ);
-    *ret = sr.value;
-    return sr.error;
-}
-
-errval_t sys_debug_print_context_counter(void)
-{
-    uint64_t val;
-    errval_t err = sys_debug_context_counter_read(&val);
-    if (err_is_ok(err)) {
-        printf("core %d: csc = %" PRIu64 "\n", disp_get_core_id(), val);
-    }
-    return err;
-}
-
-errval_t sys_debug_timeslice_counter_read(uint64_t *ret)
-{
-    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_TIMESLICE_COUNTER_READ);
-    *ret = sr.value;
-    return sr.error;
-}
-
-errval_t sys_debug_print_timeslice(void)
-{
-    uint64_t val;
-    errval_t err = sys_debug_timeslice_counter_read(&val);
-    if (err_is_ok(err)) {
-        printf("core %d: kernel_now = %" PRIu64 "\n", disp_get_core_id(), val);
-    }
-    return err;
-}
-
-errval_t sys_debug_flush_cache(void)
-{
-    return syscall2(SYSCALL_DEBUG, DEBUG_FLUSH_CACHE).error;
-}
-
-errval_t sys_debug_send_ipi(uint8_t destination, uint8_t shorthand, uint8_t vector)
-{
-    return syscall5(SYSCALL_DEBUG,
-                   DEBUG_SEND_IPI, destination, shorthand, vector).error;
-}
-
-errval_t sys_debug_set_breakpoint(uintptr_t addr, uint8_t mode, uint8_t length)
-{
-    return syscall5(SYSCALL_DEBUG,
-                    DEBUG_SET_BREAKPOINT, addr, mode, length).error;
-}
-
-errval_t sys_debug_cap_trace_ctrl(bool enable, genpaddr_t start, gensize_t size)
-{
-    return syscall5(SYSCALL_DEBUG,
-                    DEBUG_TRACE_PMEM_CTRL, enable, start, size).error;
-}
-
 errval_t sys_debug_hardware_timer_read(uintptr_t* v)
 {
     struct sysret sr
diff --git a/lib/barrelfish/arch/x86/sys_debug.c b/lib/barrelfish/arch/x86/sys_debug.c
new file mode 100644 (file)
index 0000000..bb29ef1
--- /dev/null
@@ -0,0 +1,49 @@
+/**
+ * \file
+ * \brief Debug system calls for all x86 architectures, user-side
+ */
+
+/*
+ * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#include <barrelfish/barrelfish.h>
+#include <barrelfish/dispatch.h>
+#include <barrelfish/syscall_arch.h>
+#include <barrelfish_kpi/sys_debug.h>
+#include <barrelfish/sys_debug.h>
+#include <stdio.h>
+#include <inttypes.h>
+
+errval_t sys_debug_get_tsc_per_ms(uint64_t *ret)
+{
+    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_GET_TSC_PER_MS);
+    *ret = sr.value;
+    return sr.error;
+}
+
+errval_t sys_debug_get_apic_id(uint8_t *ret)
+{
+    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_GET_APIC_ID);
+    *ret = sr.value;
+    return sr.error;
+}
+
+errval_t sys_debug_get_apic_timer(uint32_t *ret)
+{
+    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_GET_APIC_TIMER);
+    *ret = sr.value;
+    return sr.error;
+}
+
+errval_t sys_debug_get_apic_ticks_per_sec(uint32_t *ret)
+{
+    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_GET_APIC_TICKS_PER_SEC);
+    *ret = sr.value;
+    return sr.error;
+}
index d6ffc9c..d9bd119 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * \file
- * \brief Debug system calls, user-side
+ * \brief Debug system calls, specific for x86_32, user-side
  */
 
 /*
 #include <stdio.h>
 #include <inttypes.h>
 
-errval_t sys_nop(void)
-{
-    return syscall1(SYSCALL_NOP).error;
-}
-
-errval_t sys_reboot(void)
-{
-    return syscall1(SYSCALL_REBOOT).error;
-}
-
-errval_t sys_debug_context_counter_reset(void)
-{
-    return syscall2(SYSCALL_DEBUG, DEBUG_CONTEXT_COUNTER_RESET).error;
-}
-
-errval_t sys_debug_context_counter_read(uint64_t *ret)
-{
-    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_CONTEXT_COUNTER_READ);
-    *ret = sr.value;
-    return sr.error;
-}
-
-errval_t sys_debug_print_context_counter(void)
-{
-    uint64_t val;
-    errval_t err = sys_debug_context_counter_read(&val);
-    if (err_is_ok(err)) {
-        printf("core %d: csc = %" PRIu64 "\n", disp_get_core_id(), val);
-    }
-    return err;
-}
-
-errval_t sys_debug_timeslice_counter_read(uint64_t *ret)
-{
-    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_TIMESLICE_COUNTER_READ);
-    *ret = sr.value;
-    return sr.error;
-}
-
-errval_t sys_debug_get_tsc_per_ms(uint64_t *ret)
-{
-    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_GET_TSC_PER_MS);
-    *ret = sr.value;
-    return sr.error;
-}
-
-errval_t sys_debug_print_timeslice(void)
-{
-    uint64_t val;
-    errval_t err = sys_debug_timeslice_counter_read(&val);
-    if (err_is_ok(err)) {
-        printf("core %d: kernel_now = %" PRIu64 "\n", disp_get_core_id(), val);
-    }
-    return err;
-}
-
-errval_t sys_debug_flush_cache(void)
-{
-    return syscall2(SYSCALL_DEBUG, DEBUG_FLUSH_CACHE).error;
-}
-
-errval_t sys_debug_send_ipi(uint8_t destination, uint8_t shorthand, uint8_t vector)
-{
-    return syscall5(SYSCALL_DEBUG,
-                   DEBUG_SEND_IPI, destination, shorthand, vector).error;
-}
-
-errval_t sys_debug_set_breakpoint(uintptr_t addr, uint8_t mode, uint8_t length)
-{
-    return syscall5(SYSCALL_DEBUG,
-                    DEBUG_SET_BREAKPOINT, addr, mode, length).error;
-}
-
-errval_t sys_debug_cap_trace_ctrl(bool enable, genpaddr_t start, gensize_t size)
-{
-    return syscall5(SYSCALL_DEBUG,
-                    DEBUG_TRACE_PMEM_CTRL, enable, start, size).error;
-}
-
 errval_t sys_debug_feign_frame_cap(struct capref slot, lpaddr_t base,
                                    uint8_t bits)
 {
index acc0e35..7bb444d 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * \file
- * \brief Debug system calls, user-side
+ * \brief Debug system calls, specific for x86_64, user-side
  */
 
 /*
  * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  */
 
-#include <barrelfish/barrelfish.h>
-#include <barrelfish/dispatch.h>
-#include <barrelfish/syscall_arch.h>
-#include <barrelfish_kpi/sys_debug.h>
-#include <barrelfish/sys_debug.h>
-#include <stdio.h>
-#include <inttypes.h>
-
-errval_t sys_nop(void)
-{
-    return syscall1(SYSCALL_NOP).error;
-}
-
-errval_t sys_reboot(void)
-{
-    return syscall1(SYSCALL_REBOOT).error;
-}
-
-errval_t sys_debug_context_counter_reset(void)
-{
-    return syscall2(SYSCALL_DEBUG, DEBUG_CONTEXT_COUNTER_RESET).error;
-}
-
-errval_t sys_debug_context_counter_read(uint64_t *ret)
-{
-    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_CONTEXT_COUNTER_READ);
-    *ret = sr.value;
-    return sr.error;
-}
-
-errval_t sys_debug_print_context_counter(void)
-{
-    uint64_t val;
-    errval_t err = sys_debug_context_counter_read(&val);
-    if (err_is_ok(err)) {
-        printf("core %d: csc = %" PRIu64 "\n", disp_get_core_id(), val);
-    }
-    return err;
-}
-
-errval_t sys_debug_timeslice_counter_read(uint64_t *ret)
-{
-    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_TIMESLICE_COUNTER_READ);
-    *ret = sr.value;
-    return sr.error;
-}
-
-errval_t sys_debug_get_tsc_per_ms(uint64_t *ret)
-{
-    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_GET_TSC_PER_MS);
-    *ret = sr.value;
-    return sr.error;
-}
-
-errval_t sys_debug_get_apic_id(uint8_t *ret)
-{
-    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_GET_APIC_ID);
-    *ret = sr.value;
-    return sr.error;
-}
-
-errval_t sys_debug_get_apic_timer(uint32_t *ret)
-{
-    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_GET_APIC_TIMER);
-    *ret = sr.value;
-    return sr.error;
-}
-
-errval_t sys_debug_get_apic_ticks_per_sec(uint32_t *ret)
-{
-    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_GET_APIC_TICKS_PER_SEC);
-    *ret = sr.value;
-    return sr.error;
-}
-
-errval_t sys_debug_print_timeslice(void)
-{
-    uint64_t val;
-    errval_t err = sys_debug_timeslice_counter_read(&val);
-    if (err_is_ok(err)) {
-        printf("core %d: kernel_now = %" PRIu64 "\n", disp_get_core_id(), val);
-    }
-    return err;
-}
-
-errval_t sys_debug_flush_cache(void)
-{
-    return syscall2(SYSCALL_DEBUG, DEBUG_FLUSH_CACHE).error;
-}
-
-errval_t sys_debug_send_ipi(uint8_t destination, uint8_t shorthand, uint8_t vector)
-{
-    return syscall5(SYSCALL_DEBUG,
-                   DEBUG_SEND_IPI, destination, shorthand, vector).error;
-}
-
-errval_t sys_debug_set_breakpoint(uintptr_t addr, uint8_t mode, uint8_t length)
-{
-    return syscall5(SYSCALL_DEBUG,
-                    DEBUG_SET_BREAKPOINT, addr, mode, length).error;
-}
-
-errval_t sys_debug_cap_trace_ctrl(bool enable, genpaddr_t start, gensize_t size)
-{
-    return syscall5(SYSCALL_DEBUG,
-                    DEBUG_TRACE_PMEM_CTRL, enable, start, size).error;
-}
+// None
diff --git a/lib/barrelfish/sys_debug.c b/lib/barrelfish/sys_debug.c
new file mode 100644 (file)
index 0000000..c886209
--- /dev/null
@@ -0,0 +1,98 @@
+/**
+ * \file
+ * \brief Debug system calls shared by all architectures, user-side
+ */
+
+/*
+ * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#include <barrelfish/barrelfish.h>
+#include <barrelfish/dispatch.h>
+#include <barrelfish/syscall_arch.h>
+#include <barrelfish_kpi/sys_debug.h>
+#include <barrelfish/sys_debug.h>
+#include <stdio.h>
+#include <inttypes.h>
+
+errval_t sys_nop(void)
+{
+    return syscall1(SYSCALL_NOP).error;
+}
+
+errval_t sys_reboot(void)
+{
+    return syscall1(SYSCALL_REBOOT).error;
+}
+
+errval_t sys_debug_context_counter_reset(void)
+{
+    return syscall2(SYSCALL_DEBUG, DEBUG_CONTEXT_COUNTER_RESET).error;
+}
+
+errval_t sys_debug_context_counter_read(uint64_t *ret)
+{
+    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_CONTEXT_COUNTER_READ);
+    *ret = sr.value;
+    return sr.error;
+}
+
+errval_t sys_debug_print_context_counter(void)
+{
+    uint64_t val;
+    errval_t err = sys_debug_context_counter_read(&val);
+    if (err_is_ok(err)) {
+        printf("core %d: csc = %" PRIu64 "\n", disp_get_core_id(), val);
+    }
+    return err;
+}
+
+errval_t sys_debug_timeslice_counter_read(uint64_t *ret)
+{
+    struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_TIMESLICE_COUNTER_READ);
+    *ret = sr.value;
+    return sr.error;
+}
+
+errval_t sys_debug_print_timeslice(void)
+{
+    uint64_t val;
+    errval_t err = sys_debug_timeslice_counter_read(&val);
+    if (err_is_ok(err)) {
+        printf("core %d: kernel_now = %" PRIu64 "\n", disp_get_core_id(), val);
+    }
+    return err;
+}
+
+errval_t sys_debug_flush_cache(void)
+{
+    return syscall2(SYSCALL_DEBUG, DEBUG_FLUSH_CACHE).error;
+}
+
+errval_t sys_debug_send_ipi(uint8_t destination, uint8_t shorthand, uint8_t vector)
+{
+    return syscall5(SYSCALL_DEBUG,
+                   DEBUG_SEND_IPI, destination, shorthand, vector).error;
+}
+
+errval_t sys_debug_set_breakpoint(uintptr_t addr, uint8_t mode, uint8_t length)
+{
+    return syscall5(SYSCALL_DEBUG,
+                    DEBUG_SET_BREAKPOINT, addr, mode, length).error;
+}
+
+errval_t sys_debug_cap_trace_ctrl(bool enable, genpaddr_t start, gensize_t size)
+{
+    return syscall5(SYSCALL_DEBUG,
+                    DEBUG_TRACE_PMEM_CTRL, enable, start, size).error;
+}
+
+errval_t
+sys_debug_print_capabilities(void) {
+    return syscall2(SYSCALL_DEBUG, DEBUG_PRINT_CAPABILITIES).error;
+}
index 4a629e5..2ede91e 100644 (file)
@@ -34,8 +34,3 @@ errval_t sys_print(const char *string, size_t length)
 {
     return syscall3(SYSCALL_PRINT, (uintptr_t)string, length).error;
 }
-
-errval_t
-sys_debug_print_capabilities(void) {
-    return syscall1(SYSCALL_DEBUG_PRINT_CAPABILITIES).error;
-}