2015-02-06 17:29:30 +01:00
|
|
|
/*
|
|
|
|
* \brief CPU specific implementations of core
|
|
|
|
* \author Martin Stein
|
|
|
|
* \author Stefan Kalkowski
|
|
|
|
* \date 2013-11-11
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 <kernel/thread.h>
|
|
|
|
#include <kernel/pd.h>
|
|
|
|
#include <kernel/kernel.h>
|
|
|
|
|
|
|
|
using namespace Kernel;
|
|
|
|
|
|
|
|
|
|
|
|
/*************************
|
|
|
|
** Kernel::Thread_base **
|
|
|
|
*************************/
|
|
|
|
|
|
|
|
Thread_base::Thread_base(Thread * const t)
|
|
|
|
:
|
|
|
|
_fault(t),
|
|
|
|
_fault_pd(0),
|
|
|
|
_fault_addr(0),
|
|
|
|
_fault_writes(0),
|
|
|
|
_fault_signal(0)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
/********************
|
|
|
|
** Kernel::Thread **
|
|
|
|
********************/
|
|
|
|
|
|
|
|
addr_t Thread::* Thread::_reg(addr_t const id) const
|
|
|
|
{
|
2015-02-27 14:02:07 +01:00
|
|
|
static addr_t Thread::* const _regs[] = {
|
|
|
|
/* [0] */ (addr_t Thread::*)&Thread::ip,
|
|
|
|
/* [1] */ (addr_t Thread::*)&Thread::sp,
|
|
|
|
/* [2] */ (addr_t Thread::*)&Thread::_fault_pd,
|
|
|
|
/* [3] */ (addr_t Thread::*)&Thread::_fault_addr,
|
|
|
|
/* [4] */ (addr_t Thread::*)&Thread::_fault_writes,
|
|
|
|
/* [5] */ (addr_t Thread::*)&Thread::_fault_signal
|
|
|
|
};
|
|
|
|
return id < sizeof(_regs)/sizeof(_regs[0]) ? _regs[id] : 0;
|
2015-02-06 17:29:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Thread_event Thread::* Thread::_event(unsigned const id) const
|
|
|
|
{
|
2015-02-27 14:14:59 +01:00
|
|
|
static Thread_event Thread::* _events[] = {
|
|
|
|
/* [0] */ &Thread::_fault
|
|
|
|
};
|
|
|
|
return id < sizeof(_events)/sizeof(_events[0]) ? _events[id] : 0;
|
2015-02-06 17:29:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Thread::_mmu_exception()
|
|
|
|
{
|
2015-02-27 14:20:36 +01:00
|
|
|
_become_inactive(AWAITS_RESUME);
|
|
|
|
_fault_pd = (addr_t)_pd->platform_pd();
|
|
|
|
_fault_signal = _fault.signal_context_id();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* core should never raise a page-fault,
|
|
|
|
* if this happens print out an error message with debug information
|
|
|
|
*/
|
|
|
|
if (_pd == Kernel::core_pd())
|
|
|
|
PERR("Pagefault in core thread (%s): ip=%p fault=%p",
|
|
|
|
label(), (void*)ip, (void*)_fault_addr);
|
|
|
|
|
|
|
|
_fault.submit();
|
|
|
|
return;
|
2015-02-06 17:29:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************
|
|
|
|
** Kernel::Cpu_context **
|
|
|
|
*************************/
|
|
|
|
|
|
|
|
void Kernel::Cpu_context::_init(size_t const stack_size, addr_t const table)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
/*************************
|
|
|
|
** CPU-state utilities **
|
|
|
|
*************************/
|
|
|
|
|
|
|
|
typedef Thread_reg_id Reg_id;
|
|
|
|
|
|
|
|
static addr_t const _cpu_state_regs[] = { };
|
|
|
|
|
|
|
|
addr_t const * cpu_state_regs() { return _cpu_state_regs; }
|
|
|
|
|
|
|
|
|
|
|
|
size_t cpu_state_regs_length()
|
|
|
|
{
|
|
|
|
return sizeof(_cpu_state_regs)/sizeof(_cpu_state_regs[0]);
|
|
|
|
}
|