hw: don't use assert in Kernel::start_thread

ref #1101
This commit is contained in:
Martin Stein 2014-03-16 18:25:37 +01:00 committed by Norman Feske
parent fba4f54571
commit 9e089e7e75
4 changed files with 22 additions and 17 deletions

View File

@ -93,7 +93,7 @@ namespace Kernel
/** /**
* Static kernel PD that describes core * Static kernel PD that describes core
*/ */
static Pd * core() Pd * core()
{ {
/** /**
* Core protection-domain * Core protection-domain
@ -262,7 +262,7 @@ extern "C" void init_kernel_multiprocessor()
_main_thread_utcb->start_info()->init(t.id(), Genode::Native_capability()); _main_thread_utcb->start_info()->init(t.id(), Genode::Native_capability());
t.ip = (addr_t)CORE_MAIN;; t.ip = (addr_t)CORE_MAIN;;
t.sp = (addr_t)s + STACK_SIZE; 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 */ /* kernel initialization finished */
init_platform(); init_platform();

View File

@ -25,7 +25,7 @@ namespace Kernel
/** /**
* Return kernel name of core domain * Return kernel name of core domain
*/ */
unsigned core_id(); Pd * core();
/** /**
* Thread that consumes processor time if no other thread is available * 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; ip = (addr_t)&_main;
sp = (addr_t)&_stack[STACK_SIZE]; sp = (addr_t)&_stack[STACK_SIZE];
init(processor, core_id(), 0, 0); init(processor, core(), 0, 0);
} }
}; };

View File

@ -190,8 +190,7 @@ Thread::Thread(unsigned const priority, char const * const label)
} }
void void Thread::init(Processor * const processor, Pd * const pd,
Thread::init(Processor * const processor, unsigned const pd_id_arg,
Native_utcb * const utcb_phys, bool const start) Native_utcb * const utcb_phys, bool const start)
{ {
assert(_state == AWAITS_START) assert(_state == AWAITS_START)
@ -201,8 +200,7 @@ Thread::init(Processor * const processor, unsigned const pd_id_arg,
_utcb_phys = utcb_phys; _utcb_phys = utcb_phys;
/* join protection domain */ /* join protection domain */
_pd = Pd::pool()->object(pd_id_arg); _pd = pd;
assert(_pd);
addr_t const tlb = _pd->tlb()->base(); addr_t const tlb = _pd->tlb()->base();
User_context::init_thread(tlb, pd_id()); User_context::init_thread(tlb, pd_id());
@ -356,26 +354,33 @@ void Thread::_call_start_thread()
user_arg_0(0); user_arg_0(0);
return; return;
} }
/* lookup targeted thread */ /* lookup thread */
unsigned const thread_id = user_arg_1(); unsigned const thread_id = user_arg_1();
Thread * const thread = Thread::pool()->object(thread_id); Thread * const thread = Thread::pool()->object(thread_id);
if (!thread) { if (!thread) {
PWRN("unknown thread"); PWRN("failed to lookup thread");
user_arg_0(0); user_arg_0(0);
return; return;
} }
/* lookup targeted processor */ /* lookup processor */
unsigned const processor_id = user_arg_2(); unsigned const processor_id = user_arg_2();
Processor * const processor = processor_pool()->processor(processor_id); Processor * const processor = processor_pool()->processor(processor_id);
if (!processor) { 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); user_arg_0(0);
return; return;
} }
/* start thread */ /* start thread */
unsigned const pd_id = user_arg_3();
Native_utcb * const utcb = (Native_utcb *)user_arg_4(); 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()); user_arg_0((Call_ret)thread->_pd->tlb());
} }

View File

@ -301,12 +301,12 @@ class Kernel::Thread
/** /**
* Prepare thread to get scheduled the first time * Prepare thread to get scheduled the first time
* *
* \param processor kernel object of targeted processor * \param processor targeted processor
* \param pd_id kernel name of target protection domain * \param pd targeted domain
* \param utcb core local pointer to userland thread-context * \param utcb core local pointer to userland thread-context
* \param start wether to start executing the thread * \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); Native_utcb * const utcb, bool const start);