diff --git a/repos/base-fiasco/lib/mk/core-fiasco.inc b/repos/base-fiasco/lib/mk/core-fiasco.inc index 0e19568ba7..15bdadef5b 100644 --- a/repos/base-fiasco/lib/mk/core-fiasco.inc +++ b/repos/base-fiasco/lib/mk/core-fiasco.inc @@ -2,6 +2,7 @@ GEN_CORE_DIR := $(dir $(call select_from_repositories,src/core/main.cc)) GEN_SRC_DIR := $(realpath $(GEN_CORE_DIR)/..) SRC_CC += stack_area.cc \ + core_log.cc \ core_log_out.cc \ core_region_map.cc \ core_rpc_cap_alloc.cc \ @@ -52,6 +53,7 @@ vpath main.cc $(GEN_CORE_DIR) vpath pd_session_component.cc $(GEN_CORE_DIR) vpath rom_session_component.cc $(GEN_CORE_DIR) vpath cap_session_component.cc $(GEN_CORE_DIR) +vpath core_log.cc $(GEN_CORE_DIR) vpath cpu_session_component.cc $(GEN_CORE_DIR) vpath cpu_session_support.cc $(GEN_CORE_DIR) vpath cpu_thread_component.cc $(GEN_CORE_DIR) diff --git a/repos/base-foc/lib/mk/core-foc.inc b/repos/base-foc/lib/mk/core-foc.inc index 6b33a03cac..036999a8ca 100644 --- a/repos/base-foc/lib/mk/core-foc.inc +++ b/repos/base-foc/lib/mk/core-foc.inc @@ -4,6 +4,7 @@ LIBS += base-foc-common syscall-foc cxx SRC_CC += stack_area.cc \ stack_area_addr.cc \ + core_log.cc \ core_log_out.cc \ core_region_map.cc \ core_rpc_cap_alloc.cc \ @@ -47,6 +48,7 @@ INC_DIR += $(REP_DIR)/src/core/include \ include $(GEN_CORE_DIR)/version.inc vpath stack_area.cc $(GEN_CORE_DIR) +vpath core_log.cc $(GEN_CORE_DIR) vpath cpu_session_component.cc $(GEN_CORE_DIR) vpath cpu_session_support.cc $(GEN_CORE_DIR) vpath cpu_thread_component.cc $(GEN_CORE_DIR) diff --git a/repos/base-hw/lib/mk/core-hw.inc b/repos/base-hw/lib/mk/core-hw.inc index 26bef4c45e..be82f9d34d 100644 --- a/repos/base-hw/lib/mk/core-hw.inc +++ b/repos/base-hw/lib/mk/core-hw.inc @@ -17,6 +17,7 @@ INC_DIR += $(BASE_DIR)/../base-hw/src/lib SRC_CC += cpu_session_component.cc SRC_CC += cpu_session_support.cc SRC_CC += cpu_thread_component.cc +SRC_CC += core_log.cc SRC_CC += core_log_out.cc SRC_CC += core_region_map.cc SRC_CC += core_mem_alloc.cc diff --git a/repos/base-linux/src/core/linux/target.mk b/repos/base-linux/src/core/linux/target.mk index 3f30b49cd1..d3cd205c05 100644 --- a/repos/base-linux/src/core/linux/target.mk +++ b/repos/base-linux/src/core/linux/target.mk @@ -29,6 +29,7 @@ SRC_CC = main.cc \ trace_session_component.cc \ thread_linux.cc \ stack_area.cc \ + core_log.cc \ core_log_out.cc \ default_log.cc \ env_reinit.cc \ @@ -48,6 +49,7 @@ include $(GEN_CORE_DIR)/version.inc vpath main.cc $(GEN_CORE_DIR) vpath pd_session_component.cc $(GEN_CORE_DIR) +vpath core_log.cc $(GEN_CORE_DIR) vpath cpu_session_component.cc $(GEN_CORE_DIR) vpath cpu_session_support.cc $(GEN_CORE_DIR) vpath cpu_thread_component.cc $(GEN_CORE_DIR) diff --git a/repos/base-nova/lib/mk/core-nova.inc b/repos/base-nova/lib/mk/core-nova.inc index d440303213..5cabf50180 100644 --- a/repos/base-nova/lib/mk/core-nova.inc +++ b/repos/base-nova/lib/mk/core-nova.inc @@ -4,6 +4,7 @@ GEN_CORE_DIR = $(BASE_DIR)/src/core SRC_CC += stack_area.cc \ core_mem_alloc.cc \ + core_log.cc \ core_log_out.cc \ core_region_map.cc \ core_rpc_cap_alloc.cc \ @@ -52,6 +53,7 @@ include $(GEN_CORE_DIR)/version.inc vpath main.cc $(GEN_CORE_DIR) vpath pd_session_component.cc $(GEN_CORE_DIR) vpath rom_session_component.cc $(GEN_CORE_DIR) +vpath core_log.cc $(GEN_CORE_DIR) vpath cpu_session_component.cc $(GEN_CORE_DIR) vpath cpu_session_support.cc $(GEN_CORE_DIR) vpath cpu_thread_component.cc $(GEN_CORE_DIR) @@ -72,5 +74,4 @@ vpath dump_alloc.cc $(GEN_CORE_DIR) vpath platform_rom_modules.cc $(GEN_CORE_DIR) vpath platform_services.cc $(GEN_CORE_DIR)/spec/x86 vpath stack_area.cc $(GEN_CORE_DIR) -vpath core_printf.cc $(BASE_DIR)/src/lib/base vpath %.cc $(REP_DIR)/src/core diff --git a/repos/base-okl4/lib/mk/core-okl4.inc b/repos/base-okl4/lib/mk/core-okl4.inc index dce5c5d7b7..eed4e855bd 100644 --- a/repos/base-okl4/lib/mk/core-okl4.inc +++ b/repos/base-okl4/lib/mk/core-okl4.inc @@ -7,6 +7,7 @@ GEN_SRC_DIR := $(realpath $(GEN_CORE_DIR)/..) SRC_CC += stack_area.cc \ core_mem_alloc.cc \ + core_log.cc \ core_log_out.cc \ core_region_map.cc \ core_rpc_cap_alloc.cc \ @@ -50,6 +51,7 @@ include $(GEN_CORE_DIR)/version.inc vpath main.cc $(GEN_CORE_DIR) vpath pd_session_component.cc $(GEN_CORE_DIR) vpath rom_session_component.cc $(GEN_CORE_DIR) +vpath core_log.cc $(GEN_CORE_DIR) vpath cpu_session_component.cc $(GEN_CORE_DIR) vpath cpu_session_support.cc $(GEN_CORE_DIR) vpath cpu_thread_component.cc $(GEN_CORE_DIR) diff --git a/repos/base-pistachio/lib/mk/core-pistachio.inc b/repos/base-pistachio/lib/mk/core-pistachio.inc index 4ec6036c47..f39fd036bd 100644 --- a/repos/base-pistachio/lib/mk/core-pistachio.inc +++ b/repos/base-pistachio/lib/mk/core-pistachio.inc @@ -4,6 +4,7 @@ GEN_CORE_DIR := $(dir $(call select_from_repositories,src/core/main.cc)) GEN_SRC_DIR := $(realpath $(GEN_CORE_DIR)/..) SRC_CC = stack_area.cc \ + core_log.cc \ core_log_out.cc \ core_rpc_cap_alloc.cc \ core_region_map.cc \ @@ -48,6 +49,7 @@ include $(GEN_CORE_DIR)/version.inc vpath main.cc $(GEN_CORE_DIR) vpath pd_session_component.cc $(GEN_CORE_DIR) vpath rom_session_component.cc $(GEN_CORE_DIR) +vpath core_log.cc $(GEN_CORE_DIR) vpath cpu_session_component.cc $(GEN_CORE_DIR) vpath cpu_session_support.cc $(GEN_CORE_DIR) vpath cpu_thread_component.cc $(GEN_CORE_DIR) diff --git a/repos/base-sel4/lib/mk/core-sel4.inc b/repos/base-sel4/lib/mk/core-sel4.inc index 6d1d4dcb21..302fccaa54 100644 --- a/repos/base-sel4/lib/mk/core-sel4.inc +++ b/repos/base-sel4/lib/mk/core-sel4.inc @@ -28,7 +28,7 @@ SRC_CC += \ core_region_map.cc \ core_mem_alloc.cc \ core_rpc_cap_alloc.cc \ - core_log_out.cc default_log.cc \ + core_log.cc core_log_out.cc default_log.cc \ dump_alloc.cc \ stack_area.cc \ capability_space.cc \ @@ -44,6 +44,7 @@ include $(GEN_CORE_DIR)/version.inc vpath main.cc $(GEN_CORE_DIR) vpath pd_session_component.cc $(GEN_CORE_DIR) vpath rom_session_component.cc $(GEN_CORE_DIR) +vpath core_log.cc $(GEN_CORE_DIR) vpath cpu_session_component.cc $(GEN_CORE_DIR) vpath cpu_session_support.cc $(GEN_CORE_DIR) vpath cpu_thread_component.cc $(GEN_CORE_DIR) diff --git a/repos/base/src/core/core_log.cc b/repos/base/src/core/core_log.cc new file mode 100644 index 0000000000..453d87f7ae --- /dev/null +++ b/repos/base/src/core/core_log.cc @@ -0,0 +1,52 @@ +/* + * \brief Kernel backend for core log messages + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2016-10-10 + */ + +/* + * Copyright (C) 2016-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. + */ + +#include + +static Genode::Core_log_range range { 0, 0 }; +static unsigned range_pos { 0 }; + +static void out_mem(char const c) +{ + struct Log_memory + { + struct Header { unsigned value; } pos; + char data[1]; + + unsigned out(char const c, unsigned cur_pos, + Genode::Core_log_range const &range) + { + pos.value = cur_pos; + data[cur_pos++] = c; + return cur_pos % (range.size - sizeof(Log_memory::Header)); + } + } __attribute__((packed)) * mem = reinterpret_cast(range.start); + + if (!mem) + return; + + range_pos = mem->out(c, range_pos, range); +} + + +void Genode::init_core_log(Core_log_range const &r) { range = r; } + + +void Genode::Core_log::output(char const * str) +{ + for (unsigned i = 0; i < Genode::strlen(str); i++) { + out(str[i]); + out_mem(str[i]); + } +} diff --git a/repos/base/src/core/include/core_log.h b/repos/base/src/core/include/core_log.h index a2a44595a2..b298180226 100644 --- a/repos/base/src/core/include/core_log.h +++ b/repos/base/src/core/include/core_log.h @@ -19,7 +19,13 @@ namespace Genode { struct Core_log; - Core_log &core_log(); + + struct Core_log_range { + addr_t start; + addr_t size; + }; + + void init_core_log(Core_log_range const &); } @@ -27,8 +33,7 @@ struct Genode::Core_log { void out(char const c); - void output(char const * str) { - for (unsigned i = 0; i < Genode::strlen(str); i++) out(str[i]); } + void output(char const * str); }; #endif /* _CORE_LOG_H_ */