nova: use 'Native_cpu' component for thread initialization

Pass the thread type and exception base to core with a 'Native_cpu'
component instead of enhancing the 'Thread_state' class.

Fixes #2298
This commit is contained in:
Christian Prochaska
2017-02-27 19:54:03 +01:00
committed by Christian Helmuth
parent fbdfbc2476
commit ca2871e2e4
18 changed files with 413 additions and 103 deletions

View File

@ -21,6 +21,7 @@
#include <base/rpc_client.h>
#include <session/session.h>
#include <cpu_thread/client.h>
#include <nova_native_cpu/client.h>
/* base-internal includes */
#include <base/internal/stack.h>
@ -148,18 +149,27 @@ void Thread::start()
using namespace Genode;
/* create EC at core */
Thread_state state;
state.sel_exc_base = native_thread().exc_pt_sel;
state.vcpu = native_thread().vcpu;
state.global_thread = global;
try {
Nova_native_cpu::Thread_type thread_type;
if (native_thread().vcpu)
thread_type = Nova_native_cpu::Thread_type::VCPU;
else if (global)
thread_type = Nova_native_cpu::Thread_type::GLOBAL;
else
thread_type = Nova_native_cpu::Thread_type::LOCAL;
Nova_native_cpu::Exception_base exception_base { native_thread().exc_pt_sel };
Nova_native_cpu_client native_cpu(_cpu_session->native_cpu());
native_cpu.thread_type(_thread_cap, thread_type, exception_base);
} catch (...) { throw Cpu_session::Thread_creation_failed(); }
/* local thread have no start instruction pointer - set via portal entry */
addr_t thread_ip = global ? reinterpret_cast<addr_t>(_thread_start) : native_thread().initial_ip;
Cpu_thread_client cpu_thread(_thread_cap);
try { cpu_thread.state(state); }
catch (...) { throw Cpu_session::Thread_creation_failed(); }
cpu_thread.start(thread_ip, _stack->top());
/* request native EC thread cap */