From 1f7bc151f1669ba47a799f22a0379ded60daff6e Mon Sep 17 00:00:00 2001 From: Moritz Hoffmann Date: Mon, 15 Jun 2015 13:24:57 +0200 Subject: [PATCH] T118: libbarrelfish: Refactor architecture specific debug syscalls. Move common debug syscalls to top level sys_debug.c Signed-off-by: Moritz Hoffmann --- lib/barrelfish/Hakefile | 25 +++++--- lib/barrelfish/arch/arm/sys_debug.c | 74 +--------------------- lib/barrelfish/arch/x86/sys_debug.c | 49 ++++++++++++++ lib/barrelfish/arch/x86_32/sys_debug.c | 81 +----------------------- lib/barrelfish/arch/x86_64/sys_debug.c | 110 +------------------------------- lib/barrelfish/sys_debug.c | 98 ++++++++++++++++++++++++++++ lib/barrelfish/syscalls.c | 5 -- 7 files changed, 167 insertions(+), 275 deletions(-) create mode 100644 lib/barrelfish/arch/x86/sys_debug.c create mode 100644 lib/barrelfish/sys_debug.c diff --git a/lib/barrelfish/Hakefile b/lib/barrelfish/Hakefile index 34dc33d..950344b 100644 --- a/lib/barrelfish/Hakefile +++ b/lib/barrelfish/Hakefile @@ -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 @@ -55,26 +55,30 @@ "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 @@ -127,7 +131,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 @@ -155,19 +159,22 @@ "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 diff --git a/lib/barrelfish/arch/arm/sys_debug.c b/lib/barrelfish/arch/arm/sys_debug.c index 8ecea07..8a56aae 100644 --- a/lib/barrelfish/arch/arm/sys_debug.c +++ b/lib/barrelfish/arch/arm/sys_debug.c @@ -1,6 +1,6 @@ /** * \file - * \brief Debug system calls, user-side + * \brief Debug system calls, specific for arm, user-side */ /* @@ -20,78 +20,6 @@ #include #include -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 index 0000000..bb29ef1 --- /dev/null +++ b/lib/barrelfish/arch/x86/sys_debug.c @@ -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 +#include +#include +#include +#include +#include +#include + +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; +} diff --git a/lib/barrelfish/arch/x86_32/sys_debug.c b/lib/barrelfish/arch/x86_32/sys_debug.c index d6ffc9c..d9bd119 100644 --- a/lib/barrelfish/arch/x86_32/sys_debug.c +++ b/lib/barrelfish/arch/x86_32/sys_debug.c @@ -1,6 +1,6 @@ /** * \file - * \brief Debug system calls, user-side + * \brief Debug system calls, specific for x86_32, user-side */ /* @@ -21,85 +21,6 @@ #include #include -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) { diff --git a/lib/barrelfish/arch/x86_64/sys_debug.c b/lib/barrelfish/arch/x86_64/sys_debug.c index acc0e35..7bb444d 100644 --- a/lib/barrelfish/arch/x86_64/sys_debug.c +++ b/lib/barrelfish/arch/x86_64/sys_debug.c @@ -1,6 +1,6 @@ /** * \file - * \brief Debug system calls, user-side + * \brief Debug system calls, specific for x86_64, user-side */ /* @@ -12,110 +12,4 @@ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. */ -#include -#include -#include -#include -#include -#include -#include - -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 index 0000000..c886209 --- /dev/null +++ b/lib/barrelfish/sys_debug.c @@ -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 +#include +#include +#include +#include +#include +#include + +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; +} diff --git a/lib/barrelfish/syscalls.c b/lib/barrelfish/syscalls.c index 4a629e5..2ede91e 100644 --- a/lib/barrelfish/syscalls.c +++ b/lib/barrelfish/syscalls.c @@ -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; -} -- 1.7.2.5