mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-21 06:33:31 +00:00
base: restructure signal-submit initialization
This patch allows core's 'Signal_transmitter' implementation to sidestep the 'Env::Pd' interface and thereby adhere to a stricter layering within core. The 'Signal_transmitter' now uses - on kernels that depend on it - a dedicated (and fairly freestanding) RPC proxy mechanism for signal deliver, instead of channeling signals through the 'Pd_session::submit' RPC function.
This commit is contained in:
parent
71efb59873
commit
a1df4fee44
@ -9,6 +9,5 @@ include $(BASE_DIR)/lib/mk/base-common.inc
|
||||
LIBS += startup-fiasco syscall-fiasco
|
||||
|
||||
SRC_CC += capability.cc capability_raw.cc
|
||||
SRC_CC += signal_submit.cc
|
||||
SRC_CC += rpc_dispatch_loop.cc
|
||||
SRC_CC += thread.cc thread_bootstrap.cc thread_myself.cc
|
||||
|
@ -1,7 +1,8 @@
|
||||
include $(BASE_DIR)/lib/mk/base.inc
|
||||
|
||||
LIBS += syscall-fiasco timeout
|
||||
LIBS += syscall-fiasco base-fiasco-common cxx timeout
|
||||
|
||||
SRC_CC += thread_start.cc
|
||||
SRC_CC += cache.cc
|
||||
SRC_CC += capability_space.cc
|
||||
SRC_CC += signal_transmitter.cc signal.cc
|
||||
|
@ -35,6 +35,8 @@ SRC_CC += stack_area.cc \
|
||||
region_map_support.cc \
|
||||
rom_session_component.cc \
|
||||
signal_source_component.cc \
|
||||
signal_transmitter_proxy.cc \
|
||||
signal_receiver.cc \
|
||||
thread_start.cc \
|
||||
trace_session_component.cc
|
||||
|
||||
@ -65,6 +67,8 @@ vpath region_map_component.cc $(GEN_CORE_DIR)
|
||||
vpath io_mem_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath io_mem_session_support.cc $(GEN_CORE_DIR)
|
||||
vpath signal_source_component.cc $(GEN_CORE_DIR)
|
||||
vpath signal_transmitter_proxy.cc $(GEN_CORE_DIR)
|
||||
vpath signal_receiver.cc $(GEN_CORE_DIR)
|
||||
vpath trace_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath dataspace_component.cc $(GEN_CORE_DIR)
|
||||
vpath default_log.cc $(GEN_CORE_DIR)
|
||||
|
@ -9,7 +9,6 @@ include $(BASE_DIR)/lib/mk/base-common.inc
|
||||
LIBS += syscall-foc startup-foc
|
||||
|
||||
SRC_CC += spin_lock.cc cap_map.cc
|
||||
SRC_CC += signal_submit.cc
|
||||
SRC_CC += rpc_dispatch_loop.cc
|
||||
SRC_CC += thread.cc thread_bootstrap.cc thread_myself.cc utcb.cc
|
||||
SRC_CC += capability.cc
|
||||
|
@ -4,3 +4,4 @@ LIBS += base-foc-common syscall-foc cxx timeout
|
||||
|
||||
SRC_CC += cap_map_remove.cc cap_alloc.cc
|
||||
SRC_CC += thread_start.cc
|
||||
SRC_CC += signal_transmitter.cc signal.cc
|
||||
|
@ -34,6 +34,8 @@ SRC_CC += stack_area.cc \
|
||||
region_map_support.cc \
|
||||
rom_session_component.cc \
|
||||
signal_source_component.cc \
|
||||
signal_transmitter_proxy.cc \
|
||||
signal_receiver.cc \
|
||||
thread_start.cc \
|
||||
trace_session_component.cc
|
||||
|
||||
@ -61,6 +63,8 @@ vpath ram_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath region_map_component.cc $(GEN_CORE_DIR)
|
||||
vpath rom_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath trace_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath signal_transmitter_proxy.cc $(GEN_CORE_DIR)
|
||||
vpath signal_receiver.cc $(GEN_CORE_DIR)
|
||||
vpath core_rpc_cap_alloc.cc $(GEN_CORE_DIR)
|
||||
vpath core_region_map.cc $(GEN_CORE_DIR)
|
||||
vpath %.cc $(REP_DIR)/src/core
|
||||
|
@ -11,3 +11,4 @@ LIBS += syscall-hw
|
||||
|
||||
SRC_CC += rpc_dispatch_loop.cc
|
||||
SRC_CC += thread.cc thread_myself.cc thread_bootstrap.cc
|
||||
SRC_CC += signal_transmitter.cc
|
||||
|
@ -5,5 +5,6 @@ SRC_CC += env.cc
|
||||
SRC_CC += capability.cc
|
||||
SRC_CC += cache.cc
|
||||
SRC_CC += raw_write_string.cc
|
||||
SRC_CC += signal_receiver.cc
|
||||
|
||||
LIBS += startup-hw base-hw-common timeout-hw
|
||||
LIBS += startup-hw base-hw-common cxx timeout-hw
|
||||
|
@ -41,6 +41,8 @@ SRC_CC += ram_session_support.cc
|
||||
SRC_CC += region_map_component.cc
|
||||
SRC_CC += rom_session_component.cc
|
||||
SRC_CC += trace_session_component.cc
|
||||
SRC_CC += signal_receiver.cc
|
||||
SRC_CC += signal_transmitter_noinit.cc
|
||||
SRC_CC += thread_start.cc
|
||||
SRC_CC += env.cc
|
||||
SRC_CC += region_map_support.cc
|
||||
|
@ -28,41 +28,24 @@
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
namespace Genode {
|
||||
|
||||
/*
|
||||
* On base-hw, no signal thread is needed.
|
||||
*/
|
||||
void init_signal_thread(Env &) __attribute__((weak));
|
||||
void init_signal_thread(Env &) { }
|
||||
void destroy_signal_thread() { }
|
||||
}
|
||||
|
||||
|
||||
/********************
|
||||
** Signal context **
|
||||
********************/
|
||||
|
||||
void Signal_context::submit(unsigned) { Genode::error("not implemented"); }
|
||||
|
||||
|
||||
/************************
|
||||
** Signal transmitter **
|
||||
************************/
|
||||
|
||||
void Signal_transmitter::submit(unsigned cnt)
|
||||
static Pd_session *_pd_ptr;
|
||||
static Pd_session &pd()
|
||||
{
|
||||
{
|
||||
Trace::Signal_submit trace_event(cnt);
|
||||
}
|
||||
Kernel::submit_signal(Capability_space::capid(_context), cnt);
|
||||
if (_pd_ptr)
|
||||
return *_pd_ptr;
|
||||
|
||||
class Missing_init_signal_thread { };
|
||||
throw Missing_init_signal_thread();
|
||||
}
|
||||
|
||||
|
||||
/*********************
|
||||
** Signal_receiver **
|
||||
*********************/
|
||||
/*
|
||||
* On base-hw, we don't use a signal thread. We mereely save the PD session
|
||||
* pointer of the passed 'env' argument.
|
||||
*/
|
||||
void Genode::init_signal_thread(Env &env) { _pd_ptr = &env.pd(); }
|
||||
void Genode::destroy_signal_thread() { }
|
||||
|
||||
|
||||
Signal_receiver::Signal_receiver()
|
||||
{
|
||||
@ -72,7 +55,7 @@ Signal_receiver::Signal_receiver()
|
||||
Cap_quota cap_upgrade { 0 };
|
||||
|
||||
try {
|
||||
_cap = internal_env().pd().alloc_signal_source();
|
||||
_cap = pd().alloc_signal_source();
|
||||
break;
|
||||
}
|
||||
catch (Out_of_ram) { ram_upgrade = Ram_quota { 2*1024*sizeof(long) }; }
|
||||
@ -88,7 +71,7 @@ Signal_receiver::Signal_receiver()
|
||||
void Signal_receiver::_platform_destructor()
|
||||
{
|
||||
/* release server resources of receiver */
|
||||
env_deprecated()->pd_session()->free_signal_source(_cap);
|
||||
pd().free_signal_source(_cap);
|
||||
}
|
||||
|
||||
|
||||
@ -114,7 +97,7 @@ Signal_context_capability Signal_receiver::manage(Signal_context * const c)
|
||||
|
||||
try {
|
||||
/* use signal context as imprint */
|
||||
c->_cap = env_deprecated()->pd_session()->alloc_context(_cap, (unsigned long)c);
|
||||
c->_cap = pd().alloc_context(_cap, (unsigned long)c);
|
||||
c->_receiver = this;
|
||||
_contexts.insert(&c->_receiver_le);
|
||||
return c->_cap;
|
39
repos/base-hw/src/lib/base/signal_transmitter.cc
Normal file
39
repos/base-hw/src/lib/base/signal_transmitter.cc
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* \brief Implementations of the signaling framework specific for HW-core
|
||||
* \author Martin Stein
|
||||
* \date 2012-05-05
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-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.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/retry.h>
|
||||
#include <base/signal.h>
|
||||
#include <base/trace/events.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/native_utcb.h>
|
||||
#include <base/internal/native_env.h>
|
||||
#include <base/internal/capability_space.h>
|
||||
#include <base/internal/globals.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
void Genode::init_signal_transmitter(Env &) { }
|
||||
|
||||
|
||||
void Signal_context::submit(unsigned) { Genode::error("not implemented"); }
|
||||
|
||||
|
||||
void Signal_transmitter::submit(unsigned cnt)
|
||||
{
|
||||
{
|
||||
Trace::Signal_submit trace_event(cnt);
|
||||
}
|
||||
Kernel::submit_signal(Capability_space::capid(_context), cnt);
|
||||
}
|
@ -9,7 +9,6 @@ include $(BASE_DIR)/lib/mk/base-common.inc
|
||||
LIBS += syscall-linux
|
||||
|
||||
SRC_CC += region_map_mmap.cc debug.cc
|
||||
SRC_CC += signal_submit.cc
|
||||
SRC_CC += rpc_dispatch_loop.cc
|
||||
SRC_CC += thread_env.cc
|
||||
SRC_CC += capability.cc
|
||||
|
@ -6,7 +6,8 @@
|
||||
|
||||
include $(REP_DIR)/lib/mk/base-linux.inc
|
||||
|
||||
LIBS += startup-linux base-linux-common timeout
|
||||
LIBS += startup-linux base-linux-common cxx timeout
|
||||
SRC_CC += thread.cc thread_myself.cc thread_linux.cc
|
||||
SRC_CC += capability_space.cc capability_raw.cc
|
||||
SRC_CC += attach_stack_area.cc
|
||||
SRC_CC += signal_transmitter.cc signal.cc
|
||||
|
@ -1,4 +1,5 @@
|
||||
SRC_CC += lx_hybrid.cc new_delete.cc capability_space.cc
|
||||
SRC_CC += signal_transmitter.cc signal.cc
|
||||
|
||||
vpath new_delete.cc $(BASE_DIR)/src/lib/cxx
|
||||
vpath lx_hybrid.cc $(REP_DIR)/src/lib/lx_hybrid
|
||||
|
@ -24,6 +24,8 @@ SRC_CC = main.cc \
|
||||
core_rpc_cap_alloc.cc \
|
||||
io_mem_session_component.cc \
|
||||
signal_source_component.cc \
|
||||
signal_transmitter_proxy.cc \
|
||||
signal_receiver.cc \
|
||||
trace_session_component.cc \
|
||||
thread_linux.cc \
|
||||
stack_area.cc \
|
||||
@ -54,6 +56,8 @@ vpath capability_space.cc $(GEN_CORE_DIR)
|
||||
vpath rpc_cap_factory_l4.cc $(GEN_CORE_DIR)
|
||||
vpath platform_services.cc $(GEN_CORE_DIR)
|
||||
vpath signal_source_component.cc $(GEN_CORE_DIR)
|
||||
vpath signal_transmitter_proxy.cc $(GEN_CORE_DIR)
|
||||
vpath signal_receiver.cc $(GEN_CORE_DIR)
|
||||
vpath trace_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath core_rpc_cap_alloc.cc $(GEN_CORE_DIR)
|
||||
vpath default_log.cc $(GEN_CORE_DIR)
|
||||
|
@ -8,8 +8,8 @@ include $(BASE_DIR)/lib/mk/base-common.inc
|
||||
|
||||
LIBS += startup-nova
|
||||
|
||||
SRC_CC += signal_submit.cc
|
||||
SRC_CC += thread.cc thread_myself.cc
|
||||
SRC_CC += stack.cc
|
||||
SRC_CC += cap_map.cc
|
||||
SRC_CC += capability.cc
|
||||
SRC_CC += signal_transmitter.cc
|
||||
|
@ -3,3 +3,4 @@ include $(BASE_DIR)/lib/mk/base.inc
|
||||
LIBS += base-nova-common cxx timeout
|
||||
SRC_CC += thread_start.cc
|
||||
SRC_CC += cache.cc
|
||||
SRC_CC += signal.cc
|
||||
|
@ -39,7 +39,9 @@ SRC_CC += stack_area.cc \
|
||||
rom_session_component.cc \
|
||||
thread_start.cc \
|
||||
bios_data_area.cc \
|
||||
trace_session_component.cc
|
||||
trace_session_component.cc \
|
||||
signal_transmitter_noinit.cc \
|
||||
signal_receiver.cc
|
||||
|
||||
INC_DIR = $(REP_DIR)/src/core/include \
|
||||
$(REP_DIR)/src/include \
|
||||
@ -58,6 +60,8 @@ vpath pd_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR)
|
||||
vpath region_map_component.cc $(GEN_CORE_DIR)
|
||||
vpath trace_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath signal_transmitter_noinit.cc $(GEN_CORE_DIR)
|
||||
vpath signal_receiver.cc $(GEN_CORE_DIR)
|
||||
vpath io_port_session_component.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath io_port_session_support.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath io_mem_session_component.cc $(GEN_CORE_DIR)
|
||||
|
@ -11,18 +11,23 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/signal.h>
|
||||
#include <base/log.h>
|
||||
#include <base/trace/events.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/globals.h>
|
||||
|
||||
/* NOVA includes */
|
||||
#include <nova/syscalls.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
void Genode::init_signal_transmitter(Env &) { }
|
||||
|
||||
|
||||
void Signal_transmitter::submit(unsigned cnt)
|
||||
{
|
||||
{
|
@ -9,6 +9,5 @@ include $(BASE_DIR)/lib/mk/base-common.inc
|
||||
LIBS += startup-okl4 syscall-okl4
|
||||
|
||||
SRC_CC += capability.cc capability_raw.cc
|
||||
SRC_CC += signal_submit.cc
|
||||
SRC_CC += rpc_dispatch_loop.cc
|
||||
SRC_CC += thread.cc thread_bootstrap.cc thread_myself.cc
|
||||
|
@ -1,6 +1,8 @@
|
||||
include $(BASE_DIR)/lib/mk/base.inc
|
||||
|
||||
LIBS += base-okl4-common syscall-okl4 timeout
|
||||
LIBS += base-okl4-common syscall-okl4 cxx timeout
|
||||
SRC_CC += thread_start.cc
|
||||
SRC_CC += cache.cc
|
||||
SRC_CC += capability_space.cc
|
||||
SRC_CC += signal_transmitter.cc
|
||||
SRC_CC += signal.cc
|
||||
|
@ -38,6 +38,8 @@ SRC_CC += stack_area.cc \
|
||||
region_map_support.cc \
|
||||
rom_session_component.cc \
|
||||
signal_source_component.cc \
|
||||
signal_transmitter_proxy.cc \
|
||||
signal_receiver.cc \
|
||||
thread_start.cc \
|
||||
trace_session_component.cc
|
||||
|
||||
@ -61,6 +63,8 @@ vpath region_map_component.cc $(GEN_CORE_DIR)
|
||||
vpath io_mem_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath io_mem_session_support.cc $(GEN_CORE_DIR)
|
||||
vpath signal_source_component.cc $(GEN_CORE_DIR)
|
||||
vpath signal_transmitter_proxy.cc $(GEN_CORE_DIR)
|
||||
vpath signal_receiver.cc $(GEN_CORE_DIR)
|
||||
vpath trace_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath dataspace_component.cc $(GEN_CORE_DIR)
|
||||
vpath core_mem_alloc.cc $(GEN_CORE_DIR)
|
||||
|
@ -9,7 +9,6 @@ include $(BASE_DIR)/lib/mk/base-common.inc
|
||||
LIBS += startup-pistachio syscall-pistachio
|
||||
|
||||
SRC_CC += capability.cc capability_raw.cc
|
||||
SRC_CC += signal_submit.cc
|
||||
SRC_CC += rpc_dispatch_loop.cc
|
||||
SRC_CC += thread.cc thread_bootstrap.cc thread_myself.cc
|
||||
|
||||
|
@ -5,3 +5,5 @@ LIBS += base-pistachio-common syscall-pistachio cxx timeout
|
||||
SRC_CC += thread_start.cc
|
||||
SRC_CC += cache.cc
|
||||
SRC_CC += capability_space.cc
|
||||
SRC_CC += signal_transmitter.cc
|
||||
SRC_CC += signal.cc
|
||||
|
@ -36,6 +36,8 @@ SRC_CC = stack_area.cc \
|
||||
region_map_support.cc \
|
||||
rom_session_component.cc \
|
||||
signal_source_component.cc \
|
||||
signal_transmitter_proxy.cc \
|
||||
signal_receiver.cc \
|
||||
thread_start.cc \
|
||||
trace_session_component.cc
|
||||
|
||||
@ -59,6 +61,8 @@ vpath capability_space.cc $(GEN_CORE_DIR)
|
||||
vpath io_mem_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath io_mem_session_support.cc $(GEN_CORE_DIR)
|
||||
vpath signal_source_component.cc $(GEN_CORE_DIR)
|
||||
vpath signal_transmitter_proxy.cc $(GEN_CORE_DIR)
|
||||
vpath signal_receiver.cc $(GEN_CORE_DIR)
|
||||
vpath trace_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath dataspace_component.cc $(GEN_CORE_DIR)
|
||||
vpath dump_alloc.cc $(GEN_CORE_DIR)
|
||||
|
@ -8,7 +8,6 @@ include $(BASE_DIR)/lib/mk/base-common.inc
|
||||
|
||||
LIBS += startup-sel4 syscall-sel4
|
||||
|
||||
SRC_CC += signal_submit.cc
|
||||
SRC_CC += rpc_dispatch_loop.cc
|
||||
SRC_CC += thread.cc thread_myself.cc thread_bootstrap.cc
|
||||
SRC_CC += capability.cc capability_raw.cc
|
||||
|
@ -3,5 +3,6 @@ include $(BASE_DIR)/lib/mk/base.inc
|
||||
SRC_CC += capability_space.cc
|
||||
SRC_CC += thread_start.cc thread_init.cc
|
||||
SRC_CC += cache.cc
|
||||
SRC_CC += signal_transmitter.cc signal.cc
|
||||
|
||||
LIBS += syscall-sel4 base-sel4-common timeout
|
||||
LIBS += syscall-sel4 base-sel4-common cxx timeout
|
||||
|
@ -26,6 +26,8 @@ SRC_CC += \
|
||||
region_map_support.cc \
|
||||
irq_session_component.cc \
|
||||
signal_source_component.cc \
|
||||
signal_transmitter_proxy.cc \
|
||||
signal_receiver.cc \
|
||||
trace_session_component.cc \
|
||||
core_region_map.cc \
|
||||
core_mem_alloc.cc \
|
||||
@ -58,6 +60,8 @@ vpath io_mem_session_support.cc $(GEN_CORE_DIR)
|
||||
vpath io_port_session_component.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath platform_services.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath trace_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath signal_transmitter_proxy.cc $(GEN_CORE_DIR)
|
||||
vpath signal_receiver.cc $(GEN_CORE_DIR)
|
||||
vpath dataspace_component.cc $(GEN_CORE_DIR)
|
||||
vpath core_mem_alloc.cc $(GEN_CORE_DIR)
|
||||
vpath core_rpc_cap_alloc.cc $(GEN_CORE_DIR)
|
||||
|
@ -74,6 +74,8 @@ class Genode::Entrypoint : Genode::Noncopyable
|
||||
Signal_proxy_component _signal_proxy {*this};
|
||||
Capability<Signal_proxy> _signal_proxy_cap = _rpc_ep->manage(&_signal_proxy);
|
||||
|
||||
bool const _signalling_initialized;
|
||||
|
||||
Reconstructible<Signal_receiver> _sig_rec;
|
||||
|
||||
Lock _deferred_signals_mutex;
|
||||
|
@ -20,7 +20,7 @@ SRC_CC += lock.cc
|
||||
SRC_CC += log.cc
|
||||
SRC_CC += raw_output.cc
|
||||
SRC_CC += rpc_entrypoint.cc
|
||||
SRC_CC += signal.cc signal_common.cc
|
||||
SRC_CC += signal_common.cc
|
||||
SRC_CC += sleep.cc
|
||||
SRC_CC += entrypoint.cc
|
||||
SRC_CC += component.cc
|
||||
|
39
repos/base/src/core/include/signal_transmitter.h
Normal file
39
repos/base/src/core/include/signal_transmitter.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* \brief Initialization of core-specific signal-delivery mechanism
|
||||
* \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_TRANSMITTER_H_
|
||||
#define _CORE__INCLUDE__SIGNAL_TRANSMITTER_H_
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Rpc_entrypoint;
|
||||
|
||||
/*
|
||||
* Initialize the emission of signals originating from the component
|
||||
*
|
||||
* The 'ep' is the entrypoint called by the signal-source clients. On
|
||||
* kernels where signals are delivered by core as IPC-reply messages, we
|
||||
* need to ensure that the replies are sent by the same thread that
|
||||
* received the RPC request (the 'ep' thread). Otherwise, the kernel
|
||||
* (e.g., OKL4, Pistachio, L4/Fiasco) will refuse to send the reply.
|
||||
*
|
||||
* On other kernels, the argument is unused.
|
||||
*
|
||||
* Note that this function is called at a very early stage, before the
|
||||
* global constructors are executed. It should merely remember the 'ep'
|
||||
* argument.
|
||||
*/
|
||||
void init_core_signal_transmitter(Rpc_entrypoint &ep);
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__SIGNAL_TRANSMITTER_H_ */
|
@ -28,6 +28,7 @@
|
||||
/* core includes */
|
||||
#include <platform.h>
|
||||
#include <core_env.h>
|
||||
#include <signal_transmitter.h>
|
||||
#include <ram_root.h>
|
||||
#include <rom_root.h>
|
||||
#include <rm_root.h>
|
||||
@ -59,6 +60,17 @@ Core_env * Genode::core_env()
|
||||
* constructor gets called when this function is used the first time.
|
||||
*/
|
||||
static Core_env _env;
|
||||
|
||||
/*
|
||||
* Register signal-source entrypoint at core-local signal-transmitter back
|
||||
* end
|
||||
*/
|
||||
static bool signal_transmitter_initialized;
|
||||
|
||||
if (!signal_transmitter_initialized)
|
||||
signal_transmitter_initialized =
|
||||
(init_core_signal_transmitter(*_env.entrypoint()), true);
|
||||
|
||||
return &_env;
|
||||
}
|
||||
|
||||
@ -224,7 +236,8 @@ class Core_child : public Child_policy
|
||||
* the creation of regular threads within core is unsupported.
|
||||
*/
|
||||
|
||||
namespace Genode { void init_signal_thread(Env &) { } }
|
||||
void Genode::init_signal_thread(Env &) { }
|
||||
void Genode::destroy_signal_thread() { }
|
||||
|
||||
|
||||
/*******************
|
||||
|
40
repos/base/src/core/signal_receiver.cc
Normal file
40
repos/base/src/core/signal_receiver.cc
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* \brief Dummy implementation of the signal-receiver API
|
||||
* \author Norman Feske
|
||||
* \date 2017-05-11
|
||||
*
|
||||
* Core receives no signals. Therefore, we can leave the signal receiver
|
||||
* blank.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/env.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/globals.h>
|
||||
|
||||
/* core-local includes */
|
||||
#include <assertion.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
Signal_receiver::Signal_receiver() { }
|
||||
|
||||
void Signal_receiver::_platform_destructor() { }
|
||||
void Signal_receiver::_platform_begin_dissolve (Signal_context *) { }
|
||||
void Signal_receiver::_platform_finish_dissolve(Signal_context *) { }
|
||||
|
||||
void Signal_receiver::unblock_signal_waiter(Rpc_entrypoint &) { ASSERT_NEVER_CALLED; }
|
||||
|
||||
typedef Signal_context_capability Sigh_cap;
|
||||
|
||||
Sigh_cap Signal_receiver::manage(Signal_context *) { ASSERT_NEVER_CALLED; }
|
||||
void Signal_receiver::block_for_signal() { ASSERT_NEVER_CALLED; }
|
||||
void Signal_receiver::local_submit(Signal::Data) { ASSERT_NEVER_CALLED; }
|
20
repos/base/src/core/signal_transmitter_noinit.cc
Normal file
20
repos/base/src/core/signal_transmitter_noinit.cc
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* \brief Generic implementation parts of the signaling framework
|
||||
* \author Norman Feske
|
||||
* \date 2017-05-10
|
||||
*
|
||||
* This dummy is used on base platforms that transmit signals directly via
|
||||
* the kernel instead of using core's signal-source entrypoint as a proxy.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* core-local includes */
|
||||
#include <signal_transmitter.h>
|
||||
|
||||
void Genode::init_core_signal_transmitter(Rpc_entrypoint &) { }
|
120
repos/base/src/core/signal_transmitter_proxy.cc
Normal file
120
repos/base/src/core/signal_transmitter_proxy.cc
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* \brief Generic implementation parts of the signaling framework
|
||||
* \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.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/env.h>
|
||||
#include <base/rpc_server.h>
|
||||
#include <base/trace/events.h>
|
||||
|
||||
/* core-local includes */
|
||||
#include <signal_source_component.h>
|
||||
#include <signal_transmitter.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/globals.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
struct Signal_delivery_proxy
|
||||
{
|
||||
/*
|
||||
* Wrap pointer into struct to transmit it (core-locally) as plain-old
|
||||
* data.
|
||||
*/
|
||||
struct Context_ptr { Signal_context_component *ptr; };
|
||||
|
||||
GENODE_RPC(Rpc_deliver, void, _deliver_from_ep, Context_ptr, 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(Context_ptr context_ptr, unsigned cnt)
|
||||
{
|
||||
Signal_context_component *context = context_ptr.ptr;
|
||||
context->source()->submit(context, cnt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
_ep.apply(cap, [&] (Signal_context_component *context) {
|
||||
|
||||
if (context) {
|
||||
_proxy_cap.call<Rpc_deliver>(Context_ptr{context}, cnt);
|
||||
} else {
|
||||
warning("invalid signal-context capability");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
static Constructible<Signal_delivery_proxy_component> delivery_proxy;
|
||||
|
||||
|
||||
/*
|
||||
* Entrypoint that servces the 'Signal_source' RPC objects
|
||||
*/
|
||||
static Rpc_entrypoint *_ep;
|
||||
|
||||
|
||||
void Genode::init_core_signal_transmitter(Rpc_entrypoint &ep) { _ep = &ep; }
|
||||
|
||||
|
||||
void Genode::init_signal_transmitter(Env &)
|
||||
{
|
||||
if (!delivery_proxy.constructed() && _ep)
|
||||
delivery_proxy.construct(*_ep);
|
||||
}
|
||||
|
||||
|
||||
void Signal_transmitter::submit(unsigned cnt)
|
||||
{
|
||||
{
|
||||
Trace::Signal_submit trace_event(cnt);
|
||||
}
|
||||
delivery_proxy->submit(_context, cnt);
|
||||
}
|
@ -2,9 +2,6 @@
|
||||
* \brief Interfaces to library-global objects
|
||||
* \author Norman Feske
|
||||
* \date 2016-04-29
|
||||
*
|
||||
* \deprecated This header should be removed once we have completed the
|
||||
* transition to the modernized API.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -30,6 +27,7 @@ namespace Genode {
|
||||
extern Ram_session *env_stack_area_ram_session;
|
||||
|
||||
void init_exception_handling(Env &);
|
||||
void init_signal_transmitter(Env &);
|
||||
void init_cxx_heap(Env &);
|
||||
void init_ldso_phdr(Env &);
|
||||
void init_signal_thread(Env &);
|
||||
@ -37,6 +35,8 @@ namespace Genode {
|
||||
void init_log();
|
||||
void exec_static_constructors();
|
||||
|
||||
void destroy_signal_thread();
|
||||
|
||||
Id_space<Parent::Client> &env_session_id_space();
|
||||
Env &internal_env();
|
||||
}
|
||||
|
@ -272,6 +272,7 @@ namespace {
|
||||
Genode::inhibit_tracing = false;
|
||||
|
||||
Genode::call_global_static_constructors();
|
||||
Genode::init_signal_transmitter(env);
|
||||
|
||||
Component::construct(env);
|
||||
}
|
||||
@ -282,11 +283,11 @@ namespace {
|
||||
Entrypoint::Entrypoint(Env &env)
|
||||
:
|
||||
_env(env),
|
||||
_rpc_ep(&env.pd(), Component::stack_size(), initial_ep_name())
|
||||
{
|
||||
/* initialize signalling after initializing but before calling the entrypoint */
|
||||
init_signal_thread(_env);
|
||||
_rpc_ep(&env.pd(), Component::stack_size(), initial_ep_name()),
|
||||
|
||||
/* initialize signalling before creating the first signal receiver */
|
||||
_signalling_initialized((init_signal_thread(env), true))
|
||||
{
|
||||
/* initialize emulation of the original synchronous root interface */
|
||||
init_root_proxy(_env);
|
||||
|
||||
@ -317,7 +318,7 @@ Entrypoint::Entrypoint(Env &env)
|
||||
Entrypoint::Entrypoint(Env &env, size_t stack_size, char const *name)
|
||||
:
|
||||
_env(env),
|
||||
_rpc_ep(&env.pd(), stack_size, name)
|
||||
_rpc_ep(&env.pd(), stack_size, name), _signalling_initialized(true)
|
||||
{
|
||||
_signal_proxy_thread.construct(env, *this);
|
||||
}
|
||||
|
@ -2,30 +2,40 @@
|
||||
* \brief Generic implementation parts of the signaling framework
|
||||
* \author Norman Feske
|
||||
* \author Alexander Boettcher
|
||||
* \date 2015-03-17
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2008-2017 Genode Labs GmbH
|
||||
* Copyright (C) 2015-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.
|
||||
*/
|
||||
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/env.h>
|
||||
#include <base/trace/events.h>
|
||||
#include <base/signal.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/globals.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
static Pd_session *_pd;
|
||||
|
||||
|
||||
void Genode::init_signal_transmitter(Env &env) { _pd = &env.pd(); }
|
||||
|
||||
/************************
|
||||
** Signal transmitter **
|
||||
************************/
|
||||
|
||||
void Signal_transmitter::submit(unsigned cnt)
|
||||
{
|
||||
{
|
||||
Trace::Signal_submit trace_event(cnt);
|
||||
}
|
||||
env_deprecated()->pd_session()->submit(_context, cnt);
|
||||
|
||||
if (_pd)
|
||||
_pd->submit(_context, cnt);
|
||||
else
|
||||
warning("missing call of 'init_signal_submit'");
|
||||
}
|
Loading…
Reference in New Issue
Block a user