T119: implement syscall and monitor interface to debug_print_capabilities
authorMoritz Hoffmann <moritz.hoffmann@inf.ethz.ch>
Thu, 11 Jun 2015 15:27:26 +0000 (17:27 +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>

12 files changed:
if/monitor.if
include/barrelfish/monitor_client.h
include/barrelfish/syscalls.h
include/barrelfish_kpi/syscalls.h
kernel/arch/x86_64/syscall.c
kernel/capabilities.c
kernel/include/capabilities.h
kernel/include/syscall.h
kernel/syscall.c
lib/barrelfish/monitor_client.c
usr/fish/fish_common.c
usr/monitor/monitor_server.c

index 23af894..8e37190 100644 (file)
@@ -199,4 +199,7 @@ interface monitor "The monitor to client Interface" {
     response bfscope_flush_ack();
 
     message migrate_dispatcher(uintptr domain_id);
+
+    // Capability debugging
+    message debug_print_capabilities();
 };
index 482e3de..e03d7f1 100644 (file)
@@ -47,6 +47,8 @@ errval_t monitor_client_blocking_rpc_init(void);
 
 errval_t monitor_cap_set_remote(struct capref cap, bool remote);
 
+errval_t monitor_debug_print_cababilities(void);
+
 __END_DECLS
 
 #endif // BARRELFISH_MONITOR_CLIENT_H
index 9a72da3..9ab5205 100644 (file)
@@ -59,6 +59,12 @@ errval_t sys_print(const char *string, size_t length);
  * \brief get time elapsed since system boot.
  */
 uint64_t sys_get_absolute_time(void);
+
+/**
+ * \brief Print capability information.
+ */
+errval_t
+sys_debug_print_capabilities(void);
 __END_DECLS
 
 #endif //LIBBARRELFISH_SYSCALL_H
index 0825075..96a55f3 100644 (file)
@@ -62,7 +62,9 @@ struct sysret {
 #define SYSCALL_SUSPEND             9     ///< Suspend the CPU
 #define SYSCALL_GET_ABS_TIME        10    ///< Get time elapsed since boot
 
-#define SYSCALL_COUNT               11     ///< Number of syscalls [0..SYSCALL_COUNT - 1]
+#define SYSCALL_DEBUG_PRINT_CAPABILITIES 11
+
+#define SYSCALL_COUNT               12     ///< Number of syscalls [0..SYSCALL_COUNT - 1]
 
 /*
  * To understand system calls it might be helpful to know that there
index f22d939..fc5893c 100644 (file)
@@ -1260,6 +1260,11 @@ struct sysret sys_syscall(uint64_t syscall, uint64_t arg0, uint64_t arg1,
         }
         break;
 
+    case SYSCALL_DEBUG_PRINT_CAPABILITIES: {
+        retval = sys_debug_print_capabilities();
+        break;
+    }
+
     default:
         printk(LOG_ERR, "sys_syscall: Illegal system call! "
                "(0x%lx, 0x%lx, 0x%lx)\n", syscall, arg0, arg1);
index dab5918..677af1f 100644 (file)
@@ -1318,3 +1318,40 @@ errval_t caps_copy_to_cte(struct cte *dest_cte, struct cte *src_cte, bool mint,
 
     return SYS_ERR_OK;
 }
+
+
+// If you create more capability types you need to deal with them
+// in the table below.
+STATIC_ASSERT(27 == ObjType_Num, "Knowledge of all cap types");
+
+
+errval_t
+caps_debug_print(struct cte *c)
+{
+    printk(LOG_NOTE, "%s\n", __FUNCTION__);
+    switch (c->cap.type) {
+    // all cap types
+    case ObjType_CNode: {
+        struct CNode *cn = &(c->cap.u.cnode);
+        for (cslot_t slot = 0; slot < 1UL << cn->bits; slot++) {
+
+            errval_t err = caps_debug_print(
+                    (struct cte *) local_phys_to_mem(
+                            cn->cnode + slot * sizeof(*c)));
+            if (err_is_fail(err)) {
+                return err;
+            }
+        }
+        break;
+    }
+    case ObjType_Frame: {
+        break;
+    }
+    default: {
+        // Unhandled source type for mint
+        return SYS_ERR_INVALID_SOURCE_TYPE;
+    }
+    }
+
+    return SYS_ERR_OK;
+}
index 6eff5e4..bb20376 100644 (file)
@@ -120,6 +120,12 @@ errval_t caps_delete(struct cte *cte);
 errval_t caps_revoke(struct cte *cte);
 
 /*
+ * Cap debugging
+ */
+
+errval_t caps_debug_print(struct cte *cte);
+
+/*
  * Cap tracing
  */
 
index ae6c9c0..250e8b4 100644 (file)
@@ -113,4 +113,10 @@ struct sysret sys_monitor_clear_step(capaddr_t ret_cn_addr,
                                      uint8_t ret_cn_bits,
                                      cslot_t ret_slot);
 
+/*
+ * System calls for debug output.
+ */
+struct sysret
+sys_debug_print_capabilities(void);
+
 #endif
index 9dde989..6a43c6b 100644 (file)
@@ -630,3 +630,11 @@ struct sysret sys_get_absolute_time(void)
         .value = kernel_now + kcb_current->kernel_off,
     };
 }
