diff --git a/os/include/trace/policy.h b/os/include/trace/policy.h new file mode 100644 index 000000000..6a444dfce --- /dev/null +++ b/os/include/trace/policy.h @@ -0,0 +1,30 @@ +/* + * \brief Policy module function declarations + * \author Josef Soentgen + * \date 2013-08-09 + */ + +/* + * Copyright (C) 2013 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + + +#include + +typedef Genode::size_t size_t; + +namespace Genode { + struct Msgbuf_base; + struct Signal_context; +} + +extern "C" size_t max_event_size (); +extern "C" size_t rpc_call (char *dst, char const *rpc_name, Genode::Msgbuf_base const &); +extern "C" size_t rpc_returned (char *dst, char const *rpc_name, Genode::Msgbuf_base const &); +extern "C" size_t rpc_dispatch (char *dst, char const *rpc_name); +extern "C" size_t rpc_reply (char *dst, char const *rpc_name); +extern "C" size_t signal_submit (char *dst, unsigned const); +extern "C" size_t signal_receive (char *dst, Genode::Signal_context const &, unsigned); diff --git a/os/include/x86_32/trace/timestamp.h b/os/include/x86_32/trace/timestamp.h new file mode 100644 index 000000000..685c89b73 --- /dev/null +++ b/os/include/x86_32/trace/timestamp.h @@ -0,0 +1,45 @@ +/* + * \brief Trace timestamp + * \author Josef Soentgen + * \date 2013-02-12 + * + * Serialized reading of tsc on x86_32. + */ + +/* + * Copyright (C) 2013 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__TRACE_TIMESTAMP_H_ +#define _INCLUDE__TRACE_TIMESTAMP_H_ + +#include + +namespace Genode { namespace Trace { + + typedef uint64_t Timestamp; + + inline Timestamp timestamp() + { + uint64_t t; + __asm__ __volatile__ ( + "pushl %%ebx\n\t" + "xorl %%eax,%%eax\n\t" + "cpuid\n\t" + "popl %%ebx\n\t" + : + : + : "%eax", "%ecx", "%edx" + ); + __asm__ __volatile__ ( + "rdtsc" : "=A" (t) + ); + + return t; + } +} } + +#endif /* _INCLUDE__TRACE_TIMESTAMP_H_ */ diff --git a/os/include/x86_64/trace/timestamp.h b/os/include/x86_64/trace/timestamp.h new file mode 100644 index 000000000..1aefb3882 --- /dev/null +++ b/os/include/x86_64/trace/timestamp.h @@ -0,0 +1,44 @@ +/* + * \brief Trace timestamp + * \author Josef Soentgen + * \date 2013-02-12 + * + * Serialized reading of tsc on x86_64. + */ + +/* + * Copyright (C) 2013 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__TRACE_TIMESTAMP_H_ +#define _INCLUDE__TRACE_TIMESTAMP_H_ + +#include + +namespace Genode { namespace Trace { + + typedef uint64_t Timestamp; + + inline Timestamp timestamp() __attribute((always_inline)); + inline Timestamp timestamp() + { + uint32_t lo, hi; + __asm__ __volatile__ ( + "xorl %%eax,%%eax\n\t" + "cpuid\n\t" + : + : + : "%rax", "%rbx", "%rcx", "%rdx" + ); + __asm__ __volatile__ ( + "rdtsc" : "=a" (lo), "=d" (hi) + ); + + return (uint64_t)hi << 32 | lo; + } +} } + +#endif /* _INCLUDE__TRACE_TIMESTAMP_H_ */ diff --git a/os/src/lib/trace/policy/null/policy.cc b/os/src/lib/trace/policy/null/policy.cc new file mode 100644 index 000000000..1c5aabc3b --- /dev/null +++ b/os/src/lib/trace/policy/null/policy.cc @@ -0,0 +1,39 @@ +#include + +using namespace Genode; + +size_t max_event_size() +{ + return 0; +} + +size_t rpc_call(char *dst, char const *rpc_name, Msgbuf_base const &) +{ + return 0; +} + +size_t rpc_returned(char *dst, char const *rpc_name, Msgbuf_base const &) +{ + return 0; +} + +size_t rpc_dispatch(char *dst, char const *rpc_name) +{ + return 0; +} + +size_t rpc_reply(char *dst, char const *rpc_name) +{ + return 0; +} + +size_t signal_submit(char *dst, unsigned const) +{ + return 0; +} + +size_t signal_receive(char *dst, Signal_context const &, unsigned) +{ + return 0; +} + diff --git a/os/src/lib/trace/policy/null/target.mk b/os/src/lib/trace/policy/null/target.mk new file mode 100644 index 000000000..3c8282ad8 --- /dev/null +++ b/os/src/lib/trace/policy/null/target.mk @@ -0,0 +1,5 @@ +TARGET = null_policy + +TARGET_POLICY = null + +include $(PRG_DIR)/../policy.inc diff --git a/os/src/lib/trace/policy/policy.inc b/os/src/lib/trace/policy/policy.inc new file mode 100644 index 000000000..f420e1326 --- /dev/null +++ b/os/src/lib/trace/policy/policy.inc @@ -0,0 +1,35 @@ +# +# \brief Common build rules for creating trace-policy modules +# \author Josef Soentgen +# \date 2013-08-12 +# + +CXX_OPT = -g -ffreestanding -fPIC -fno-exceptions -fno-rtti -nostdinc -nostdlib + +LD_SCRIPT= $(PRG_DIR)/../policy.ld + +-include *.d +-include ../*.d + +LIBS = platform + +%.o : %.cc + $(MSG_COMP)$@ + $(VERBOSE)$(CXX) -c $(CC_MARCH) $(CXX_OPT) $(INCLUDES) $< -o $@ + +$(TARGET_POLICY).elf: table.o policy.o + $(MSG_LINK)$@ + $(VERBOSE)$(LD) $(LD_MARCH) -T $(LD_SCRIPT) -Ttext=0 $^ -o $@ + +$(INSTALL_DIR)/$(TARGET_POLICY): $(TARGET_POLICY).elf + $(VERBOSE)$(OBJCOPY) -O binary $< $@ + +$(TARGET): $(INSTALL_DIR)/$(TARGET_POLICY) + +clean cleanall: clean_policy + +clean_policy: + $(VERBOSE)$(RM) ../*.o ../*.d *.o *.d $(TARGET_POLICY).elf \ + $(BUILD_BASE_DIR)/bin/$(TARGET_POLICY) + +vpath table.cc $(REP_DIR)/src/lib/trace/policy diff --git a/os/src/lib/trace/policy/policy.ld b/os/src/lib/trace/policy/policy.ld new file mode 100644 index 000000000..1ff5d776c --- /dev/null +++ b/os/src/lib/trace/policy/policy.ld @@ -0,0 +1,11 @@ +PHDRS { rw PT_LOAD; } +SECTIONS { + + .text : { + *(.data) /* must be first because it contains policy module header */ + *(.text .text.*) + *(.bss) + } : rw + + /DISCARD/ : { *(.*) } +} diff --git a/os/src/lib/trace/policy/rpc_name/policy.cc b/os/src/lib/trace/policy/rpc_name/policy.cc new file mode 100644 index 000000000..4d131f613 --- /dev/null +++ b/os/src/lib/trace/policy/rpc_name/policy.cc @@ -0,0 +1,53 @@ +#include +#include + +using namespace Genode; + +enum { MAX_EVENT_SIZE = 64 }; + +size_t max_event_size() +{ + return MAX_EVENT_SIZE; +} + +size_t rpc_call(char *dst, char const *rpc_name, Msgbuf_base const &) +{ + size_t len = strlen(rpc_name); + + memcpy(dst, (void*)rpc_name, len); + return len; +} + +size_t rpc_returned(char *dst, char const *rpc_name, Msgbuf_base const &) +{ + size_t len = strlen(rpc_name); + + memcpy(dst, (void*)rpc_name, len); + return len; +} + +size_t rpc_dispatch(char *dst, char const *rpc_name) +{ + size_t len = strlen(rpc_name); + + memcpy(dst, (void*)rpc_name, len); + return len; +} + +size_t rpc_reply(char *dst, char const *rpc_name) +{ + size_t len = strlen(rpc_name); + + memcpy(dst, (void*)rpc_name, len); + return len; +} + +size_t signal_submit(char *dst, unsigned const) +{ + return 0; +} + +size_t signal_receive(char *dst, Signal_context const &, unsigned) +{ + return 0; +} diff --git a/os/src/lib/trace/policy/rpc_name/target.mk b/os/src/lib/trace/policy/rpc_name/target.mk new file mode 100644 index 000000000..769cde33f --- /dev/null +++ b/os/src/lib/trace/policy/rpc_name/target.mk @@ -0,0 +1,5 @@ +TARGET = rpc_name_policy + +TARGET_POLICY = rpc_name + +include $(PRG_DIR)/../policy.inc diff --git a/os/src/lib/trace/policy/table.cc b/os/src/lib/trace/policy/table.cc new file mode 100644 index 000000000..d3de69b61 --- /dev/null +++ b/os/src/lib/trace/policy/table.cc @@ -0,0 +1,29 @@ +/* + * \brief Header of tracing policy module + * \author Norman Feske + * \date 2013-08-15 + */ + +/* + * Copyright (C) 2013 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include +#include + +extern "C" { + + Genode::Trace::Policy_module policy_jump_table = + { + max_event_size, + rpc_call, + rpc_returned, + rpc_dispatch, + rpc_reply, + signal_submit, + signal_receive + }; +}