black_hole: add report session support

This commit is contained in:
Josef Söntgen 2022-11-15 15:41:55 +01:00 committed by Christian Helmuth
parent 03165c96cc
commit 14d0b72f52
4 changed files with 101 additions and 0 deletions

View File

@ -8,6 +8,7 @@
<nic/>
<uplink/>
<rom/>
<report/>
<gpu/>
<usb/>
</provides>

View File

@ -4,6 +4,7 @@ audio_out_session
capture_session
event_session
nic_session
report_session
uplink_session
gpu_session
usb_session

View File

@ -27,6 +27,7 @@
#include "event.h"
#include "nic.h"
#include "uplink.h"
#include "report.h"
#include "rom.h"
#include "gpu.h"
#include "usb.h"
@ -50,6 +51,7 @@ struct Black_hole::Main
Genode::Constructible<Event_root> event_root { };
Genode::Constructible<Nic_root> nic_root { };
Genode::Constructible<Uplink_root> uplink_root { };
Genode::Constructible<Report_root> report_root { };
Genode::Constructible<Rom_root> rom_root { };
Genode::Constructible<Gpu_root> gpu_root { };
Genode::Constructible<Usb_root> usb_root { };
@ -86,6 +88,10 @@ struct Black_hole::Main
rom_root.construct(env, heap);
env.parent().announce(env.ep().manage(*rom_root));
}
if (_config_rom.xml().has_sub_node("report")) {
report_root.construct(env, heap);
env.parent().announce(env.ep().manage(*report_root));
}
if (_config_rom.xml().has_sub_node("gpu")) {
gpu_root.construct(env, heap);
env.parent().announce(env.ep().manage(*gpu_root));

View File

@ -0,0 +1,93 @@
/*
* \brief Report session component and root
* \author Josef Soentgen
* \date 2022-11-15
*/
/*
* Copyright (C) 2022 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _REPORT_H_
#define _REPORT_H_
/* base includes */
#include <base/attached_ram_dataspace.h>
#include <report_session/report_session.h>
#include <root/component.h>
namespace Black_hole {
using namespace Genode;
class Report_session;
class Report_root;
}
class Black_hole::Report_session : public Session_object<Report::Session>
{
private:
enum { RAM_DS_SIZE = 16 };
Env &_env;
Attached_ram_dataspace _ram_ds { _env.ram(), _env.rm(), RAM_DS_SIZE };
public:
Report_session(Env &env,
Resources const &resources,
Label const &label,
Diag const &diag)
:
Session_object(env.ep(), resources, label, diag),
_env { env }
{
copy_cstring(_ram_ds.local_addr<char>(), "<empty/>", RAM_DS_SIZE);
}
Dataspace_capability dataspace() override
{
return static_cap_cast<Dataspace>(_ram_ds.cap());
}
void submit(size_t /* length */) override { }
void response_sigh(Signal_context_capability /* sigh */) override { }
size_t obtain_response() override { return RAM_DS_SIZE; }
};
class Black_hole::Report_root : public Root_component<Report_session>
{
private:
Env &_env;
protected:
Report_session *_create_session(const char *args) override
{
return new (md_alloc())
Report_session {
_env, session_resources_from_args(args),
session_label_from_args(args),
session_diag_from_args(args) };
}
public:
Report_root(Env &env,
Allocator &alloc)
:
Root_component<Report_session> { &env.ep().rpc_ep(), &alloc },
_env { env }
{ }
};
#endif /* _REPORT_H_ */