diff --git a/repos/base-fiasco/lib/mk/base-fiasco-common.mk b/repos/base-fiasco/lib/mk/base-fiasco-common.mk index 7d0a6a5fb..27d54dd5a 100644 --- a/repos/base-fiasco/lib/mk/base-fiasco-common.mk +++ b/repos/base-fiasco/lib/mk/base-fiasco-common.mk @@ -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 diff --git a/repos/base-fiasco/lib/mk/base-fiasco.mk b/repos/base-fiasco/lib/mk/base-fiasco.mk index 6a594d41a..a98ceba70 100644 --- a/repos/base-fiasco/lib/mk/base-fiasco.mk +++ b/repos/base-fiasco/lib/mk/base-fiasco.mk @@ -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 diff --git a/repos/base-fiasco/lib/mk/core-fiasco.inc b/repos/base-fiasco/lib/mk/core-fiasco.inc index 83926058a..f8c89da33 100644 --- a/repos/base-fiasco/lib/mk/core-fiasco.inc +++ b/repos/base-fiasco/lib/mk/core-fiasco.inc @@ -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) diff --git a/repos/base-foc/lib/mk/base-foc-common.inc b/repos/base-foc/lib/mk/base-foc-common.inc index 231043134..e573f5d24 100644 --- a/repos/base-foc/lib/mk/base-foc-common.inc +++ b/repos/base-foc/lib/mk/base-foc-common.inc @@ -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 diff --git a/repos/base-foc/lib/mk/base-foc.inc b/repos/base-foc/lib/mk/base-foc.inc index 3ad06fce1..4f0175471 100644 --- a/repos/base-foc/lib/mk/base-foc.inc +++ b/repos/base-foc/lib/mk/base-foc.inc @@ -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 diff --git a/repos/base-foc/lib/mk/core-foc.inc b/repos/base-foc/lib/mk/core-foc.inc index fc9e76b6e..98930fc70 100644 --- a/repos/base-foc/lib/mk/core-foc.inc +++ b/repos/base-foc/lib/mk/core-foc.inc @@ -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 diff --git a/repos/base-hw/lib/mk/base-hw-common.mk b/repos/base-hw/lib/mk/base-hw-common.mk index c75ff8a7e..d839caf3d 100644 --- a/repos/base-hw/lib/mk/base-hw-common.mk +++ b/repos/base-hw/lib/mk/base-hw-common.mk @@ -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 diff --git a/repos/base-hw/lib/mk/base-hw.mk b/repos/base-hw/lib/mk/base-hw.mk index c861eadcd..686697fa6 100644 --- a/repos/base-hw/lib/mk/base-hw.mk +++ b/repos/base-hw/lib/mk/base-hw.mk @@ -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 diff --git a/repos/base-hw/lib/mk/core-hw.inc b/repos/base-hw/lib/mk/core-hw.inc index 760d50877..72974919e 100644 --- a/repos/base-hw/lib/mk/core-hw.inc +++ b/repos/base-hw/lib/mk/core-hw.inc @@ -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 diff --git a/repos/base-hw/src/lib/base/signal.cc b/repos/base-hw/src/lib/base/signal_receiver.cc similarity index 78% rename from repos/base-hw/src/lib/base/signal.cc rename to repos/base-hw/src/lib/base/signal_receiver.cc index 41c4987c2..eaa58c0ca 100644 --- a/repos/base-hw/src/lib/base/signal.cc +++ b/repos/base-hw/src/lib/base/signal_receiver.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; diff --git a/repos/base-hw/src/lib/base/signal_transmitter.cc b/repos/base-hw/src/lib/base/signal_transmitter.cc new file mode 100644 index 000000000..e4944274f --- /dev/null +++ b/repos/base-hw/src/lib/base/signal_transmitter.cc @@ -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 +#include +#include + +/* base-internal includes */ +#include +#include +#include +#include + +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); +} diff --git a/repos/base-linux/lib/mk/base-linux-common.mk b/repos/base-linux/lib/mk/base-linux-common.mk index 1227f67c2..461c75c6f 100644 --- a/repos/base-linux/lib/mk/base-linux-common.mk +++ b/repos/base-linux/lib/mk/base-linux-common.mk @@ -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 diff --git a/repos/base-linux/lib/mk/base-linux.mk b/repos/base-linux/lib/mk/base-linux.mk index 767921c27..1ce498bd1 100644 --- a/repos/base-linux/lib/mk/base-linux.mk +++ b/repos/base-linux/lib/mk/base-linux.mk @@ -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 diff --git a/repos/base-linux/lib/mk/lx_hybrid.mk b/repos/base-linux/lib/mk/lx_hybrid.mk index 5e2907de7..77686587b 100644 --- a/repos/base-linux/lib/mk/lx_hybrid.mk +++ b/repos/base-linux/lib/mk/lx_hybrid.mk @@ -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 diff --git a/repos/base-linux/src/core/linux/target.mk b/repos/base-linux/src/core/linux/target.mk index 83999db0b..3e8efc23e 100644 --- a/repos/base-linux/src/core/linux/target.mk +++ b/repos/base-linux/src/core/linux/target.mk @@ -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) diff --git a/repos/base-nova/lib/mk/base-nova-common.mk b/repos/base-nova/lib/mk/base-nova-common.mk index 29a55a50b..5ff6fa4ad 100644 --- a/repos/base-nova/lib/mk/base-nova-common.mk +++ b/repos/base-nova/lib/mk/base-nova-common.mk @@ -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 diff --git a/repos/base-nova/lib/mk/base-nova.mk b/repos/base-nova/lib/mk/base-nova.mk index 45aa1d988..0040696ef 100644 --- a/repos/base-nova/lib/mk/base-nova.mk +++ b/repos/base-nova/lib/mk/base-nova.mk @@ -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 diff --git a/repos/base-nova/lib/mk/core-nova.inc b/repos/base-nova/lib/mk/core-nova.inc index 2a1109c0b..928cacd56 100644 --- a/repos/base-nova/lib/mk/core-nova.inc +++ b/repos/base-nova/lib/mk/core-nova.inc @@ -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) diff --git a/repos/base-nova/src/lib/base/signal_submit.cc b/repos/base-nova/src/lib/base/signal_transmitter.cc similarity index 89% rename from repos/base-nova/src/lib/base/signal_submit.cc rename to repos/base-nova/src/lib/base/signal_transmitter.cc index f9da0fadb..b475e21ac 100644 --- a/repos/base-nova/src/lib/base/signal_submit.cc +++ b/repos/base-nova/src/lib/base/signal_transmitter.cc @@ -11,18 +11,23 @@ * under the terms of the GNU Affero General Public License version 3. */ - /* Genode includes */ #include #include #include +/* base-internal includes */ +#include + /* NOVA includes */ #include using namespace Genode; +void Genode::init_signal_transmitter(Env &) { } + + void Signal_transmitter::submit(unsigned cnt) { { diff --git a/repos/base-okl4/lib/mk/base-okl4-common.mk b/repos/base-okl4/lib/mk/base-okl4-common.mk index 6781caaf0..590b57991 100644 --- a/repos/base-okl4/lib/mk/base-okl4-common.mk +++ b/repos/base-okl4/lib/mk/base-okl4-common.mk @@ -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 diff --git a/repos/base-okl4/lib/mk/base-okl4.mk b/repos/base-okl4/lib/mk/base-okl4.mk index 4d6223e9c..db7b34ae9 100644 --- a/repos/base-okl4/lib/mk/base-okl4.mk +++ b/repos/base-okl4/lib/mk/base-okl4.mk @@ -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 diff --git a/repos/base-okl4/lib/mk/core-okl4.inc b/repos/base-okl4/lib/mk/core-okl4.inc index e69cd218d..0cc17aa7f 100644 --- a/repos/base-okl4/lib/mk/core-okl4.inc +++ b/repos/base-okl4/lib/mk/core-okl4.inc @@ -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) diff --git a/repos/base-pistachio/lib/mk/base-pistachio-common.mk b/repos/base-pistachio/lib/mk/base-pistachio-common.mk index 7aa17aaa8..833e729cb 100644 --- a/repos/base-pistachio/lib/mk/base-pistachio-common.mk +++ b/repos/base-pistachio/lib/mk/base-pistachio-common.mk @@ -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 diff --git a/repos/base-pistachio/lib/mk/base-pistachio.mk b/repos/base-pistachio/lib/mk/base-pistachio.mk index 37a55542d..90c7de5c7 100644 --- a/repos/base-pistachio/lib/mk/base-pistachio.mk +++ b/repos/base-pistachio/lib/mk/base-pistachio.mk @@ -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 diff --git a/repos/base-pistachio/lib/mk/core-pistachio.inc b/repos/base-pistachio/lib/mk/core-pistachio.inc index b685e1bf3..2a38646ad 100644 --- a/repos/base-pistachio/lib/mk/core-pistachio.inc +++ b/repos/base-pistachio/lib/mk/core-pistachio.inc @@ -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) diff --git a/repos/base-sel4/lib/mk/base-sel4-common.mk b/repos/base-sel4/lib/mk/base-sel4-common.mk index b1fefb171..b173938e5 100644 --- a/repos/base-sel4/lib/mk/base-sel4-common.mk +++ b/repos/base-sel4/lib/mk/base-sel4-common.mk @@ -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 diff --git a/repos/base-sel4/lib/mk/base-sel4.mk b/repos/base-sel4/lib/mk/base-sel4.mk index 3ebad650f..531615ffe 100644 --- a/repos/base-sel4/lib/mk/base-sel4.mk +++ b/repos/base-sel4/lib/mk/base-sel4.mk @@ -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 diff --git a/repos/base-sel4/lib/mk/core-sel4.mk b/repos/base-sel4/lib/mk/core-sel4.mk index aed7c5e2e..47af7aa9d 100644 --- a/repos/base-sel4/lib/mk/core-sel4.mk +++ b/repos/base-sel4/lib/mk/core-sel4.mk @@ -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) diff --git a/repos/base/include/base/entrypoint.h b/repos/base/include/base/entrypoint.h index 158724f0f..ba14451be 100644 --- a/repos/base/include/base/entrypoint.h +++ b/repos/base/include/base/entrypoint.h @@ -74,6 +74,8 @@ class Genode::Entrypoint : Genode::Noncopyable Signal_proxy_component _signal_proxy {*this}; Capability _signal_proxy_cap = _rpc_ep->manage(&_signal_proxy); + bool const _signalling_initialized; + Reconstructible _sig_rec; Lock _deferred_signals_mutex; diff --git a/repos/base/lib/mk/base-common.inc b/repos/base/lib/mk/base-common.inc index 64f3ed380..ba2e87be2 100644 --- a/repos/base/lib/mk/base-common.inc +++ b/repos/base/lib/mk/base-common.inc @@ -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 diff --git a/repos/base/src/core/include/signal_transmitter.h b/repos/base/src/core/include/signal_transmitter.h new file mode 100644 index 000000000..b06a6f407 --- /dev/null +++ b/repos/base/src/core/include/signal_transmitter.h @@ -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_ */ diff --git a/repos/base/src/core/main.cc b/repos/base/src/core/main.cc index a9d6b8cc4..3f3cf8f43 100644 --- a/repos/base/src/core/main.cc +++ b/repos/base/src/core/main.cc @@ -28,6 +28,7 @@ /* core includes */ #include #include +#include #include #include #include @@ -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() { } /******************* diff --git a/repos/base/src/core/signal_receiver.cc b/repos/base/src/core/signal_receiver.cc new file mode 100644 index 000000000..94de4769b --- /dev/null +++ b/repos/base/src/core/signal_receiver.cc @@ -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-internal includes */ +#include + +/* core-local includes */ +#include + +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; } diff --git a/repos/base/src/core/signal_transmitter_noinit.cc b/repos/base/src/core/signal_transmitter_noinit.cc new file mode 100644 index 000000000..aeafdae15 --- /dev/null +++ b/repos/base/src/core/signal_transmitter_noinit.cc @@ -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 + +void Genode::init_core_signal_transmitter(Rpc_entrypoint &) { } diff --git a/repos/base/src/core/signal_transmitter_proxy.cc b/repos/base/src/core/signal_transmitter_proxy.cc new file mode 100644 index 000000000..476d082cd --- /dev/null +++ b/repos/base/src/core/signal_transmitter_proxy.cc @@ -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 +#include +#include + +/* core-local includes */ +#include +#include + +/* base-internal includes */ +#include + +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 + { + Rpc_entrypoint &_ep; + + Capability _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(Context_ptr{context}, cnt); + } else { + warning("invalid signal-context capability"); + } + }); + } + }; +} + + +static Constructible 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); +} diff --git a/repos/base/src/include/base/internal/globals.h b/repos/base/src/include/base/internal/globals.h index b47383cd4..81314206e 100644 --- a/repos/base/src/include/base/internal/globals.h +++ b/repos/base/src/include/base/internal/globals.h @@ -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 &env_session_id_space(); Env &internal_env(); } diff --git a/repos/base/src/lib/base/entrypoint.cc b/repos/base/src/lib/base/entrypoint.cc index dfbee8b02..5b9643a5f 100644 --- a/repos/base/src/lib/base/entrypoint.cc +++ b/repos/base/src/lib/base/entrypoint.cc @@ -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); } diff --git a/repos/base/src/lib/base/signal_submit.cc b/repos/base/src/lib/base/signal_transmitter.cc similarity index 55% rename from repos/base/src/lib/base/signal_submit.cc rename to repos/base/src/lib/base/signal_transmitter.cc index 4d15787d5..bede53c53 100644 --- a/repos/base/src/lib/base/signal_submit.cc +++ b/repos/base/src/lib/base/signal_transmitter.cc @@ -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 #include +#include + +/* base-internal includes */ +#include 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'"); }