From 9e089e7e75938519ec57f30db1391a96bcbf440e Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Sun, 16 Mar 2014 18:25:37 +0100 Subject: [PATCH] hw: don't use assert in Kernel::start_thread ref #1101 --- base-hw/src/core/kernel/kernel.cc | 4 ++-- base-hw/src/core/kernel/processor_pool.h | 4 ++-- base-hw/src/core/kernel/thread.cc | 25 ++++++++++++++---------- base-hw/src/core/kernel/thread.h | 6 +++--- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/base-hw/src/core/kernel/kernel.cc b/base-hw/src/core/kernel/kernel.cc index 76b0ecbd3..afdf83755 100644 --- a/base-hw/src/core/kernel/kernel.cc +++ b/base-hw/src/core/kernel/kernel.cc @@ -93,7 +93,7 @@ namespace Kernel /** * Static kernel PD that describes core */ - static Pd * core() + Pd * core() { /** * Core protection-domain @@ -262,7 +262,7 @@ extern "C" void init_kernel_multiprocessor() _main_thread_utcb->start_info()->init(t.id(), Genode::Native_capability()); t.ip = (addr_t)CORE_MAIN;; t.sp = (addr_t)s + STACK_SIZE; - t.init(processor_pool()->processor(processor_id), core_id(), &utcb, 1); + t.init(processor_pool()->processor(processor_id), core(), &utcb, 1); /* kernel initialization finished */ init_platform(); diff --git a/base-hw/src/core/kernel/processor_pool.h b/base-hw/src/core/kernel/processor_pool.h index 61c909708..2b4d26b17 100644 --- a/base-hw/src/core/kernel/processor_pool.h +++ b/base-hw/src/core/kernel/processor_pool.h @@ -25,7 +25,7 @@ namespace Kernel /** * Return kernel name of core domain */ - unsigned core_id(); + Pd * core(); /** * Thread that consumes processor time if no other thread is available @@ -75,7 +75,7 @@ class Kernel::Idle_thread : public Thread { ip = (addr_t)&_main; sp = (addr_t)&_stack[STACK_SIZE]; - init(processor, core_id(), 0, 0); + init(processor, core(), 0, 0); } }; diff --git a/base-hw/src/core/kernel/thread.cc b/base-hw/src/core/kernel/thread.cc index 743544e06..fa2d6e8f3 100644 --- a/base-hw/src/core/kernel/thread.cc +++ b/base-hw/src/core/kernel/thread.cc @@ -190,8 +190,7 @@ Thread::Thread(unsigned const priority, char const * const label) } -void -Thread::init(Processor * const processor, unsigned const pd_id_arg, +void Thread::init(Processor * const processor, Pd * const pd, Native_utcb * const utcb_phys, bool const start) { assert(_state == AWAITS_START) @@ -201,8 +200,7 @@ Thread::init(Processor * const processor, unsigned const pd_id_arg, _utcb_phys = utcb_phys; /* join protection domain */ - _pd = Pd::pool()->object(pd_id_arg); - assert(_pd); + _pd = pd; addr_t const tlb = _pd->tlb()->base(); User_context::init_thread(tlb, pd_id()); @@ -356,26 +354,33 @@ void Thread::_call_start_thread() user_arg_0(0); return; } - /* lookup targeted thread */ + /* lookup thread */ unsigned const thread_id = user_arg_1(); Thread * const thread = Thread::pool()->object(thread_id); if (!thread) { - PWRN("unknown thread"); + PWRN("failed to lookup thread"); user_arg_0(0); return; } - /* lookup targeted processor */ + /* lookup processor */ unsigned const processor_id = user_arg_2(); Processor * const processor = processor_pool()->processor(processor_id); if (!processor) { - PWRN("unknown processor"); + PWRN("failed to lookup processor"); + user_arg_0(0); + return; + } + /* lookup domain */ + unsigned const pd_id = user_arg_3(); + Pd * const pd = Pd::pool()->object(pd_id); + if (!pd) { + PWRN("failed to lookup domain"); user_arg_0(0); return; } /* start thread */ - unsigned const pd_id = user_arg_3(); Native_utcb * const utcb = (Native_utcb *)user_arg_4(); - thread->init(processor, pd_id, utcb, 1); + thread->init(processor, pd, utcb, 1); user_arg_0((Call_ret)thread->_pd->tlb()); } diff --git a/base-hw/src/core/kernel/thread.h b/base-hw/src/core/kernel/thread.h index 4cfd61ba9..e0a2e9e53 100644 --- a/base-hw/src/core/kernel/thread.h +++ b/base-hw/src/core/kernel/thread.h @@ -301,12 +301,12 @@ class Kernel::Thread /** * Prepare thread to get scheduled the first time * - * \param processor kernel object of targeted processor - * \param pd_id kernel name of target protection domain + * \param processor targeted processor + * \param pd targeted domain * \param utcb core local pointer to userland thread-context * \param start wether to start executing the thread */ - void init(Processor * const processor, unsigned const pd_id, + void init(Processor * const processor, Pd * const pd, Native_utcb * const utcb, bool const start);