mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-09 04:15:52 +00:00
parent
8bc4389411
commit
19fe5da9be
@ -83,6 +83,7 @@ class Genode::Core_env : public Env_deprecated
|
||||
Ram_allocator &ram_allocator() { return _synced_ram_allocator; }
|
||||
Region_map &local_rm() { return _region_map; }
|
||||
|
||||
Rpc_entrypoint &signal_ep();
|
||||
|
||||
/******************************
|
||||
** Env_deprecated interface **
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <signal_source_component.h>
|
||||
#include <signal_source/capability.h>
|
||||
#include <signal_context_slab.h>
|
||||
#include <signal_delivery_proxy.h>
|
||||
|
||||
namespace Genode { class Signal_broker; }
|
||||
|
||||
@ -30,6 +31,7 @@ class Genode::Signal_broker
|
||||
Signal_source_component _source;
|
||||
Signal_source_capability _source_cap;
|
||||
Signal_context_slab _contexts_slab { _md_alloc };
|
||||
Signal_delivery_proxy_component _delivery_proxy { _source_ep };
|
||||
|
||||
public:
|
||||
|
||||
@ -93,16 +95,9 @@ class Genode::Signal_broker
|
||||
destroy(&_contexts_slab, context);
|
||||
}
|
||||
|
||||
void submit(Signal_context_capability cap, unsigned cnt)
|
||||
void submit(Signal_context_capability const cap, unsigned const cnt)
|
||||
{
|
||||
_source_ep.apply(cap, [&] (Signal_context_component *context) {
|
||||
if (!context) {
|
||||
warning("invalid signal-context capability");
|
||||
return;
|
||||
}
|
||||
|
||||
context->source()->submit(context, cnt);
|
||||
});
|
||||
_delivery_proxy.submit(cap, cnt);
|
||||
}
|
||||
};
|
||||
|
||||
|
80
repos/base/src/core/include/signal_delivery_proxy.h
Normal file
80
repos/base/src/core/include/signal_delivery_proxy.h
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* \brief Mechanism to deliver signals via core
|
||||
* \author Norman Feske
|
||||
* \date 2017-05-10
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 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 _CORE__INCLUDE__SIGNAL_DELIVERY_PROXY_H_
|
||||
#define _CORE__INCLUDE__SIGNAL_DELIVERY_PROXY_H_
|
||||
|
||||
namespace Genode {
|
||||
|
||||
struct Signal_delivery_proxy
|
||||
{
|
||||
GENODE_RPC(Rpc_deliver, void, _deliver_from_ep, Signal_context_capability, unsigned);
|
||||
GENODE_RPC_INTERFACE(Rpc_deliver);
|
||||
};
|
||||
|
||||
struct Signal_delivery_proxy_component
|
||||
:
|
||||
Rpc_object<Signal_delivery_proxy, Signal_delivery_proxy_component>
|
||||
{
|
||||
Rpc_entrypoint &_ep;
|
||||
|
||||
Capability<Signal_delivery_proxy> _proxy_cap;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param ep entrypoint to be used as a proxy for delivering signals
|
||||
* as IPC-reply messages.
|
||||
*/
|
||||
Signal_delivery_proxy_component(Rpc_entrypoint &ep) : _ep(ep)
|
||||
{
|
||||
_proxy_cap = _ep.manage(this);
|
||||
}
|
||||
|
||||
~Signal_delivery_proxy_component()
|
||||
{
|
||||
if (_proxy_cap.valid())
|
||||
_ep.dissolve(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal_delivery_proxy RPC interface
|
||||
*
|
||||
* This method is executed in the context of the 'ep'. Hence, it
|
||||
* can produce legitimate IPC reply messages to 'Signal_source'
|
||||
* clients.
|
||||
*/
|
||||
void _deliver_from_ep(Signal_context_capability cap, unsigned cnt)
|
||||
{
|
||||
_ep.apply(cap, [&] (Signal_context_component *context) {
|
||||
if (context)
|
||||
context->source()->submit(context, cnt);
|
||||
else
|
||||
warning("invalid signal-context capability");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deliver signal via the proxy mechanism
|
||||
*
|
||||
* Since this method perform an RPC call to the 'ep' specified at the
|
||||
* constructor, is must never be called from this ep.
|
||||
*
|
||||
* Called from threads other than 'ep'.
|
||||
*/
|
||||
void submit(Signal_context_capability cap, unsigned cnt) {
|
||||
_proxy_cap.call<Rpc_deliver>(cap, cnt); }
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__SIGNLA_DELIVERY_PROXY_H_ */
|
@ -69,7 +69,7 @@ Core_env * Genode::core_env()
|
||||
|
||||
if (!signal_transmitter_initialized)
|
||||
signal_transmitter_initialized =
|
||||
(init_core_signal_transmitter(*_env.entrypoint()), true);
|
||||
(init_core_signal_transmitter(_env.signal_ep()), true);
|
||||
|
||||
return &_env;
|
||||
}
|
||||
@ -256,7 +256,8 @@ int main()
|
||||
static Rm_root rm_root (&ep, &sliced_heap, pager_ep);
|
||||
static Cpu_root cpu_root (&ep, &ep, &pager_ep, &sliced_heap,
|
||||
Trace::sources());
|
||||
static Pd_root pd_root (ep, ep, pager_ep, *platform()->ram_alloc(),
|
||||
static Pd_root pd_root (ep, core_env()->signal_ep(), pager_ep,
|
||||
*platform()->ram_alloc(),
|
||||
local_rm, sliced_heap,
|
||||
*platform_specific()->core_mem_alloc());
|
||||
static Log_root log_root (&ep, &sliced_heap);
|
||||
|
@ -15,6 +15,11 @@
|
||||
*/
|
||||
|
||||
/* core-local includes */
|
||||
#include <core_env.h>
|
||||
#include <signal_transmitter.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
void Genode::init_core_signal_transmitter(Rpc_entrypoint &) { }
|
||||
|
||||
Rpc_entrypoint &Core_env::signal_ep() { return _entrypoint; }
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <base/trace/events.h>
|
||||
|
||||
/* core-local includes */
|
||||
#include <core_env.h>
|
||||
#include <signal_source_component.h>
|
||||
#include <signal_transmitter.h>
|
||||
|
||||
@ -26,66 +27,11 @@
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
struct Signal_delivery_proxy
|
||||
{
|
||||
GENODE_RPC(Rpc_deliver, void, _deliver_from_ep, Signal_context_capability, unsigned);
|
||||
GENODE_RPC_INTERFACE(Rpc_deliver);
|
||||
};
|
||||
|
||||
struct Signal_delivery_proxy_component
|
||||
:
|
||||
Rpc_object<Signal_delivery_proxy, Signal_delivery_proxy_component>
|
||||
{
|
||||
Rpc_entrypoint &_ep;
|
||||
|
||||
Capability<Signal_delivery_proxy> _proxy_cap = _ep.manage(this);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param ep entrypoint to be used as a proxy for delivering signals
|
||||
* as IPC-reply messages.
|
||||
*/
|
||||
Signal_delivery_proxy_component(Rpc_entrypoint &ep) : _ep(ep) { }
|
||||
|
||||
/**
|
||||
* Signal_delivery_proxy RPC interface
|
||||
*
|
||||
* This method is executed in the context of the 'ep'. Hence, it
|
||||
* can produce legitimate IPC reply messages to 'Signal_source'
|
||||
* clients.
|
||||
*/
|
||||
void _deliver_from_ep(Signal_context_capability cap, unsigned cnt)
|
||||
{
|
||||
_ep.apply(cap, [&] (Signal_context_component *context) {
|
||||
if (context)
|
||||
context->source()->submit(context, cnt);
|
||||
else
|
||||
warning("invalid signal-context capability");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deliver signal via the proxy mechanism
|
||||
*
|
||||
* Since this method perform an RPC call to the 'ep' specified at the
|
||||
* constructor, is must never be called from this ep.
|
||||
*
|
||||
* Called from threads other than 'ep'.
|
||||
*/
|
||||
void submit(Signal_context_capability cap, unsigned cnt) {
|
||||
_proxy_cap.call<Rpc_deliver>(cap, cnt); }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
static Constructible<Signal_delivery_proxy_component> delivery_proxy;
|
||||
|
||||
|
||||
/*
|
||||
* Entrypoint that servces the 'Signal_source' RPC objects
|
||||
* Entrypoint that serves the 'Signal_source' RPC objects
|
||||
*/
|
||||
static Rpc_entrypoint *_ep;
|
||||
|
||||
@ -107,3 +53,11 @@ void Signal_transmitter::submit(unsigned cnt)
|
||||
}
|
||||
delivery_proxy->submit(_context, cnt);
|
||||
}
|
||||
|
||||
|
||||
Rpc_entrypoint &Core_env::signal_ep()
|
||||
{
|
||||
static Rpc_entrypoint ep(nullptr, ENTRYPOINT_STACK_SIZE,
|
||||
"signal_entrypoint");
|
||||
return ep;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user