From b85126a638f17827a09d6ab4a38920a4837e7592 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 7 Oct 2013 15:37:58 +0200 Subject: [PATCH] hw: enable verbose thread starts ref #899 --- base-hw/src/core/kernel/thread.cc | 77 +++++++++++++++++++++++++++++++ base-hw/src/core/kernel/thread.h | 47 +++++++++---------- base-hw/src/core/target.inc | 1 + 3 files changed, 101 insertions(+), 24 deletions(-) create mode 100644 base-hw/src/core/kernel/thread.cc diff --git a/base-hw/src/core/kernel/thread.cc b/base-hw/src/core/kernel/thread.cc new file mode 100644 index 000000000..9742a1a65 --- /dev/null +++ b/base-hw/src/core/kernel/thread.cc @@ -0,0 +1,77 @@ +/* + * \brief Kernel backend for execution contexts in userland + * \author Martin Stein + * \date 2013-09-15 + */ + +/* + * Copyright (C) 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. + */ + +/* core includes */ +#include +#include +#include +#include + +using namespace Kernel; + + +char const * Kernel::Thread::label() +{ + if (!platform_thread()) { + if (!phys_utcb()) { return "idle"; } + return "core"; + } + return platform_thread()->name(); +} + + +char const * Kernel::Thread::pd_label() +{ + if (core()) { return "core"; } + if (!pd()) { return "?"; } + return pd()->platform_pd()->label(); +} + + +void +Kernel::Thread::prepare_to_start(void * const ip, + void * const sp, + unsigned const cpu_id, + unsigned const pd_id, + Native_utcb * const utcb_phys, + Native_utcb * const utcb_virt, + bool const main) +{ + assert(_state == AWAIT_START) + + /* FIXME: support SMP */ + if (cpu_id) { PERR("multicore processing not supported"); } + + /* store thread parameters */ + _phys_utcb = utcb_phys; + _virt_utcb = utcb_virt; + _pd_id = pd_id; + + /* join a protection domain */ + Pd * const pd = Pd::pool()->object(_pd_id); + assert(pd); + addr_t const tlb = pd->tlb()->base(); + + /* initialize CPU context */ + User_context * const c = static_cast(this); + bool const core = (_pd_id == core_id()); + if (!main) { c->init_thread(ip, sp, tlb, pd_id); } + else if (!core) { c->init_main_thread(ip, utcb_virt, tlb, pd_id); } + else { c->init_core_main_thread(ip, sp, tlb, pd_id); } + + /* print log message */ + if (START_VERBOSE) { + PINF("in program %u '%s' start thread %u '%s'", + this->pd_id(), pd_label(), id(), label()); + } +} diff --git a/base-hw/src/core/kernel/thread.h b/base-hw/src/core/kernel/thread.h index a296f6048..27fd36d4f 100644 --- a/base-hw/src/core/kernel/thread.h +++ b/base-hw/src/core/kernel/thread.h @@ -101,6 +101,8 @@ class Kernel::Thread { private: + enum { START_VERBOSE = 0 }; + enum State { SCHEDULED = 1, @@ -301,6 +303,26 @@ class Kernel::Thread _signal_receiver(0) { } + /** + * Return wether the thread is a core thread + */ + bool core() { return pd_id() == core_id(); } + + /** + * Return kernel backend of protection domain the thread is in + */ + Pd * pd() { return Pd::pool()->object(pd_id()); } + + /** + * Return user label of the thread + */ + char const * label(); + + /** + * return user label of the protection domain the thread is in + */ + char const * pd_label(); + /** * Suspend the thread unrecoverably */ @@ -327,30 +349,7 @@ class Kernel::Thread unsigned const pd_id, Native_utcb * const utcb_phys, Native_utcb * const utcb_virt, - bool const main) - { - assert(_state == AWAIT_START) - - /* FIXME: support SMP */ - if (cpu_id) { PERR("multicore processing not supported"); } - - /* store thread parameters */ - _phys_utcb = utcb_phys; - _virt_utcb = utcb_virt; - _pd_id = pd_id; - - /* join a protection domain */ - Pd * const pd = Pd::pool()->object(_pd_id); - assert(pd); - addr_t const tlb = pd->tlb()->base(); - - /* initialize CPU context */ - User_context * const c = static_cast(this); - bool const core = (_pd_id == core_id()); - if (!main) { c->init_thread(ip, sp, tlb, pd_id); } - else if (!core) { c->init_main_thread(ip, utcb_virt, tlb, pd_id); } - else { c->init_core_main_thread(ip, sp, tlb, pd_id); } - } + bool const main); /** * Start this thread diff --git a/base-hw/src/core/target.inc b/base-hw/src/core/target.inc index 9300d6a3e..d5d71d450 100644 --- a/base-hw/src/core/target.inc +++ b/base-hw/src/core/target.inc @@ -47,6 +47,7 @@ SRC_CC += console.cc \ trace_session_component.cc \ thread.cc \ kernel.cc \ + kernel/thread.cc \ kernel/signal_receiver.cc \ rm_session_support.cc \ kernel_support.cc \