mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-19 03:06:39 +00:00
os: example trace policy-modules
This commit is contained in:
parent
baa55dabc4
commit
17eb342156
30
os/include/trace/policy.h
Normal file
30
os/include/trace/policy.h
Normal file
@ -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 <base/stdint.h>
|
||||
|
||||
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);
|
45
os/include/x86_32/trace/timestamp.h
Normal file
45
os/include/x86_32/trace/timestamp.h
Normal file
@ -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 <base/fixed_stdint.h>
|
||||
|
||||
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_ */
|
44
os/include/x86_64/trace/timestamp.h
Normal file
44
os/include/x86_64/trace/timestamp.h
Normal file
@ -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 <base/fixed_stdint.h>
|
||||
|
||||
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_ */
|
39
os/src/lib/trace/policy/null/policy.cc
Normal file
39
os/src/lib/trace/policy/null/policy.cc
Normal file
@ -0,0 +1,39 @@
|
||||
#include <trace/policy.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
5
os/src/lib/trace/policy/null/target.mk
Normal file
5
os/src/lib/trace/policy/null/target.mk
Normal file
@ -0,0 +1,5 @@
|
||||
TARGET = null_policy
|
||||
|
||||
TARGET_POLICY = null
|
||||
|
||||
include $(PRG_DIR)/../policy.inc
|
35
os/src/lib/trace/policy/policy.inc
Normal file
35
os/src/lib/trace/policy/policy.inc
Normal file
@ -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
|
11
os/src/lib/trace/policy/policy.ld
Normal file
11
os/src/lib/trace/policy/policy.ld
Normal file
@ -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/ : { *(.*) }
|
||||
}
|
53
os/src/lib/trace/policy/rpc_name/policy.cc
Normal file
53
os/src/lib/trace/policy/rpc_name/policy.cc
Normal file
@ -0,0 +1,53 @@
|
||||
#include <util/string.h>
|
||||
#include <trace/policy.h>
|
||||
|
||||
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;
|
||||
}
|
5
os/src/lib/trace/policy/rpc_name/target.mk
Normal file
5
os/src/lib/trace/policy/rpc_name/target.mk
Normal file
@ -0,0 +1,5 @@
|
||||
TARGET = rpc_name_policy
|
||||
|
||||
TARGET_POLICY = rpc_name
|
||||
|
||||
include $(PRG_DIR)/../policy.inc
|
29
os/src/lib/trace/policy/table.cc
Normal file
29
os/src/lib/trace/policy/table.cc
Normal file
@ -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 <trace/policy.h>
|
||||
#include <base/trace/policy.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
Genode::Trace::Policy_module policy_jump_table =
|
||||
{
|
||||
max_event_size,
|
||||
rpc_call,
|
||||
rpc_returned,
|
||||
rpc_dispatch,
|
||||
rpc_reply,
|
||||
signal_submit,
|
||||
signal_receive
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user