black_hole: provide Event service

Fixes #4419
This commit is contained in:
Martin Stein 2021-12-20 18:09:37 +01:00 committed by Norman Feske
parent 53dea7e623
commit fcb3e32fee
5 changed files with 113 additions and 0 deletions

View File

@ -4,12 +4,14 @@
<audio_in/>
<audio_out/>
<capture/>
<event/>
</provides>
<config>
<audio_in/>
<audio_out/>
<capture/>
<event/>
</config>
<content>

View File

@ -2,4 +2,5 @@ base
audio_in_session
audio_out_session
capture_session
event_session
os

View File

@ -7,9 +7,11 @@ in the configuration of the component:
* Audio_in
* Audio_out
* Capture
* Event
<config>
<audio_in/>
<audio_out/>
<capture/>
<event/>
</config>

View File

@ -0,0 +1,102 @@
/*
* \brief Event session component and root
* \author Martin Stein
* \date 2021-12-20
*/
/*
* Copyright (C) 2021 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 _EVENT_H_
#define _EVENT_H_
/* Genode includes */
#include <base/session_object.h>
#include <event_session/event_session.h>
namespace Black_hole {
using namespace Genode;
class Event_session;
class Event_root;
}
class Black_hole::Event_session
:
public Session_object<Event::Session, Event_session>
{
private:
Constrained_ram_allocator _ram;
Attached_ram_dataspace _ds;
public:
Event_session(Env &env,
Resources const &resources,
Label const &label,
Diag const &diag)
:
Session_object(env.ep(), resources, label, diag),
_ram(env.ram(), _ram_quota_guard(), _cap_quota_guard()),
_ds(_ram, env.rm(), 4096)
{ }
~Event_session() { }
/*****************************
** Event session interface **
*****************************/
Dataspace_capability dataspace() { return _ds.cap(); }
void submit_batch(unsigned const /* count */) { }
};
class Black_hole::Event_root : public Root_component<Event_session>
{
private:
Env &_env;
protected:
Event_session *_create_session(const char *args) override
{
return new (md_alloc())
Event_session(_env,
session_resources_from_args(args),
session_label_from_args(args),
session_diag_from_args(args));
}
void _upgrade_session(Event_session *s, const char *args) override
{
s->upgrade(ram_quota_from_args(args));
s->upgrade(cap_quota_from_args(args));
}
void _destroy_session(Event_session *session) override
{
Genode::destroy(md_alloc(), session);
}
public:
Event_root(Env &env, Allocator &md_alloc)
:
Root_component<Event_session>(&env.ep().rpc_ep(), &md_alloc),
_env(env)
{ }
};
#endif /* _EVENT_H_ */

View File

@ -24,6 +24,7 @@
#include "audio_in.h"
#include "audio_out.h"
#include "capture.h"
#include "event.h"
/***************
@ -41,6 +42,7 @@ struct Black_hole::Main
Genode::Constructible<Audio_in::Root> audio_in_root { };
Genode::Constructible<Audio_out::Root> audio_out_root { };
Genode::Constructible<Capture::Root> capture_root { };
Genode::Constructible<Event_root> event_root { };
Main(Genode::Env &env) : env(env)
{
@ -60,6 +62,10 @@ struct Black_hole::Main
capture_root.construct(env, heap);
env.parent().announce(env.ep().manage(*capture_root));
}
if (_config_rom.xml().has_sub_node("event")) {
event_root.construct(env, heap);
env.parent().announce(env.ep().manage(*event_root));
}
}
};