hw: get rid of kernel/thread_* files

The distinction between Kernel::Thread and Kernel::Thread_base is
unnecessary as currently all Hw platforms would have the same content in
the latter class. Thus I've merged Kernel::Thread_base into
Kernel::Thread. Thereby, Kernel::Thread_event can be moved to
kernel/thread.h.

Ref #1652
This commit is contained in:
Martin Stein 2015-08-24 15:35:54 +02:00 committed by Christian Helmuth
parent dd9793cdc7
commit 4e98a0f64a
11 changed files with 97 additions and 226 deletions

View File

@ -8,7 +8,6 @@
INC_DIR += $(REP_DIR)/src/core/include/spec/arm
# add C++ sources
SRC_CC += spec/arm/kernel/thread_base.cc
SRC_CC += spec/arm/kernel/thread.cc
SRC_CC += spec/arm/kernel/cpu.cc
SRC_CC += spec/arm/kernel/pd.cc

View File

@ -14,7 +14,7 @@ SRC_S += spec/x86_64/kernel/crt0.s
SRC_S += spec/x86_64/crt0.s
# add C++ sources
SRC_CC += spec/x86_64/kernel/thread_base.cc
SRC_CC += spec/x86_64/kernel/thread.cc
SRC_CC += spec/x86_64/idt.cc
SRC_CC += spec/x86_64/tss.cc

View File

@ -18,27 +18,68 @@
#include <kernel/signal_receiver.h>
#include <kernel/ipc_node.h>
#include <kernel/cpu.h>
#include <kernel/thread_base.h>
#include <kernel/object.h>
#include <base/signal.h>
namespace Kernel
{
class Thread;
/**
* Kernel backend for userland execution-contexts
*/
class Thread;
class Thread_event;
class Core_thread;
}
/**
* Event that is provided by kernel thread-objects for user handling
*/
class Kernel::Thread_event : public Signal_ack_handler
{
private:
Thread * const _thread;
Signal_context * _signal_context;
/************************
** Signal_ack_handler **
************************/
void _signal_acknowledged();
public:
/**
* Constructor
*
* \param t thread that blocks on the event
*/
Thread_event(Thread * const t);
/**
* Submit to listening handlers just like a signal context
*/
void submit();
/**
* Kernel name of assigned signal context or 0 if not assigned
*/
Signal_context * const signal_context() const;
/**
* Override signal context of the event
*
* \param c new signal context or 0 to dissolve current signal context
*/
void signal_context(Signal_context * const c);
};
/**
* Kernel back-end for userland execution-contexts
*/
class Kernel::Thread
: public Kernel::Object,
public Cpu::User_context,
public Cpu_domain_update, public Ipc_node, public Signal_context_killer,
public Signal_handler, public Thread_base, public Cpu_job
:
public Kernel::Object, public Cpu::User_context, public Cpu_domain_update,
public Ipc_node, public Signal_context_killer, public Signal_handler,
public Cpu_job
{
friend class Thread_event;
friend class Core_thread;
@ -58,9 +99,16 @@ class Kernel::Thread
STOPPED = 7,
};
State _state;
Signal_receiver * _signal_receiver;
char const * const _label;
Thread_event _fault;
addr_t _fault_pd;
addr_t _fault_addr;
addr_t _fault_writes;
addr_t _fault_signal;
State _state;
Signal_receiver * _signal_receiver;
char const * const _label;
void _init();
/**
* Notice that another thread yielded the CPU to this thread
@ -302,7 +350,11 @@ class Kernel::Thread
** Accessors **
***************/
char const * label() const { return _label; }
char const * label() const { return _label; }
addr_t fault_pd() const { return _fault_pd; }
addr_t fault_addr() const { return _fault_addr; }
addr_t fault_writes() const { return _fault_writes; }
addr_t fault_signal() const { return _fault_signal; }
};

View File

@ -1,54 +0,0 @@
/*
* \brief Hardware specific base of kernel thread-objects
* \author Martin Stein
* \date 2013-11-13
*/
/*
* 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.
*/
#ifndef _KERNEL__THREAD_BASE_H_
#define _KERNEL__THREAD_BASE_H_
/* core includes */
#include <kernel/thread_event.h>
namespace Kernel
{
/**
* Hardware specific base of kernel thread-objects
*/
class Thread_base;
}
class Kernel::Thread_base
{
protected:
Thread_event _fault;
addr_t _fault_pd;
addr_t _fault_addr;
addr_t _fault_writes;
addr_t _fault_signal;
/**
* Constructor
*
* \param t generic part of kernel thread-object
*/
Thread_base(Thread * const t);
public:
/* Accessors */
addr_t fault_pd() const { return _fault_pd; }
addr_t fault_addr() const { return _fault_addr; }
addr_t fault_writes() const { return _fault_writes; }
addr_t fault_signal() const { return _fault_signal; }
};
#endif /* _KERNEL__THREAD_BASE_H_ */

View File

