ca971bbfd8
This patch changes the top-level directory layout as a preparatory step for improving the tools for managing 3rd-party source codes. The rationale is described in the issue referenced below. Issue #1082
129 lines
2.6 KiB
C++
129 lines
2.6 KiB
C++
/*
|
|
* \brief Report server that dumps reports to the LOG
|
|
* \author Norman Feske
|
|
* \date 2014-01-10
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2014 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 <report_session/report_session.h>
|
|
#include <util/arg_string.h>
|
|
#include <base/heap.h>
|
|
#include <base/env.h>
|
|
#include <root/component.h>
|
|
#include <os/server.h>
|
|
#include <os/attached_ram_dataspace.h>
|
|
|
|
|
|
namespace Report {
|
|
using Server::Entrypoint;
|
|
using Genode::env;
|
|
|
|
class Session_component;
|
|
class Root;
|
|
struct Main;
|
|
}
|
|
|
|
|
|
class Report::Session_component : public Genode::Rpc_object<Session>
|
|
{
|
|
public:
|
|
|
|
typedef Genode::String<200> Label;
|
|
|
|
private:
|
|
|
|
Label _label;
|
|
|
|
Genode::Attached_ram_dataspace _ds;
|
|
|
|
public:
|
|
|
|
Session_component(Label const &label, size_t buffer_size)
|
|
:
|
|
_label(label), _ds(env()->ram_session(), buffer_size)
|
|
{ }
|
|
|
|
Dataspace_capability dataspace() override { return _ds.cap(); }
|
|
|
|
void submit(size_t const length) override
|
|
{
|
|
using namespace Genode;
|
|
|
|
printf("\nreport: %s\n", _label.string());
|
|
|
|
char buf[1024];
|
|
for (size_t consumed = 0; consumed < length; consumed += strlen(buf)) {
|
|
strncpy(buf, _ds.local_addr<char>() + consumed, sizeof(buf));
|
|
printf("%s", buf);
|
|
}
|
|
printf("\nend of report\n");
|
|
}
|
|
|
|
void response_sigh(Genode::Signal_context_capability) override { }
|
|
|
|
size_t obtain_response() override { return 0; }
|
|
};
|
|
|
|
|
|
class Report::Root : public Genode::Root_component<Session_component>
|
|
{
|
|
protected:
|
|
|
|
Session_component *_create_session(const char *args) override
|
|
{
|
|
using namespace Genode;
|
|
|
|
/* read label from session arguments */
|
|
char label[200];
|
|
Arg_string::find_arg(args, "label").string(label, sizeof(label), "");
|
|
|
|
/* read report buffer size from session arguments */
|
|
size_t const buffer_size =
|
|
Arg_string::find_arg(args, "buffer_size").long_value(0);
|
|
|
|
return new (md_alloc())
|
|
Session_component(Session_component::Label(label), buffer_size);
|
|
}
|
|
|
|
public:
|
|
|
|
Root(Entrypoint &ep, Genode::Allocator &md_alloc)
|
|
:
|
|
Genode::Root_component<Session_component>(&ep.rpc_ep(), &md_alloc)
|
|
{ }
|
|
};
|
|
|
|
|
|
struct Report::Main
|
|
{
|
|
Entrypoint &ep;
|
|
|
|
Genode::Sliced_heap sliced_heap = { env()->ram_session(),
|
|
env()->rm_session() };
|
|
Root root = { ep, sliced_heap };
|
|
|
|
Main(Entrypoint &ep) : ep(ep)
|
|
{
|
|
env()->parent()->announce(ep.manage(root));
|
|
}
|
|
};
|
|
|
|
|
|
namespace Server {
|
|
|
|
char const *name() { return "log_report_ep"; }
|
|
|
|
size_t stack_size() { return 4*1024*sizeof(long); }
|
|
|
|
void construct(Entrypoint &ep)
|
|
{
|
|
static Report::Main main(ep);
|
|
}
|
|
}
|