+
+struct sysret
+sys_debug_print_capabilities(void) {
+
+    caps_debug_print(&dcb_current->cspace);
+
+    return SYSRET(SYS_ERR_OK);
+}
index 41d0ee1..e075466 100644 (file)
@@ -406,3 +406,13 @@ errval_t monitor_client_blocking_rpc_init(void)
     
     return st.err;
 }
+
+errval_t monitor_debug_print_cababilities(void)
+{
+    errval_t err;
+
+    struct monitor_binding *mb = get_monitor_binding();
+    err = mb->tx_vtbl.debug_print_capabilities(mb, NOP_CONT);
+
+    return err;
+}
index 98e9d37..208bd06 100644 (file)
@@ -23,6 +23,7 @@
 #include <barrelfish/dispatch.h>
 #include <barrelfish_kpi/init.h>
 #include <barrelfish/debug.h>
+#include <barrelfish/monitor_client.h>
 #include <barrelfish/nameservice_client.h>
 #include <barrelfish/spawn_client.h>
 #include <barrelfish/terminal.h>
@@ -123,6 +124,11 @@ static int print_cspace(int argc, char *argv[])
     return EXIT_SUCCESS;
 }
 
+static int debug_print_caps(int argc, char *argv[]) {
+    monitor_debug_print_cababilities();
+    return EXIT_SUCCESS;
+}
+
 static int setenvcmd(int argc, char *argv[])
 {
     if (argc <= 1) {
@@ -1212,6 +1218,7 @@ static struct cmd commands[] = {
     {"src", src, "Execute the list of commands in a file"},
     {"printenv", printenv, "Display environment variables"},
     {"free", freecmd, "Display amount of free memory in the system"},
+    {"debug_print_caps", debug_print_caps, "Display cspace debug information"},
 };
 
 static void getline(char *input, size_t size)
index 98d42d8..1b0e11c 100644 (file)
@@ -18,6 +18,7 @@
 #include <trace_definitions/trace_defs.h>
 #include <if/mem_defs.h>
 #include <barrelfish/monitor_client.h>
+#include <barrelfish/syscalls.h>
 #include <barrelfish_kpi/distcaps.h>
 #include <if/monitor_loopback_defs.h>
 #include "capops.h"
@@ -804,6 +805,10 @@ static void migrate_dispatcher_request(struct monitor_binding *b,
    printf("%s:%d\n", __FUNCTION__, __LINE__);
 }
 
+static void debug_print_capabilities(struct monitor_binding *b) {
+    sys_debug_print_capabilities();
+}
+
 struct monitor_rx_vtbl the_table = {
     .alloc_iref_request = alloc_iref_request,
 
@@ -828,7 +833,9 @@ struct monitor_rx_vtbl the_table = {
 
     .span_domain_request    = span_domain_request,
 
-    .migrate_dispatcher_request = migrate_dispatcher_request
+    .migrate_dispatcher_request = migrate_dispatcher_request,
+
+    .debug_print_capabilities = debug_print_capabilities
 };
 
 errval_t monitor_client_setup(struct spawninfo *si)