From 2a2e5c2df4c0f7eb40aa57ad1b0eb9da5946fba9 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Mon, 10 Oct 2016 16:22:43 +0200 Subject: [PATCH] base-*: remove usage of printf base generic code: * Remove unused verbosity code from mmio framework * Remove escape sequence end heuristic from LOG * replace Core_console with Core_log (no format specifiers) * move test/printf to test/log * remove `printf()` tests from the log test * check for exact match of the log test output base-fiasco: * remove unused Fiasco::print_l4_threadid function base-nova: * remove unused hexdump utility from core base-hw: * remove unused Kernel::Thread::_print_* debug utilities * always print resource summary of core during startup * remove Kernel::Ipc_node::pd_label (not used anymore) base*: * Turn `printf`,`PWRN`, etc. calls into their log equivalents Ref #1987 Fix #2119 --- repos/base-fiasco/src/core/core_log.cc | 20 +++ repos/base-fiasco/src/core/include/util.h | 1 - repos/base-fiasco/src/core/platform.cc | 2 +- .../src/core/region_map_support.cc | 5 +- repos/base-fiasco/src/core/target.inc | 3 +- .../src/include/base/internal/core_console.h | 35 ------ .../base/internal/fiasco_thread_helper.h | 11 -- repos/base-fiasco/src/lib/base/lock.cc | 1 - repos/base-foc/src/core/core_log.cc | 20 +++ repos/base-foc/src/core/include/irq_object.h | 1 - repos/base-foc/src/core/include/map_local.h | 3 +- repos/base-foc/src/core/include/util.h | 1 - .../base-foc/src/core/native_cpu_component.cc | 6 +- repos/base-foc/src/core/platform_thread.cc | 17 +-- repos/base-foc/src/core/rpc_cap_factory.cc | 6 +- repos/base-foc/src/core/target.inc | 3 +- repos/base-foc/src/core/thread_start.cc | 2 +- .../src/include/base/internal/core_console.h | 35 ------ repos/base-foc/src/lib/base/thread_start.cc | 1 - repos/base-hw/lib/mk/core.inc | 1 - repos/base-hw/src/core/console.cc | 91 -------------- repos/base-hw/src/core/default_log.cc | 72 +++++++++++ .../src/core/include/kernel/ipc_node.h | 3 +- repos/base-hw/src/core/include/kernel/log.h | 19 +++ .../base-hw/src/core/include/kernel/thread.h | 21 +--- repos/base-hw/src/core/include/map_local.h | 3 - .../spec/arm/short_translation_table.h | 1 - .../spec/arm_v7/long_translation_table.h | 1 - .../arm_v7/trustzone/vm_session_component.h | 6 +- .../src/core/include/spec/riscv/timer.h | 1 - .../include/spec/x86_64/muen/sinfo_instance.h | 4 - .../spec/x86_64/muen/vm_session_component.h | 4 +- .../src/core/include/spec/x86_64/timer.h | 1 - .../include/spec/x86_64/translation_table.h | 1 - repos/base-hw/src/core/include/util.h | 1 - repos/base-hw/src/core/kernel/cpu.cc | 2 +- repos/base-hw/src/core/kernel/init.cc | 5 +- repos/base-hw/src/core/kernel/ipc_node.cc | 4 - repos/base-hw/src/core/kernel/thread.cc | 119 +++++------------- repos/base-hw/src/core/platform.cc | 53 ++++---- repos/base-hw/src/core/region_map_support.cc | 2 +- .../src/core/spec/arm/kernel/thread.cc | 10 +- .../core/spec/arm_v7/trustzone/kernel/vm.cc | 2 +- .../arm_v7/trustzone/vm_session_component.cc | 4 +- repos/base-hw/src/core/spec/riscv/cpu.cc | 1 - .../src/core/spec/riscv/kernel/thread.cc | 4 +- .../core/spec/x86_64/kernel/cpu_exception.cc | 4 +- .../spec/x86_64/kernel/thread_exception.cc | 9 +- .../spec/x86_64/muen/kernel/cpu_exception.cc | 4 +- .../x86_64/muen/kernel/thread_exception.cc | 9 +- .../src/core/spec/x86_64/muen/kernel/vm.cc | 4 +- .../src/core/spec/x86_64/platform_support.cc | 3 +- .../src/lib/base/riscv/kernel/interface.cc | 1 - .../src/lib/base/x86_64/kernel/interface.cc | 1 - repos/base-hw/src/test/cpu_quota/main.cc | 18 +-- repos/base-linux/src/core/core_log.cc | 20 +++ repos/base-linux/src/core/include/core_env.h | 2 +- .../src/core/include/dataspace_component.h | 3 +- .../core/include/io_mem_session_component.h | 1 - .../src/core/io_mem_session_component.cc | 8 +- repos/base-linux/src/core/stack_area.cc | 8 +- repos/base-linux/src/core/target.mk | 3 +- .../src/include/base/internal/core_console.h | 35 ------ .../base-linux/src/lib/lx_hybrid/lx_hybrid.cc | 1 - .../src/test/lx_hybrid_ctors/main.cc | 8 +- .../src/test/lx_hybrid_exception/main.cc | 10 +- repos/base-nova/src/core/core_log.cc | 30 +++++ repos/base-nova/src/core/include/ipc_pager.h | 1 - repos/base-nova/src/core/include/map_local.h | 1 - .../src/core/include/rpc_cap_factory.h | 4 +- .../src/core/include/signal_broker.h | 8 +- repos/base-nova/src/core/include/util.h | 15 +-- repos/base-nova/src/core/target.inc | 3 +- .../src/include/base/internal/core_console.h | 48 ------- repos/base-okl4/src/core/core_log.cc | 21 ++++ .../base-okl4/src/core/region_map_support.cc | 3 - repos/base-okl4/src/core/target.inc | 4 +- .../src/include/base/internal/core_console.h | 34 ----- repos/base-pistachio/src/core/core_log.cc | 22 ++++ .../src/core/include/map_local.h | 4 +- .../src/core/region_map_support.cc | 7 -- repos/base-pistachio/src/core/target.inc | 3 +- .../src/include/base/internal/core_console.h | 35 ------ repos/base-sel4/lib/mk/core.mk | 2 +- repos/base-sel4/lib/mk/core_log.mk | 6 + repos/base-sel4/lib/mk/core_printf.mk | 6 - repos/base-sel4/src/core/capability_space.cc | 1 - repos/base-sel4/src/core/core_log.cc | 21 ++++ repos/base-sel4/src/core/include/cnode.h | 8 +- repos/base-sel4/src/core/include/map_local.h | 3 - repos/base-sel4/src/core/include/platform.h | 3 - .../base-sel4/src/core/include/thread_sel4.h | 3 - repos/base-sel4/src/core/include/util.h | 4 - repos/base-sel4/src/core/rpc_cap_factory.cc | 2 +- .../src/include/base/internal/core_console.h | 37 ------ .../src/lib/base/capability_space.cc | 4 +- repos/base/include/util/mmio.h | 44 +------ repos/base/include/util/register.h | 16 --- repos/base/run/log.run | 36 ++++++ repos/base/run/printf.run | 26 ---- repos/base/src/core/default_log.cc | 27 ++-- repos/base/src/core/dump_alloc.cc | 14 +-- repos/base/src/core/include/core_log.h | 34 +++++ .../src/core/include/log_session_component.h | 17 --- repos/base/src/core/include/signal_broker.h | 5 - .../src/include/base/internal/page_size.h | 2 + repos/base/src/lib/base/core_printf.cc | 76 ----------- repos/base/src/lib/base/default_log.cc | 12 +- repos/base/src/test/ada/add.cc | 10 +- repos/base/src/test/{printf => log}/main.cc | 9 +- repos/base/src/test/{printf => log}/target.mk | 2 +- repos/base/src/test/mp_server/main.cc | 30 +++-- repos/base/src/test/new_delete/main.cc | 16 +-- repos/base/src/test/rm_nested/main.cc | 22 ++-- repos/base/src/test/segfault/main.cc | 4 +- repos/base/src/test/thread/main.cc | 6 +- repos/base/src/test/util_mmio/main.cc | 28 +---- repos/os/run/report_rom.run | 2 +- repos/os/run/rom_filter.run | 2 +- .../os/src/drivers/nic/spec/gem/marvell_phy.h | 1 + .../nic/spec/gem/tx_buffer_descriptor.h | 3 +- .../src/drivers/platform/spec/arndale/cmu.h | 19 +-- .../src/drivers/platform/spec/arndale/pmu.h | 13 +- .../src/drivers/platform/spec/odroid_x2/pmu.h | 12 +- repos/os/src/server/vmm/main.cc | 65 +++++----- tool/autopilot.list | 2 +- 126 files changed, 639 insertions(+), 1020 deletions(-) create mode 100644 repos/base-fiasco/src/core/core_log.cc delete mode 100644 repos/base-fiasco/src/include/base/internal/core_console.h create mode 100644 repos/base-foc/src/core/core_log.cc delete mode 100644 repos/base-foc/src/include/base/internal/core_console.h delete mode 100644 repos/base-hw/src/core/console.cc create mode 100644 repos/base-hw/src/core/default_log.cc create mode 100644 repos/base-hw/src/core/include/kernel/log.h create mode 100644 repos/base-linux/src/core/core_log.cc delete mode 100644 repos/base-linux/src/include/base/internal/core_console.h create mode 100644 repos/base-nova/src/core/core_log.cc delete mode 100644 repos/base-nova/src/include/base/internal/core_console.h create mode 100644 repos/base-okl4/src/core/core_log.cc delete mode 100644 repos/base-okl4/src/include/base/internal/core_console.h create mode 100644 repos/base-pistachio/src/core/core_log.cc delete mode 100644 repos/base-pistachio/src/include/base/internal/core_console.h create mode 100644 repos/base-sel4/lib/mk/core_log.mk delete mode 100644 repos/base-sel4/lib/mk/core_printf.mk create mode 100644 repos/base-sel4/src/core/core_log.cc delete mode 100644 repos/base-sel4/src/include/base/internal/core_console.h create mode 100644 repos/base/run/log.run delete mode 100644 repos/base/run/printf.run create mode 100644 repos/base/src/core/include/core_log.h delete mode 100644 repos/base/src/lib/base/core_printf.cc rename repos/base/src/test/{printf => log}/main.cc (74%) rename repos/base/src/test/{printf => log}/target.mk (59%) diff --git a/repos/base-fiasco/src/core/core_log.cc b/repos/base-fiasco/src/core/core_log.cc new file mode 100644 index 0000000000..5059e35160 --- /dev/null +++ b/repos/base-fiasco/src/core/core_log.cc @@ -0,0 +1,20 @@ +/* + * \brief Kernel-specific core's 'log' backend + * \author Stefan Kalkowski + * \date 2016-10-10 + */ + +/* + * Copyright (C) 2016 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include + +namespace Fiasco { +#include +} +void Genode::Core_log::out(char const c) { Fiasco::outchar(c); } diff --git a/repos/base-fiasco/src/core/include/util.h b/repos/base-fiasco/src/core/include/util.h index 03067fed47..bebfa001d4 100644 --- a/repos/base-fiasco/src/core/include/util.h +++ b/repos/base-fiasco/src/core/include/util.h @@ -18,7 +18,6 @@ /* Genode includes */ #include -#include #include #include diff --git a/repos/base-fiasco/src/core/platform.cc b/repos/base-fiasco/src/core/platform.cc index 6a8e6601bf..e21b2046b7 100644 --- a/repos/base-fiasco/src/core/platform.cc +++ b/repos/base-fiasco/src/core/platform.cc @@ -338,7 +338,7 @@ static Fiasco::l4_kernel_info_t *get_kip() amok = true; } if (!l4_ipc_fpage_received(r)) { - printf("No fpage received\n"); + warning("No fpage received"); amok = true; } diff --git a/repos/base-fiasco/src/core/region_map_support.cc b/repos/base-fiasco/src/core/region_map_support.cc index 1588084c8e..8673d621d6 100644 --- a/repos/base-fiasco/src/core/region_map_support.cc +++ b/repos/base-fiasco/src/core/region_map_support.cc @@ -35,8 +35,9 @@ void Rm_client::unmap(addr_t core_local_base, addr_t virt_base, size_t size) */ if (verbose_unmap) { Fiasco::l4_threadid_t tid; tid.raw = badge(); - printf("RM client %p (%x.%x) unmap core-local [%lx,%lx)\n", - this, tid.id.task, tid.id.lthread, core_local_base, core_local_base + size); + log("RM client ", this, " (", (unsigned)tid.id.task, ".", + (unsigned)tid.id.lthread, ") unmap core-local [", + Hex(core_local_base), ",", Hex(core_local_base + size), ")"); } using namespace Fiasco; diff --git a/repos/base-fiasco/src/core/target.inc b/repos/base-fiasco/src/core/target.inc index 63603ddbdd..1cb620ded0 100644 --- a/repos/base-fiasco/src/core/target.inc +++ b/repos/base-fiasco/src/core/target.inc @@ -3,7 +3,7 @@ TARGET = core GEN_CORE_DIR = $(BASE_DIR)/src/core SRC_CC += stack_area.cc \ - core_printf.cc \ + core_log.cc \ core_region_map.cc \ core_rpc_cap_alloc.cc \ cpu_session_component.cc \ @@ -74,5 +74,4 @@ vpath default_log.cc $(GEN_CORE_DIR) vpath dump_alloc.cc $(GEN_CORE_DIR) vpath stack_area.cc $(GEN_CORE_DIR) vpath pager_ep.cc $(GEN_CORE_DIR) -vpath core_printf.cc $(BASE_DIR)/src/lib/base vpath %.cc $(REP_DIR)/src/core diff --git a/repos/base-fiasco/src/include/base/internal/core_console.h b/repos/base-fiasco/src/include/base/internal/core_console.h deleted file mode 100644 index 490093a128..0000000000 --- a/repos/base-fiasco/src/include/base/internal/core_console.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * \brief Console backend using the Fiasco kernel debugger - * \author Norman Feske - * \date 2006-04-08 - */ - -/* - * Copyright (C) 2006-2013 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -#ifndef _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ -#define _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ - -/* Fiasco includes */ -namespace Fiasco { -#include -} - -/* Genode includes */ -#include - -namespace Genode { - - class Core_console : public Console - { - protected: - - void _out_char(char c) { Fiasco::outchar(c); } - }; -} - -#endif /* _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ */ diff --git a/repos/base-fiasco/src/include/base/internal/fiasco_thread_helper.h b/repos/base-fiasco/src/include/base/internal/fiasco_thread_helper.h index 84cf9099d9..5ec5bd1651 100644 --- a/repos/base-fiasco/src/include/base/internal/fiasco_thread_helper.h +++ b/repos/base-fiasco/src/include/base/internal/fiasco_thread_helper.h @@ -14,20 +14,9 @@ #ifndef _INCLUDE__FIASCO__THREAD_HELPER_H_ #define _INCLUDE__FIASCO__THREAD_HELPER_H_ -#include - namespace Fiasco { #include - inline void print_l4_threadid(l4_threadid_t t) - { - Genode::printf("THREAD %x.%02x\n", t.id.task, t.id.lthread); - Genode::printf(" unsigned version_low:10 = %x\n", t.id.version_low); - Genode::printf(" unsigned lthread:7 = %x\n", t.id.lthread); - Genode::printf(" unsigned task:11 = %x\n", t.id.task); - } - - /** * Sigma0 thread ID * diff --git a/repos/base-fiasco/src/lib/base/lock.cc b/repos/base-fiasco/src/lib/base/lock.cc index 4516e3fee0..097326c575 100644 --- a/repos/base-fiasco/src/lib/base/lock.cc +++ b/repos/base-fiasco/src/lib/base/lock.cc @@ -15,7 +15,6 @@ #include #include #include -#include /* L4/Fiasco includes */ namespace Fiasco { diff --git a/repos/base-foc/src/core/core_log.cc b/repos/base-foc/src/core/core_log.cc new file mode 100644 index 0000000000..5059e35160 --- /dev/null +++ b/repos/base-foc/src/core/core_log.cc @@ -0,0 +1,20 @@ +/* + * \brief Kernel-specific core's 'log' backend + * \author Stefan Kalkowski + * \date 2016-10-10 + */ + +/* + * Copyright (C) 2016 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include + +namespace Fiasco { +#include +} +void Genode::Core_log::out(char const c) { Fiasco::outchar(c); } diff --git a/repos/base-foc/src/core/include/irq_object.h b/repos/base-foc/src/core/include/irq_object.h index e05bfd99a3..1f3211b73f 100644 --- a/repos/base-foc/src/core/include/irq_object.h +++ b/repos/base-foc/src/core/include/irq_object.h @@ -17,7 +17,6 @@ #define _CORE__INCLUDE__IRQ_OBJECT_H_ /* Genode includes */ -#include #include #include diff --git a/repos/base-foc/src/core/include/map_local.h b/repos/base-foc/src/core/include/map_local.h index 74e22bf39d..529b2832ff 100644 --- a/repos/base-foc/src/core/include/map_local.h +++ b/repos/base-foc/src/core/include/map_local.h @@ -56,7 +56,8 @@ namespace Genode { L4_BASE_TASK_CAP, snd_fpage, to_addr + offset))) { - PWRN("could not locally remap 0x%lx to 0x%lx", from_addr, to_addr); + warning("could not locally remap ", (void*)from_addr, " to ", + (void*)to_addr); return false; } } diff --git a/repos/base-foc/src/core/include/util.h b/repos/base-foc/src/core/include/util.h index fa373c2b75..fcf65e4a5e 100644 --- a/repos/base-foc/src/core/include/util.h +++ b/repos/base-foc/src/core/include/util.h @@ -19,7 +19,6 @@ /* Genode includes */ #include -#include #include #include diff --git a/repos/base-foc/src/core/native_cpu_component.cc b/repos/base-foc/src/core/native_cpu_component.cc index 7aaac41a60..b1f6363ff6 100644 --- a/repos/base-foc/src/core/native_cpu_component.cc +++ b/repos/base-foc/src/core/native_cpu_component.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* core includes */ #include @@ -42,7 +42,7 @@ void Genode::Native_cpu_component::enable_vcpu(Genode::Thread_capability thread_ l4_msgtag_t tag = l4_thread_vcpu_control(tid, vcpu_state); if (l4_msgtag_has_error(tag)) - PWRN("l4_thread_vcpu_control failed"); + warning("l4_thread_vcpu_control failed"); }; _thread_ep.apply(thread_cap, lambda); } @@ -81,7 +81,7 @@ Genode::Native_capability Genode::Native_cpu_component::alloc_irq() Cap_index* i = cap_map()->insert(platform_specific()->cap_id_alloc()->alloc()); l4_msgtag_t res = l4_factory_create_irq(L4_BASE_FACTORY_CAP, i->kcap()); if (l4_error(res)) { - PWRN("Allocation of irq object failed!"); + warning("Allocation of irq object failed!"); return Genode::Native_capability(); } diff --git a/repos/base-foc/src/core/platform_thread.cc b/repos/base-foc/src/core/platform_thread.cc index 47e664a871..6d6efcc6ef 100644 --- a/repos/base-foc/src/core/platform_thread.cc +++ b/repos/base-foc/src/core/platform_thread.cc @@ -48,8 +48,8 @@ int Platform_thread::start(void *ip, void *sp) l4_thread_control_bind((l4_utcb_t *)_utcb, _platform_pd->native_task().data()->kcap()); l4_msgtag_t tag = l4_thread_control_commit(_thread.local.data()->kcap()); if (l4_msgtag_has_error(tag)) { - PWRN("l4_thread_control_commit for %lx failed!", - (unsigned long) _thread.local.data()->kcap()); + warning("l4_thread_control_commit for ", + Hex(_thread.local.data()->kcap()), " failed!"); return -1; } @@ -59,7 +59,7 @@ int Platform_thread::start(void *ip, void *sp) tag = l4_thread_ex_regs(_thread.local.data()->kcap(), (l4_addr_t) ip, (l4_addr_t) sp, 0); if (l4_msgtag_has_error(tag)) { - PWRN("l4_thread_ex_regs failed!"); + warning("l4_thread_ex_regs failed!"); return -1; } @@ -161,8 +161,8 @@ void Platform_thread::unbind() l4_thread_control_pager(_gate.remote); l4_thread_control_exc_handler(_gate.remote); if (l4_msgtag_has_error(l4_thread_control_commit(_thread.local.data()->kcap()))) - PWRN("l4_thread_control_commit for %lx failed!", - (unsigned long) _thread.local.data()->kcap()); + warning("l4_thread_control_commit for ", + Hex(_thread.local.data()->kcap()), " failed!"); /* now force it into a pagefault */ l4_thread_ex_regs(_thread.local.data()->kcap(), 0, 0, L4_THREAD_EX_REGS_CANCEL); @@ -219,7 +219,8 @@ void Platform_thread::affinity(Affinity::Location location) l4_msgtag_t tag = l4_scheduler_run_thread(L4_BASE_SCHEDULER_CAP, _thread.local.data()->kcap(), ¶ms); if (l4_error(tag)) - PWRN("setting affinity of %lx to %d failed!", _thread.local.data()->kcap(), cpu); + warning("setting affinity of ", Hex(_thread.local.data()->kcap()), + " to ", cpu, " failed!"); } @@ -254,12 +255,12 @@ void Platform_thread::_finalize_construction(const char *name) l4_msgtag_t tag = l4_factory_create_irq(L4_BASE_FACTORY_CAP, _irq.local.data()->kcap()); if (l4_msgtag_has_error(tag)) - PWRN("creating thread's irq failed"); + warning("creating thread's irq failed"); /* attach thread to irq */ tag = l4_irq_attach(_irq.local.data()->kcap(), 0, _thread.local.data()->kcap()); if (l4_msgtag_has_error(tag)) - PWRN("attaching thread's irq failed"); + warning("attaching thread's irq failed"); /* set human readable name in kernel debugger */ strncpy(_name, name, sizeof(_name)); diff --git a/repos/base-foc/src/core/rpc_cap_factory.cc b/repos/base-foc/src/core/rpc_cap_factory.cc index 5ec9ed53a6..4127ab2e14 100644 --- a/repos/base-foc/src/core/rpc_cap_factory.cc +++ b/repos/base-foc/src/core/rpc_cap_factory.cc @@ -92,7 +92,7 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep) Native_capability cap; if (!ep.valid()) { - PWRN("Invalid reference capability!"); + warning("Invalid reference capability!"); return cap; } @@ -110,7 +110,7 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep) Core_cap_index* idx = static_cast(cap_map()->insert(id)); if (!idx) { - PWRN("Out of capability indices!"); + warning("Out of capability indices!"); platform_specific()->cap_id_alloc()->free(id); return cap; } @@ -164,7 +164,7 @@ void Rpc_cap_factory::free(Native_capability cap) if (e) { _pool.remove(e); } else - PWRN("Could not find capability to be deleted"); + warning("Could not find capability to be deleted"); }); if (entry) destroy(_md_alloc, entry); } diff --git a/repos/base-foc/src/core/target.inc b/repos/base-foc/src/core/target.inc index 6ba978f441..60836a50a6 100644 --- a/repos/base-foc/src/core/target.inc +++ b/repos/base-foc/src/core/target.inc @@ -6,7 +6,7 @@ GEN_CORE_DIR = $(BASE_DIR)/src/core LIBS += base-common SRC_CC += stack_area.cc \ - core_printf.cc \ + core_log.cc \ core_region_map.cc \ core_rpc_cap_alloc.cc \ cpu_session_component.cc \ @@ -69,6 +69,5 @@ vpath rom_session_component.cc $(GEN_CORE_DIR) vpath trace_session_component.cc $(GEN_CORE_DIR) vpath core_rpc_cap_alloc.cc $(GEN_CORE_DIR) vpath core_region_map.cc $(GEN_CORE_DIR) -vpath core_printf.cc $(BASE_DIR)/src/lib/base vpath %.cc $(REP_DIR)/src/core vpath %.cc $(REP_DIR)/src/lib/base diff --git a/repos/base-foc/src/core/thread_start.cc b/repos/base-foc/src/core/thread_start.cc index 215e2e424c..6c2afe4a47 100644 --- a/repos/base-foc/src/core/thread_start.cc +++ b/repos/base-foc/src/core/thread_start.cc @@ -33,7 +33,7 @@ using namespace Genode; void Thread::_deinit_platform_thread() { - PWRN("%s: not implemented yet!", __func__); + warning(__func__, ": not implemented yet!"); } diff --git a/repos/base-foc/src/include/base/internal/core_console.h b/repos/base-foc/src/include/base/internal/core_console.h deleted file mode 100644 index 490093a128..0000000000 --- a/repos/base-foc/src/include/base/internal/core_console.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * \brief Console backend using the Fiasco kernel debugger - * \author Norman Feske - * \date 2006-04-08 - */ - -/* - * Copyright (C) 2006-2013 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -#ifndef _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ -#define _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ - -/* Fiasco includes */ -namespace Fiasco { -#include -} - -/* Genode includes */ -#include - -namespace Genode { - - class Core_console : public Console - { - protected: - - void _out_char(char c) { Fiasco::outchar(c); } - }; -} - -#endif /* _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ */ diff --git a/repos/base-foc/src/lib/base/thread_start.cc b/repos/base-foc/src/lib/base/thread_start.cc index 1a8170cb9e..c5785bcaf3 100644 --- a/repos/base-foc/src/lib/base/thread_start.cc +++ b/repos/base-foc/src/lib/base/thread_start.cc @@ -15,7 +15,6 @@ /* Genode includes */ #include -#include #include #include #include diff --git a/repos/base-hw/lib/mk/core.inc b/repos/base-hw/lib/mk/core.inc index a63a0a4e4a..cc7c2c9979 100644 --- a/repos/base-hw/lib/mk/core.inc +++ b/repos/base-hw/lib/mk/core.inc @@ -17,7 +17,6 @@ INC_DIR += $(BASE_DIR)/../base-hw/src/include INC_DIR += $(BASE_DIR)/src/include # add C++ sources -SRC_CC += console.cc SRC_CC += cpu_session_component.cc SRC_CC += cpu_session_support.cc SRC_CC += cpu_thread_component.cc diff --git a/repos/base-hw/src/core/console.cc b/repos/base-hw/src/core/console.cc deleted file mode 100644 index 9f0fb52c09..0000000000 --- a/repos/base-hw/src/core/console.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* - * \brief Genode-console backend - * \author Martin Stein - * \date 2011-10-17 - */ - -/* - * Copyright (C) 2011-2013 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -/* Genode includes */ -#include -#include - -/* core includes */ -#include - -/* base-internal includes */ -#include - -namespace Genode -{ - /** - * Platform specific Genode console - */ - class Platform_console : public Console, public Serial - { - enum { BAUD_RATE = 115200 }; - - protected: - - /** - * Print a char to the console - */ - void _out_char(char c) - { - enum { - ASCII_LINE_FEED = 10, - ASCII_CARRIAGE_RETURN = 13, - }; - - /* auto complete new line commands */ - if (c == ASCII_LINE_FEED) - Serial::put_char(ASCII_CARRIAGE_RETURN); - - /* print char */ - Serial::put_char(c); - } - - public: - - /** - * Constructor - */ - Platform_console() : Serial(BAUD_RATE) { } - }; -} - -using namespace Genode; - - -/** - * Static object to print log output - */ -static Platform_console * platform_console() -{ - return unmanaged_singleton(); -} - - -/**************************** - ** Genode print functions ** - ****************************/ - -void Genode::printf(const char *format, ...) -{ - va_list list; - va_start(list, format); - platform_console()->vprintf(format, list); - va_end(list); -} - - -void Genode::vprintf(const char *format, va_list list) -{ - platform_console()->vprintf(format, list); -} - diff --git a/repos/base-hw/src/core/default_log.cc b/repos/base-hw/src/core/default_log.cc new file mode 100644 index 0000000000..e2cb3617cb --- /dev/null +++ b/repos/base-hw/src/core/default_log.cc @@ -0,0 +1,72 @@ +/* + * \brief Access to the core's log facility + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2016-05-03 + */ + +/* + * Copyright (C) 2016 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* base-internal includes */ +#include +#include +#include + +#include +#include +#include + +using namespace Genode; + +static Log *log_ptr; + + +Log &Log::log() { return *log_ptr; } + + +static void out_char(char const c) +{ + enum { + ASCII_LINE_FEED = 10, + ASCII_CARRIAGE_RETURN = 13, + BAUD_RATE = 115200 + }; + + Serial & serial = *unmanaged_singleton(BAUD_RATE); + if (c == ASCII_LINE_FEED) serial.put_char(ASCII_CARRIAGE_RETURN); + serial.put_char(c); +} + + +void Genode::Core_log::out(char const c) { out_char(c); } + + +void Genode::init_log() +{ + /* ignore subsequent calls */ + if (log_ptr) return; + + struct Write_fn + { + Core_log log; + void operator () (char const *s) { log.output(s); } + }; + + typedef Buffered_output<512, Write_fn> Buffered_log_output; + + static Buffered_log_output *buffered_log_output = + unmanaged_singleton(Write_fn()); + + log_ptr = unmanaged_singleton(*buffered_log_output); +} + + +void Kernel::log(char const c) { out_char(c); } diff --git a/repos/base-hw/src/core/include/kernel/ipc_node.h b/repos/base-hw/src/core/include/kernel/ipc_node.h index 39c96071da..7459549d65 100644 --- a/repos/base-hw/src/core/include/kernel/ipc_node.h +++ b/repos/base-hw/src/core/include/kernel/ipc_node.h @@ -200,8 +200,7 @@ class Kernel::Ipc_node : public Ipc_node_queue::Element ** Accessors ** ***************/ - Pd * const pd() const { return _pd; } - char const * pd_label() const; + Pd * const pd() const { return _pd; } Genode::Native_utcb * utcb() { return _utcb; } }; diff --git a/repos/base-hw/src/core/include/kernel/log.h b/repos/base-hw/src/core/include/kernel/log.h new file mode 100644 index 0000000000..4032e053e7 --- /dev/null +++ b/repos/base-hw/src/core/include/kernel/log.h @@ -0,0 +1,19 @@ +/* + * \brief Kernel backend log messages + * \author Stefan Kalkowski + * \date 2016-10-10 + */ + +/* + * Copyright (C) 2016 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__KERNEL__LOG_H_ +#define _CORE__INCLUDE__KERNEL__LOG_H_ + +namespace Kernel { void log(char const); } + +#endif diff --git a/repos/base-hw/src/core/include/kernel/thread.h b/repos/base-hw/src/core/include/kernel/thread.h index 3868fd646c..8c11d5a694 100644 --- a/repos/base-hw/src/core/include/kernel/thread.h +++ b/repos/base-hw/src/core/include/kernel/thread.h @@ -86,8 +86,6 @@ class Kernel::Thread private: - enum { START_VERBOSE = 0 }; - enum State { ACTIVE = 1, @@ -195,23 +193,6 @@ class Kernel::Thread */ size_t _core_to_kernel_quota(size_t const quota) const; - /** - * Print the activity of the thread - * - * \param printing_thread wether this thread caused the debugging - */ - void _print_activity(bool const printing_thread); - - /** - * Print the activity of the thread when it awaits a message - */ - void _print_activity_when_awaits_ipc(); - - /** - * Print activity info that is printed regardless of the thread state - */ - void _print_common_activity(); - /********************************************************* ** Kernel-call back-ends, see kernel-interface headers ** @@ -340,6 +321,8 @@ class Kernel::Thread static void syscall_destroy(Thread * thread) { call(call_id_delete_thread(), (Call_arg)thread); } + void print(Genode::Output &out) const; + /************* ** Cpu_job ** diff --git a/repos/base-hw/src/core/include/map_local.h b/repos/base-hw/src/core/include/map_local.h index 581e3b30d4..32b087b01a 100644 --- a/repos/base-hw/src/core/include/map_local.h +++ b/repos/base-hw/src/core/include/map_local.h @@ -14,9 +14,6 @@ #ifndef _CORE__INCLUDE__MAP_LOCAL_H_ #define _CORE__INCLUDE__MAP_LOCAL_H_ -/* Genode includes */ -#include - /* core includes */ #include diff --git a/repos/base-hw/src/core/include/spec/arm/short_translation_table.h b/repos/base-hw/src/core/include/spec/arm/short_translation_table.h index b1101b7ad4..9d223e140d 100644 --- a/repos/base-hw/src/core/include/spec/arm/short_translation_table.h +++ b/repos/base-hw/src/core/include/spec/arm/short_translation_table.h @@ -17,7 +17,6 @@ /* Genode includes */ #include -#include /* core includes */ #include diff --git a/repos/base-hw/src/core/include/spec/arm_v7/long_translation_table.h b/repos/base-hw/src/core/include/spec/arm_v7/long_translation_table.h index 71d3264654..3cb6b31436 100644 --- a/repos/base-hw/src/core/include/spec/arm_v7/long_translation_table.h +++ b/repos/base-hw/src/core/include/spec/arm_v7/long_translation_table.h @@ -17,7 +17,6 @@ /* Genode includes */ #include #include -#include /* base-hw includes */ #include diff --git a/repos/base-hw/src/core/include/spec/arm_v7/trustzone/vm_session_component.h b/repos/base-hw/src/core/include/spec/arm_v7/trustzone/vm_session_component.h index 59bf16fe65..8d0674f3fa 100644 --- a/repos/base-hw/src/core/include/spec/arm_v7/trustzone/vm_session_component.h +++ b/repos/base-hw/src/core/include/spec/arm_v7/trustzone/vm_session_component.h @@ -64,13 +64,13 @@ class Genode::Vm_session_component void pause(void); void attach(Dataspace_capability ds_cap, addr_t vm_addr) { - PWRN("Not implemented for TrustZone case"); } + warning("Not implemented for TrustZone case"); } void attach_pic(addr_t vm_addr) { - PWRN("Not implemented for TrustZone case"); } + warning("Not implemented for TrustZone case"); } void detach(addr_t vm_addr, size_t size) { - PWRN("Not implemented for TrustZone case"); } + warning("Not implemented for TrustZone case"); } }; #endif /* _CORE__INCLUDE__SPEC__ARM_V7__TRUSTZONE__VM_SESSION_COMPONENT_H_ */ diff --git a/repos/base-hw/src/core/include/spec/riscv/timer.h b/repos/base-hw/src/core/include/spec/riscv/timer.h index d885a05cc5..a84279cdd7 100644 --- a/repos/base-hw/src/core/include/spec/riscv/timer.h +++ b/repos/base-hw/src/core/include/spec/riscv/timer.h @@ -18,7 +18,6 @@ #include /* Genode includes */ -#include #include /* Core includes */ diff --git a/repos/base-hw/src/core/include/spec/x86_64/muen/sinfo_instance.h b/repos/base-hw/src/core/include/spec/x86_64/muen/sinfo_instance.h index 446d2e1471..359409318f 100644 --- a/repos/base-hw/src/core/include/spec/x86_64/muen/sinfo_instance.h +++ b/repos/base-hw/src/core/include/spec/x86_64/muen/sinfo_instance.h @@ -15,12 +15,8 @@ #define _CORE__INCLUDE__SPEC__X86_64__MUEN__SINFO_INSTANCE_H_ /* base includes */ -#include #include -/* core includes */ -#include - namespace Genode { /** diff --git a/repos/base-hw/src/core/include/spec/x86_64/muen/vm_session_component.h b/repos/base-hw/src/core/include/spec/x86_64/muen/vm_session_component.h index b019d6b70b..3b2604cca1 100644 --- a/repos/base-hw/src/core/include/spec/x86_64/muen/vm_session_component.h +++ b/repos/base-hw/src/core/include/spec/x86_64/muen/vm_session_component.h @@ -51,8 +51,8 @@ class Genode::Vm_session_component void exception_handler(Signal_context_capability handler) { if (!create(&_state, Capability_space::capid(handler), nullptr)) - PWRN("Cannot instantiate vm kernel object, " - "invalid signal context?"); + warning("Cannot instantiate vm kernel object, " + "invalid signal context?"); } void run(void) diff --git a/repos/base-hw/src/core/include/spec/x86_64/timer.h b/repos/base-hw/src/core/include/spec/x86_64/timer.h index 1d047b9f40..3a35c79a25 100644 --- a/repos/base-hw/src/core/include/spec/x86_64/timer.h +++ b/repos/base-hw/src/core/include/spec/x86_64/timer.h @@ -21,7 +21,6 @@ /* Genode includes */ #include #include -#include /* core includes */ #include diff --git a/repos/base-hw/src/core/include/spec/x86_64/translation_table.h b/repos/base-hw/src/core/include/spec/x86_64/translation_table.h index 13a76ea5d6..16fad44867 100644 --- a/repos/base-hw/src/core/include/spec/x86_64/translation_table.h +++ b/repos/base-hw/src/core/include/spec/x86_64/translation_table.h @@ -17,7 +17,6 @@ /* Genode includes */ #include #include -#include #include /* base-hw includes */ diff --git a/repos/base-hw/src/core/include/util.h b/repos/base-hw/src/core/include/util.h index 98289deb5d..0d66bd683c 100644 --- a/repos/base-hw/src/core/include/util.h +++ b/repos/base-hw/src/core/include/util.h @@ -16,7 +16,6 @@ /* Genode includes */ #include -#include /* base-internal includes */ #include diff --git a/repos/base-hw/src/core/kernel/cpu.cc b/repos/base-hw/src/core/kernel/cpu.cc index 8826f7267d..7d5873de45 100644 --- a/repos/base-hw/src/core/kernel/cpu.cc +++ b/repos/base-hw/src/core/kernel/cpu.cc @@ -84,7 +84,7 @@ void Cpu_job::_interrupt(unsigned const cpu_id) /* it needs to be a user interrupt */ User_irq * irq = User_irq::object(irq_id); if (irq) irq->occurred(); - else PWRN("Unknown interrupt %u", irq_id); + else Genode::warning("Unknown interrupt ", irq_id); } /* end interrupt request at controller */ diff --git a/repos/base-hw/src/core/kernel/init.cc b/repos/base-hw/src/core/kernel/init.cc index f94f1ae268..9eceb2a0a8 100644 --- a/repos/base-hw/src/core/kernel/init.cc +++ b/repos/base-hw/src/core/kernel/init.cc @@ -22,6 +22,7 @@ /* base includes */ #include +#include using namespace Kernel; @@ -59,7 +60,9 @@ extern "C" void init_kernel() Core_thread::singleton(); - Genode::printf("\nkernel initialized\n"); + Genode::init_log(); + Genode::log(""); + Genode::log("kernel initialized"); kernel(); } diff --git a/repos/base-hw/src/core/kernel/ipc_node.cc b/repos/base-hw/src/core/kernel/ipc_node.cc index 45bad4fdce..65c29d5301 100644 --- a/repos/base-hw/src/core/kernel/ipc_node.cc +++ b/repos/base-hw/src/core/kernel/ipc_node.cc @@ -252,10 +252,6 @@ void Ipc_node::cancel_waiting() } -char const * Ipc_node::pd_label() const { - return (_pd) ? _pd->platform_pd()->label() : "?"; } - - Ipc_node::~Ipc_node() { _cancel_request_queue(); diff --git a/repos/base-hw/src/core/kernel/thread.cc b/repos/base-hw/src/core/kernel/thread.cc index ede6d940a9..64b94d0775 100644 --- a/repos/base-hw/src/core/kernel/thread.cc +++ b/repos/base-hw/src/core/kernel/thread.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -176,7 +177,7 @@ Cpu_job * Thread::helping_sink() { void Thread::_receive_yielded_cpu() { if (_state == AWAITS_RESUME) { _become_active(); } - else { PWRN("failed to receive yielded CPU"); } + else { Genode::warning("failed to receive yielded CPU"); } } @@ -216,7 +217,7 @@ void Thread::_call_start_thread() /* lookup CPU */ Cpu * const cpu = cpu_pool()->cpu(user_arg_2()); if (!cpu) { - PWRN("failed to lookup CPU"); + Genode::warning("failed to lookup CPU"); user_arg_0(-2); return; } @@ -230,15 +231,6 @@ void Thread::_call_start_thread() /* join protection domain */ thread->_pd = (Pd *) user_arg_3(); thread->_pd->admit(thread); - - /* print log message */ - if (START_VERBOSE) { - Genode::printf("start thread '%s' in program '%s' ", - thread->label(), thread->pd_label()); - if (NR_OF_CPUS) { - Genode::printf("on CPU %u/%u ", cpu->id(), NR_OF_CPUS); } - Genode::printf("\n"); - } thread->Ipc_node::_init((Native_utcb *)user_arg_4(), this); thread->_become_active(); } @@ -262,8 +254,8 @@ void Thread::_call_resume_local_thread() /* lookup thread */ Thread * const thread = pd()->cap_tree().find(user_arg_1()); if (!thread || pd() != thread->pd()) { - PWRN("%s -> %s: failed to lookup thread %u to resume it", - pd_label(), label(), (capid_t)user_arg_1()); + warning(*this, ": failed to lookup thread ", (unsigned)user_arg_1(), + " to resume it"); _stop(); return; } @@ -319,9 +311,8 @@ void Thread::timeout_triggered() { Signal_context * const c = pd()->cap_tree().find(_timeout_sigid); - if(!c || c->submit(1)) { - PWRN("%s -> %s: failed to submit timeout signal", pd_label(), label()); - } + if (!c || c->submit(1)) + Genode::warning(*this, ": failed to submit timeout signal"); } @@ -330,8 +321,8 @@ void Thread::_call_send_request_msg() Object_identity_reference * oir = pd()->cap_tree().find(user_arg_1()); Thread * const dst = (oir) ? oir->object() : nullptr; if (!dst) { - PWRN("%s -> %s: cannot send to unknown recipient %llu", - pd_label(), label(), (unsigned long long)user_arg_1()); + Genode::warning(*this, ": cannot send to unknown recipient ", + (unsigned)user_arg_1()); _become_inactive(AWAITS_IPC); return; } @@ -386,60 +377,7 @@ Signal_context * const Thread_event::signal_context() const { return _signal_context; } -void Thread::_print_activity(bool const printing_thread) -{ - Genode::printf("\033[33m%s -> %s:\033[0m", pd_label(), label()); - switch (_state) { - case AWAITS_START: { - Genode::printf("\033[32m init\033[0m"); - break; } - case ACTIVE: { - if (!printing_thread) { Genode::printf("\033[32m run\033[0m"); } - else { Genode::printf("\033[32m debug\033[0m"); } - break; } - case AWAITS_IPC: { - _print_activity_when_awaits_ipc(); - break; } - case AWAITS_RESUME: { - Genode::printf("\033[32m await RES\033[0m"); - break; } - case AWAITS_SIGNAL: { - Genode::printf("\033[32m await SIG\033[0m"); - break; } - case AWAITS_SIGNAL_CONTEXT_KILL: { - Genode::printf("\033[32m await SCK\033[0m"); - break; } - case STOPPED: { - Genode::printf("\033[32m stop\033[0m"); - break; } - } - _print_common_activity(); -} - - -void Thread::_print_common_activity() -{ - Genode::printf(" ip %lx sp %lx\n", ip, sp); -} - - -void Thread::_print_activity_when_awaits_ipc() -{ - switch (Ipc_node::state()) { - case AWAIT_REPLY: { - Thread * const server = dynamic_cast(Ipc_node::callee()); - Genode::printf("\033[32m await RPL %s -> %s\033[0m", - server->pd_label(), server->label()); - break; } - case AWAIT_REQUEST: { - Genode::printf("\033[32m await REQ\033[0m"); - break; } - default: break; - } -} - - -void Thread::_call_print_char() { Genode::printf("%c", (char)user_arg_1()); } +void Thread::_call_print_char() { Kernel::log((char)user_arg_1()); } void Thread::_call_await_signal() @@ -447,14 +385,14 @@ void Thread::_call_await_signal() /* lookup receiver */ Signal_receiver * const r = pd()->cap_tree().find(user_arg_1()); if (!r) { - PWRN("%s -> %s: cannot await, unknown signal receiver %u", - pd_label(), label(), (capid_t)user_arg_1()); + Genode::warning(*this, ": cannot await, unknown signal receiver ", + (unsigned)user_arg_1()); user_arg_0(-1); return; } /* register handler at the receiver */ if (r->add_handler(this)) { - PWRN("failed to register handler at signal receiver"); + Genode::warning("failed to register handler at signal receiver"); user_arg_0(-1); return; } @@ -467,15 +405,14 @@ void Thread::_call_submit_signal() /* lookup signal context */ Signal_context * const c = pd()->cap_tree().find(user_arg_1()); if(!c) { - PWRN("%s -> %s: cannot submit unknown signal context", - pd_label(), label()); + Genode::warning(*this, ": cannot submit unknown signal context"); user_arg_0(-1); return; } /* trigger signal context */ if (c->submit(user_arg_2())) { - PWRN("failed to submit signal context"); + Genode::warning("failed to submit signal context"); user_arg_0(-1); return; } @@ -488,8 +425,7 @@ void Thread::_call_ack_signal() /* lookup signal context */ Signal_context * const c = pd()->cap_tree().find(user_arg_1()); if (!c) { - PWRN("%s -> %s: cannot ack unknown signal context", - pd_label(), label()); + Genode::warning(*this, ": cannot ack unknown signal context"); return; } @@ -503,15 +439,14 @@ void Thread::_call_kill_signal_context() /* lookup signal context */ Signal_context * const c = pd()->cap_tree().find(user_arg_1()); if (!c) { - PWRN("%s -> %s: cannot kill unknown signal context", - pd_label(), label()); + Genode::warning(*this, ": cannot kill unknown signal context"); user_arg_0(-1); return; } /* kill signal context */ if (c->kill(this)) { - PWRN("failed to kill signal context"); + Genode::warning("failed to kill signal context"); user_arg_0(-1); return; } @@ -522,8 +457,7 @@ void Thread::_call_new_irq() { Signal_context * const c = pd()->cap_tree().find(user_arg_3()); if (!c) { - PWRN("%s -> %s: invalid signal context for interrupt", - pd_label(), label()); + Genode::warning(*this, ": invalid signal context for interrupt"); user_arg_0(-1); return; } @@ -545,7 +479,7 @@ void Thread::_call_new_obj() if (!thread || (static_cast*>(thread)->capid() != ref->capid())) { if (thread) - PWRN("faked thread %s -> %s", thread->pd_label(), thread->label()); + Genode::warning("faked thread", thread); user_arg_0(cap_id_invalid()); return; } @@ -610,8 +544,7 @@ void Thread::_call() default: /* check wether this is a core thread */ if (!_core()) { - PWRN("%s -> %s: not entitled to do kernel call", - pd_label(), label()); + Genode::warning(*this, ": not entitled to do kernel call"); _stop(); return; } @@ -648,7 +581,7 @@ void Thread::_call() case call_id_new_obj(): _call_new_obj(); return; case call_id_delete_obj(): _call_delete_obj(); return; default: - PWRN("%s -> %s: unknown kernel call", pd_label(), label()); + Genode::warning(*this, ": unknown kernel call"); _stop(); return; } @@ -674,6 +607,14 @@ Thread_event Thread::* Thread::_event(unsigned const id) const } +void Thread::print(Genode::Output &out) const +{ + Genode::print(out, (_pd) ? _pd->platform_pd()->label() : "?"); + Genode::print(out, " -> "); + Genode::print(out, label()); +} + + /***************** ** Core_thread ** *****************/ diff --git a/repos/base-hw/src/core/platform.cc b/repos/base-hw/src/core/platform.cc index a06c6594fa..263d5a4eda 100644 --- a/repos/base-hw/src/core/platform.cc +++ b/repos/base-hw/src/core/platform.cc @@ -13,8 +13,6 @@ */ /* Genode includes */ -#include -#include #include /* core includes */ @@ -133,7 +131,6 @@ Platform::Platform() * Core mem alloc must come first because it is * used by the other allocators. */ - enum { VERBOSE = 0 }; init_alloc(_core_mem_alloc.phys_alloc(), _ram_regions, _core_only_ram_regions, get_page_size_log2()); init_alloc(_core_mem_alloc.virt_alloc(), virt_region, @@ -165,32 +162,30 @@ Platform::Platform() _init_additional(); /* print ressource summary */ - if (VERBOSE) { - printf("Core virtual memory allocator\n"); - printf("---------------------\n"); - (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); - printf("\n"); - printf("RAM memory allocator\n"); - printf("---------------------\n"); - (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); - printf("\n"); - printf("IO memory allocator\n"); - printf("-------------------\n"); - _io_mem_alloc()->dump_addr_tree(); - printf("\n"); - printf("IO port allocator\n"); - printf("-------------------\n"); - _io_port_alloc()->dump_addr_tree(); - printf("\n"); - printf("IRQ allocator\n"); - printf("-------------------\n"); - _irq_alloc()->dump_addr_tree(); - printf("\n"); - printf("ROM filesystem\n"); - printf("--------------\n"); - _rom_fs.print_fs(); - printf("\n"); - } + log("Core virtual memory allocator"); + log("---------------------"); + (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); + log("\n"); + log("RAM memory allocator"); + log("---------------------"); + (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); + log(""); + log("IO memory allocator"); + log("-------------------"); + _io_mem_alloc()->dump_addr_tree(); + log(""); + log("IO port allocator"); + log("-------------------"); + _io_port_alloc()->dump_addr_tree(); + log(""); + log("IRQ allocator"); + log("-------------------"); + _irq_alloc()->dump_addr_tree(); + log(""); + log("ROM filesystem"); + log("--------------"); + _rom_fs.print_fs(); + log(""); } diff --git a/repos/base-hw/src/core/region_map_support.cc b/repos/base-hw/src/core/region_map_support.cc index e370f7ea61..7ff8320127 100644 --- a/repos/base-hw/src/core/region_map_support.cc +++ b/repos/base-hw/src/core/region_map_support.cc @@ -63,7 +63,7 @@ void Pager_entrypoint::entry() /* fetch fault data */ Platform_thread * const pt = (Platform_thread *)po->badge(); if (!pt) { - PWRN("failed to get platform thread of faulter"); + Genode::warning("failed to get platform thread of faulter"); return; } diff --git a/repos/base-hw/src/core/spec/arm/kernel/thread.cc b/repos/base-hw/src/core/spec/arm/kernel/thread.cc index a41451dfd5..fd578e865a 100644 --- a/repos/base-hw/src/core/spec/arm/kernel/thread.cc +++ b/repos/base-hw/src/core/spec/arm/kernel/thread.cc @@ -39,15 +39,15 @@ void Thread::exception(unsigned const cpu) return; case UNDEFINED_INSTRUCTION: if (_cpu->retry_undefined_instr(*this)) { return; } - Genode::warning(pd_label(), " -> ", label(), ": " - "undefined instruction at ip=", Genode::Hex(ip)); + Genode::warning(*this, ": undefined instruction at ip=", + Genode::Hex(ip)); _stop(); return; case RESET: return; default: - Genode::warning(pd_label(), " -> ", label(), ": " - "triggered an unknown exception ", cpu_exception); + Genode::warning(*this, ": triggered an unknown exception ", + cpu_exception); _stop(); return; } @@ -72,7 +72,7 @@ void Thread::_mmu_exception() _fault.submit(); return; } - Genode::error(pd_label(), " -> ", label(), ": raised unhandled ", + Genode::error(*this, ": raised unhandled ", cpu_exception == DATA_ABORT ? "data abort" : "prefetch abort", " " "DFSR=", Genode::Hex(Cpu::Dfsr::read()), " " "ISFR=", Genode::Hex(Cpu::Ifsr::read()), " " diff --git a/repos/base-hw/src/core/spec/arm_v7/trustzone/kernel/vm.cc b/repos/base-hw/src/core/spec/arm_v7/trustzone/kernel/vm.cc index 2e7e0d898b..fa05fb9fb3 100644 --- a/repos/base-hw/src/core/spec/arm_v7/trustzone/kernel/vm.cc +++ b/repos/base-hw/src/core/spec/arm_v7/trustzone/kernel/vm.cc @@ -63,7 +63,7 @@ void Vm::proceed(unsigned const cpu) unsigned const irq = _state->irq_injection; if (irq) { if (secure_irq(irq)) { - PWRN("Refuse to inject secure IRQ into VM"); + Genode::warning("Refuse to inject secure IRQ into VM"); } else { pic()->trigger(irq); _state->irq_injection = 0; diff --git a/repos/base-hw/src/core/spec/arm_v7/trustzone/vm_session_component.cc b/repos/base-hw/src/core/spec/arm_v7/trustzone/vm_session_component.cc index 4ffb813ee5..5050ebefc9 100644 --- a/repos/base-hw/src/core/spec/arm_v7/trustzone/vm_session_component.cc +++ b/repos/base-hw/src/core/spec/arm_v7/trustzone/vm_session_component.cc @@ -23,8 +23,8 @@ void Vm_session_component::exception_handler(Signal_context_capability handler) if (!create((void*)_ds.core_local_addr(), Capability_space::capid(handler), nullptr)) { - PWRN("Cannot instantiate vm kernel object twice," - "or invalid signal context?"); + warning("Cannot instantiate vm kernel object twice," + "or invalid signal context?"); } } diff --git a/repos/base-hw/src/core/spec/riscv/cpu.cc b/repos/base-hw/src/core/spec/riscv/cpu.cc index f1ab154b90..5540a30e4c 100644 --- a/repos/base-hw/src/core/spec/riscv/cpu.cc +++ b/repos/base-hw/src/core/spec/riscv/cpu.cc @@ -12,7 +12,6 @@ */ /* Genode includes */ -#include #include /* Core includes */ diff --git a/repos/base-hw/src/core/spec/riscv/kernel/thread.cc b/repos/base-hw/src/core/spec/riscv/kernel/thread.cc index b17f29cad0..97de5b3afb 100644 --- a/repos/base-hw/src/core/spec/riscv/kernel/thread.cc +++ b/repos/base-hw/src/core/spec/riscv/kernel/thread.cc @@ -35,8 +35,8 @@ void Thread::exception(unsigned const cpu) _mmu_exception(); break; default: - PWRN("%s -> %s: unhandled exception %lu at ip=%lx addr=%lx", - pd_label(), label(), cpu_exception, ip, Cpu::sbadaddr()); + Genode::warning(*this, ": unhandled exception ", cpu_exception, + " at ip=", (void*)ip, " addr=", Cpu::sbadaddr()); _stop(); } } diff --git a/repos/base-hw/src/core/spec/x86_64/kernel/cpu_exception.cc b/repos/base-hw/src/core/spec/x86_64/kernel/cpu_exception.cc index f8475d6869..acc53f1cdb 100644 --- a/repos/base-hw/src/core/spec/x86_64/kernel/cpu_exception.cc +++ b/repos/base-hw/src/core/spec/x86_64/kernel/cpu_exception.cc @@ -24,7 +24,7 @@ void Kernel::Cpu_idle::exception(unsigned const cpu) return; } - PWRN("Unknown exception %lu with error code %lu at ip=%p", trapno, - errcode, (void *)ip); + Genode::warning("Unknown exception ", trapno, " with error code ", + errcode, " at ip=", (void *)ip); assert(0); } diff --git a/repos/base-hw/src/core/spec/x86_64/kernel/thread_exception.cc b/repos/base-hw/src/core/spec/x86_64/kernel/thread_exception.cc index 5a2c3e392c..57948caeaa 100644 --- a/repos/base-hw/src/core/spec/x86_64/kernel/thread_exception.cc +++ b/repos/base-hw/src/core/spec/x86_64/kernel/thread_exception.cc @@ -26,12 +26,11 @@ void Thread::exception(unsigned const cpu) return; case NO_MATH_COPROC: if (_cpu->fpu().fault(*this)) { return; } - PWRN("%s -> %s: FPU error", pd_label(), label()); + Genode::warning(*this, ": FPU error"); _stop(); return; case UNDEFINED_INSTRUCTION: - PWRN("%s -> %s: undefined instruction at ip=%p", - pd_label(), label(), (void*)ip); + Genode::warning(*this, ": undefined instruction at ip=", (void*)ip); _stop(); return; case SUPERVISOR_CALL: @@ -42,7 +41,7 @@ void Thread::exception(unsigned const cpu) _interrupt(cpu); return; } - PWRN("%s -> %s: triggered unknown exception %lu with error code %lu" - " at ip=%p", pd_label(), label(), trapno, errcode, (void*)ip); + Genode::warning(*this, ": triggered unknown exception ", trapno, + " with error code ", errcode, " at ip=%p", (void*)ip); _stop(); } diff --git a/repos/base-hw/src/core/spec/x86_64/muen/kernel/cpu_exception.cc b/repos/base-hw/src/core/spec/x86_64/muen/kernel/cpu_exception.cc index 809f760d5d..604b11022f 100644 --- a/repos/base-hw/src/core/spec/x86_64/muen/kernel/cpu_exception.cc +++ b/repos/base-hw/src/core/spec/x86_64/muen/kernel/cpu_exception.cc @@ -25,7 +25,7 @@ void Kernel::Cpu_idle::exception(unsigned const cpu) return; } - PWRN("Unknown exception %lu with error code %lu at ip=%p", trapno, - errcode, (void *)ip); + Genode::warning("Unknown exception ", trapno, " with error code ", errcode, + " at ip=", (void *)ip); assert(0); } diff --git a/repos/base-hw/src/core/spec/x86_64/muen/kernel/thread_exception.cc b/repos/base-hw/src/core/spec/x86_64/muen/kernel/thread_exception.cc index 8c4326e795..df20bd56b2 100644 --- a/repos/base-hw/src/core/spec/x86_64/muen/kernel/thread_exception.cc +++ b/repos/base-hw/src/core/spec/x86_64/muen/kernel/thread_exception.cc @@ -26,12 +26,11 @@ void Thread::exception(unsigned const cpu) return; case NO_MATH_COPROC: if (_cpu->fpu().fault(*this)) { return; } - PWRN("%s -> %s: FPU error", pd_label(), label()); + Genode::warning(*this, ": FPU error"); _stop(); return; case UNDEFINED_INSTRUCTION: - PWRN("%s -> %s: undefined instruction at ip=%p", - pd_label(), label(), (void*)ip); + Genode::warning(*this, ": undefined instruction at ip=", (void*)ip); _stop(); return; case SUPERVISOR_CALL: @@ -43,7 +42,7 @@ void Thread::exception(unsigned const cpu) _interrupt(cpu); return; } - PWRN("%s -> %s: triggered unknown exception %lu with error code %lu" - " at ip=%p", pd_label(), label(), trapno, errcode, (void*)ip); + Genode::warning(*this, ": triggered unknown exception ", trapno, + " with error code ", errcode, " at ip=%p", (void*)ip); _stop(); } diff --git a/repos/base-hw/src/core/spec/x86_64/muen/kernel/vm.cc b/repos/base-hw/src/core/spec/x86_64/muen/kernel/vm.cc index 7b1432f852..24beaba9db 100644 --- a/repos/base-hw/src/core/spec/x86_64/muen/kernel/vm.cc +++ b/repos/base-hw/src/core/spec/x86_64/muen/kernel/vm.cc @@ -50,8 +50,8 @@ void Kernel::Vm::exception(unsigned const cpu_id) _context->submit(1); return; } - PWRN("VM: triggered unknown exception %lu with error code %lu", - _state->trapno, _state->errcode); + Genode::warning("VM: triggered unknown exception ", _state->trapno, + " with error code ", _state->errcode); assert(false); } diff --git a/repos/base-hw/src/core/spec/x86_64/platform_support.cc b/repos/base-hw/src/core/spec/x86_64/platform_support.cc index b6fa5f4213..1815ccce07 100644 --- a/repos/base-hw/src/core/spec/x86_64/platform_support.cc +++ b/repos/base-hw/src/core/spec/x86_64/platform_support.cc @@ -81,7 +81,8 @@ Native_region * Platform::_ram_regions(unsigned const i) } _regions[i] = { base, size }; } else if (i >= max) - PWRN("physical ram region 0x%llx+0x%llx will be not used", base, size); + warning("physical ram region ", (void*)base, "+", (size_t)size, + " will be not used"); return i < max ? &_regions[i] : nullptr; } diff --git a/repos/base-hw/src/lib/base/riscv/kernel/interface.cc b/repos/base-hw/src/lib/base/riscv/kernel/interface.cc index 5eea576272..51e6eff9df 100644 --- a/repos/base-hw/src/lib/base/riscv/kernel/interface.cc +++ b/repos/base-hw/src/lib/base/riscv/kernel/interface.cc @@ -12,7 +12,6 @@ */ /* Genode includes */ -#include #include using namespace Kernel; diff --git a/repos/base-hw/src/lib/base/x86_64/kernel/interface.cc b/repos/base-hw/src/lib/base/x86_64/kernel/interface.cc index 99f968b858..a2780f815a 100644 --- a/repos/base-hw/src/lib/base/x86_64/kernel/interface.cc +++ b/repos/base-hw/src/lib/base/x86_64/kernel/interface.cc @@ -12,7 +12,6 @@ */ /* Genode includes */ -#include #include using namespace Kernel; diff --git a/repos/base-hw/src/test/cpu_quota/main.cc b/repos/base-hw/src/test/cpu_quota/main.cc index 753a8eb837..5e014f6e58 100644 --- a/repos/base-hw/src/test/cpu_quota/main.cc +++ b/repos/base-hw/src/test/cpu_quota/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -77,7 +77,7 @@ class Counter : private Thread_deprecated<2 * 1024 * sizeof(Genode::addr_t)> { private: - char const _name; + String<64> _name; unsigned long long volatile _value; Sync::Signal _sync_sig; unsigned volatile _stage; @@ -103,7 +103,7 @@ class Counter : private Thread_deprecated<2 * 1024 * sizeof(Genode::addr_t)> public: - Counter(char const name, size_t const weight, + Counter(char const *name, size_t const weight, Sync::Session * const sync) : Thread_deprecated(weight, "counter"), _name(name), _value(0) , @@ -123,7 +123,7 @@ class Counter : private Thread_deprecated<2 * 1024 * sizeof(Genode::addr_t)> void go() { _stage_1_end.submit(); } - void result() { printf("counter %c %llu\n", _name, _value); } + void result() { log("counter ", _name, " ", _value); } }; @@ -145,8 +145,8 @@ int main() Timer::Connection timer; Sync::Connection sync; Sync::Signal sync_sig(&sync, SYNC_SIG); - Counter counter_a('A', Cpu_session::quota_lim_upscale(10, 100), &sync); - Counter counter_b('B', Cpu_session::quota_lim_upscale(90, 100), &sync); + Counter counter_a("A", Cpu_session::quota_lim_upscale(10, 100), &sync); + Counter counter_b("B", Cpu_session::quota_lim_upscale(90, 100), &sync); timer.sigh(timer_sig); @@ -168,10 +168,10 @@ int main() sync_sig.threshold(3); sync_sig.sync(); Cpu_session::Quota quota = Genode::env()->cpu_session()->quota(); - Genode::printf("quota super period %lu\n", quota.super_period_us); - Genode::printf("quota %lu\n", quota.us); + log("quota super period ", quota.super_period_us); + log("quota ", quota.us); counter_a.result(); counter_b.result(); - printf("done\n"); + log("done"); sleep_forever(); } diff --git a/repos/base-linux/src/core/core_log.cc b/repos/base-linux/src/core/core_log.cc new file mode 100644 index 0000000000..1f63552f4c --- /dev/null +++ b/repos/base-linux/src/core/core_log.cc @@ -0,0 +1,20 @@ +/* + * \brief Kernel-specific core's 'log' backend + * \author Stefan Kalkowski + * \date 2016-10-10 + */ + +/* + * Copyright (C) 2016 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include + +/* Linux syscall bindings */ +#include + +void Genode::Core_log::out(char const c) { lx_write(1, &c, sizeof(c)); } diff --git a/repos/base-linux/src/core/include/core_env.h b/repos/base-linux/src/core/include/core_env.h index e5bf0b0903..b6073b12c1 100644 --- a/repos/base-linux/src/core/include/core_env.h +++ b/repos/base-linux/src/core/include/core_env.h @@ -207,7 +207,7 @@ namespace Genode { Cpu_session_capability cpu_session_cap() override { - PWRN("%s:%u not implemented", __FILE__, __LINE__); + warning(__FILE__, ":", __LINE__, " not implemented"); return Cpu_session_capability(); } }; diff --git a/repos/base-linux/src/core/include/dataspace_component.h b/repos/base-linux/src/core/include/dataspace_component.h index 3ca5e4b39f..1a62120185 100644 --- a/repos/base-linux/src/core/include/dataspace_component.h +++ b/repos/base-linux/src/core/include/dataspace_component.h @@ -23,7 +23,6 @@ #include #include #include -#include /* base-internal includes */ #include @@ -79,7 +78,7 @@ namespace Genode { : _size(size), _addr(phys_addr), _fd(-1), _owner(_owner) { - PWRN("Should only be used for IOMEM and not within Linux."); + warning("Should only be used for IOMEM and not within Linux."); _fname.buf[0] = 0; } diff --git a/repos/base-linux/src/core/include/io_mem_session_component.h b/repos/base-linux/src/core/include/io_mem_session_component.h index 95d9085baa..e86e1e8425 100644 --- a/repos/base-linux/src/core/include/io_mem_session_component.h +++ b/repos/base-linux/src/core/include/io_mem_session_component.h @@ -16,7 +16,6 @@ /* Genode includes */ #include -#include #include #include diff --git a/repos/base-linux/src/core/io_mem_session_component.cc b/repos/base-linux/src/core/io_mem_session_component.cc index 6b2541f050..40cca18391 100644 --- a/repos/base-linux/src/core/io_mem_session_component.cc +++ b/repos/base-linux/src/core/io_mem_session_component.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include @@ -21,7 +21,5 @@ using namespace Genode; Io_mem_session_component::Io_mem_session_component(Range_allocator *io_mem_alloc, Range_allocator *ram_alloc, Rpc_entrypoint *ds_ep, - const char *args) -{ - PWRN("no io_mem support on Linux (args=\"%s\")", args); -} + const char *args) { + warning("no io_mem support on Linux (args=\"", args, "\")"); } diff --git a/repos/base-linux/src/core/stack_area.cc b/repos/base-linux/src/core/stack_area.cc index 6bba507a01..07d5815416 100644 --- a/repos/base-linux/src/core/stack_area.cc +++ b/repos/base-linux/src/core/stack_area.cc @@ -14,7 +14,6 @@ /* Genode includes */ #include #include -#include #include /* base-internal includes */ @@ -64,8 +63,11 @@ class Stack_area_region_map : public Genode::Region_map return local_addr; } - void detach(Local_addr local_addr) { - PWRN("stack area detach from 0x%p - not implemented", (void *)local_addr); } + void detach(Local_addr local_addr) + { + Genode::warning("stack area detach from ", (void*)local_addr, + " - not implemented"); + } void fault_handler(Genode::Signal_context_capability) { } diff --git a/repos/base-linux/src/core/target.mk b/repos/base-linux/src/core/target.mk index a36f6d821c..88097b79d7 100644 --- a/repos/base-linux/src/core/target.mk +++ b/repos/base-linux/src/core/target.mk @@ -27,7 +27,7 @@ SRC_CC = main.cc \ trace_session_component.cc \ thread_linux.cc \ stack_area.cc \ - core_printf.cc \ + core_log.cc \ default_log.cc \ env_reinit.cc \ thread.cc thread_myself.cc @@ -55,7 +55,6 @@ vpath signal_source_component.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) -vpath core_printf.cc $(BASE_DIR)/src/lib/base vpath thread.cc $(BASE_DIR)/src/lib/base vpath thread_myself.cc $(BASE_DIR)/src/lib/base vpath trace.cc $(BASE_DIR)/src/lib/base diff --git a/repos/base-linux/src/include/base/internal/core_console.h b/repos/base-linux/src/include/base/internal/core_console.h deleted file mode 100644 index 9ce049c6bd..0000000000 --- a/repos/base-linux/src/include/base/internal/core_console.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * \brief Printf backend using Linux stdout - * \author Norman Feske - * \date 2006-04-08 - * - * This console back-end should only be used by core. - */ - -/* - * Copyright (C) 2006-2013 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -#ifndef _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ -#define _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ - -/* Genode includes */ -#include - -/* Linux syscall bindings */ -#include - -namespace Genode { - - class Core_console : public Console - { - protected: - - void _out_char(char c) { lx_write(1, &c, sizeof(c)); } - }; -} - -#endif /* _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ */ diff --git a/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc b/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc index b6d89f5882..a97645269b 100644 --- a/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc +++ b/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc @@ -109,7 +109,6 @@ void Genode::call_global_static_constructors() { } int main() { - Genode::init_log(); Genode::bootstrap_component(); /* never reached */ diff --git a/repos/base-linux/src/test/lx_hybrid_ctors/main.cc b/repos/base-linux/src/test/lx_hybrid_ctors/main.cc index 972c22d10e..09ef897225 100644 --- a/repos/base-linux/src/test/lx_hybrid_ctors/main.cc +++ b/repos/base-linux/src/test/lx_hybrid_ctors/main.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include /* local includes */ #include "testlib.h" @@ -28,7 +28,7 @@ struct Testapp_testclass { Testapp_testclass() { - Genode::printf("Global static constructor of Genode application called\n"); + Genode::log("Global static constructor of Genode application called"); } void dummy() { } @@ -52,7 +52,7 @@ Genode::size_t Component::stack_size() { return 16*1024*sizeof(long); } */ void Component::construct(Genode::Env &env) { - printf("--- lx_hybrid global static constructor test ---\n"); + log("--- lx_hybrid global static constructor test ---"); /* * Call a dummy function on each test object to make sure that the @@ -61,7 +61,7 @@ void Component::construct(Genode::Env &env) testlib_testobject.dummy(); testapp_testobject.dummy(); - printf("--- returning from main ---\n"); + log("--- returning from main ---"); exit_status = 0; env.ep().schedule_suspend(exit_on_suspended, nullptr); } diff --git a/repos/base-linux/src/test/lx_hybrid_exception/main.cc b/repos/base-linux/src/test/lx_hybrid_exception/main.cc index 2b878cb227..9a955dcb8c 100644 --- a/repos/base-linux/src/test/lx_hybrid_exception/main.cc +++ b/repos/base-linux/src/test/lx_hybrid_exception/main.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include /* Linux includes */ #include @@ -35,16 +35,16 @@ Genode::size_t Component::stack_size() { return 16*1024*sizeof(long); } */ void Component::construct(Genode::Env &env) { - printf("--- lx_hybrid exception test ---\n"); + log("--- lx_hybrid exception test ---"); try { - printf("Throwing Test_exception\n"); + log("Throwing Test_exception"); throw Test_exception(); } catch (Test_exception) { - printf("Caught Test_exception\n"); + log("Caught Test_exception"); } - printf("--- returning from main ---\n"); + log("--- returning from main ---"); exit_status = 0; env.ep().schedule_suspend(exit_on_suspended, nullptr); } diff --git a/repos/base-nova/src/core/core_log.cc b/repos/base-nova/src/core/core_log.cc new file mode 100644 index 0000000000..e46d692768 --- /dev/null +++ b/repos/base-nova/src/core/core_log.cc @@ -0,0 +1,30 @@ +/* + * \brief Kernel-specific core's 'log' backend + * \author Stefan Kalkowski + * \date 2016-10-10 + */ + +/* + * Copyright (C) 2016 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include + +/* Genode includes */ +#include +#include + +void Genode::Core_log::out(char const c) +{ + enum { CLOCK = 0, BAUDRATE = 115200 }; + + static X86_uart_base uart(Bios_data_area::singleton()->serial_port(), + CLOCK, BAUDRATE); + if (c == '\n') + uart.put_char('\r'); + uart.put_char(c); +} diff --git a/repos/base-nova/src/core/include/ipc_pager.h b/repos/base-nova/src/core/include/ipc_pager.h index b7d0e6eae1..a810ac7e97 100644 --- a/repos/base-nova/src/core/include/ipc_pager.h +++ b/repos/base-nova/src/core/include/ipc_pager.h @@ -18,7 +18,6 @@ #include #include #include -#include /* NOVA includes */ #include diff --git a/repos/base-nova/src/core/include/map_local.h b/repos/base-nova/src/core/include/map_local.h index 7019581015..393cccbb97 100644 --- a/repos/base-nova/src/core/include/map_local.h +++ b/repos/base-nova/src/core/include/map_local.h @@ -15,7 +15,6 @@ #define _CORE__INCLUDE__MAP_LOCAL_H_ /* Genode includes */ -#include #include /* core includes */ diff --git a/repos/base-nova/src/core/include/rpc_cap_factory.h b/repos/base-nova/src/core/include/rpc_cap_factory.h index 189c82fc31..62cc3282be 100644 --- a/repos/base-nova/src/core/include/rpc_cap_factory.h +++ b/repos/base-nova/src/core/include/rpc_cap_factory.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include namespace Genode { class Rpc_cap_factory; } @@ -56,7 +56,7 @@ class Genode::Rpc_cap_factory Native_capability alloc(Native_capability) { - PWRN("unexpected call to non-implemented Rpc_cap_factory::alloc"); + warning("unexpected call to non-implemented Rpc_cap_factory::alloc"); return Native_capability(); } diff --git a/repos/base-nova/src/core/include/signal_broker.h b/repos/base-nova/src/core/include/signal_broker.h index 72fce06e74..6ea1f9d81d 100644 --- a/repos/base-nova/src/core/include/signal_broker.h +++ b/repos/base-nova/src/core/include/signal_broker.h @@ -83,7 +83,7 @@ class Genode::Signal_broker Native_capability sm = _source.blocking_semaphore(); if (!sm.valid()) { - PWRN("signal receiver sm is not valid"); + warning("signal receiver sm is not valid"); for (;;); return Signal_context_capability(); } @@ -94,7 +94,7 @@ class Genode::Signal_broker uint8_t res = Nova::create_si(cap.local_name(), __core_pd_sel, imprint, sm.local_name()); if (res != Nova::NOVA_OK) { - PWRN("creating signal failed - error %u", res); + warning("creating signal failed - error ", res); return Signal_context_capability(); } @@ -115,8 +115,8 @@ class Genode::Signal_broker _obj_pool.apply(context_cap, lambda); if (!context) { - PWRN("%p - specified signal-context capability has wrong type %lx", - this, context_cap.local_name()); + warning(this, " - specified signal-context capability has wrong type ", + Hex(context_cap.local_name())); return; } destroy(&_contexts_slab, context); diff --git a/repos/base-nova/src/core/include/util.h b/repos/base-nova/src/core/include/util.h index f7b903f693..ea083b2696 100644 --- a/repos/base-nova/src/core/include/util.h +++ b/repos/base-nova/src/core/include/util.h @@ -16,7 +16,7 @@ /* Genode includes */ #include -#include +#include /* base-internal includes */ #include @@ -51,19 +51,6 @@ namespace Genode { log(" ", __builtin_return_address(3)); log(" ", __builtin_return_address(4)); } - - - inline void hexdump(void *addr) - { - unsigned char *s = (unsigned char *)addr; - printf("\nhexdump at 0x%p:\n", addr); - for (unsigned j = 0; j < 4; j++) { - printf(" "); - for (unsigned i = 0; i < 16; i++) - printf("0x%02x ", s[j*16 + i]); - printf("\n"); - } - } } #endif /* _CORE__INCLUDE__UTIL_H_ */ diff --git a/repos/base-nova/src/core/target.inc b/repos/base-nova/src/core/target.inc index 271937c3b0..f78f3c2cad 100644 --- a/repos/base-nova/src/core/target.inc +++ b/repos/base-nova/src/core/target.inc @@ -5,7 +5,7 @@ GEN_CORE_DIR = $(BASE_DIR)/src/core SRC_CC = stack_area.cc \ core_mem_alloc.cc \ - core_printf.cc \ + core_log.cc \ core_region_map.cc \ core_rpc_cap_alloc.cc \ cpu_session_component.cc \ @@ -69,5 +69,4 @@ vpath default_log.cc $(GEN_CORE_DIR) vpath dump_alloc.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-nova/src/include/base/internal/core_console.h b/repos/base-nova/src/include/base/internal/core_console.h deleted file mode 100644 index 096d93ee78..0000000000 --- a/repos/base-nova/src/include/base/internal/core_console.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * \brief Console backend for NOVA - * \author Norman Feske - * \author Alexander Boettcher - * \date 2009-12-28 - */ - -/* - * Copyright (C) 2009-2015 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -#ifndef _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ -#define _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ - -/* Genode includes */ -#include -#include -#include - -namespace Genode { class Core_console; } - -class Genode::Core_console : public X86_uart_base, public Console -{ - private: - - enum { CLOCK = 0, BAUDRATE = 115200 }; - - void _out_char(char c) - { - if (c == '\n') - put_char('\r'); - - put_char(c); - } - - public: - - Core_console() - : - X86_uart_base(Bios_data_area::singleton()->serial_port(), - CLOCK, BAUDRATE) - { } -}; - -#endif /* _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ */ diff --git a/repos/base-okl4/src/core/core_log.cc b/repos/base-okl4/src/core/core_log.cc new file mode 100644 index 0000000000..de4dc84621 --- /dev/null +++ b/repos/base-okl4/src/core/core_log.cc @@ -0,0 +1,21 @@ +/* + * \brief Kernel-specific core's 'log' backend + * \author Stefan Kalkowski + * \date 2016-10-10 + */ + +/* + * Copyright (C) 2016 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include + +namespace Okl4 { extern "C" { +#include +}; } + +void Genode::Core_log::out(char const c) { Okl4::L4_KDB_PrintChar(c); } diff --git a/repos/base-okl4/src/core/region_map_support.cc b/repos/base-okl4/src/core/region_map_support.cc index 948dfd80a7..79a52b62b1 100644 --- a/repos/base-okl4/src/core/region_map_support.cc +++ b/repos/base-okl4/src/core/region_map_support.cc @@ -11,9 +11,6 @@ * under the terms of the GNU General Public License version 2. */ -/* Genode includes */ -#include - /* core includes */ #include diff --git a/repos/base-okl4/src/core/target.inc b/repos/base-okl4/src/core/target.inc index df81d3e48d..0309e91439 100644 --- a/repos/base-okl4/src/core/target.inc +++ b/repos/base-okl4/src/core/target.inc @@ -6,7 +6,7 @@ GEN_CORE_DIR = $(BASE_DIR)/src/core SRC_CC += stack_area.cc \ core_mem_alloc.cc \ - core_printf.cc \ + core_log.cc \ core_region_map.cc \ core_rpc_cap_alloc.cc \ cpu_session_component.cc \ @@ -69,5 +69,3 @@ vpath default_log.cc $(GEN_CORE_DIR) vpath stack_area.cc $(GEN_CORE_DIR) vpath pager_ep.cc $(GEN_CORE_DIR) vpath %.cc $(REP_DIR)/src/core -vpath core_printf.cc $(BASE_DIR)/src/lib/base - diff --git a/repos/base-okl4/src/include/base/internal/core_console.h b/repos/base-okl4/src/include/base/internal/core_console.h deleted file mode 100644 index 166840e206..0000000000 --- a/repos/base-okl4/src/include/base/internal/core_console.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * \brief Console backend for OKL4 - * \author Norman Feske - * \date 2009-03-25 - */ - -/* - * Copyright (C) 2009-2013 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -#ifndef _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ -#define _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ - -namespace Okl4 { extern "C" { -#include -} } - -#include - - -namespace Genode -{ - class Core_console : public Console - { - protected: - - void _out_char(char c) { Okl4::L4_KDB_PrintChar(c); } - }; -} - -#endif /* _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ */ diff --git a/repos/base-pistachio/src/core/core_log.cc b/repos/base-pistachio/src/core/core_log.cc new file mode 100644 index 0000000000..fc4ac8fbe0 --- /dev/null +++ b/repos/base-pistachio/src/core/core_log.cc @@ -0,0 +1,22 @@ +/* + * \brief Kernel-specific core's 'log' backend + * \author Stefan Kalkowski + * \date 2016-10-10 + */ + +/* + * Copyright (C) 2016 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include + +/* Pistachio includes */ +namespace Pistachio { +#include +} + +void Genode::Core_log::out(char const c) { Pistachio::L4_KDB_PrintChar(c); } diff --git a/repos/base-pistachio/src/core/include/map_local.h b/repos/base-pistachio/src/core/include/map_local.h index 086233be5d..326e155287 100644 --- a/repos/base-pistachio/src/core/include/map_local.h +++ b/repos/base-pistachio/src/core/include/map_local.h @@ -70,8 +70,8 @@ namespace Genode { L4_MsgTag_t result = L4_Call(core_pager); if (L4_IpcFailed(result)) { - PWRN("could not locally remap 0x%lx to 0x%lx, error code is %ld", - from_addr, to_addr, L4_ErrorCode()); + warning("could not locally remap ", (void*)from_addr, " to ", + (void*)to_addr, ", error code is ", L4_ErrorCode()); return false; } } diff --git a/repos/base-pistachio/src/core/region_map_support.cc b/repos/base-pistachio/src/core/region_map_support.cc index ab15abac16..3949c0976f 100644 --- a/repos/base-pistachio/src/core/region_map_support.cc +++ b/repos/base-pistachio/src/core/region_map_support.cc @@ -22,9 +22,6 @@ namespace Pistachio { using namespace Genode; -static const bool verbose_unmap = false; - - void Rm_client::unmap(addr_t core_local_base, addr_t virt_base, size_t size) { /* @@ -38,10 +35,6 @@ void Rm_client::unmap(addr_t core_local_base, addr_t virt_base, size_t size) L4_Word_t page_size = get_page_size(); - if (verbose_unmap) - printf("RM client %p (%lx) unmap core-local [%lx,%lx)\n", - this, badge(), core_local_base, core_local_base + size); - addr_t addr = core_local_base; for (; addr < core_local_base + size; addr += page_size) { L4_Fpage_t fp = L4_Fpage(addr, page_size); diff --git a/repos/base-pistachio/src/core/target.inc b/repos/base-pistachio/src/core/target.inc index 91bd4edc8d..ed4ddb64bf 100644 --- a/repos/base-pistachio/src/core/target.inc +++ b/repos/base-pistachio/src/core/target.inc @@ -5,7 +5,7 @@ LIBS = base-common GEN_CORE_DIR = $(BASE_DIR)/src/core SRC_CC = stack_area.cc \ - core_printf.cc \ + core_log.cc \ core_rpc_cap_alloc.cc \ core_region_map.cc \ cpu_session_component.cc \ @@ -69,5 +69,4 @@ vpath core_rpc_cap_alloc.cc $(GEN_CORE_DIR) vpath core_region_map.cc $(GEN_CORE_DIR) vpath stack_area.cc $(GEN_CORE_DIR) vpath pager_ep.cc $(GEN_CORE_DIR) -vpath core_printf.cc $(BASE_DIR)/src/lib/base vpath %.cc $(REP_DIR)/src/core diff --git a/repos/base-pistachio/src/include/base/internal/core_console.h b/repos/base-pistachio/src/include/base/internal/core_console.h deleted file mode 100644 index cfd6af8ca0..0000000000 --- a/repos/base-pistachio/src/include/base/internal/core_console.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * \brief Console backend for Pistachio - * \author Julian Stecklina - * \date 2008-08-20 - */ - -/* - * Copyright (C) 2008-2013 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -#ifndef _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ -#define _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ - -/* Pistachio includes */ -namespace Pistachio { -#include -} - -/* Genode includes */ -#include - -namespace Genode -{ - class Core_console : public Console - { - protected: - - void _out_char(char c) { Pistachio::L4_KDB_PrintChar(c); } - }; -} - -#endif /* _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ */ diff --git a/repos/base-sel4/lib/mk/core.mk b/repos/base-sel4/lib/mk/core.mk index 0113717390..00cad504dc 100644 --- a/repos/base-sel4/lib/mk/core.mk +++ b/repos/base-sel4/lib/mk/core.mk @@ -37,7 +37,7 @@ SRC_CC += \ capability_space.cc \ pager.cc -LIBS += core_printf base-common syscall +LIBS += core_log base-common syscall INC_DIR += $(REP_DIR)/src/core/include $(GEN_CORE_DIR)/include \ $(REP_DIR)/src/include $(BASE_DIR)/src/include diff --git a/repos/base-sel4/lib/mk/core_log.mk b/repos/base-sel4/lib/mk/core_log.mk new file mode 100644 index 0000000000..3bfb458da7 --- /dev/null +++ b/repos/base-sel4/lib/mk/core_log.mk @@ -0,0 +1,6 @@ +SRC_CC = core_log.cc default_log.cc +INC_DIR += $(REP_DIR)/src/include $(BASE_DIR)/src/include $(BASE_DIR)/src/core/include +LIBS += syscall + +vpath core_log.cc $(REP_DIR)/src/core +vpath default_log.cc $(BASE_DIR)/src/core diff --git a/repos/base-sel4/lib/mk/core_printf.mk b/repos/base-sel4/lib/mk/core_printf.mk deleted file mode 100644 index c34a6f380e..0000000000 --- a/repos/base-sel4/lib/mk/core_printf.mk +++ /dev/null @@ -1,6 +0,0 @@ -SRC_CC = core_printf.cc default_log.cc -INC_DIR += $(REP_DIR)/src/include $(BASE_DIR)/src/include -LIBS += syscall - -vpath core_printf.cc $(BASE_DIR)/src/lib/base -vpath default_log.cc $(BASE_DIR)/src/core diff --git a/repos/base-sel4/src/core/capability_space.cc b/repos/base-sel4/src/core/capability_space.cc index 9bf930e41b..edfbbfd589 100644 --- a/repos/base-sel4/src/core/capability_space.cc +++ b/repos/base-sel4/src/core/capability_space.cc @@ -13,7 +13,6 @@ /* base includes */ #include -#include /* base-internal includes */ #include diff --git a/repos/base-sel4/src/core/core_log.cc b/repos/base-sel4/src/core/core_log.cc new file mode 100644 index 0000000000..6154fbf01e --- /dev/null +++ b/repos/base-sel4/src/core/core_log.cc @@ -0,0 +1,21 @@ +/* + * \brief Kernel-specific core's 'log' backend + * \author Stefan Kalkowski + * \date 2016-10-10 + */ + +/* + * Copyright (C) 2016 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include + +/* seL4 includes */ +#include +#include + +void Genode::Core_log::out(char const c) { seL4_DebugPutChar(c); } diff --git a/repos/base-sel4/src/core/include/cnode.h b/repos/base-sel4/src/core/include/cnode.h index 9646637903..2ea53a6240 100644 --- a/repos/base-sel4/src/core/include/cnode.h +++ b/repos/base-sel4/src/core/include/cnode.h @@ -59,8 +59,8 @@ class Genode::Cnode_base int const ret = seL4_CNode_Copy(service, dest_index, dest_depth, src_root, src_index, src_depth, rights); if (ret != 0) { - PWRN("%s: seL4_CNode_Copy (0x%lx) returned %d", __FUNCTION__, - from_idx.value(), ret); + warning(__FUNCTION__, ": seL4_CNode_Copy (", + (void*)from_idx.value(), ") returned ", ret); } } @@ -112,8 +112,8 @@ class Genode::Cnode_base int const ret = seL4_CNode_Move(service, dest_index, dest_depth, src_root, src_index, src_depth); if (ret != 0) { - PWRN("%s: seL4_CNode_Move (0x%lx) returned %d", __FUNCTION__, - from_idx.value(), ret); + warning(__FUNCTION__, ": seL4_CNode_Move (", + (void*)from_idx.value(), ") returned ", ret); } } diff --git a/repos/base-sel4/src/core/include/map_local.h b/repos/base-sel4/src/core/include/map_local.h index 912ec2dab6..268aa60424 100644 --- a/repos/base-sel4/src/core/include/map_local.h +++ b/repos/base-sel4/src/core/include/map_local.h @@ -14,9 +14,6 @@ #ifndef _CORE__INCLUDE__MAP_LOCAL_H_ #define _CORE__INCLUDE__MAP_LOCAL_H_ -/* Genode includes */ -#include - /* core includes */ #include #include diff --git a/repos/base-sel4/src/core/include/platform.h b/repos/base-sel4/src/core/include/platform.h index 66707de537..c316f16ad6 100644 --- a/repos/base-sel4/src/core/include/platform.h +++ b/repos/base-sel4/src/core/include/platform.h @@ -14,9 +14,6 @@ #ifndef _CORE__INCLUDE__PLATFORM_H_ #define _CORE__INCLUDE__PLATFORM_H_ -/* Genode includes */ -#include - /* local includes */ #include #include diff --git a/repos/base-sel4/src/core/include/thread_sel4.h b/repos/base-sel4/src/core/include/thread_sel4.h index ebfe541767..548d736393 100644 --- a/repos/base-sel4/src/core/include/thread_sel4.h +++ b/repos/base-sel4/src/core/include/thread_sel4.h @@ -17,9 +17,6 @@ #ifndef _CORE__INCLUDE__THREAD_SEL4_H_ #define _CORE__INCLUDE__THREAD_SEL4_H_ -/* Genode includes */ -#include - /* base-internal includes */ #include diff --git a/repos/base-sel4/src/core/include/util.h b/repos/base-sel4/src/core/include/util.h index b9259b8849..da5a78dbcc 100644 --- a/repos/base-sel4/src/core/include/util.h +++ b/repos/base-sel4/src/core/include/util.h @@ -14,10 +14,6 @@ #ifndef _CORE__INCLUDE__UTIL_H_ #define _CORE__INCLUDE__UTIL_H_ -/* Genode includes */ -#include -#include - /* base-internal includes */ #include diff --git a/repos/base-sel4/src/core/rpc_cap_factory.cc b/repos/base-sel4/src/core/rpc_cap_factory.cc index 67fb611c61..493ed9dffe 100644 --- a/repos/base-sel4/src/core/rpc_cap_factory.cc +++ b/repos/base-sel4/src/core/rpc_cap_factory.cc @@ -33,7 +33,7 @@ Native_capability Rpc_cap_factory::_alloc(Rpc_cap_factory *owner, Native_capability ep) { if (!ep.valid()) { - PWRN("Invalid entrypoint capability"); + warning("Invalid entrypoint capability"); return Native_capability(); } diff --git a/repos/base-sel4/src/include/base/internal/core_console.h b/repos/base-sel4/src/include/base/internal/core_console.h deleted file mode 100644 index 88c314c2e1..0000000000 --- a/repos/base-sel4/src/include/base/internal/core_console.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * \brief Console backend for seL4 - * \author Norman Feske - * \date 2014-10-14 - */ - -/* - * Copyright (C) 2014 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -#ifndef _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ -#define _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ - -/* Genode includes */ -#include - -/* seL4 includes */ -#include -#include - -namespace Genode { class Core_console; } - - -class Genode::Core_console : public Console -{ - protected: - - void _out_char(char c) - { - seL4_DebugPutChar(c); - } -}; - -#endif /* _INCLUDE__BASE__INTERNAL__CORE_CONSOLE_H_ */ diff --git a/repos/base-sel4/src/lib/base/capability_space.cc b/repos/base-sel4/src/lib/base/capability_space.cc index 86444373f6..5df7303197 100644 --- a/repos/base-sel4/src/lib/base/capability_space.cc +++ b/repos/base-sel4/src/lib/base/capability_space.cc @@ -13,7 +13,7 @@ /* base includes */ #include -#include +#include #include /* base-internal includes */ @@ -156,7 +156,7 @@ void Capability_space::reset_sel(unsigned sel) { int ret = seL4_CNode_Delete(INITIAL_SEL_CNODE, sel, CSPACE_SIZE_LOG2); if (ret != 0) - PWRN("seL4_CNode_Delete returned %d", ret); + warning("seL4_CNode_Delete returned ", ret); } diff --git a/repos/base/include/util/mmio.h b/repos/base/include/util/mmio.h index c82d686d37..9a83846e35 100644 --- a/repos/base/include/util/mmio.h +++ b/repos/base/include/util/mmio.h @@ -30,32 +30,6 @@ namespace Genode { class Mmio; } */ class Genode::Mmio { - /* - * If set 0 verbosity isn't needed at all and the enum enables the - * compiler to remove all verbosity code. If set 1 verbosity code - * gets compiled and is then switched via '*_verbose' member variables. - */ - enum { VERBOSITY_AVAILABLE = 0 }; - - /** - * Proclaim a MMIO access - * - * \param _ACCESS_T integer type of access - * \param dst access destination - * \param v access value - * \param w 1: write access 0: read access - */ - template - inline void _access_verbosity(addr_t const dst, _ACCESS_T const v, - bool const w) const - { - if (!VERBOSITY_AVAILABLE) return; - if ((w && !_write_verbose) || (!w && !_read_verbose)) return; - printf("mmio %s 0x%p: 0x", w ? "write" : "read ", (void *)dst); - Trait::Uint_type<_ACCESS_T>::print_hex(v); - printf("\n"); - } - /** * Write '_ACCESS_T' typed 'value' to MMIO base + 'o' */ @@ -63,7 +37,6 @@ class Genode::Mmio inline void _write(off_t const o, _ACCESS_T const value) { addr_t const dst = (addr_t)base + o; - _access_verbosity<_ACCESS_T>(dst, value, 1); *(_ACCESS_T volatile *)dst = value; } @@ -75,23 +48,9 @@ class Genode::Mmio { addr_t const dst = (addr_t)base + o; _ACCESS_T const value = *(_ACCESS_T volatile *)dst; - _access_verbosity<_ACCESS_T>(dst, value, 0); return value; } - protected: - - /* - * If VERBOSITY_AVAILABLE is set MMIO isn't verbose by default. - * Instead it causes this switches to be asked everytime MMIO - * could be verbose. This way the user can either enable verbosity - * locally by overwriting them in a deriving class or change their - * initialization temporarily to enable verbosity globally and - * then supress it locally by overwriting it. - */ - bool _write_verbose; - bool _read_verbose; - public: enum { BYTE_WIDTH_LOG2 = 3, BYTE_WIDTH = 1 << BYTE_WIDTH_LOG2 }; @@ -287,8 +246,7 @@ class Genode::Mmio * * \param mmio_base base address of targeted MMIO region */ - inline Mmio(addr_t mmio_base) - : _write_verbose(0), _read_verbose(0), base(mmio_base) { } + inline Mmio(addr_t mmio_base) : base(mmio_base) { } /************************* diff --git a/repos/base/include/util/register.h b/repos/base/include/util/register.h index 9bceb591c8..64f228a70f 100644 --- a/repos/base/include/util/register.h +++ b/repos/base/include/util/register.h @@ -16,7 +16,6 @@ /* Genode includes */ #include -#include namespace Genode { @@ -55,45 +54,30 @@ namespace Genode { namespace Trait { * Access widths wich are dividers to the compound type width */ template struct Divisor; - - static inline void print_hex(bool const v) { - printf("%01x", v); } }; template <> struct Uint_width<8> : Uint_width<1> { typedef uint8_t Type; enum { WIDTH_LOG2 = 3 }; - - static inline void print_hex(uint8_t const v) { - printf("%02x", v); } }; template <> struct Uint_width<16> : Uint_width<8> { typedef uint16_t Type; enum { WIDTH_LOG2 = 4 }; - - static inline void print_hex(uint16_t const v) { - printf("%04x", v); } }; template <> struct Uint_width<32> : Uint_width<16> { typedef uint32_t Type; enum { WIDTH_LOG2 = 5 }; - - static inline void print_hex (uint32_t const v) { - printf("%08x", v); } }; template <> struct Uint_width<64> : Uint_width<32> { typedef uint64_t Type; enum { WIDTH_LOG2 = 6 }; - - static inline void print_hex(uint64_t const v) { - printf("%016llx", v); } }; template <> struct Uint_width<1>::Divisor<1> { enum { WIDTH_LOG2 = 0 }; }; diff --git a/repos/base/run/log.run b/repos/base/run/log.run new file mode 100644 index 0000000000..611820ce8a --- /dev/null +++ b/repos/base/run/log.run @@ -0,0 +1,36 @@ +build "core init test/log" + +create_boot_directory + +install_config { + + + + + + + + + + + + +} + +build_boot_image "core init test-log" + +append qemu_args "-nographic -m 64" + +run_genode_until "Test done.*\n" 10 + +grep_output {\[init -\> test-log\]} + +compare_output_to { +[init -> test-log] hex range: [0e00,1680) +[init -> test-log] empty hex range: [0abc0000,0abc0000) (empty!) +[init -> test-log] hex range to limit: [f8,ff] +[init -> test-log] invalid hex range: [f8,08) (overflow!) +[init -> test-log] negative hex char: 0xfe +[init -> test-log] positive hex char: 0x02 +[init -> test-log] Test done. +} diff --git a/repos/base/run/printf.run b/repos/base/run/printf.run deleted file mode 100644 index 032d3f2a66..0000000000 --- a/repos/base/run/printf.run +++ /dev/null @@ -1,26 +0,0 @@ -build "core init test/printf" - -create_boot_directory - -install_config { - - - - - - - - - - - - -} - -build_boot_image "core init test-printf" - -append qemu_args "-nographic -m 64" - -run_genode_until {-1 = -1 = -1} 10 - -puts "Test succeeded" diff --git a/repos/base/src/core/default_log.cc b/repos/base/src/core/default_log.cc index 26f5ad22a8..7e0f37d6f2 100644 --- a/repos/base/src/core/default_log.cc +++ b/repos/base/src/core/default_log.cc @@ -1,6 +1,7 @@ /* * \brief Access to the core's log facility * \author Norman Feske + * \author Stefan Kalkowski * \date 2016-05-03 */ @@ -13,15 +14,17 @@ /* Genode includes */ #include -#include +#include /* base-internal includes */ #include #include #include -using namespace Genode; +/* core includes */ +#include +using namespace Genode; static Log *log_ptr; @@ -32,14 +35,19 @@ Log &Log::log() { return *log_ptr; } void Genode::init_log() { /* ignore subsequent calls */ - if (log_ptr) - return; + if (log_ptr) return; - /* - * Currently, we still rely on the old format-string support and - * produce output via 'core_printf.cc'. - */ - struct Write_fn { void operator () (char const *s) { printf("%s", s); } }; + struct Write_fn + { + Lock lock; + Core_log log; + + void operator () (char const *s) + { + Lock::Guard guard(lock); + log.output(s); + } + }; typedef Buffered_output<512, Write_fn> Buffered_log_output; @@ -48,4 +56,3 @@ void Genode::init_log() log_ptr = unmanaged_singleton(*buffered_log_output); } - diff --git a/repos/base/src/core/dump_alloc.cc b/repos/base/src/core/dump_alloc.cc index 66a17d4331..73ee2685f4 100644 --- a/repos/base/src/core/dump_alloc.cc +++ b/repos/base/src/core/dump_alloc.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include using namespace Genode; @@ -19,8 +19,9 @@ using namespace Genode; void Allocator_avl_base::Block::dump() { - printf(" Block: [%08lx,%08lx) size=%08lx avail=%08lx max_avail=%08lx\n", - addr(), addr() + size(), size(), avail(), max_avail()); + log(" Block: [", Hex(addr()), ",", Hex(addr() + size()), "] ", + "size=", Hex(size()), " avail=", Hex(avail()), " ", + "max_avail=", Hex(max_avail())); } @@ -33,7 +34,7 @@ void Allocator_avl_base::dump_addr_tree(Block *addr_node) if (addr_node == 0) { addr_node = _addr_tree.first(); - printf("Allocator %p dump:\n", this); + log("Allocator ", this, " dump:"); mem_size = mem_avail = 0; top = true; } @@ -52,7 +53,6 @@ void Allocator_avl_base::dump_addr_tree(Block *addr_node) dump_addr_tree(addr_node->child(1)); if (top) - printf(" => mem_size=%lu (%lu MB) / mem_avail=%lu (%lu MB)\n", - mem_size, mem_size / 1024 / 1024, - mem_avail, mem_avail / 1024 / 1024); + log(" => mem_size=", mem_size, " (", mem_size / 1024 / 1024, " MB) ", + "/ mem_avail=", mem_avail, " (", mem_avail / 1024 / 1024, " MB)"); } diff --git a/repos/base/src/core/include/core_log.h b/repos/base/src/core/include/core_log.h new file mode 100644 index 0000000000..216ef5d470 --- /dev/null +++ b/repos/base/src/core/include/core_log.h @@ -0,0 +1,34 @@ +/* + * \brief Kernel backend for core log messages + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2016-10-10 + */ + +/* + * Copyright (C) 2016 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE_LOG_H_ +#define _CORE_LOG_H_ + +#include + +namespace Genode { + struct Core_log; + Core_log &core_log(); +} + + +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]); } +}; + +#endif /* _CORE_LOG_H_ */ diff --git a/repos/base/src/core/include/log_session_component.h b/repos/base/src/core/include/log_session_component.h index 20eac1c9b1..31d71af81e 100644 --- a/repos/base/src/core/include/log_session_component.h +++ b/repos/base/src/core/include/log_session_component.h @@ -15,7 +15,6 @@ #define _CORE__INCLUDE__LOG_SESSION_COMPONENT_H_ #include -#include #include #include #include @@ -55,22 +54,6 @@ namespace Genode { char const *string = string_buf.string(); size_t len = strlen(string); - /* - * Heuristic: The Log console implementation flushes - * the output preferably in front of escape - * sequences. If the line contains only - * the escape sequence, we skip the printing - * of the label and cut the line break (last - * character). - */ - enum { ESC = 27 }; - if ((string[0] == ESC) && (len == 5) && (string[4] == '\n')) { - char buf[5]; - strncpy(buf, string, 5); - printf("%s", buf); - return len; - } - char buf[string_buf.MAX_SIZE]; unsigned from_i = 0; diff --git a/repos/base/src/core/include/signal_broker.h b/repos/base/src/core/include/signal_broker.h index dcc5245d68..22d990784f 100644 --- a/repos/base/src/core/include/signal_broker.h +++ b/repos/base/src/core/include/signal_broker.h @@ -97,11 +97,6 @@ class Genode::Signal_broker { _source_ep.apply(cap, [&] (Signal_context_component *context) { if (!context) { - /* - * We do not use PWRN() to enable the build system to - * suppress this warning in release mode (SPECS += - * release). - */ warning("invalid signal-context capability"); return; } diff --git a/repos/base/src/include/base/internal/page_size.h b/repos/base/src/include/base/internal/page_size.h index 5768624bd4..41e5ef1c06 100644 --- a/repos/base/src/include/base/internal/page_size.h +++ b/repos/base/src/include/base/internal/page_size.h @@ -14,6 +14,8 @@ #ifndef _INCLUDE__BASE__INTERNAL__PAGE_SIZE_H_ #define _INCLUDE__BASE__INTERNAL__PAGE_SIZE_H_ +#include + namespace Genode { constexpr size_t get_page_size_log2() { return 12; } diff --git a/repos/base/src/lib/base/core_printf.cc b/repos/base/src/lib/base/core_printf.cc deleted file mode 100644 index b0ec88f7ef..0000000000 --- a/repos/base/src/lib/base/core_printf.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* - * \brief Core-specific 'printf' implementation - * \author Norman Feske - * \date 2010-08-31 - * - * In contrast to regular Genode processes, which use the platform- - * independent LOG-session interface as back end of 'printf', core has - * to rely on a platform-specific back end such as a serial driver or a - * kernel-debugger function. The platform-specific back end is called - * 'Core_console'. - * - * This file contains the generic glue code between 'printf' and - * 'Core_console'. - */ - -/* - * Copyright (C) 2010-2013 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -/* Genode includes */ -#include -#include - -/* base-internal includes */ -#include - -using namespace Genode; - - -/** - * Synchronized version of the core console - * - * This class synchronizes calls of the 'Console::vprintf' function as - * used by 'printf' and 'vprintf' to prevent multiple printf-using - * threads within core from interfering with each other. - */ -struct Synchronized_core_console : public Core_console, public Lock -{ - void vprintf(const char *format, va_list list) - { - Lock::Guard lock_guard(*this); - Core_console::vprintf(format, list); - } -}; - - -/** - * Return singleton instance of synchronized core console - */ -static Synchronized_core_console &core_console() -{ - static Synchronized_core_console _console; - return _console; -} - - -void Genode::printf(const char *format, ...) -{ - va_list list; - va_start(list, format); - - core_console().vprintf(format, list); - - va_end(list); -} - - -void Genode::vprintf(const char *format, va_list list) -{ - core_console().vprintf(format, list); -} - - diff --git a/repos/base/src/lib/base/default_log.cc b/repos/base/src/lib/base/default_log.cc index 9f681c1232..f149dd071b 100644 --- a/repos/base/src/lib/base/default_log.cc +++ b/repos/base/src/lib/base/default_log.cc @@ -26,7 +26,17 @@ using namespace Genode; static Log *log_ptr; -Log &Log::log() { return *log_ptr; } +Log &Log::log() +{ + /* + * Ensure the log is initialized before use. This is only needed for + * components that do not initialize the log explicitly in the startup + * code, i.e., Linux hybrid components. + */ + Genode::init_log(); + + return *log_ptr; +} extern "C" int stdout_write(const char *s); diff --git a/repos/base/src/test/ada/add.cc b/repos/base/src/test/ada/add.cc index 5fb5bccc35..66365601bf 100644 --- a/repos/base/src/test/ada/add.cc +++ b/repos/base/src/test/ada/add.cc @@ -5,20 +5,20 @@ */ /* Genode includes */ -#include +#include -using namespace Genode; +using Genode::log; extern "C" void add(int a, int b, int *result) { - printf("add called with a=%d, b=%d, result at address 0x%p\n", - a, b, result); + log("add called with a=", a, ", b=", b, ", result at address ", + (void*)result); *result = a + b; } extern "C" void print_int(int a) { - printf("print_int called with argument %d\n", a); + log("print_int called with argument ", a); } diff --git a/repos/base/src/test/printf/main.cc b/repos/base/src/test/log/main.cc similarity index 74% rename from repos/base/src/test/printf/main.cc rename to repos/base/src/test/log/main.cc index 8335989a4d..132a0284c5 100644 --- a/repos/base/src/test/printf/main.cc +++ b/repos/base/src/test/log/main.cc @@ -1,5 +1,5 @@ /* - * \brief Testing 'printf()' with negative integer + * \brief Testing 'log()' with negative integer * \author Christian Prochaska * \date 2012-04-20 * @@ -13,7 +13,6 @@ */ #include -#include #include @@ -27,9 +26,5 @@ void Component::construct(Genode::Env &env) log("invalid hex range: ", Hex_range(0xf8, 0x10)); log("negative hex char: ", Hex((char)-2LL, Hex::PREFIX, Hex::PAD)); log("positive hex char: ", Hex((char) 2LL, Hex::PREFIX, Hex::PAD)); - - /* test that unsupported commands don't crash the printf parser */ - printf("%#x %s\n", 0x38, "test 1"); - printf("%#lx %s\n", 0x38L, "test 2"); - printf("-1 = %d = %ld\n", -1, -1L); + log("Test done."); } diff --git a/repos/base/src/test/printf/target.mk b/repos/base/src/test/log/target.mk similarity index 59% rename from repos/base/src/test/printf/target.mk rename to repos/base/src/test/log/target.mk index 103e3a5bcb..9a43e074e7 100644 --- a/repos/base/src/test/printf/target.mk +++ b/repos/base/src/test/log/target.mk @@ -1,3 +1,3 @@ -TARGET = test-printf +TARGET = test-log SRC_CC = main.cc LIBS = base diff --git a/repos/base/src/test/mp_server/main.cc b/repos/base/src/test/mp_server/main.cc index 890cd27d68..ee456ef7fd 100644 --- a/repos/base/src/test/mp_server/main.cc +++ b/repos/base/src/test/mp_server/main.cc @@ -13,7 +13,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -63,19 +63,17 @@ namespace Test { * Session implementation */ void Component::test_untyped(unsigned value) { - Genode::printf("function %s: got value %u\n", __FUNCTION__, value); + Genode::log("function ", __FUNCTION__, ": got value ", value); } void Component::test_cap(Genode::Native_capability cap) { - Genode::printf("function %s: capability is valid ? %s - idx %lx\n", - __FUNCTION__, cap.valid() ? "yes" : "no", - cap.local_name()); + Genode::log("function ", __FUNCTION__, ": capability is valid ? ", + cap.valid() ? "yes" : "no", " - idx ", cap.local_name()); } Genode::Native_capability Component::test_cap_reply(Genode::Native_capability cap) { - Genode::printf("function %s: capability is valid ? %s - idx %lx\n", - __FUNCTION__, cap.valid() ? "yes" : "no", - cap.local_name()); + Genode::log("function ", __FUNCTION__, ": capability is valid ? ", + cap.valid() ? "yes" : "no", " - idx ", cap.local_name()); return cap; } } @@ -87,11 +85,11 @@ int main(int argc, char **argv) { using namespace Genode; - printf("--- test-mp_server started ---\n"); + log("--- test-mp_server started ---"); Affinity::Space cpus = env()->cpu_session()->affinity_space(); - printf("Detected %ux%u CPU%s\n", - cpus.width(), cpus.height(), cpus.total() > 1 ? "s." : "."); + log("Detected ", cpus.width(), "x", cpus.height(), " CPU", + cpus.total() > 1 ? "s." : "."); enum { STACK_SIZE = 2*1024*sizeof(long) }; @@ -114,26 +112,26 @@ int main(int argc, char **argv) /* Test: Invoke RPC entrypoint on different CPUs */ for (unsigned i = 0; i < cpus.total(); i++) { - printf("call server on CPU %u\n", i); + log("call server on CPU ", i); clients[i]->test_untyped(i); } /* Test: Transfer a capability to RPC Entrypoints on different CPUs */ for (unsigned i = 0; i < cpus.total(); i++) { Native_capability cap = caps[0]; - printf("call server on CPU %u - transfer cap %lx\n", i, cap.local_name()); + log("call server on CPU ", i, " - transfer cap ", cap.local_name()); clients[i]->test_cap(cap); } /* Test: Transfer a capability to RPC Entrypoints and back */ for (unsigned i = 0; i < cpus.total(); i++) { Native_capability cap = caps[0]; - printf("call server on CPU %u - transfer cap %lx\n", i, cap.local_name()); + log("call server on CPU ", i, " - transfer cap ", cap.local_name()); Native_capability rcap = clients[i]->test_cap_reply(cap); - printf("got from server on CPU %u - received cap %lx\n", i, rcap.local_name()); + log("got from server on CPU ", i, " - received cap ", rcap.local_name()); } - printf("done\n"); + log("done"); sleep_forever(); } diff --git a/repos/base/src/test/new_delete/main.cc b/repos/base/src/test/new_delete/main.cc index f4b79bc3e3..d0061a00ef 100644 --- a/repos/base/src/test/new_delete/main.cc +++ b/repos/base/src/test/new_delete/main.cc @@ -12,14 +12,14 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include -using Genode::printf; +using Genode::log; using Genode::destroy; -#define L() printf(" %s\n", __func__) +#define L() log(" ", __func__) struct A { int a; A() { L(); } virtual ~A() { L(); } }; @@ -32,7 +32,7 @@ struct E : C, D { int e; - E(bool thro) { L(); if (thro) { printf("throw exception\n"); throw 1; } } + E(bool thro) { L(); if (thro) { log("throw exception"); throw 1; } } virtual ~E() { L(); } }; @@ -64,14 +64,14 @@ struct Allocator : Genode::Allocator { *p = heap.alloc(size); - printf("Allocator::alloc()\n"); + log("Allocator::alloc()"); return *p != 0; } void free(void *p, Genode::size_t size) override { - printf("Allocator::free()\n"); + log("Allocator::free()"); heap.free(p, size); } }; @@ -95,7 +95,7 @@ int main() try { E *e = new (&a) E(true); destroy(&a, e); - } catch (...) { printf("exception caught\n"); } + } catch (...) { log("exception caught"); } /************************* ** Allocator reference ** @@ -111,5 +111,5 @@ int main() try { E *e = new (a) E(true); destroy(&a, e); - } catch (...) { printf("exception caught\n"); } + } catch (...) { log("exception caught"); } } diff --git a/repos/base/src/test/rm_nested/main.cc b/repos/base/src/test/rm_nested/main.cc index 101107f114..38b88ba208 100644 --- a/repos/base/src/test/rm_nested/main.cc +++ b/repos/base/src/test/rm_nested/main.cc @@ -18,7 +18,6 @@ * under the terms of the GNU General Public License version 2. */ -#include #include #include #include @@ -58,25 +57,25 @@ class Local_fault_handler : public Thread_deprecated<4096> { Region_map::State state = _region_map.state(); - printf("region-map state is %s, pf_addr=0x%lx\n", + log("region-map state is ", state.type == Region_map::State::READ_FAULT ? "READ_FAULT" : state.type == Region_map::State::WRITE_FAULT ? "WRITE_FAULT" : state.type == Region_map::State::EXEC_FAULT ? "EXEC_FAULT" : "READY", - state.addr); + ", pf_addr=", Hex(state.addr, Hex::PREFIX)); - printf("allocate dataspace and attach it to sub region map\n"); + log("allocate dataspace and attach it to sub region map"); Dataspace_capability ds = env()->ram_session()->alloc(PAGE_SIZE); _region_map.attach_at(ds, state.addr & ~(PAGE_SIZE - 1)); - printf("returning from handle_fault\n"); + log("returning from handle_fault"); } void entry() { while (true) { - printf("fault handler: waiting for fault signal\n"); + log("fault handler: waiting for fault signal"); Signal signal = _receiver.wait_for_signal(); - printf("received %u fault signals\n", signal.num()); + log("received ", signal.num(), " fault signals"); for (unsigned i = 0; i < signal.num(); i++) handle_fault(); } @@ -86,7 +85,7 @@ class Local_fault_handler : public Thread_deprecated<4096> int main(int argc, char **argv) { - printf("--- nested region map test ---\n"); + log("--- nested region map test ---"); /* * Initialize sub region map and set up a local fault handler for it. @@ -105,16 +104,17 @@ int main(int argc, char **argv) */ void *addr = env()->rm_session()->attach(region_map.dataspace()); - printf("attached sub dataspace at local address 0x%p\n", addr); + log("attached sub dataspace at local address ", addr); Dataspace_client client(region_map.dataspace()); - printf("sub dataspace size is %lu should be %u\n", client.size(), MANAGED_SIZE); + log("sub dataspace size is ", client.size(), " should be ", + (size_t)MANAGED_SIZE); /* * Walk through the address range belonging to the region map */ char *managed = (char *)addr; for (int i = 0; i < MANAGED_SIZE; i += PAGE_SIZE/16) { - printf("write to %p\n", &managed[i]); + log("write to ", (void*)&managed[i]); managed[i] = 13; } diff --git a/repos/base/src/test/segfault/main.cc b/repos/base/src/test/segfault/main.cc index 311be3bb7a..97e719e4f3 100644 --- a/repos/base/src/test/segfault/main.cc +++ b/repos/base/src/test/segfault/main.cc @@ -4,11 +4,11 @@ * \date 2012-11-01 */ -#include +#include int main(int argc, char **argv) { - Genode::printf("going to produce a segmentation fault...\n"); + Genode::log("going to produce a segmentation fault..."); *((int *)0x44) = 0x55; return 0; diff --git a/repos/base/src/test/thread/main.cc b/repos/base/src/test/thread/main.cc index b0f61a7181..8b324b657c 100644 --- a/repos/base/src/test/thread/main.cc +++ b/repos/base/src/test/thread/main.cc @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -94,9 +93,8 @@ static void test_stack_alignment_varargs(char const *format, ...) { va_list list; va_start(list, format); - - vprintf(format, list); - + log(va_arg(list, double)); + log(va_arg(list, double)); va_end(list); } diff --git a/repos/base/src/test/util_mmio/main.cc b/repos/base/src/test/util_mmio/main.cc index 2f8f98472d..f617cdb72b 100644 --- a/repos/base/src/test/util_mmio/main.cc +++ b/repos/base/src/test/util_mmio/main.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include using namespace Genode; @@ -152,22 +152,6 @@ struct Test_mmio : public Mmio }; -/** - * Print out memory content hexadecimal - */ -void dump_mem(uint8_t * base, size_t size) -{ - addr_t top = (addr_t)base + size; - bool print_separator = 0; - for(; (addr_t)base < top;) { - if (print_separator) { printf("-"); } - else { print_separator = 1; } - printf("%1x%1x", (*(uint8_t *)base) & 0xf, *(uint8_t *)base >> 4); - base = (uint8_t *)((addr_t)base + sizeof(uint8_t)); - } -} - - /** * Zero-fill memory region */ @@ -199,13 +183,7 @@ int compare_mem(uint8_t * base1, uint8_t * base2, size_t size) /** * End a failed test */ -void error(unsigned line) -{ - printf("Test in line %i failed\n", line); - printf(" mmio_mem: hex "); - dump_mem(mmio_mem, sizeof(mmio_mem)); - printf("\n cpu_state: 0x%4X\n", cpu_state); -} +void error(unsigned line) { error("Test in line ", line, " failed"); } int main() @@ -486,7 +464,7 @@ int main() if (compare_mem(mmio_mem, cmp_mem, MMIO_SIZE)) { error(__LINE__); } } - printf("Test done\n"); + log("Test done"); return 0; } diff --git a/repos/os/run/report_rom.run b/repos/os/run/report_rom.run index ecc5e70607..c3b4d9810e 100644 --- a/repos/os/run/report_rom.run +++ b/repos/os/run/report_rom.run @@ -48,7 +48,7 @@ append qemu_args "-nographic -m 128" run_genode_until {child "test-report_rom" exited with exit value 0.*\n} 30 -grep_output {^\[init -> test-report_rom} +grep_output {^\[init -> test-report_rom\] .+} unify_output {\[init \-\> test\-report_rom\] upgrading quota donation for .* \([0-9]+ bytes\)} "" trim_lines diff --git a/repos/os/run/rom_filter.run b/repos/os/run/rom_filter.run index a86518808e..96d29e0d6c 100644 --- a/repos/os/run/rom_filter.run +++ b/repos/os/run/rom_filter.run @@ -120,7 +120,7 @@ append qemu_args " -nographic " run_genode_until {.*finished.*\n} 20 # pay only attention to the output of the rom_logger -grep_output {^\[init -> rom_logger} +grep_output {^\[init -> rom_logger\] .+} unify_output {\[init \-\> rom_logger\] upgrading quota donation for .* \([0-9]+ bytes\)} "" trim_lines diff --git a/repos/os/src/drivers/nic/spec/gem/marvell_phy.h b/repos/os/src/drivers/nic/spec/gem/marvell_phy.h index e0b30f1b61..551c10ec83 100644 --- a/repos/os/src/drivers/nic/spec/gem/marvell_phy.h +++ b/repos/os/src/drivers/nic/spec/gem/marvell_phy.h @@ -16,6 +16,7 @@ #define _INCLUDE__DRIVERS__NIC__GEM__MARVELL_PHY_H_ /* Genode includes */ +#include #include #include #include diff --git a/repos/os/src/drivers/nic/spec/gem/tx_buffer_descriptor.h b/repos/os/src/drivers/nic/spec/gem/tx_buffer_descriptor.h index e0053e9830..b2401e7b06 100644 --- a/repos/os/src/drivers/nic/spec/gem/tx_buffer_descriptor.h +++ b/repos/os/src/drivers/nic/spec/gem/tx_buffer_descriptor.h @@ -14,6 +14,7 @@ #ifndef _INCLUDE__DRIVERS__NIC__GEM__TX_BUFFER_DESCRIPTOR_H_ #define _INCLUDE__DRIVERS__NIC__GEM__TX_BUFFER_DESCRIPTOR_H_ +#include #include #include "buffer_descriptor.h" @@ -50,7 +51,7 @@ class Tx_buffer_descriptor : public Buffer_descriptor void add_to_queue(const char* const packet, const size_t size) { if (size > MAX_PACKAGE_SIZE) { - PWRN("Ethernet package to big. Not sent!"); + warning("Ethernet package to big. Not sent!"); return; } diff --git a/repos/os/src/drivers/platform/spec/arndale/cmu.h b/repos/os/src/drivers/platform/spec/arndale/cmu.h index c5489a7eb4..29d76f8234 100644 --- a/repos/os/src/drivers/platform/spec/arndale/cmu.h +++ b/repos/os/src/drivers/platform/spec/arndale/cmu.h @@ -14,13 +14,14 @@ #ifndef _DRIVERS__PLATFORM__SPEC__ARNDALE__CMU_H_ #define _DRIVERS__PLATFORM__SPEC__ARNDALE__CMU_H_ +#include #include #include #include #include using namespace Regulator; - +using Genode::warning; class Cmu : public Regulator::Driver, public Genode::Attached_mmio @@ -284,9 +285,9 @@ class Cmu : public Regulator::Driver, freq = 8; break; default: - PWRN("Unsupported CPU frequency level %ld", level); - PWRN("Supported values are 200, 400, 600, 800 MHz"); - PWRN("and 1, 1.2, 1.4, 1.6, 1.7 GHz"); + warning("Unsupported CPU frequency level ", level); + warning("Supported values are 200, 400, 600, 800 MHz"); + warning("and 1, 1.2, 1.4, 1.6, 1.7 GHz"); return; }; @@ -399,7 +400,7 @@ class Cmu : public Regulator::Driver, write(1); break; default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } } @@ -423,7 +424,7 @@ class Cmu : public Regulator::Driver, write(0); break; default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } } @@ -482,7 +483,7 @@ class Cmu : public Regulator::Driver, _cpu_clk_freq(level); break; default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } } @@ -495,7 +496,7 @@ class Cmu : public Regulator::Driver, case CLK_SATA: return 66666666; /* 66 MHz */ default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } return 0; } @@ -524,7 +525,7 @@ class Cmu : public Regulator::Driver, return read() && read(); default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } return true; } diff --git a/repos/os/src/drivers/platform/spec/arndale/pmu.h b/repos/os/src/drivers/platform/spec/arndale/pmu.h index da0ab4ab10..d61f6f2f98 100644 --- a/repos/os/src/drivers/platform/spec/arndale/pmu.h +++ b/repos/os/src/drivers/platform/spec/arndale/pmu.h @@ -14,13 +14,14 @@ #ifndef _DRIVERS__PLATFORM__SPEC__ARNDALE__PMU_H_ #define _DRIVERS__PLATFORM__SPEC__ARNDALE__PMU_H_ +#include #include #include #include #include using namespace Regulator; - +using Genode::warning; class Pmu : public Regulator::Driver, public Genode::Attached_mmio @@ -132,7 +133,7 @@ class Pmu : public Regulator::Driver, write(hpc); break; } default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } } @@ -149,7 +150,7 @@ class Pmu : public Regulator::Driver, write(0); break; default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } } @@ -192,7 +193,7 @@ class Pmu : public Regulator::Driver, { switch (id) { default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } } @@ -200,7 +201,7 @@ class Pmu : public Regulator::Driver, { switch (id) { default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } return 0; } @@ -223,7 +224,7 @@ class Pmu : public Regulator::Driver, case PWR_SATA: return read(); default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } return true; } diff --git a/repos/os/src/drivers/platform/spec/odroid_x2/pmu.h b/repos/os/src/drivers/platform/spec/odroid_x2/pmu.h index 147a06fd8a..44d1bb869d 100644 --- a/repos/os/src/drivers/platform/spec/odroid_x2/pmu.h +++ b/repos/os/src/drivers/platform/spec/odroid_x2/pmu.h @@ -16,11 +16,13 @@ #ifndef _DRIVERS__PLATFORM__SPEC__ODROID_X2__PMU_H_ #define _DRIVERS__PLATFORM__SPEC__ODROID_X2__PMU_H_ +#include #include #include #include #include +using Genode::warning; using namespace Regulator; @@ -85,7 +87,7 @@ class Pmu : public Regulator::Driver, break; } default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } } @@ -101,7 +103,7 @@ class Pmu : public Regulator::Driver, write(0); break; default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } } @@ -128,7 +130,7 @@ class Pmu : public Regulator::Driver, { switch (id) { default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } } @@ -136,7 +138,7 @@ class Pmu : public Regulator::Driver, { switch (id) { default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } return 0; } @@ -155,7 +157,7 @@ class Pmu : public Regulator::Driver, case PWR_USB20: return read(); default: - PWRN("Unsupported for %s", names[id].name); + warning("Unsupported for ", names[id].name); } return true; } diff --git a/repos/os/src/server/vmm/main.cc b/repos/os/src/server/vmm/main.cc index a5f7574844..145e1d79a6 100644 --- a/repos/os/src/server/vmm/main.cc +++ b/repos/os/src/server/vmm/main.cc @@ -13,18 +13,20 @@ /* Genode includes */ #include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include +#include + #include #include @@ -224,31 +226,34 @@ class Vm { { "nope", "reset", "undefined", "svc", "pf_abort", "data_abort", "irq", "fiq", "trap" }; - printf("Cpu state:\n"); - printf(" r0 = %08lx\n", _state->r0); - printf(" r1 = %08lx\n", _state->r1); - printf(" r2 = %08lx\n", _state->r2); - printf(" r3 = %08lx\n", _state->r3); - printf(" r4 = %08lx\n", _state->r4); - printf(" r5 = %08lx\n", _state->r5); - printf(" r6 = %08lx\n", _state->r6); - printf(" r7 = %08lx\n", _state->r7); - printf(" r8 = %08lx\n", _state->r8); - printf(" r9 = %08lx\n", _state->r9); - printf(" r10 = %08lx\n", _state->r10); - printf(" r11 = %08lx\n", _state->r11); - printf(" r12 = %08lx\n", _state->r12); - printf(" sp = %08lx\n", _state->sp); - printf(" lr = %08lx\n", _state->lr); - printf(" ip = %08lx\n", _state->ip); - printf(" cpsr = %08lx\n", _state->cpsr); + log("Cpu state:"); + log(" r0 = ", Hex(_state->r0, Hex::PREFIX, Hex::PAD)); + log(" r1 = ", Hex(_state->r1, Hex::PREFIX, Hex::PAD)); + log(" r2 = ", Hex(_state->r2, Hex::PREFIX, Hex::PAD)); + log(" r3 = ", Hex(_state->r3, Hex::PREFIX, Hex::PAD)); + log(" r4 = ", Hex(_state->r4, Hex::PREFIX, Hex::PAD)); + log(" r5 = ", Hex(_state->r5, Hex::PREFIX, Hex::PAD)); + log(" r6 = ", Hex(_state->r6, Hex::PREFIX, Hex::PAD)); + log(" r7 = ", Hex(_state->r7, Hex::PREFIX, Hex::PAD)); + log(" r8 = ", Hex(_state->r8, Hex::PREFIX, Hex::PAD)); + log(" r9 = ", Hex(_state->r9, Hex::PREFIX, Hex::PAD)); + log(" r10 = ", Hex(_state->r10, Hex::PREFIX, Hex::PAD)); + log(" r11 = ", Hex(_state->r11, Hex::PREFIX, Hex::PAD)); + log(" r12 = ", Hex(_state->r12, Hex::PREFIX, Hex::PAD)); + log(" sp = ", Hex(_state->sp, Hex::PREFIX, Hex::PAD)); + log(" lr = ", Hex(_state->lr, Hex::PREFIX, Hex::PAD)); + log(" ip = ", Hex(_state->ip, Hex::PREFIX, Hex::PAD)); + log(" cpsr = ", Hex(_state->cpsr, Hex::PREFIX, Hex::PAD)); for (unsigned i = 0; i < State::Mode_state::MAX; i++) { - printf(" sp_%s = %08lx\n", modes[i], _state->mode[i].sp); - printf(" lr_%s = %08lx\n", modes[i], _state->mode[i].lr); - printf(" spsr_%s = %08lx\n", modes[i], _state->mode[i].spsr); + log(" sp_", modes[i], " = ", + Hex(_state->mode[i].sp, Hex::PREFIX, Hex::PAD)); + log(" lr_", modes[i], " = ", + Hex(_state->mode[i].lr, Hex::PREFIX, Hex::PAD)); + log(" spsr_", modes[i], " = ", + Hex(_state->mode[i].spsr, Hex::PREFIX, Hex::PAD)); } - printf(" exception = %s\n", exc[_state->cpu_exception]); + log(" exception = ", exc[_state->cpu_exception]); } State *state() const { return _state; } diff --git a/tool/autopilot.list b/tool/autopilot.list index 1e892cd134..a306a2d6bb 100644 --- a/tool/autopilot.list +++ b/tool/autopilot.list @@ -61,7 +61,7 @@ stdcxx nic_loopback platform report_rom -printf +log rom_filter clipboard rust