sel4: implement thread suspend/pause/resume

Issue #2044
This commit is contained in:
Alexander Boettcher 2016-07-19 19:39:58 +02:00 committed by Christian Helmuth
parent 155621767a
commit 997f5e8e27

View File

@ -12,7 +12,7 @@
*/
/* Genode includes */
#include <base/printf.h>
#include <base/log.h>
#include <util/string.h>
/* core includes */
@ -159,33 +159,65 @@ int Platform_thread::start(void *ip, void *sp, unsigned int cpu_no)
void Platform_thread::pause()
{
PDBG("not implemented");
int const ret = seL4_TCB_Suspend(_info.tcb_sel.value());
if (ret != seL4_NoError)
error("pausing thread failed with ", ret);
}
void Platform_thread::resume()
{
PDBG("not implemented");
int const ret = seL4_TCB_Resume(_info.tcb_sel.value());
if (ret != seL4_NoError)
error("pausing thread failed with ", ret);
}
void Platform_thread::state(Thread_state s)
{
PDBG("not implemented");
warning(__PRETTY_FUNCTION__, " not implemented");
throw Cpu_thread::State_access_failed();
}
Thread_state Platform_thread::state()
{
PDBG("not implemented");
throw Cpu_thread::State_access_failed();
seL4_TCB const thread = _info.tcb_sel.value();
seL4_Bool const suspend_source = false;
seL4_Uint8 const arch_flags = 0;
seL4_UserContext registers;
seL4_Word const register_count = sizeof(registers) / sizeof(registers.eip);
int const ret = seL4_TCB_ReadRegisters(thread, suspend_source, arch_flags,
register_count, &registers);
if (ret != seL4_NoError) {
error("reading thread state ", ret);
throw Cpu_thread::State_access_failed();
}
Thread_state state;
state.ip = registers.eip;
state.sp = registers.esp;
state.edi = registers.edi;
state.esi = registers.esi;
state.ebp = registers.ebp;
state.ebx = registers.ebx;
state.edx = registers.edx;
state.ecx = registers.ecx;
state.eax = registers.eax;
state.gs = registers.gs;
state.fs = registers.fs;
state.eflags = registers.eflags;
state.trapno = 0; /* XXX detect/track if in exception and report here */
/* registers.tls_base unused */
return state;
}
void Platform_thread::cancel_blocking()
{
PDBG("not implemented");
warning(__PRETTY_FUNCTION__, " not implemented");
}