2014-01-11 02:09:40 +01:00
|
|
|
/*
|
|
|
|
* \brief Report server that dumps reports to the LOG
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2014-01-10
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-01-13 16:00:31 +01:00
|
|
|
* Copyright (C) 2014-2017 Genode Labs GmbH
|
2014-01-11 02:09:40 +01:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2014-01-11 02:09:40 +01:00
|
|
|
*/
|
|
|
|
|
2017-01-13 16:00:31 +01:00
|
|
|
#include <base/component.h>
|
2014-01-11 02:09:40 +01:00
|
|
|
#include <report_session/report_session.h>
|
|
|
|
#include <util/arg_string.h>
|
|
|
|
#include <base/heap.h>
|
|
|
|
#include <base/env.h>
|
2017-01-13 16:00:31 +01:00
|
|
|
#include <base/log.h>
|
2016-05-12 14:58:51 +02:00
|
|
|
#include <base/session_label.h>
|
2014-01-11 02:09:40 +01:00
|
|
|
#include <root/component.h>
|
2017-01-30 11:35:12 +01:00
|
|
|
#include <base/attached_ram_dataspace.h>
|
2014-01-11 02:09:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
namespace Report {
|
2017-01-13 16:00:31 +01:00
|
|
|
using namespace Genode;
|
2014-01-11 02:09:40 +01:00
|
|
|
|
|
|
|
class Session_component;
|
|
|
|
class Root;
|
|
|
|
struct Main;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class Report::Session_component : public Genode::Rpc_object<Session>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2016-05-12 14:58:51 +02:00
|
|
|
Genode::Session_label _label;
|
2014-01-11 02:09:40 +01:00
|
|
|
|
|
|
|
Genode::Attached_ram_dataspace _ds;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2019-01-21 10:48:39 +01:00
|
|
|
Session_component(Ram_allocator &ram,
|
2017-01-13 16:00:31 +01:00
|
|
|
Region_map &rm,
|
|
|
|
Genode::Session_label const &label,
|
|
|
|
size_t buffer_size)
|
2014-01-11 02:09:40 +01:00
|
|
|
:
|
2017-01-13 16:00:31 +01:00
|
|
|
_label(label), _ds(ram, rm, buffer_size)
|
2014-01-11 02:09:40 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
Dataspace_capability dataspace() override { return _ds.cap(); }
|
|
|
|
|
|
|
|
void submit(size_t const length) override
|
|
|
|
{
|
|
|
|
using namespace Genode;
|
|
|
|
|
2017-01-13 16:00:31 +01:00
|
|
|
log("\nreport: ", _label.string());
|
2014-01-11 02:09:40 +01:00
|
|
|
|
|
|
|
char buf[1024];
|
|
|
|
for (size_t consumed = 0; consumed < length; consumed += strlen(buf)) {
|
2020-05-11 16:10:27 +02:00
|
|
|
copy_cstring(buf, _ds.local_addr<char>() + consumed, sizeof(buf));
|
2017-01-13 16:00:31 +01:00
|
|
|
log(Cstring(buf));
|
2014-01-11 02:09:40 +01:00
|
|
|
}
|
2017-01-13 16:00:31 +01:00
|
|
|
log("\nend of report");
|
2014-01-11 02:09:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void response_sigh(Genode::Signal_context_capability) override { }
|
|
|
|
|
|
|
|
size_t obtain_response() override { return 0; }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Report::Root : public Genode::Root_component<Session_component>
|
|
|
|
{
|
2017-01-13 16:00:31 +01:00
|
|
|
private:
|
|
|
|
|
2019-01-21 10:48:39 +01:00
|
|
|
Ram_allocator &_ram;
|
|
|
|
Region_map &_rm;
|
2017-01-13 16:00:31 +01:00
|
|
|
|
2014-01-11 02:09:40 +01:00
|
|
|
protected:
|
|
|
|
|
|
|
|
Session_component *_create_session(const char *args) override
|
|
|
|
{
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
|
|
/* read label from session arguments */
|
2016-05-12 14:58:51 +02:00
|
|
|
Session_label label = label_from_args(args);
|
2014-01-11 02:09:40 +01:00
|
|
|
|
|
|
|
/* read report buffer size from session arguments */
|
|
|
|
size_t const buffer_size =
|
2015-03-27 14:02:04 +01:00
|
|
|
Arg_string::find_arg(args, "buffer_size").ulong_value(0);
|
2014-01-11 02:09:40 +01:00
|
|
|
|
|
|
|
return new (md_alloc())
|
2017-01-13 16:00:31 +01:00
|
|
|
Session_component(_ram, _rm, label, buffer_size);
|
2014-01-11 02:09:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2017-01-13 16:00:31 +01:00
|
|
|
Root(Entrypoint &ep, Genode::Allocator &md_alloc,
|
2019-01-21 10:48:39 +01:00
|
|
|
Ram_allocator &ram, Region_map &rm)
|
2014-01-11 02:09:40 +01:00
|
|
|
:
|
2017-01-13 16:00:31 +01:00
|
|
|
Genode::Root_component<Session_component>(&ep.rpc_ep(), &md_alloc),
|
|
|
|
_ram(ram), _rm(rm)
|
2014-01-11 02:09:40 +01:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct Report::Main
|
|
|
|
{
|
2017-01-13 16:00:31 +01:00
|
|
|
Env &_env;
|
2014-01-11 02:09:40 +01:00
|
|
|
|
2017-01-13 16:00:31 +01:00
|
|
|
Sliced_heap sliced_heap { _env.ram(), _env.rm() };
|
2014-01-11 02:09:40 +01:00
|
|
|
|
2017-01-13 16:00:31 +01:00
|
|
|
Root root { _env.ep(), sliced_heap, _env.ram(), _env.rm() };
|
|
|
|
|
|
|
|
Main(Env &env) : _env(env)
|
2014-01-11 02:09:40 +01:00
|
|
|
{
|
2017-01-13 16:00:31 +01:00
|
|
|
env.parent().announce(env.ep().manage(root));
|
2014-01-11 02:09:40 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-01-13 16:00:31 +01:00
|
|
|
void Component::construct(Genode::Env &env) { static Report::Main main(env); }
|