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:
parent
dd9793cdc7
commit
4e98a0f64a
|
@ -8,7 +8,6 @@
|
||||||
INC_DIR += $(REP_DIR)/src/core/include/spec/arm
|
INC_DIR += $(REP_DIR)/src/core/include/spec/arm
|
||||||
|
|
||||||
# add C++ sources
|
# add C++ sources
|
||||||
SRC_CC += spec/arm/kernel/thread_base.cc
|
|
||||||
SRC_CC += spec/arm/kernel/thread.cc
|
SRC_CC += spec/arm/kernel/thread.cc
|
||||||
SRC_CC += spec/arm/kernel/cpu.cc
|
SRC_CC += spec/arm/kernel/cpu.cc
|
||||||
SRC_CC += spec/arm/kernel/pd.cc
|
SRC_CC += spec/arm/kernel/pd.cc
|
||||||
|
|
|
@ -14,7 +14,7 @@ SRC_S += spec/x86_64/kernel/crt0.s
|
||||||
SRC_S += spec/x86_64/crt0.s
|
SRC_S += spec/x86_64/crt0.s
|
||||||
|
|
||||||
# add C++ sources
|
# 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/idt.cc
|
||||||
SRC_CC += spec/x86_64/tss.cc
|
SRC_CC += spec/x86_64/tss.cc
|
||||||
|
|
||||||
|
|
|
@ -18,27 +18,68 @@
|
||||||
#include <kernel/signal_receiver.h>
|
#include <kernel/signal_receiver.h>
|
||||||
#include <kernel/ipc_node.h>
|
#include <kernel/ipc_node.h>
|
||||||
#include <kernel/cpu.h>
|
#include <kernel/cpu.h>
|
||||||
#include <kernel/thread_base.h>
|
|
||||||
#include <kernel/object.h>
|
#include <kernel/object.h>
|
||||||
#include <base/signal.h>
|
#include <base/signal.h>
|
||||||
|
|
||||||
namespace Kernel
|
namespace Kernel
|
||||||
{
|
{
|
||||||
class Thread;
|
class Thread;
|
||||||
|
class Thread_event;
|
||||||
/**
|
|
||||||
* Kernel backend for userland execution-contexts
|
|
||||||
*/
|
|
||||||
class Thread;
|
|
||||||
|
|
||||||
class Core_thread;
|
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
|
class Kernel::Thread
|
||||||
: public Kernel::Object,
|
:
|
||||||
public Cpu::User_context,
|
public Kernel::Object, public Cpu::User_context, public Cpu_domain_update,
|
||||||
public Cpu_domain_update, public Ipc_node, public Signal_context_killer,
|
public Ipc_node, public Signal_context_killer, public Signal_handler,
|
||||||
public Signal_handler, public Thread_base, public Cpu_job
|
public Cpu_job
|
||||||
{
|
{
|
||||||
friend class Thread_event;
|
friend class Thread_event;
|
||||||
friend class Core_thread;
|
friend class Core_thread;
|
||||||
|
@ -58,9 +99,16 @@ class Kernel::Thread
|
||||||
STOPPED = 7,
|
STOPPED = 7,
|
||||||
};
|
};
|
||||||
|
|
||||||
State _state;
|
Thread_event _fault;
|
||||||
Signal_receiver * _signal_receiver;
|
addr_t _fault_pd;
|
||||||
char const * const _label;
|
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
|
* Notice that another thread yielded the CPU to this thread
|
||||||
|
@ -302,7 +350,11 @@ class Kernel::Thread
|
||||||
** Accessors **
|
** 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; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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_ */
|
|
|
@ -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);
|
|
||||||
};
|
|
|
@ -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 Martin Stein
|
||||||
* \author Stefan Kalkowski
|
* \author Stefan Kalkowski
|
||||||
* \date 2013-09-15
|
* \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("on CPU %u/%u ", cpu->id(), NR_OF_CPUS); }
|
||||||
Genode::printf("\n");
|
Genode::printf("\n");
|
||||||
}
|
}
|
||||||
thread->_init((Native_utcb *)user_arg_4(), this);
|
thread->Ipc_node::_init((Native_utcb *)user_arg_4(), this);
|
||||||
thread->_become_active();
|
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 **
|
** Core_thread **
|
||||||
*****************/
|
*****************/
|
||||||
|
|
|
@ -20,12 +20,7 @@
|
||||||
|
|
||||||
using namespace Kernel;
|
using namespace Kernel;
|
||||||
|
|
||||||
|
void Kernel::Thread::_init() { cpu_exception = RESET; }
|
||||||
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 Thread::exception(unsigned const cpu)
|
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()
|
void Thread::_mmu_exception()
|
||||||
{
|
{
|
||||||
_become_inactive(AWAITS_RESUME);
|
_become_inactive(AWAITS_RESUME);
|
||||||
|
|
|
@ -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)
|
|
||||||
{ }
|
|
|
@ -17,12 +17,6 @@
|
||||||
|
|
||||||
using namespace Kernel;
|
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)
|
void Thread::exception(unsigned const cpu)
|
||||||
{
|
{
|
||||||
switch (trapno) {
|
switch (trapno) {
|
||||||
|
@ -51,6 +45,3 @@ void Thread::exception(unsigned const cpu)
|
||||||
" at ip=%p", pd_label(), label(), trapno, errcode, (void*)ip);
|
" at ip=%p", pd_label(), label(), trapno, errcode, (void*)ip);
|
||||||
_stop();
|
_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Thread::_call_update_pd() { }
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* \brief CPU specific implementations of core
|
* \brief Kernel back-end for execution contexts in userland
|
||||||
* \author Martin Stein
|
* \author Martin Stein
|
||||||
* \author Reto Buerki
|
* \author Reto Buerki
|
||||||
* \author Stefan Kalkowski
|
* \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
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
|
@ -21,33 +21,10 @@
|
||||||
using namespace Kernel;
|
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 **
|
** 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()
|
void Thread::_mmu_exception()
|
||||||
{
|
{
|
||||||
_become_inactive(AWAITS_RESUME);
|
_become_inactive(AWAITS_RESUME);
|
||||||
|
@ -68,6 +45,12 @@ void Thread::_mmu_exception()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Thread::_init() { }
|
||||||
|
|
||||||
|
|
||||||
|
void Thread::_call_update_pd() { }
|
||||||
|
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
** Kernel::Cpu_context **
|
** Kernel::Cpu_context **
|
||||||
*************************/
|
*************************/
|
|
@ -18,12 +18,6 @@
|
||||||
|
|
||||||
using namespace Kernel;
|
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)
|
void Thread::exception(unsigned const cpu)
|
||||||
{
|
{
|
||||||
switch (trapno) {
|
switch (trapno) {
|
||||||
|
@ -52,6 +46,3 @@ void Thread::exception(unsigned const cpu)
|
||||||
" at ip=%p", pd_label(), label(), trapno, errcode, (void*)ip);
|
" at ip=%p", pd_label(), label(), trapno, errcode, (void*)ip);
|
||||||
_stop();
|
_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Thread::_call_update_pd() { }
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user