@ -1,63 +0,0 @@
/*
* \brief Event that is provided by akernel thread-object for user handling
* \author Martin Stein
* \date 2013-11-13
*/
/*
* 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.
*/
namespace Kernel
{
class Thread;
/**
* Event that is provided by kernel thread-objects for user handling
*/
class Thread_event;
}
class Kernel::Thread_event : public Signal_ack_handler
{
private:
Thread * const _thread;
Signal_context * _signal_context;
/************************
** Signal_ack_handler **
************************/
void _signal_acknowledged();
public:
/**
* Constructor
*
* \param t thread that blocks on the event
*/
Thread_event(Thread * const t);
/**
* Submit to listening handlers just like a signal context
*/
void submit();
/**
* Kernel name of assigned signal context or 0 if not assigned
*/
Signal_context * const signal_context() const;
/**
* Override signal context of the event
*
* \param c new signal context or 0 to dissolve current signal context
*/
void signal_context(Signal_context * const c);
};

View File

@ -1,5 +1,5 @@
/*
* \brief Kernel backend for execution contexts in userland
* \brief Kernel back-end for execution contexts in userland
* \author Martin Stein
* \author Stefan Kalkowski
* \date 2013-09-15
@ -236,7 +236,7 @@ void Thread::_call_start_thread()
Genode::printf("on CPU %u/%u ", cpu->id(), NR_OF_CPUS); }
Genode::printf("\n");
}
thread->_init((Native_utcb *)user_arg_4(), this);
thread->Ipc_node::_init((Native_utcb *)user_arg_4(), this);
thread->_become_active();
}
@ -683,6 +683,24 @@ void Thread::_call()
}
Thread::Thread(unsigned const priority, unsigned const quota,
char const * const label)
:
Cpu_job(priority, quota), _fault(this), _fault_pd(0), _fault_addr(0),
_fault_writes(0), _fault_signal(0), _state(AWAITS_START),
_signal_receiver(0), _label(label)
{
_init();
}
Thread_event Thread::* Thread::_event(unsigned const id) const
{
static Thread_event Thread::* _events[] = { &Thread::_fault };
return id < sizeof(_events)/sizeof(_events[0]) ? _events[id] : 0;
}
/*****************
** Core_thread **
*****************/

View File

@ -20,12 +20,7 @@
using namespace Kernel;
Thread::Thread(unsigned const priority, unsigned const quota,
char const * const label)
: Thread_base(this), Cpu_job(priority, quota),
_state(AWAITS_START), _signal_receiver(0),
_label(label) { cpu_exception = RESET; }
void Kernel::Thread::_init() { cpu_exception = RESET; }
void Thread::exception(unsigned const cpu)
@ -63,15 +58,6 @@ void Thread::exception(unsigned const cpu)
}
Thread_event Thread::* Thread::_event(unsigned const id) const
{
static Thread_event Thread::* _events[] = {
/* [0] */ &Thread::_fault
};
return id < sizeof(_events)/sizeof(_events[0]) ? _events[id] : 0;
}
void Thread::_mmu_exception()
{
_become_inactive(AWAITS_RESUME);

View File

@ -1,32 +0,0 @@
/*
* \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>
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)
{ }

View File

@ -17,12 +17,6 @@
using namespace Kernel;
Thread::Thread(unsigned const priority, unsigned const quota,
char const * const label)
: Thread_base(this), Cpu_job(priority, quota), _state(AWAITS_START),
_signal_receiver(0), _label(label) { }
void Thread::exception(unsigned const cpu)
{
switch (trapno) {
@ -51,6 +45,3 @@ void Thread::exception(unsigned const cpu)
" at ip=%p", pd_label(), label(), trapno, errcode, (void*)ip);
_stop();
}
void Thread::_call_update_pd() { }

View File

@ -1,5 +1,5 @@
/*
* \brief CPU specific implementations of core
* \brief Kernel back-end for execution contexts in userland
* \author Martin Stein
* \author Reto Buerki
* \author Stefan Kalkowski
@ -7,7 +7,7 @@
*/
/*
* Copyright (C) 2013, 2015 Genode Labs GmbH
* Copyright (C) 2013-2015 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.
@ -21,33 +21,10 @@
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 **
********************/
Thread_event Thread::* Thread::_event(unsigned const id) const
{
static Thread_event Thread::* _events[] = {
/* [0] */ &Thread::_fault
};
return id < sizeof(_events)/sizeof(_events[0]) ? _events[id] : 0;
}
void Thread::_mmu_exception()
{
_become_inactive(AWAITS_RESUME);
@ -68,6 +45,12 @@ void Thread::_mmu_exception()
}
void Thread::_init() { }
void Thread::_call_update_pd() { }
/*************************
** Kernel::Cpu_context **
*************************/

View File

@ -18,12 +18,6 @@
using namespace Kernel;
Thread::Thread(unsigned const priority, unsigned const quota,
char const * const label)
: Thread_base(this), Cpu_job(priority, quota), _state(AWAITS_START),
_signal_receiver(0), _label(label) { }
void Thread::exception(unsigned const cpu)
{
switch (trapno) {
@ -52,6 +46,3 @@ void Thread::exception(unsigned const cpu)
" at ip=%p", pd_label(), label(), trapno, errcode, (void*)ip);
_stop();
}
void Thread::_call_update_pd() { }