diff --git a/repos/base-fiasco/include/base/native_types.h b/repos/base-fiasco/include/base/native_types.h
index 0946fd58e6..e0861c2d7d 100644
--- a/repos/base-fiasco/include/base/native_types.h
+++ b/repos/base-fiasco/include/base/native_types.h
@@ -65,7 +65,7 @@ namespace Genode {
/**
* Empty UTCB type expected by the thread library
*
- * On this kernel, UTCBs are not placed within the the context area. Each
+ * On this kernel, UTCBs are not placed within the the stack area. Each
* thread can request its own UTCB pointer using the kernel interface.
*/
typedef struct { } Native_utcb;
@@ -76,17 +76,17 @@ namespace Genode {
struct Native_config
{
/**
- * Thread-context area configuration.
+ * Stack area configuration
*/
- static constexpr addr_t context_area_virtual_base() {
+ static constexpr addr_t stack_area_virtual_base() {
return 0x40000000UL; }
- static constexpr addr_t context_area_virtual_size() {
+ static constexpr addr_t stack_area_virtual_size() {
return 0x10000000UL; }
/**
- * Size of virtual address region holding the context of one thread
+ * Size of virtual address region holding the stack of one thread
*/
- static constexpr addr_t context_virtual_size() { return 0x00100000UL; }
+ static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
};
struct Native_pd_args { };
diff --git a/repos/base-fiasco/lib/mk/base-common.mk b/repos/base-fiasco/lib/mk/base-common.mk
index 1b612a46ef..99d12a1642 100644
--- a/repos/base-fiasco/lib/mk/base-common.mk
+++ b/repos/base-fiasco/lib/mk/base-common.mk
@@ -21,7 +21,7 @@ SRC_CC += signal/signal.cc signal/common.cc signal/platform.cc
SRC_CC += server/server.cc server/common.cc
SRC_CC += thread/thread.cc thread/thread_bootstrap.cc thread/trace.cc
SRC_CC += thread/myself.cc
-SRC_CC += thread/context_allocator.cc
+SRC_CC += thread/stack_allocator.cc
SRC_CC += sleep.cc
SRC_CC += rm_session_client.cc
diff --git a/repos/base-fiasco/lib/mk/base.mk b/repos/base-fiasco/lib/mk/base.mk
index 6510601ba0..0b0792e1d4 100644
--- a/repos/base-fiasco/lib/mk/base.mk
+++ b/repos/base-fiasco/lib/mk/base.mk
@@ -8,7 +8,7 @@ LIBS += base-common
SRC_CC += console/log_console.cc
SRC_CC += cpu/cache.cc
-SRC_CC += env/env.cc env/context_area.cc env/reinitialize.cc
+SRC_CC += env/env.cc env/stack_area.cc env/reinitialize.cc
SRC_CC += thread/thread_start.cc
SRC_CC += irq/platform.cc
SRC_CC += server/rpc_cap_alloc.cc
diff --git a/repos/base-fiasco/src/core/platform.cc b/repos/base-fiasco/src/core/platform.cc
index e0bc786e88..40e8098393 100644
--- a/repos/base-fiasco/src/core/platform.cc
+++ b/repos/base-fiasco/src/core/platform.cc
@@ -306,8 +306,8 @@ void Platform::_setup_mem_alloc()
}
region.start = addr; region.end = addr + size;
- if (!region.intersects(Native_config::context_area_virtual_base(),
- Native_config::context_area_virtual_size())) {
+ if (!region.intersects(Native_config::stack_area_virtual_base(),
+ Native_config::stack_area_virtual_size())) {
add_region(region, _ram_alloc);
add_region(region, _core_address_ranges());
}
@@ -411,9 +411,9 @@ void Platform::_setup_basics()
_vm_start = _vm_start == 0 ? L4_PAGESIZE : _vm_start;
_region_alloc.add_range(_vm_start, _vm_size);
- /* preserve context area in core's virtual address space */
- _region_alloc.remove_range(Native_config::context_area_virtual_base(),
- Native_config::context_area_virtual_size());
+ /* preserve stack area in core's virtual address space */
+ _region_alloc.remove_range(Native_config::stack_area_virtual_base(),
+ Native_config::stack_area_virtual_size());
/* I/O memory could be the whole user address space */
/* FIXME if the kernel helps to find out max address - use info here */
diff --git a/repos/base-fiasco/src/core/target.inc b/repos/base-fiasco/src/core/target.inc
index df5d270cb2..1a3f7348ea 100644
--- a/repos/base-fiasco/src/core/target.inc
+++ b/repos/base-fiasco/src/core/target.inc
@@ -2,7 +2,7 @@ TARGET = core
GEN_CORE_DIR = $(BASE_DIR)/src/core
-SRC_CC += context_area.cc \
+SRC_CC += stack_area.cc \
core_printf.cc \
core_rpc_cap_alloc.cc \
cpu_session_component.cc \
@@ -62,7 +62,7 @@ vpath signal_source_component.cc $(GEN_CORE_DIR)
vpath trace_session_component.cc $(GEN_CORE_DIR)
vpath dataspace_component.cc $(GEN_CORE_DIR)
vpath dump_alloc.cc $(GEN_CORE_DIR)
-vpath context_area.cc $(GEN_CORE_DIR)
+vpath stack_area.cc $(GEN_CORE_DIR)
vpath pager_object.cc $(GEN_CORE_DIR)
vpath pager_ep.cc $(GEN_CORE_DIR)
vpath core_printf.cc $(BASE_DIR)/src/base/console
diff --git a/repos/base-fiasco/src/core/thread_start.cc b/repos/base-fiasco/src/core/thread_start.cc
index 60712f63da..9dad277559 100644
--- a/repos/base-fiasco/src/core/thread_start.cc
+++ b/repos/base-fiasco/src/core/thread_start.cc
@@ -15,6 +15,9 @@
#include
#include
+/* base-internal includes */
+#include
+
/* core includes */
#include
#include
@@ -35,7 +38,7 @@ void Thread_base::start()
{
/* create and start platform thread */
_tid.pt = new(platform()->core_mem_alloc())
- Platform_thread(0, _context->name);
+ Platform_thread(0, _stack->name().string());
platform_specific()->core_pd()->bind_thread(_tid.pt);
diff --git a/repos/base-foc/include/base/native_types.h b/repos/base-foc/include/base/native_types.h
index b40b6e4c18..257ab9cf43 100644
--- a/repos/base-foc/include/base/native_types.h
+++ b/repos/base-foc/include/base/native_types.h
@@ -82,9 +82,29 @@ namespace Fiasco {
namespace Genode {
typedef Fiasco::l4_cap_idx_t Native_thread_id;
- typedef Fiasco::l4_cap_idx_t Native_thread;
+
+
+ struct Native_thread
+ {
+ Fiasco::l4_cap_idx_t kcap = 0;
+
+ Native_thread() { }
+ explicit Native_thread(Fiasco::l4_cap_idx_t kcap) : kcap(kcap) { }
+ };
+
+
typedef Fiasco::l4_cap_idx_t Native_task;
- typedef Fiasco::l4_utcb_t* Native_utcb;
+
+
+ struct Native_utcb
+ {
+ /*
+ * The 'Native_utcb' is located within the stack slot of the thread.
+ * We merely use it for remembering a pointer to the real UTCB, which
+ * resides somewhere in the kernel's address space.
+ */
+ Fiasco::l4_utcb_t *foc_utcb = nullptr;
+ };
/**
diff --git a/repos/base-foc/include/base/thread_state.h b/repos/base-foc/include/base/thread_state.h
index 31e6c3167e..c12c398a48 100644
--- a/repos/base-foc/include/base/thread_state.h
+++ b/repos/base-foc/include/base/thread_state.h
@@ -24,9 +24,9 @@ namespace Genode {
struct Thread_state : Thread_state_base
{
- Native_thread kcap; /* thread's gate cap in its pd */
+ Fiasco::l4_cap_idx_t kcap; /* thread's gate cap in its pd */
int id; /* id of gate capability */
- Native_utcb utcb; /* thread's utcb in its pd */
+ addr_t utcb; /* thread's utcb in its pd */
unsigned exceptions; /* counts exceptions raised by the thread */
bool paused; /* indicates whether thread is stopped */
bool in_exception; /* true if thread is in exception */
diff --git a/repos/base-foc/include/signal_source/client.h b/repos/base-foc/include/signal_source/client.h
index b5f65f598e..83f20f67bb 100644
--- a/repos/base-foc/include/signal_source/client.h
+++ b/repos/base-foc/include/signal_source/client.h
@@ -53,7 +53,7 @@ namespace Genode {
_sem = call();
l4_msgtag_t tag = l4_irq_attach(_sem.dst(), 0,
- Thread_base::myself()->tid());
+ Thread_base::myself()->tid().kcap);
if (l4_error(tag))
PERR("l4_irq_attach failed with %ld!", l4_error(tag));
}
diff --git a/repos/base-foc/include/spec/arm/base/native_config.h b/repos/base-foc/include/spec/arm/base/native_config.h
index 340ff18a0d..84aa2f0da5 100644
--- a/repos/base-foc/include/spec/arm/base/native_config.h
+++ b/repos/base-foc/include/spec/arm/base/native_config.h
@@ -1,5 +1,5 @@
/*
- * \brief Platform-specific context area definitions
+ * \brief Platform-specific stack area definitions
* \author Stefan Kalkowski
* \date 2014-01-24
*/
@@ -21,17 +21,17 @@ namespace Genode {
struct Native_config
{
/**
- * Thread-context area configuration
+ * Stack area configuration
*/
- static constexpr addr_t context_area_virtual_base() {
+ static constexpr addr_t stack_area_virtual_base() {
return 0x20000000UL; }
- static constexpr addr_t context_area_virtual_size() {
+ static constexpr addr_t stack_area_virtual_size() {
return 0x10000000UL; }
/**
- * Size of virtual address region holding the context of one thread
+ * Size of virtual address region holding the stack of one thread
*/
- static constexpr addr_t context_virtual_size() { return 0x00100000UL; }
+ static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
};
}
diff --git a/repos/base-foc/include/spec/x86/base/native_config.h b/repos/base-foc/include/spec/x86/base/native_config.h
index 8829c4195e..3036ae8603 100644
--- a/repos/base-foc/include/spec/x86/base/native_config.h
+++ b/repos/base-foc/include/spec/x86/base/native_config.h
@@ -1,5 +1,5 @@
/*
- * \brief Platform-specific context area definitions
+ * \brief Platform-specific stack area definitions
* \author Stefan Kalkowski
* \date 2014-01-24
*/
@@ -21,17 +21,17 @@ namespace Genode {
struct Native_config
{
/**
- * Thread-context area configuration
+ * Stack area configuration
*/
- static constexpr addr_t context_area_virtual_base() {
+ static constexpr addr_t stack_area_virtual_base() {
return 0x40000000UL; }
- static constexpr addr_t context_area_virtual_size() {
+ static constexpr addr_t stack_area_virtual_size() {
return 0x10000000UL; }
/**
- * Size of virtual address region holding the context of one thread
+ * Size of virtual address region holding the stack of one thread
*/
- static constexpr addr_t context_virtual_size() { return 0x00100000UL; }
+ static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
};
}
diff --git a/repos/base-foc/lib/mk/base-common.mk b/repos/base-foc/lib/mk/base-common.mk
index 1a183ef543..4c912c959e 100644
--- a/repos/base-foc/lib/mk/base-common.mk
+++ b/repos/base-foc/lib/mk/base-common.mk
@@ -21,7 +21,8 @@ SRC_CC += signal/signal.cc signal/common.cc signal/platform.cc
SRC_CC += server/server.cc server/common.cc
SRC_CC += thread/thread.cc thread/thread_bootstrap.cc thread/trace.cc
SRC_CC += thread/myself.cc
-SRC_CC += thread/context_allocator.cc
+SRC_CC += thread/stack_allocator.cc
+SRC_CC += thread/thread_utcb.cc
SRC_CC += sleep.cc
SRC_CC += rm_session_client.cc
diff --git a/repos/base-foc/lib/mk/base.mk b/repos/base-foc/lib/mk/base.mk
index bb3e929e2a..7066fa964e 100644
--- a/repos/base-foc/lib/mk/base.mk
+++ b/repos/base-foc/lib/mk/base.mk
@@ -8,7 +8,7 @@ LIBS += base-common
SRC_CC += console/log_console.cc
SRC_CC += cpu/cache.cc
-SRC_CC += env/env.cc env/context_area.cc env/reinitialize.cc \
+SRC_CC += env/env.cc env/stack_area.cc env/reinitialize.cc \
env/cap_map_remove.cc env/cap_alloc.cc
SRC_CC += thread/thread_start.cc
SRC_CC += irq/platform.cc
diff --git a/repos/base-foc/src/base/thread/thread_start.cc b/repos/base-foc/src/base/thread/thread_start.cc
index b12aa94b81..90ffb61cbd 100644
--- a/repos/base-foc/src/base/thread/thread_start.cc
+++ b/repos/base-foc/src/base/thread/thread_start.cc
@@ -19,6 +19,9 @@
#include
#include
+/* base-internal includes */
+#include
+
namespace Fiasco {
#include
}
@@ -30,8 +33,8 @@ void Thread_base::_deinit_platform_thread()
{
using namespace Fiasco;
- if (_context->utcb && _thread_cap.valid()) {
- Cap_index *i = (Cap_index*)l4_utcb_tcr_u(_context->utcb)->user[UTCB_TCR_BADGE];
+ if (_tid.kcap && _thread_cap.valid()) {
+ Cap_index *i = (Cap_index*)l4_utcb_tcr_u(utcb()->foc_utcb)->user[UTCB_TCR_BADGE];
cap_map()->remove(i);
_cpu_session->kill_thread(_thread_cap);
env()->rm_session()->remove_client(_pager_cap);
@@ -59,7 +62,7 @@ void Thread_base::_init_platform_thread(size_t weight, Type type)
return;
}
/* adjust values whose computation differs for a main thread */
- _tid = Fiasco::MAIN_THREAD_CAP;
+ _tid.kcap = Fiasco::MAIN_THREAD_CAP;
_thread_cap = env()->parent()->main_thread_cap();
if (!_thread_cap.valid())
@@ -83,15 +86,19 @@ void Thread_base::start()
Thread_state state;
try { state = _cpu_session->state(_thread_cap); }
catch (...) { throw Cpu_session::Thread_creation_failed(); }
- _tid = state.kcap;
- _context->utcb = state.utcb;
+
+ /* remember UTCB of the new thread */
+ Fiasco::l4_utcb_t * const foc_utcb = (Fiasco::l4_utcb_t *)state.utcb;
+ utcb()->foc_utcb = foc_utcb;
+
+ _tid = Native_thread(state.kcap);
Cap_index *i = cap_map()->insert(state.id, state.kcap);
- l4_utcb_tcr_u(state.utcb)->user[UTCB_TCR_BADGE] = (unsigned long) i;
- l4_utcb_tcr_u(state.utcb)->user[UTCB_TCR_THREAD_OBJ] = (addr_t)this;
+ l4_utcb_tcr_u(foc_utcb)->user[UTCB_TCR_BADGE] = (unsigned long) i;
+ l4_utcb_tcr_u(foc_utcb)->user[UTCB_TCR_THREAD_OBJ] = (addr_t)this;
/* register initial IP and SP at core */
- _cpu_session->start(_thread_cap, (addr_t)_thread_start, _context->stack_top());
+ _cpu_session->start(_thread_cap, (addr_t)_thread_start, _stack->top());
}
diff --git a/repos/base-foc/src/core/cpu_session_extension.cc b/repos/base-foc/src/core/cpu_session_extension.cc
index 88c79b15c5..e796c8253f 100644
--- a/repos/base-foc/src/core/cpu_session_extension.cc
+++ b/repos/base-foc/src/core/cpu_session_extension.cc
@@ -43,7 +43,7 @@ void Genode::Cpu_session_component::enable_vcpu(Genode::Thread_capability thread
auto lambda = [&] (Cpu_thread_component *thread) {
if (!thread) return;
- Native_thread tid = thread->platform_thread()->thread().local.dst();
+ l4_cap_idx_t tid = thread->platform_thread()->thread().local.dst();
l4_msgtag_t tag = l4_thread_vcpu_control(tid, vcpu_state);
if (l4_msgtag_has_error(tag))
@@ -103,7 +103,7 @@ void Genode::Cpu_session_component::single_step(Genode::Thread_capability thread
auto lambda = [&] (Cpu_thread_component *thread) {
if (!thread) return;
- Native_thread tid = thread->platform_thread()->thread().local.dst();
+ Fiasco::l4_cap_idx_t tid = thread->platform_thread()->thread().local.dst();
enum { THREAD_SINGLE_STEP = 0x40000 };
int flags = enable ? THREAD_SINGLE_STEP : 0;
diff --git a/repos/base-foc/src/core/include/irq_object.h b/repos/base-foc/src/core/include/irq_object.h
index 49ef03f715..e05bfd99a3 100644
--- a/repos/base-foc/src/core/include/irq_object.h
+++ b/repos/base-foc/src/core/include/irq_object.h
@@ -38,7 +38,7 @@ class Genode::Irq_object
Signal_context_capability _sig_cap;
- Native_thread _capability() const { return _cap->kcap(); }
+ Fiasco::l4_cap_idx_t _capability() const { return _cap->kcap(); }
public:
diff --git a/repos/base-foc/src/core/include/platform_pd.h b/repos/base-foc/src/core/include/platform_pd.h
index d84a4d88a5..4d362667a3 100644
--- a/repos/base-foc/src/core/include/platform_pd.h
+++ b/repos/base-foc/src/core/include/platform_pd.h
@@ -48,8 +48,8 @@ namespace Genode {
addr_t utcb_area_start()
{
- return (Native_config::context_area_virtual_base() +
- THREAD_MAX * Native_config::context_virtual_size());
+ return (Native_config::stack_area_virtual_base() +
+ THREAD_MAX * Native_config::stack_virtual_size());
}
Cap_mapping _task;
diff --git a/repos/base-foc/src/core/include/platform_thread.h b/repos/base-foc/src/core/include/platform_thread.h
index 432d35bfb4..0cc5897c5f 100644
--- a/repos/base-foc/src/core/include/platform_thread.h
+++ b/repos/base-foc/src/core/include/platform_thread.h
@@ -42,7 +42,7 @@ namespace Genode {
Cap_mapping _gate;
Cap_mapping _pager;
Cap_mapping _irq;
- Native_utcb _utcb;
+ addr_t _utcb;
char _name[32]; /* thread name that will be
registered at the kernel
debugger */
@@ -185,7 +185,7 @@ namespace Genode {
Cap_mapping& gate() { return _gate; }
const char *name() const { return _name; }
bool core_thread() const { return _core_thread; }
- Native_utcb utcb() const { return _utcb; }
+ addr_t utcb() const { return _utcb; }
};
}
diff --git a/repos/base-foc/src/core/ipc_pager.cc b/repos/base-foc/src/core/ipc_pager.cc
index 811f9829cd..ffe49a807c 100644
--- a/repos/base-foc/src/core/ipc_pager.cc
+++ b/repos/base-foc/src/core/ipc_pager.cc
@@ -106,7 +106,7 @@ void Ipc_pager::reply_and_wait_for_fault()
}
l4_utcb_mr()->mr[1] = _reply_mapping.fpage().raw;
- _tag = l4_ipc_send_and_wait(_last, l4_utcb(), snd_tag,
+ _tag = l4_ipc_send_and_wait(_last.kcap, l4_utcb(), snd_tag,
&label, L4_IPC_SEND_TIMEOUT_0);
int err = l4_ipc_error(_tag, l4_utcb());
if (err) {
@@ -119,7 +119,7 @@ void Ipc_pager::reply_and_wait_for_fault()
void Ipc_pager::acknowledge_wakeup()
{
- l4_cap_idx_t dst = Fiasco::Capability::valid(_last) ? _last : L4_SYSF_REPLY;
+ l4_cap_idx_t dst = Fiasco::Capability::valid(_last.kcap) ? _last.kcap : L4_SYSF_REPLY;
/* answer wakeup call from one of core's region-manager sessions */
l4_ipc_send(dst, l4_utcb(), l4_msgtag(0, 0, 0, 0), L4_IPC_SEND_TIMEOUT_0);
@@ -129,7 +129,7 @@ void Ipc_pager::acknowledge_wakeup()
void Ipc_pager::acknowledge_exception()
{
memcpy(l4_utcb_exc(), &_regs, sizeof(l4_exc_regs_t));
- l4_cap_idx_t dst = Fiasco::Capability::valid(_last) ? _last : L4_SYSF_REPLY;
+ l4_cap_idx_t dst = Fiasco::Capability::valid(_last.kcap) ? _last.kcap : L4_SYSF_REPLY;
l4_ipc_send(dst, l4_utcb(), l4_msgtag(0, L4_UTCB_EXCEPTION_REGS_SIZE, 0, 0), L4_IPC_SEND_TIMEOUT_0);
}
diff --git a/repos/base-foc/src/core/irq_session_component.cc b/repos/base-foc/src/core/irq_session_component.cc
index c932e019cc..1c1f198ff7 100644
--- a/repos/base-foc/src/core/irq_session_component.cc
+++ b/repos/base-foc/src/core/irq_session_component.cc
@@ -53,7 +53,7 @@ class Genode::Interrupt_handler : public Thread<2048*sizeof(long)>
void entry();
- static Native_thread handler_cap()
+ static Fiasco::l4_cap_idx_t handler_cap()
{
static Interrupt_handler handler;
return handler._thread_cap.dst();
diff --git a/repos/base-foc/src/core/pager.cc b/repos/base-foc/src/core/pager.cc
index f8fa7951b1..722c4f1807 100644
--- a/repos/base-foc/src/core/pager.cc
+++ b/repos/base-foc/src/core/pager.cc
@@ -69,7 +69,7 @@ void Pager_entrypoint::entry()
PDBG("Could not resolve pf=%p ip=%p",
(void*)_pager.fault_addr(), (void*)_pager.fault_ip());
} else {
- _pager.set_reply_dst(obj->badge());
+ _pager.set_reply_dst(Native_thread(obj->badge()));
reply_pending = true;
return;
}
@@ -99,7 +99,7 @@ void Pager_entrypoint::entry()
}
/* send wake up message to requested thread */
- _pager.set_reply_dst(obj->badge());
+ _pager.set_reply_dst(Native_thread(obj->badge()));
_pager.acknowledge_exception();
break;
}
@@ -121,7 +121,7 @@ void Pager_entrypoint::entry()
* that case we unblock it immediately.
*/
if (!obj->state.paused) {
- _pager.set_reply_dst(obj->badge());
+ _pager.set_reply_dst(Native_thread(obj->badge()));
reply_pending = true;
}
break;
diff --git a/repos/base-foc/src/core/platform.cc b/repos/base-foc/src/core/platform.cc
index 3274d139ad..5dfe65f4a4 100644
--- a/repos/base-foc/src/core/platform.cc
+++ b/repos/base-foc/src/core/platform.cc
@@ -327,8 +327,8 @@ void Platform::_setup_mem_alloc()
}
region.start = addr; region.end = addr + size;
- if (!region.intersects(Native_config::context_area_virtual_base(),
- Native_config::context_area_virtual_size())) {
+ if (!region.intersects(Native_config::stack_area_virtual_base(),
+ Native_config::stack_area_virtual_size())) {
add_region(region, _ram_alloc);
add_region(region, _core_address_ranges());
}
@@ -402,9 +402,9 @@ void Platform::_setup_basics()
_vm_start = _vm_start == 0 ? L4_PAGESIZE : _vm_start;
_region_alloc.add_range(_vm_start, _vm_size);
- /* preserve context area in core's virtual address space */
- _region_alloc.remove_range(Native_config::context_area_virtual_base(),
- Native_config::context_area_virtual_size());
+ /* preserve stack area in core's virtual address space */
+ _region_alloc.remove_range(Native_config::stack_area_virtual_base(),
+ Native_config::stack_area_virtual_size());
/* preserve utcb- area in core's virtual address space */
_region_alloc.remove_range((addr_t)l4_utcb(), L4_PAGESIZE * 16);
diff --git a/repos/base-foc/src/core/platform_pd.cc b/repos/base-foc/src/core/platform_pd.cc
index dc4dc47fa6..0c18371135 100644
--- a/repos/base-foc/src/core/platform_pd.cc
+++ b/repos/base-foc/src/core/platform_pd.cc
@@ -54,16 +54,19 @@ int Platform_pd::bind_thread(Platform_thread *thread)
if (_threads[i])
continue;
- _threads[i] = thread;
+ _threads[i] = thread;
+
if (thread->core_thread())
- thread->_utcb = (l4_utcb_t*) (core_utcb_base() + i * L4_UTCB_OFFSET);
+ thread->_utcb = (addr_t) (core_utcb_base() + i * L4_UTCB_OFFSET);
else
thread->_utcb =
- reinterpret_cast(utcb_area_start() + i * L4_UTCB_OFFSET);
- Native_thread cap_offset = THREAD_AREA_BASE + i * THREAD_AREA_SLOT;
- thread->_gate.remote = cap_offset + THREAD_GATE_CAP;
- thread->_pager.remote = cap_offset + THREAD_PAGER_CAP;
- thread->_irq.remote = cap_offset + THREAD_IRQ_CAP;
+ reinterpret_cast(utcb_area_start() + i * L4_UTCB_OFFSET);
+
+ Fiasco::l4_cap_idx_t cap_offset = THREAD_AREA_BASE + i * THREAD_AREA_SLOT;
+
+ thread->_gate.remote = cap_offset + THREAD_GATE_CAP;
+ thread->_pager.remote = cap_offset + THREAD_PAGER_CAP;
+ thread->_irq.remote = cap_offset + THREAD_IRQ_CAP;
/* if it's no core-thread we have to map parent and pager gate cap */
if (!thread->core_thread()) {
diff --git a/repos/base-foc/src/core/platform_thread.cc b/repos/base-foc/src/core/platform_thread.cc
index eb1aa7927d..938d3c31f8 100644
--- a/repos/base-foc/src/core/platform_thread.cc
+++ b/repos/base-foc/src/core/platform_thread.cc
@@ -45,7 +45,7 @@ int Platform_thread::start(void *ip, void *sp)
l4_thread_control_start();
l4_thread_control_pager(_pager.remote);
l4_thread_control_exc_handler(_pager.remote);
- l4_thread_control_bind(_utcb, _platform_pd->native_task().dst());
+ l4_thread_control_bind((l4_utcb_t *)_utcb, _platform_pd->native_task().dst());
l4_msgtag_t tag = l4_thread_control_commit(_thread.local.dst());
if (l4_msgtag_has_error(tag)) {
PWRN("l4_thread_control_commit for %lx failed!",
diff --git a/repos/base-foc/src/core/target.inc b/repos/base-foc/src/core/target.inc
index cb894d7380..0462f117c7 100644
--- a/repos/base-foc/src/core/target.inc
+++ b/repos/base-foc/src/core/target.inc
@@ -5,7 +5,7 @@ GEN_CORE_DIR = $(BASE_DIR)/src/core
LIBS += base-common
-SRC_CC += context_area.cc \
+SRC_CC += stack_area.cc \
core_printf.cc \
core_rpc_cap_alloc.cc \
cpu_session_component.cc \
@@ -45,7 +45,7 @@ INC_DIR += $(REP_DIR)/src/core/include \
include $(GEN_CORE_DIR)/version.inc
-vpath context_area.cc $(GEN_CORE_DIR)
+vpath stack_area.cc $(GEN_CORE_DIR)
vpath cpu_session_component.cc $(GEN_CORE_DIR)
vpath dataspace_component.cc $(GEN_CORE_DIR)
vpath dump_alloc.cc $(GEN_CORE_DIR)
diff --git a/repos/base-foc/src/core/thread_start.cc b/repos/base-foc/src/core/thread_start.cc
index bf751dd5a5..1338156ce5 100644
--- a/repos/base-foc/src/core/thread_start.cc
+++ b/repos/base-foc/src/core/thread_start.cc
@@ -16,6 +16,9 @@
#include
#include
+/* base-internal includes */
+#include
+
/* core includes */
#include
#include
@@ -43,19 +46,24 @@ void Thread_base::start()
/* create and start platform thread */
Platform_thread *pt =
- new(platform()->core_mem_alloc()) Platform_thread(_context->name);
+ new(platform()->core_mem_alloc()) Platform_thread(_stack->name().string());
if (platform_specific()->core_pd()->bind_thread(pt))
throw Cpu_session::Thread_creation_failed();
- _tid = pt->gate().remote;
+ l4_utcb_t *foc_utcb = (l4_utcb_t *)(pt->utcb());
+
+ _tid = Native_thread(pt->gate().remote);
+
+ utcb()->foc_utcb = foc_utcb;
+
_thread_cap =
reinterpret_cap_cast(Native_capability(pt->thread().local));
+
pt->pager(platform_specific()->core_pager());
- _context->utcb = pt->utcb();
- l4_utcb_tcr_u(pt->utcb())->user[UTCB_TCR_BADGE] = (unsigned long) pt->gate().local.idx();
- l4_utcb_tcr_u(pt->utcb())->user[UTCB_TCR_THREAD_OBJ] = (addr_t)this;
+ l4_utcb_tcr_u(foc_utcb)->user[UTCB_TCR_BADGE] = (unsigned long) pt->gate().local.idx();
+ l4_utcb_tcr_u(foc_utcb)->user[UTCB_TCR_THREAD_OBJ] = (addr_t)this;
pt->start((void *)_thread_start, stack_top());
}
diff --git a/repos/base-foc/src/include/base/internal/lock_helper.h b/repos/base-foc/src/include/base/internal/lock_helper.h
index d9c2dc1c66..c910b9ded0 100644
--- a/repos/base-foc/src/include/base/internal/lock_helper.h
+++ b/repos/base-foc/src/include/base/internal/lock_helper.h
@@ -48,7 +48,7 @@ static inline void thread_yield() { Fiasco::l4_thread_yield(); }
static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_base)
{
Genode::Native_thread_id tid = thread_base ?
- thread_base->tid() :
+ thread_base->tid().kcap :
Fiasco::MAIN_THREAD_CAP;
Genode::Native_thread_id irq = tid + Fiasco::THREAD_IRQ_CAP;
Fiasco::l4_irq_trigger(irq);
@@ -62,7 +62,7 @@ static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_
static inline void thread_switch_to(Genode::Thread_base *thread_base)
{
Genode::Native_thread_id tid = thread_base ?
- thread_base->tid() :
+ thread_base->tid().kcap :
Fiasco::MAIN_THREAD_CAP;
Fiasco::l4_thread_switch(tid);
}
@@ -82,7 +82,7 @@ static void thread_stop_myself()
Genode::Thread_base *myself = Genode::Thread_base::myself();
Genode::Native_thread_id tid = myself ?
- myself->tid() :
+ myself->tid().kcap :
Fiasco::MAIN_THREAD_CAP;
Genode::Native_thread_id irq = tid + THREAD_IRQ_CAP;
l4_irq_receive(irq, L4_IPC_NEVER);
diff --git a/repos/base-hw/include/base/native_types.h b/repos/base-hw/include/base/native_types.h
index 5ea3ef500b..e04a60ac0b 100644
--- a/repos/base-hw/include/base/native_types.h
+++ b/repos/base-hw/include/base/native_types.h
@@ -19,6 +19,7 @@
#include
#include
#include
+#include
namespace Genode
{
@@ -80,17 +81,17 @@ struct Genode::Native_region
struct Genode::Native_config
{
/**
- * Thread-context area configuration.
+ * Stack area configuration
*/
- static constexpr addr_t context_area_virtual_base() {
+ static constexpr addr_t stack_area_virtual_base() {
return 0xe0000000UL; }
- static constexpr addr_t context_area_virtual_size() {
+ static constexpr addr_t stack_area_virtual_size() {
return 0x10000000UL; }
/**
- * Size of virtual address region holding the context of one thread
+ * Size of virtual address region holding the stack of one thread
*/
- static constexpr addr_t context_virtual_size() { return 0x00100000UL; }
+ static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
};
@@ -105,8 +106,8 @@ class Genode::Native_utcb
private:
Kernel::capid_t _caps[MAX_CAP_ARGS]; /* capability buffer */
- size_t _cap_cnt = 0; /* capability counter */
- size_t _size = 0; /* bytes to transfer */
+ size_t _cap_cnt; /* capability counter */
+ size_t _size; /* bytes to transfer */
uint8_t _buf[get_page_size() - sizeof(_caps) -
sizeof(_cap_cnt) - sizeof(_size)];
@@ -190,7 +191,7 @@ namespace Genode
/**
* The main thread's UTCB, used during bootstrap of the main thread before it
- * allocates its context area, needs to be outside the virtual memory area
+ * allocates its stack area, needs to be outside the virtual memory area
* controlled by the RM session, because it is needed before the main
* thread can access its RM session.
*/
diff --git a/repos/base-hw/lib/mk/base-common.inc b/repos/base-hw/lib/mk/base-common.inc
index dcba144e8a..49842603fe 100644
--- a/repos/base-hw/lib/mk/base-common.inc
+++ b/repos/base-hw/lib/mk/base-common.inc
@@ -25,7 +25,7 @@ SRC_CC += thread/thread.cc
SRC_CC += thread/myself.cc
SRC_CC += thread/bootstrap.cc
SRC_CC += thread/trace.cc
-SRC_CC += thread/context_allocator.cc
+SRC_CC += thread/stack_allocator.cc
SRC_CC += kernel/interface.cc
SRC_CC += sleep.cc
SRC_CC += rm_session_client.cc
diff --git a/repos/base-hw/lib/mk/base.mk b/repos/base-hw/lib/mk/base.mk
index 278588f474..7fbf4eaccf 100644
--- a/repos/base-hw/lib/mk/base.mk
+++ b/repos/base-hw/lib/mk/base.mk
@@ -9,7 +9,7 @@ LIBS += base-common startup
SRC_CC += console/log_console.cc
SRC_CC += cpu/cache.cc
SRC_CC += env/env.cc
-SRC_CC += env/context_area.cc
+SRC_CC += env/stack_area.cc
SRC_CC += env/reinitialize.cc
SRC_CC += thread/start.cc
SRC_CC += irq/platform.cc
diff --git a/repos/base-hw/lib/mk/core.inc b/repos/base-hw/lib/mk/core.inc
index ea7773ba6f..ebe3c87334 100644
--- a/repos/base-hw/lib/mk/core.inc
+++ b/repos/base-hw/lib/mk/core.inc
@@ -33,7 +33,7 @@ SRC_CC += pd_assign_pci.cc
SRC_CC += platform.cc
SRC_CC += platform_pd.cc
SRC_CC += platform_thread.cc
-SRC_CC += context_area.cc
+SRC_CC += stack_area.cc
SRC_CC += ram_session_component.cc
SRC_CC += ram_session_support.cc
SRC_CC += rm_session_component.cc
diff --git a/repos/base-hw/src/base/thread/bootstrap.cc b/repos/base-hw/src/base/thread/bootstrap.cc
index 5f8f475994..cf7c61fc38 100644
--- a/repos/base-hw/src/base/thread/bootstrap.cc
+++ b/repos/base-hw/src/base/thread/bootstrap.cc
@@ -17,6 +17,9 @@
#include
#include
+/* base-internal includes */
+#include
+
/* base-hw includes */
#include
@@ -57,9 +60,9 @@ void prepare_reinit_main_thread() { prepare_init_main_thread(); }
** Thread_base **
*****************/
-Native_utcb * Thread_base::utcb()
+Native_utcb *Thread_base::utcb()
{
- if (this) { return &_context->utcb; }
+ if (this) { return &_stack->utcb(); }
return utcb_main_thread();
}
diff --git a/repos/base-hw/src/base/thread/start.cc b/repos/base-hw/src/base/thread/start.cc
index 8ac1d69347..46dce2d9fd 100644
--- a/repos/base-hw/src/base/thread/start.cc
+++ b/repos/base-hw/src/base/thread/start.cc
@@ -18,9 +18,12 @@
#include
#include
+/* base-internal includes */
+#include
+
using namespace Genode;
-namespace Genode { Rm_session * env_context_area_rm_session(); }
+namespace Genode { Rm_session * env_stack_area_rm_session(); }
namespace Hw {
extern Ram_dataspace_capability _main_thread_utcb_ds;
@@ -39,18 +42,19 @@ void Thread_base::_init_platform_thread(size_t weight, Type type)
/* create server object */
char buf[48];
name(buf, sizeof(buf));
- addr_t const utcb = (addr_t)&_context->utcb;
+ addr_t const utcb = (addr_t)&_stack->utcb();
_thread_cap = _cpu_session->create_thread(weight, buf, utcb);
return;
}
/* if we got reinitialized we have to get rid of the old UTCB */
- size_t const utcb_size = sizeof(Native_utcb);
- addr_t const context_area = Native_config::context_area_virtual_base();
- addr_t const utcb_new = (addr_t)&_context->utcb - context_area;
- Rm_session * const rm = env_context_area_rm_session();
+ size_t const utcb_size = sizeof(Native_utcb);
+ addr_t const stack_area = Native_config::stack_area_virtual_base();
+ addr_t const utcb_new = (addr_t)&_stack->utcb() - stack_area;
+ Rm_session * const rm = env_stack_area_rm_session();
+
if (type == REINITIALIZED_MAIN) { rm->detach(utcb_new); }
- /* remap initial main-thread UTCB according to context-area spec */
+ /* remap initial main-thread UTCB according to stack-area spec */
try { rm->attach_at(Hw::_main_thread_utcb_ds, utcb_new, utcb_size); }
catch(...) {
PERR("failed to re-map UTCB");
@@ -69,12 +73,12 @@ void Thread_base::_deinit_platform_thread()
_cpu_session->kill_thread(_thread_cap);
- /* detach userland thread-context */
- size_t const size = sizeof(_context->utcb);
- addr_t utcb = Context_allocator::addr_to_base(_context) +
- Native_config::context_virtual_size() - size -
- Native_config::context_area_virtual_base();
- env_context_area_rm_session()->detach(utcb);
+ /* detach userland stack */
+ size_t const size = sizeof(_stack->utcb());
+ addr_t utcb = Stack_allocator::addr_to_base(_stack) +
+ Native_config::stack_virtual_size() - size -
+ Native_config::stack_area_virtual_base();
+ env_stack_area_rm_session()->detach(utcb);
if (_pager_cap.valid()) {
env()->rm_session()->remove_client(_pager_cap);
@@ -91,20 +95,20 @@ void Thread_base::start()
_pager_cap = env()->rm_session()->add_client(_thread_cap);
_cpu_session->set_pager(_thread_cap, _pager_cap);
- /* attach userland thread-context */
+ /* attach userland stack */
try {
Ram_dataspace_capability ds = _cpu_session->utcb(_thread_cap);
- size_t const size = sizeof(_context->utcb);
- addr_t dst = Context_allocator::addr_to_base(_context) +
- Native_config::context_virtual_size() - size -
- Native_config::context_area_virtual_base();
- env_context_area_rm_session()->attach_at(ds, dst, size);
+ size_t const size = sizeof(_stack->utcb());
+ addr_t dst = Stack_allocator::addr_to_base(_stack) +
+ Native_config::stack_virtual_size() - size -
+ Native_config::stack_area_virtual_base();
+ env_stack_area_rm_session()->attach_at(ds, dst, size);
} catch (...) {
- PERR("failed to attach userland thread-context");
+ PERR("failed to attach userland stack");
sleep_forever();
}
/* start thread with its initial IP and aligned SP */
- _cpu_session->start(_thread_cap, (addr_t)_thread_start, _context->stack_top());
+ _cpu_session->start(_thread_cap, (addr_t)_thread_start, _stack->top());
}
diff --git a/repos/base-hw/src/core/include/platform_thread.h b/repos/base-hw/src/core/include/platform_thread.h
index 2607ff20f6..f2f140a2d8 100644
--- a/repos/base-hw/src/core/include/platform_thread.h
+++ b/repos/base-hw/src/core/include/platform_thread.h
@@ -95,7 +95,7 @@ namespace Genode {
* \param quota CPU quota that shall be granted to the thread
* \param label debugging label
* \param virt_prio unscaled processor-scheduling priority
- * \param utcb core local pointer to userland thread-context
+ * \param utcb core local pointer to userland stack
*/
Platform_thread(size_t const quota, const char * const label,
unsigned const virt_prio, addr_t const utcb);
diff --git a/repos/base-hw/src/core/platform.cc b/repos/base-hw/src/core/platform.cc
index 48a75bb7a5..1ad82bdfde 100644
--- a/repos/base-hw/src/core/platform.cc
+++ b/repos/base-hw/src/core/platform.cc
@@ -138,8 +138,8 @@ Platform::Platform()
/* preserve stack area in core's virtual address space */
_core_mem_alloc.virt_alloc()->remove_range(
- Native_config::context_area_virtual_base(),
- Native_config::context_area_virtual_size());
+ Native_config::stack_area_virtual_base(),
+ Native_config::stack_area_virtual_size());
_init_io_port_alloc();
diff --git a/repos/base-hw/src/core/thread_start.cc b/repos/base-hw/src/core/thread_start.cc
index cee122b94d..307e1e726b 100644
--- a/repos/base-hw/src/core/thread_start.cc
+++ b/repos/base-hw/src/core/thread_start.cc
@@ -17,6 +17,9 @@
#include
#include
+/* base-internal stack */
+#include
+
/* core includes */
#include
#include
@@ -25,11 +28,10 @@
using namespace Genode;
-namespace Genode { Rm_session * env_context_area_rm_session(); }
+namespace Genode { Rm_session *env_stack_area_rm_session(); }
+
+namespace Hw { extern Untyped_capability _main_thread_cap; }
-namespace Hw {
- extern Untyped_capability _main_thread_cap;
-}
void Thread_base::start()
{
@@ -56,13 +58,13 @@ void Thread_base::_init_platform_thread(size_t, Type type)
{
if (type == NORMAL) {
_tid.platform_thread = new (platform()->core_mem_alloc())
- Platform_thread(_context->name, &_context->utcb);
+ Platform_thread(_stack->name().string(), &_stack->utcb());
return;
}
- /* remap initial main-thread UTCB according to context-area spec */
+ /* remap initial main-thread UTCB according to stack-area spec */
Genode::map_local((addr_t)Kernel::Core_thread::singleton().utcb(),
- (addr_t)&_context->utcb,
+ (addr_t)&_stack->utcb(),
max(sizeof(Native_utcb) / get_page_size(), (size_t)1));
/* adjust initial object state in case of a main thread */
diff --git a/repos/base-linux/include/base/native_types.h b/repos/base-linux/include/base/native_types.h
index da9b9d1716..a859d2ad7d 100644
--- a/repos/base-linux/include/base/native_types.h
+++ b/repos/base-linux/include/base/native_types.h
@@ -26,7 +26,7 @@
* Genode from POSIX.
*/
-extern Genode::addr_t _context_area_start;
+extern Genode::addr_t _stack_area_start;
namespace Genode {
@@ -128,21 +128,21 @@ namespace Genode {
struct Native_config
{
/**
- * Thread-context area configuration.
+ * Stack area configuration
*
* Please update platform-specific files after changing these
- * functions, e.g., 'base-linux/src/ld/context_area.*.ld'.
+ * functions, e.g., 'base-linux/src/ld/stack_area.*.ld'.
*/
- static addr_t context_area_virtual_base() {
- return align_addr((addr_t)&_context_area_start, 20); }
+ static addr_t stack_area_virtual_base() {
+ return align_addr((addr_t)&_stack_area_start, 20); }
- static constexpr addr_t context_area_virtual_size() {
+ static constexpr addr_t stack_area_virtual_size() {
return 0x10000000UL; }
/**
- * Size of virtual address region holding the context of one thread
+ * Size of virtual address region holding the stack of one thread
*/
- static constexpr addr_t context_virtual_size() { return 0x00100000UL; }
+ static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
};
class Native_pd_args
diff --git a/repos/base-linux/lib/mk/base-common.mk b/repos/base-linux/lib/mk/base-common.mk
index 4d754f701a..6dbec89bc2 100644
--- a/repos/base-linux/lib/mk/base-common.mk
+++ b/repos/base-linux/lib/mk/base-common.mk
@@ -19,7 +19,7 @@ SRC_CC += lock/lock.cc
SRC_CC += env/rm_session_mmap.cc env/debug.cc
SRC_CC += signal/signal.cc signal/common.cc signal/platform.cc
SRC_CC += server/server.cc server/common.cc
-SRC_CC += thread/trace.cc thread/thread_env.cc thread/context_allocator.cc
+SRC_CC += thread/trace.cc thread/thread_env.cc thread/stack_allocator.cc
SRC_CC += irq/platform.cc
SRC_CC += sleep.cc
SRC_CC += rm_session_client.cc
diff --git a/repos/base-linux/lib/mk/base.inc b/repos/base-linux/lib/mk/base.inc
index 4aec5c5607..42572634c0 100644
--- a/repos/base-linux/lib/mk/base.inc
+++ b/repos/base-linux/lib/mk/base.inc
@@ -10,7 +10,7 @@
LIBS += base-common syscall cxx
SRC_CC += console/log_console.cc
-SRC_CC += env/env.cc env/platform_env.cc env/context_area.cc
+SRC_CC += env/env.cc env/platform_env.cc env/stack_area.cc
SRC_CC += server/rpc_cap_alloc.cc
INC_DIR += $(REP_DIR)/src/include $(BASE_DIR)/src/include
diff --git a/repos/base-linux/mk/spec/linux.mk b/repos/base-linux/mk/spec/linux.mk
index a1131f7fc8..96bd24e04e 100644
--- a/repos/base-linux/mk/spec/linux.mk
+++ b/repos/base-linux/mk/spec/linux.mk
@@ -4,13 +4,13 @@
#
# Startup code to be used when building a program and linker script that is
-# specific for Linux. We also reserve the thread-context area via a segment in
+# specific for Linux. We also reserve the stack area via a segment in
# the program under Linux to prevent clashes with vdso.
#
ifneq ($(USE_HOST_LD_SCRIPT),yes)
LD_TEXT_ADDR ?= 0x01000000
LD_SCRIPT_STATIC = $(call select_from_repositories,src/ld/genode.ld) \
- $(call select_from_repositories,src/ld/context_area.nostdlib.ld)
+ $(call select_from_repositories,src/ld/stack_area.nostdlib.ld)
else
LD_SCRIPT_STATIC ?=
endif
diff --git a/repos/base-linux/mk/spec/linux_arm.mk b/repos/base-linux/mk/spec/linux_arm.mk
index 150388a2e0..262db0186e 100644
--- a/repos/base-linux/mk/spec/linux_arm.mk
+++ b/repos/base-linux/mk/spec/linux_arm.mk
@@ -10,7 +10,7 @@ endif
#
# We need to manually add the default linker script on the command line in case
# of standard library use. Otherwise, we were not able to extend it by the
-# context area section.
+# stack area section.
#
ifeq ($(USE_HOST_LD_SCRIPT),yes)
LD_SCRIPT_STATIC = ldscripts/armelf_linux_eabi.xc
diff --git a/repos/base-linux/mk/spec/linux_x86_32.mk b/repos/base-linux/mk/spec/linux_x86_32.mk
index 7d3488ca92..dbea24d8a2 100644
--- a/repos/base-linux/mk/spec/linux_x86_32.mk
+++ b/repos/base-linux/mk/spec/linux_x86_32.mk
@@ -6,7 +6,7 @@ SPECS += linux x86_32
#
# We need to manually add the default linker script on the command line in case
# of standard library use. Otherwise, we were not able to extend it by the
-# context area section.
+# stack area section.
#
ifeq ($(USE_HOST_LD_SCRIPT),yes)
LD_SCRIPT_DEFAULT = ldscripts/elf_i386.xc
diff --git a/repos/base-linux/mk/spec/linux_x86_64.mk b/repos/base-linux/mk/spec/linux_x86_64.mk
index f3145caa74..b9f5cdfc07 100644
--- a/repos/base-linux/mk/spec/linux_x86_64.mk
+++ b/repos/base-linux/mk/spec/linux_x86_64.mk
@@ -6,7 +6,7 @@ SPECS += linux x86_64
#
# We need to manually add the default linker script on the command line in case
# of standard library use. Otherwise, we were not able to extend it by the
-# context area section.
+# stack area section.
#
ifeq ($(USE_HOST_LD_SCRIPT),yes)
LD_SCRIPT_DEFAULT = ldscripts/elf_x86_64.xc
diff --git a/repos/base-linux/src/base/env/rm_session_mmap.cc b/repos/base-linux/src/base/env/rm_session_mmap.cc
index 58ff015004..687434c15b 100644
--- a/repos/base-linux/src/base/env/rm_session_mmap.cc
+++ b/repos/base-linux/src/base/env/rm_session_mmap.cc
@@ -8,7 +8,7 @@
* dataspaces and 2) get the kernel to manage VM regions as we intent.
*
* The kernel sets up mappings for the binary on execve(), which are text and
- * data segments, the context area and special regions (stack, vdso, vsyscall).
+ * data segments, the stack area and special regions (stack, vdso, vsyscall).
* Later mappings are done by the Genode program itself, which knows nothing
* about these initial mappings. Therefore, most mmap() operations are _soft_
* to detect region conflicts with existing mappings or let the kernel find
@@ -17,10 +17,10 @@
* but not populated dataspaces are "holes" in the Linux VM space represented
* by PROT_NONE mappings (see _reserve_local()).
*
- * The context area is a managed dataspace as on other platforms, which is
+ * The stack area is a managed dataspace as on other platforms, which is
* created and attached during program launch. The managed dataspace replaces
* the inital reserved area, which is therefore flushed beforehand. Hybrid
- * programs have no context area.
+ * programs have no stack area.
*
* Note, we do not support nesting of managed dataspaces.
*/
@@ -40,7 +40,7 @@
/* base-internal includes */
#include
#include
-#include
+#include
using namespace Genode;
@@ -58,13 +58,13 @@ addr_t Platform_env_base::Rm_session_mmap::_reserve_local(bool use_loc
addr_t local_addr,
Genode::size_t size)
{
- /* special handling for context area */
+ /* special handling for stack area */
if (use_local_addr
- && local_addr == Native_config::context_area_virtual_base()
- && size == Native_config::context_area_virtual_size()) {
+ && local_addr == Native_config::stack_area_virtual_base()
+ && size == Native_config::stack_area_virtual_size()) {
/*
- * On the first request to reserve the context area, we flush the
+ * On the first request to reserve the stack area, we flush the
* initial mapping preserved in linker script and apply the actual
* reservation. Subsequent requests are just ignored.
*/
@@ -73,8 +73,8 @@ addr_t Platform_env_base::Rm_session_mmap::_reserve_local(bool use_loc
{
Context()
{
- flush_context_area();
- reserve_context_area();
+ flush_stack_area();
+ reserve_stack_area();
}
} inst;
diff --git a/repos/base-linux/src/base/thread/thread_linux.cc b/repos/base-linux/src/base/thread/thread_linux.cc
index 2ff5243d80..07fbc26fd1 100644
--- a/repos/base-linux/src/base/thread/thread_linux.cc
+++ b/repos/base-linux/src/base/thread/thread_linux.cc
@@ -19,6 +19,9 @@
#include
#include
+/* base-internal includes */
+#include
+
/* Linux syscall bindings */
#include
@@ -77,7 +80,7 @@ void Thread_base::_init_platform_thread(size_t weight, Type type)
/* for normal threads create an object at the CPU session */
if (type == NORMAL) {
- _thread_cap = _cpu_session->create_thread(weight, _context->name);
+ _thread_cap = _cpu_session->create_thread(weight, _stack->name().string());
return;
}
/* adjust initial object state for main threads */
diff --git a/repos/base-linux/src/core/include/core_env.h b/repos/base-linux/src/core/include/core_env.h
index 00574231ba..9aad5d5b71 100644
--- a/repos/base-linux/src/core/include/core_env.h
+++ b/repos/base-linux/src/core/include/core_env.h
@@ -28,7 +28,6 @@
/* base-internal includes */
#include
-
namespace Genode {
/**
diff --git a/repos/base-linux/src/core/context_area.cc b/repos/base-linux/src/core/stack_area.cc
similarity index 67%
rename from repos/base-linux/src/core/context_area.cc
rename to repos/base-linux/src/core/stack_area.cc
index 6137b415a2..d6b4ea2936 100644
--- a/repos/base-linux/src/core/context_area.cc
+++ b/repos/base-linux/src/core/stack_area.cc
@@ -18,29 +18,29 @@
#include
/* base-internal includes */
-#include
+#include
/**
- * Region-manager session for allocating thread contexts
+ * Region-manager session for allocating stacks
*
- * This class corresponds to the managed dataspace that is normally
- * used for organizing thread contexts with the thread context area.
- * It "emulates" the sub address space by adjusting the local address
- * argument to 'attach' with the offset of the thread context area.
+ * This class corresponds to the managed dataspace that is normally used for
+ * organizing stacks within the stack. It "emulates" the sub address space by
+ * adjusting the local address argument to 'attach' with the offset of the
+ * stack area.
*/
-class Context_area_rm_session : public Genode::Rm_session
+class Stack_area_rm_session : public Genode::Rm_session
{
public:
- Context_area_rm_session()
+ Stack_area_rm_session()
{
- flush_context_area();
- reserve_context_area();
+ flush_stack_area();
+ reserve_stack_area();
}
/**
- * Attach backing store to thread-context area
+ * Attach backing store to stack area
*/
Local_addr attach(Genode::Dataspace_capability ds_cap,
Genode::size_t size, Genode::off_t offset,
@@ -49,9 +49,9 @@ class Context_area_rm_session : public Genode::Rm_session
{
using namespace Genode;
- /* convert context-area-relative to absolute virtual address */
+ /* convert stack-area-relative to absolute virtual address */
addr_t addr = local_addr;
- addr += Native_config::context_area_virtual_base();
+ addr += Native_config::stack_area_virtual_base();
/* use anonymous mmap for allocating stack backing store */
int flags = MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE;
@@ -65,7 +65,7 @@ class Context_area_rm_session : public Genode::Rm_session
}
void detach(Local_addr local_addr) {
- PWRN("context area detach from 0x%p - not implemented", (void *)local_addr); }
+ PWRN("stack area detach from 0x%p - not implemented", (void *)local_addr); }
Genode::Pager_capability add_client(Genode::Thread_capability) {
return Genode::Pager_capability(); }
@@ -81,7 +81,7 @@ class Context_area_rm_session : public Genode::Rm_session
};
-class Context_area_ram_session : public Genode::Ram_session
+class Stack_area_ram_session : public Genode::Ram_session
{
public:
@@ -102,19 +102,19 @@ class Context_area_ram_session : public Genode::Ram_session
/**
- * Return single instance of the context-area RM and RAM session
+ * Return single instance of the stack-area RM and RAM session
*/
namespace Genode {
- Rm_session *env_context_area_rm_session()
+ Rm_session *env_stack_area_rm_session()
{
- static Context_area_rm_session inst;
+ static Stack_area_rm_session inst;
return &inst;
}
- Ram_session *env_context_area_ram_session()
+ Ram_session *env_stack_area_ram_session()
{
- static Context_area_ram_session inst;
+ static Stack_area_ram_session inst;
return &inst;
}
}
diff --git a/repos/base-linux/src/core/target.mk b/repos/base-linux/src/core/target.mk
index e77cd1389e..64adaff218 100644
--- a/repos/base-linux/src/core/target.mk
+++ b/repos/base-linux/src/core/target.mk
@@ -24,7 +24,7 @@ SRC_CC = main.cc \
signal_source_component.cc \
trace_session_component.cc \
thread_linux.cc \
- context_area.cc \
+ stack_area.cc \
core_printf.cc \
thread.cc myself.cc
diff --git a/repos/base-linux/src/include/base/internal/platform_env.h b/repos/base-linux/src/include/base/internal/platform_env.h
index 9cc75c1aa4..b398950ed1 100644
--- a/repos/base-linux/src/include/base/internal/platform_env.h
+++ b/repos/base-linux/src/include/base/internal/platform_env.h
@@ -211,7 +211,7 @@ namespace Genode {
* the common use case of managed dataspaces as mechanism
* to reserve parts of the local address space from being
* populated by the 'env()->rm_session()'. (i.e., for the
- * context area, or for the placement of consecutive
+ * stack area, or for the placement of consecutive
* shared-library segments)
*/
addr_t _base;
diff --git a/repos/base-linux/src/include/base/internal/context_area.h b/repos/base-linux/src/include/base/internal/stack_area.h
similarity index 64%
rename from repos/base-linux/src/include/base/internal/context_area.h
rename to repos/base-linux/src/include/base/internal/stack_area.h
index c0e3630260..b17b06aff2 100644
--- a/repos/base-linux/src/include/base/internal/context_area.h
+++ b/repos/base-linux/src/include/base/internal/stack_area.h
@@ -1,5 +1,5 @@
/*
- * \brief Linux-specific utilities for context area
+ * \brief Linux-specific utilities for stack area
* \author Christian Helmuth
* \date 2013-09-26
*/
@@ -11,8 +11,8 @@
* under the terms of the GNU General Public License version 2.
*/
-#ifndef _INCLUDE__BASE__INTERNAL__CONTEXT_AREA_H_
-#define _INCLUDE__BASE__INTERNAL__CONTEXT_AREA_H_
+#ifndef _INCLUDE__BASE__INTERNAL__STACK_AREA_H_
+#define _INCLUDE__BASE__INTERNAL__STACK_AREA_H_
/* Genode includes */
#include
@@ -24,12 +24,12 @@
#include
-static inline void flush_context_area()
+static inline void flush_stack_area()
{
using namespace Genode;
- void * const base = (void *) Native_config::context_area_virtual_base();
- size_t const size = Native_config::context_area_virtual_size();
+ void * const base = (void *) Native_config::stack_area_virtual_base();
+ size_t const size = Native_config::stack_area_virtual_size();
int ret;
if ((ret = lx_munmap(base, size)) < 0) {
@@ -39,14 +39,14 @@ static inline void flush_context_area()
}
-static inline Genode::addr_t reserve_context_area()
+static inline Genode::addr_t reserve_stack_area()
{
using namespace Genode;
int const flags = MAP_ANONYMOUS | MAP_PRIVATE;
int const prot = PROT_NONE;
- size_t const size = Native_config::context_area_virtual_size();
- void * const addr_in = (void *)Native_config::context_area_virtual_base();
+ size_t const size = Native_config::stack_area_virtual_size();
+ void * const addr_in = (void *)Native_config::stack_area_virtual_base();
void * const addr_out = lx_mmap(addr_in, size, prot, flags, -1, 0);
/* reserve at local address failed - unmap incorrect mapping */
@@ -61,4 +61,4 @@ static inline Genode::addr_t reserve_context_area()
return (addr_t) addr_out;
}
-#endif /* _INCLUDE__BASE__INTERNAL__CONTEXT_AREA_H_ */
+#endif /* _INCLUDE__BASE__INTERNAL__STACK_AREA_H_ */
diff --git a/repos/base-linux/src/ld/context_area.nostdlib.ld b/repos/base-linux/src/ld/stack_area.nostdlib.ld
similarity index 70%
rename from repos/base-linux/src/ld/context_area.nostdlib.ld
rename to repos/base-linux/src/ld/stack_area.nostdlib.ld
index 2496139d45..6bf7080d7b 100644
--- a/repos/base-linux/src/ld/context_area.nostdlib.ld
+++ b/repos/base-linux/src/ld/stack_area.nostdlib.ld
@@ -13,16 +13,16 @@
PHDRS
{
- context_area PT_LOAD FLAGS(0);
+ stack_area PT_LOAD FLAGS(0);
}
SECTIONS
{
. = 0x40000000;
- _context_area_start = .;
+ _stack_area_start = .;
/*
- * Since Linux loads ldso page aligned, we align the context area after
+ * Since Linux loads ldso page aligned, we align the stack area after
* loading to a 1 MiB boundary, therefore we reserve one MiB more here.
*/
- .context_area : { . += 0x10100000; } : context_area
+ .stack_area : { . += 0x10100000; } : stack_area
}
diff --git a/repos/base-linux/src/ld/context_area.stdlib.ld b/repos/base-linux/src/ld/stack_area.stdlib.ld
similarity index 84%
rename from repos/base-linux/src/ld/context_area.stdlib.ld
rename to repos/base-linux/src/ld/stack_area.stdlib.ld
index b846c154c3..0ce4705654 100644
--- a/repos/base-linux/src/ld/context_area.stdlib.ld
+++ b/repos/base-linux/src/ld/stack_area.stdlib.ld
@@ -14,6 +14,6 @@
SECTIONS
{
. = 0x40000000;
- _context_area_start = .;
- .context_area : { . += 0x10000000; }
+ _stack_area_start = .;
+ .stack_area : { . += 0x10000000; }
}
diff --git a/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc b/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc
index d49ce0f406..da1c825164 100644
--- a/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc
+++ b/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc
@@ -20,9 +20,9 @@
extern "C" int raw_write_str(const char *str);
/**
- * Define context area
+ * Define stack area
*/
-Genode::addr_t _context_area_start;
+Genode::addr_t _stack_area_start;
enum { verbose_atexit = false };
@@ -137,7 +137,7 @@ namespace Genode {
struct Thread_meta_data
{
/**
- * Filled out by 'thread_start' function in the context of the new
+ * Filled out by 'thread_start' function in the stack of the new
* thread
*/
Thread_base * const thread_base;
@@ -419,7 +419,7 @@ Thread_base::Thread_base(size_t weight, const char *name, size_t stack_size,
PERR("pthread_create failed (returned %d, errno=%d)",
ret, errno);
destroy(env()->heap(), _tid.meta_data);
- throw Context_alloc_failed();
+ throw Out_of_stack_space();
}
_tid.meta_data->wait_for_construction();
diff --git a/repos/base-nova/include/base/native_types.h b/repos/base-nova/include/base/native_types.h
index f12d98a035..efdf315c69 100644
--- a/repos/base-nova/include/base/native_types.h
+++ b/repos/base-nova/include/base/native_types.h
@@ -241,17 +241,17 @@ namespace Genode {
struct Native_config
{
/**
- * Thread-context area configuration.
+ * Stack area configuration
*/
- static constexpr addr_t context_area_virtual_base() {
+ static constexpr addr_t stack_area_virtual_base() {
return 0xa0000000UL; }
- static constexpr addr_t context_area_virtual_size() {
+ static constexpr addr_t stack_area_virtual_size() {
return 0x10000000UL; }
/**
- * Size of virtual address region holding the context of one thread
+ * Size of virtual address region holding the stack of one thread
*/
- static constexpr addr_t context_virtual_size() { return 0x00100000UL; }
+ static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
};
struct Native_pd_args { };
diff --git a/repos/base-nova/lib/mk/base-common.mk b/repos/base-nova/lib/mk/base-common.mk
index b5b7533920..776b79bb95 100644
--- a/repos/base-nova/lib/mk/base-common.mk
+++ b/repos/base-nova/lib/mk/base-common.mk
@@ -18,9 +18,9 @@ SRC_CC += elf/elf_binary.cc
SRC_CC += lock/lock.cc
SRC_CC += signal/signal.cc signal/common.cc signal/platform.cc
SRC_CC += server/server.cc
-SRC_CC += thread/thread.cc thread/thread_context.cc thread/trace.cc
+SRC_CC += thread/thread.cc thread/stack.cc thread/trace.cc
SRC_CC += thread/myself.cc
-SRC_CC += thread/context_allocator.cc env/cap_map.cc
+SRC_CC += thread/stack_allocator.cc env/cap_map.cc
SRC_CC += sleep.cc
SRC_CC += rm_session_client.cc
diff --git a/repos/base-nova/lib/mk/base.mk b/repos/base-nova/lib/mk/base.mk
index 502d4204cb..02269b63c9 100644
--- a/repos/base-nova/lib/mk/base.mk
+++ b/repos/base-nova/lib/mk/base.mk
@@ -8,7 +8,7 @@ LIBS += base-common
SRC_CC += console/log_console.cc
SRC_CC += cpu/cache.cc
-SRC_CC += env/env.cc env/context_area.cc env/reinitialize.cc
+SRC_CC += env/env.cc env/stack_area.cc env/reinitialize.cc
SRC_CC += thread/thread_nova.cc
SRC_CC += irq/platform.cc
SRC_CC += server/rpc_cap_alloc.cc
diff --git a/repos/base-nova/src/base/server/server.cc b/repos/base-nova/src/base/server/server.cc
index 9c350e4676..ee5a1e1770 100644
--- a/repos/base-nova/src/base/server/server.cc
+++ b/repos/base-nova/src/base/server/server.cc
@@ -18,6 +18,9 @@
#include
#include
+/* base-internal includes */
+#include
+
/* NOVA includes */
#include
#include
@@ -213,7 +216,7 @@ Rpc_entrypoint::Rpc_entrypoint(Pd_session *pd_session, size_t stack_size,
throw Cpu_session::Thread_creation_failed();
/* prepare portal receive window of new thread */
- if (!_rcv_buf.prepare_rcv_window((Nova::Utcb *)&_context->utcb))
+ if (!_rcv_buf.prepare_rcv_window((Nova::Utcb *)&_stack->utcb()))
throw Cpu_session::Thread_creation_failed();
if (start_on_construction)
diff --git a/repos/base-nova/src/base/thread/thread_context.cc b/repos/base-nova/src/base/thread/stack.cc
similarity index 89%
rename from repos/base-nova/src/base/thread/thread_context.cc
rename to repos/base-nova/src/base/thread/stack.cc
index 9d75d58cfb..c3acea199f 100644
--- a/repos/base-nova/src/base/thread/thread_context.cc
+++ b/repos/base-nova/src/base/thread/stack.cc
@@ -1,5 +1,5 @@
/*
- * \brief Thread-context specific part of the thread library
+ * \brief Stack-specific part of the thread library
* \author Norman Feske
* \author Alexander Boettcher
* \author Martin Stein
@@ -21,6 +21,9 @@
#include
#include
+/* base-internal includes */
+#include
+
/* base-nova includes */
#include
@@ -37,8 +40,8 @@ Native_utcb * main_thread_utcb()
{
using namespace Genode;
return reinterpret_cast(
- Native_config::context_area_virtual_base() +
- Native_config::context_virtual_size() - Nova::PAGE_SIZE_BYTE);
+ Native_config::stack_area_virtual_base() +
+ Native_config::stack_virtual_size() - Nova::PAGE_SIZE_BYTE);
}
@@ -119,5 +122,5 @@ Native_utcb *Thread_base::utcb()
*/
if (this == 0) return main_thread_utcb();
- return &_context->utcb;
+ return &_stack->utcb();
}
diff --git a/repos/base-nova/src/base/thread/thread_nova.cc b/repos/base-nova/src/base/thread/thread_nova.cc
index ddd2cc3e39..f91049387e 100644
--- a/repos/base-nova/src/base/thread/thread_nova.cc
+++ b/repos/base-nova/src/base/thread/thread_nova.cc
@@ -18,10 +18,12 @@
#include
#include
#include
-
#include
#include
+/* base-internal includes */
+#include
+
/* NOVA includes */
#include
#include
@@ -99,7 +101,7 @@ void Thread_base::_init_platform_thread(size_t weight, Type type)
* afterwards.
*/
Rights rwx(true, true, true);
- addr_t utcb = reinterpret_cast(&_context->utcb);
+ addr_t utcb = reinterpret_cast(&_stack->utcb());
revoke(Mem_crd(utcb >> 12, 0, rwx));
_tid.exc_pt_sel = cap_map()->insert(NUM_INITIAL_PT_LOG2);
@@ -177,7 +179,7 @@ void Thread_base::start()
try { _cpu_session->state(_thread_cap, state); }
catch (...) { throw Cpu_session::Thread_creation_failed(); }
- if (_cpu_session->start(_thread_cap, thread_ip, _context->stack_top()))
+ if (_cpu_session->start(_thread_cap, thread_ip, _stack->top()))
throw Cpu_session::Thread_creation_failed();
/* request native EC thread cap */
diff --git a/repos/base-nova/src/core/include/platform_thread.h b/repos/base-nova/src/core/include/platform_thread.h
index a17e07f502..9674b37a9c 100644
--- a/repos/base-nova/src/core/include/platform_thread.h
+++ b/repos/base-nova/src/core/include/platform_thread.h
@@ -21,6 +21,9 @@
#include
#include
+/* base-internal includes */
+#include
+
/* core includes */
#include
#include
@@ -43,10 +46,10 @@ namespace Genode {
VCPU = 0x2U,
WORKER = 0x4U,
};
- uint8_t _features;
- uint8_t _priority;
+ uint8_t _features;
+ uint8_t _priority;
- char _name[Thread_base::Context::NAME_LEN];
+ Stack::Name _name;
addr_t _sel_ec() const { return _id_base; }
addr_t _sel_pt_oom() const { return _id_base + 1; }
diff --git a/repos/base-nova/src/core/platform.cc b/repos/base-nova/src/core/platform.cc
index ccadbdcc38..984fac4e87 100644
--- a/repos/base-nova/src/core/platform.cc
+++ b/repos/base-nova/src/core/platform.cc
@@ -126,13 +126,13 @@ static void page_fault_handler()
pf_type & Ipc_pager::ERR_W ? "W" : "w",
pf_type & Ipc_pager::ERR_P ? "P" : "p");
- if ((Native_config::context_area_virtual_base() <= pf_sp) &&
- (pf_sp < Native_config::context_area_virtual_base() +
- Native_config::context_area_virtual_size()))
+ if ((Native_config::stack_area_virtual_base() <= pf_sp) &&
+ (pf_sp < Native_config::stack_area_virtual_base() +
+ Native_config::stack_area_virtual_size()))
{
- addr_t utcb_addr_f = pf_sp / Native_config::context_virtual_size();
- utcb_addr_f *= Native_config::context_virtual_size();
- utcb_addr_f += Native_config::context_virtual_size();
+ addr_t utcb_addr_f = pf_sp / Native_config::stack_virtual_size();
+ utcb_addr_f *= Native_config::stack_virtual_size();
+ utcb_addr_f += Native_config::stack_virtual_size();
utcb_addr_f -= 4096;
Nova::Utcb * utcb_fault = reinterpret_cast(utcb_addr_f);
@@ -397,9 +397,9 @@ Platform::Platform() :
/* preserve Bios Data Area (BDA) in core's virtual address space */
region_alloc()->remove_range(BDA_VIRT_ADDR, 0x1000);
- /* preserve context area in core's virtual address space */
- region_alloc()->remove_range(Native_config::context_area_virtual_base(),
- Native_config::context_area_virtual_size());
+ /* preserve stack area in core's virtual address space */
+ region_alloc()->remove_range(Native_config::stack_area_virtual_base(),
+ Native_config::stack_area_virtual_size());
/* exclude utcb of core pager thread + empty guard pages before and after */
region_alloc()->remove_range(CORE_PAGER_UTCB_ADDR - get_page_size(),
@@ -420,14 +420,14 @@ Platform::Platform() :
};
for (unsigned i = 0; i < sizeof(check) / sizeof(check[0]); i++) {
- if (Native_config::context_area_virtual_base() <= check[i] &&
- check[i] < Native_config::context_area_virtual_base() +
- Native_config::context_area_virtual_size())
+ if (Native_config::stack_area_virtual_base() <= check[i] &&
+ check[i] < Native_config::stack_area_virtual_base() +
+ Native_config::stack_area_virtual_size())
{
PERR("overlapping area - [%lx, %lx) vs %lx",
- Native_config::context_area_virtual_base(),
- Native_config::context_area_virtual_base() +
- Native_config::context_area_virtual_size(), check[i]);
+ Native_config::stack_area_virtual_base(),
+ Native_config::stack_area_virtual_base() +
+ Native_config::stack_area_virtual_size(), check[i]);
nova_die();
}
}
diff --git a/repos/base-nova/src/core/platform_thread.cc b/repos/base-nova/src/core/platform_thread.cc
index ff1e7d6360..f311a7f0ba 100644
--- a/repos/base-nova/src/core/platform_thread.cc
+++ b/repos/base-nova/src/core/platform_thread.cc
@@ -119,8 +119,8 @@ int Platform_thread::start(void *ip, void *sp)
_sel_exc_base = is_vcpu() ? _pager->exc_pt_vcpu() : _pager->exc_pt_sel_client();
if (!is_vcpu()) {
- pd_utcb = Native_config::context_area_virtual_base() +
- Native_config::context_virtual_size() - get_page_size();
+ pd_utcb = Native_config::stack_area_virtual_base() +
+ Native_config::stack_virtual_size() - get_page_size();
addr_t remap_src[] = { _pd->parent_pt_sel(), _pager->Object_pool::Entry::cap().local_name() };
addr_t remap_dst[] = { PT_SEL_PARENT, PT_SEL_MAIN_PAGER };
@@ -315,7 +315,7 @@ Native_capability Platform_thread::single_step(bool on)
unsigned long Platform_thread::pager_object_badge() const
{
- return reinterpret_cast(_name);
+ return reinterpret_cast(_name.string());
}
@@ -353,17 +353,16 @@ Platform_thread::Platform_thread(const char *name, unsigned prio, int thread_id)
_pd(0), _pager(0), _id_base(cap_map()->insert(2)),
_sel_exc_base(Native_thread::INVALID_INDEX), _location(boot_cpu(), 0, 0, 0),
_features(0),
- _priority(Cpu_session::scale_priority(Nova::Qpd::DEFAULT_PRIORITY, prio))
+ _priority(Cpu_session::scale_priority(Nova::Qpd::DEFAULT_PRIORITY, prio)),
+ _name(name)
{
- strncpy(_name, name, sizeof(_name));
-
if (_priority == 0) {
- PWRN("priority of thread '%s' below minimum - boost to 1", _name);
+ PWRN("priority of thread '%s' below minimum - boost to 1", _name.string());
_priority = 1;
}
if (_priority > Nova::Qpd::DEFAULT_PRIORITY) {
PWRN("priority of thread '%s' above maximum - limit to %u",
- _name, Nova::Qpd::DEFAULT_PRIORITY);
+ _name.string(), Nova::Qpd::DEFAULT_PRIORITY);
_priority = Nova::Qpd::DEFAULT_PRIORITY;
}
}
diff --git a/repos/base-nova/src/core/target.inc b/repos/base-nova/src/core/target.inc
index d62f9974f7..6d8c0ee31f 100644
--- a/repos/base-nova/src/core/target.inc
+++ b/repos/base-nova/src/core/target.inc
@@ -3,7 +3,7 @@ LIBS = base-common core
GEN_CORE_DIR = $(BASE_DIR)/src/core
-SRC_CC = context_area.cc \
+SRC_CC = stack_area.cc \
core_mem_alloc.cc \
core_printf.cc \
core_rm_session.cc \
@@ -61,6 +61,6 @@ vpath dataspace_component.cc $(GEN_CORE_DIR)
vpath core_mem_alloc.cc $(GEN_CORE_DIR)
vpath dump_alloc.cc $(GEN_CORE_DIR)
vpath platform_services.cc $(GEN_CORE_DIR)/spec/x86
-vpath context_area.cc $(GEN_CORE_DIR)
+vpath stack_area.cc $(GEN_CORE_DIR)
vpath core_printf.cc $(BASE_DIR)/src/base/console
vpath %.cc $(REP_DIR)/src/core
diff --git a/repos/base-nova/src/core/thread_start.cc b/repos/base-nova/src/core/thread_start.cc
index d8578f05cb..d648428f88 100644
--- a/repos/base-nova/src/core/thread_start.cc
+++ b/repos/base-nova/src/core/thread_start.cc
@@ -17,6 +17,9 @@
#include
#include
+/* base-internal includes */
+#include
+
/* NOVA includes */
#include
@@ -74,7 +77,7 @@ void Thread_base::_deinit_platform_thread()
/* revoke utcb */
Nova::Rights rwx(true, true, true);
- addr_t utcb = reinterpret_cast(&_context->utcb);
+ addr_t utcb = reinterpret_cast(&_stack->utcb());
Nova::revoke(Nova::Mem_crd(utcb >> 12, 0, rwx));
}
@@ -87,9 +90,9 @@ void Thread_base::start()
*/
using namespace Nova;
- addr_t sp = _context->stack_top();
- addr_t utcb = reinterpret_cast(&_context->utcb);
- Utcb * utcb_obj = reinterpret_cast(&_context->utcb);
+ addr_t sp = _stack->top();
+ addr_t utcb = reinterpret_cast(&_stack->utcb());
+ Utcb * utcb_obj = reinterpret_cast(&_stack->utcb());
addr_t pd_sel = Platform_pd::pd_core_sel();
/*
diff --git a/repos/base-okl4/include/base/native_types.h b/repos/base-okl4/include/base/native_types.h
index 9e953b6337..0365481062 100644
--- a/repos/base-okl4/include/base/native_types.h
+++ b/repos/base-okl4/include/base/native_types.h
@@ -74,7 +74,7 @@ namespace Genode {
/**
* Empty UTCB type expected by the thread library, unused on OKL4
*
- * On this kernel, UTCBs are not placed within the the context area. Each
+ * On this kernel, UTCBs are not placed within the stack area. Each
* thread can request its own UTCB pointer using the kernel interface.
*/
typedef struct { } Native_utcb;
@@ -93,17 +93,17 @@ namespace Genode {
struct Native_config
{
/**
- * Thread-context area configuration.
+ * Stack area configuration
*/
- static constexpr addr_t context_area_virtual_base() {
+ static constexpr addr_t stack_area_virtual_base() {
return 0x40000000UL; }
- static constexpr addr_t context_area_virtual_size() {
+ static constexpr addr_t stack_area_virtual_size() {
return 0x10000000UL; }
/**
- * Size of virtual address region holding the context of one thread
+ * Size of virtual address region holding the stack of one thread
*/
- static constexpr addr_t context_virtual_size() { return 0x00100000UL; }
+ static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
};
struct Native_pd_args { };
diff --git a/repos/base-okl4/lib/mk/base-common.mk b/repos/base-okl4/lib/mk/base-common.mk
index 1b612a46ef..99d12a1642 100644
--- a/repos/base-okl4/lib/mk/base-common.mk
+++ b/repos/base-okl4/lib/mk/base-common.mk
@@ -21,7 +21,7 @@ SRC_CC += signal/signal.cc signal/common.cc signal/platform.cc
SRC_CC += server/server.cc server/common.cc
SRC_CC += thread/thread.cc thread/thread_bootstrap.cc thread/trace.cc
SRC_CC += thread/myself.cc
-SRC_CC += thread/context_allocator.cc
+SRC_CC += thread/stack_allocator.cc
SRC_CC += sleep.cc
SRC_CC += rm_session_client.cc
diff --git a/repos/base-okl4/lib/mk/base.mk b/repos/base-okl4/lib/mk/base.mk
index e7e1f392f7..a58ec8a405 100644
--- a/repos/base-okl4/lib/mk/base.mk
+++ b/repos/base-okl4/lib/mk/base.mk
@@ -1,6 +1,6 @@
SRC_CC += console/log_console.cc
SRC_CC += cpu/cache.cc
-SRC_CC += env/env.cc env/context_area.cc env/reinitialize.cc
+SRC_CC += env/env.cc env/stack_area.cc env/reinitialize.cc
SRC_CC += thread/thread_start.cc
SRC_CC += irq/platform.cc
SRC_CC += server/rpc_cap_alloc.cc
diff --git a/repos/base-okl4/src/core/platform.cc b/repos/base-okl4/src/core/platform.cc
index 13eaf2b1ac..a57f3f5387 100644
--- a/repos/base-okl4/src/core/platform.cc
+++ b/repos/base-okl4/src/core/platform.cc
@@ -271,9 +271,9 @@ Platform::Platform() :
/* I/O port allocator (only meaningful for x86) */
_io_port_alloc.add_range(0, 0x10000);
- /* preserve context area in core's virtual address space */
- _core_mem_alloc.virt_alloc()->remove_range(Native_config::context_area_virtual_base(),
- Native_config::context_area_virtual_size());
+ /* preserve stack area in core's virtual address space */
+ _core_mem_alloc.virt_alloc()->remove_range(Native_config::stack_area_virtual_base(),
+ Native_config::stack_area_virtual_size());
_vm_start = 0x1000;
_vm_size = 0xb0000000 - 0x1000;
diff --git a/repos/base-okl4/src/core/target.inc b/repos/base-okl4/src/core/target.inc
index db1dcb1daf..e18197cc20 100644
--- a/repos/base-okl4/src/core/target.inc
+++ b/repos/base-okl4/src/core/target.inc
@@ -4,7 +4,7 @@ LIBS += boot_info base-common
GEN_CORE_DIR = $(BASE_DIR)/src/core
-SRC_CC += context_area.cc \
+SRC_CC += stack_area.cc \
core_mem_alloc.cc \
core_printf.cc \
core_rm_session.cc \
@@ -59,7 +59,7 @@ vpath dataspace_component.cc $(GEN_CORE_DIR)
vpath core_mem_alloc.cc $(GEN_CORE_DIR)
vpath core_rpc_cap_alloc.cc $(GEN_CORE_DIR)
vpath dump_alloc.cc $(GEN_CORE_DIR)
-vpath context_area.cc $(GEN_CORE_DIR)
+vpath stack_area.cc $(GEN_CORE_DIR)
vpath pager_ep.cc $(GEN_CORE_DIR)
vpath pager_object.cc $(GEN_CORE_DIR)
vpath %.cc $(REP_DIR)/src/core
diff --git a/repos/base-okl4/src/core/thread_start.cc b/repos/base-okl4/src/core/thread_start.cc
index c1f7c1607e..02a01b6797 100644
--- a/repos/base-okl4/src/core/thread_start.cc
+++ b/repos/base-okl4/src/core/thread_start.cc
@@ -15,6 +15,9 @@
#include
#include
+/* base-internal includes */
+#include
+
/* core includes */
#include
#include
@@ -35,7 +38,7 @@ void Thread_base::start()
{
/* create and start platform thread */
_tid.pt = new(platform_specific()->thread_slab())
- Platform_thread(0, _context->name);
+ Platform_thread(0, _stack->name().string());
if (platform_specific()->core_pd()->bind_thread(_tid.pt))
throw Cpu_session::Thread_creation_failed();
diff --git a/repos/base-pistachio/include/base/native_types.h b/repos/base-pistachio/include/base/native_types.h
index 7803408a57..84bbfffe31 100644
--- a/repos/base-pistachio/include/base/native_types.h
+++ b/repos/base-pistachio/include/base/native_types.h
@@ -65,8 +65,8 @@ namespace Genode {
/**
* Empty UTCB type expected by the thread library
*
- * On this kernel, UTCBs are not placed within the the context area. Each
- * thread can request its own UTCB pointer using the kernel interface.
+ * On this kernel, UTCBs are not placed within the stack area. Each thread
+ * can request its own UTCB pointer using the kernel interface.
*/
typedef struct { } Native_utcb;
@@ -77,17 +77,17 @@ namespace Genode {
struct Native_config
{
/**
- * Thread-context area configuration.
+ * Stack area configuration
*/
- static constexpr addr_t context_area_virtual_base() {
+ static constexpr addr_t stack_area_virtual_base() {
return 0x40000000UL; }
- static constexpr addr_t context_area_virtual_size() {
+ static constexpr addr_t stack_area_virtual_size() {
return 0x10000000UL; }
/**
- * Size of virtual address region holding the context of one thread
+ * Size of virtual address region holding the stack of one thread
*/
- static constexpr addr_t context_virtual_size() { return 0x00100000UL; }
+ static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
};
struct Native_pd_args { };
diff --git a/repos/base-pistachio/lib/mk/base-common.mk b/repos/base-pistachio/lib/mk/base-common.mk
index ea6a5cab48..02524fd49f 100644
--- a/repos/base-pistachio/lib/mk/base-common.mk
+++ b/repos/base-pistachio/lib/mk/base-common.mk
@@ -21,7 +21,7 @@ SRC_CC += signal/signal.cc signal/common.cc signal/platform.cc
SRC_CC += server/server.cc server/common.cc
SRC_CC += thread/thread.cc thread/trace.cc thread/thread_bootstrap.cc
SRC_CC += thread/myself.cc
-SRC_CC += thread/context_allocator.cc
+SRC_CC += thread/stack_allocator.cc
SRC_CC += sleep.cc
SRC_CC += rm_session_client.cc
diff --git a/repos/base-pistachio/lib/mk/base.mk b/repos/base-pistachio/lib/mk/base.mk
index 6510601ba0..0b0792e1d4 100644
--- a/repos/base-pistachio/lib/mk/base.mk
+++ b/repos/base-pistachio/lib/mk/base.mk
@@ -8,7 +8,7 @@ LIBS += base-common
SRC_CC += console/log_console.cc
SRC_CC += cpu/cache.cc
-SRC_CC += env/env.cc env/context_area.cc env/reinitialize.cc
+SRC_CC += env/env.cc env/stack_area.cc env/reinitialize.cc
SRC_CC += thread/thread_start.cc
SRC_CC += irq/platform.cc
SRC_CC += server/rpc_cap_alloc.cc
diff --git a/repos/base-pistachio/src/core/platform.cc b/repos/base-pistachio/src/core/platform.cc
index 2ff6b76efe..bd1c8b4ee2 100644
--- a/repos/base-pistachio/src/core/platform.cc
+++ b/repos/base-pistachio/src/core/platform.cc
@@ -434,8 +434,8 @@ void Platform::_setup_mem_alloc()
} else {
region.start = addr; region.end = addr + size;
- if (region.intersects(Native_config::context_area_virtual_base(),
- Native_config::context_area_virtual_size()) ||
+ if (region.intersects(Native_config::stack_area_virtual_base(),
+ Native_config::stack_area_virtual_size()) ||
intersects_kip_archdep(kip, addr, size)) {
unmap_local(region.start, size >> get_page_size_log2());
} else {
@@ -563,11 +563,11 @@ void Platform::_setup_basics()
L4_MemoryDescLow(md), L4_MemoryDescHigh(md));
}
- /* configure core's virtual memory, exclude KIP, context area */
+ /* configure core's virtual memory, exclude KIP, stack area */
_region_alloc.add_range(_vm_start, _vm_size);
_region_alloc.remove_range((addr_t)kip, kip_size);
- _region_alloc.remove_range(Native_config::context_area_virtual_base(),
- Native_config::context_area_virtual_size());
+ _region_alloc.remove_range(Native_config::stack_area_virtual_base(),
+ Native_config::stack_area_virtual_size());
/* remove KIP and MBI area from region and IO_MEM allocator */
remove_region(Region((addr_t)kip, (addr_t)kip + kip_size), _region_alloc);
diff --git a/repos/base-pistachio/src/core/target.inc b/repos/base-pistachio/src/core/target.inc
index 0b40236e67..aae5c7d4dc 100644
--- a/repos/base-pistachio/src/core/target.inc
+++ b/repos/base-pistachio/src/core/target.inc
@@ -4,7 +4,7 @@ LIBS = base-common
GEN_CORE_DIR = $(BASE_DIR)/src/core
-SRC_CC = context_area.cc \
+SRC_CC = stack_area.cc \
core_printf.cc \
core_rpc_cap_alloc.cc \
cpu_session_component.cc \
@@ -58,7 +58,7 @@ vpath trace_session_component.cc $(GEN_CORE_DIR)
vpath dataspace_component.cc $(GEN_CORE_DIR)
vpath dump_alloc.cc $(GEN_CORE_DIR)
vpath core_rpc_cap_alloc.cc $(GEN_CORE_DIR)
-vpath context_area.cc $(GEN_CORE_DIR)
+vpath stack_area.cc $(GEN_CORE_DIR)
vpath pager_ep.cc $(GEN_CORE_DIR)
vpath pager_object.cc $(GEN_CORE_DIR)
vpath core_printf.cc $(BASE_DIR)/src/base/console
diff --git a/repos/base-pistachio/src/core/thread_start.cc b/repos/base-pistachio/src/core/thread_start.cc
index 60712f63da..9dad277559 100644
--- a/repos/base-pistachio/src/core/thread_start.cc
+++ b/repos/base-pistachio/src/core/thread_start.cc
@@ -15,6 +15,9 @@
#include
#include
+/* base-internal includes */
+#include
+
/* core includes */
#include
#include
@@ -35,7 +38,7 @@ void Thread_base::start()
{
/* create and start platform thread */
_tid.pt = new(platform()->core_mem_alloc())
- Platform_thread(0, _context->name);
+ Platform_thread(0, _stack->name().string());
platform_specific()->core_pd()->bind_thread(_tid.pt);
diff --git a/repos/base-sel4/include/base/native_types.h b/repos/base-sel4/include/base/native_types.h
index cd6c1eb36c..193b0b661d 100644
--- a/repos/base-sel4/include/base/native_types.h
+++ b/repos/base-sel4/include/base/native_types.h
@@ -129,17 +129,17 @@ namespace Genode {
struct Native_config
{
/**
- * Thread-context area configuration.
+ * Stack-area configuration.
*/
- static constexpr addr_t context_area_virtual_base() {
+ static constexpr addr_t stack_area_virtual_base() {
return 0x40000000UL; }
- static constexpr addr_t context_area_virtual_size() {
+ static constexpr addr_t stack_area_virtual_size() {
return 0x10000000UL; }
/**
- * Size of virtual address region holding the context of one thread
+ * Size of virtual address region holding the stack of one thread
*/
- static constexpr addr_t context_virtual_size() { return 0x00100000UL; }
+ static constexpr addr_t stack_virtual_size() { return 0x00100000UL; }
};
struct Native_pd_args { };
diff --git a/repos/base-sel4/lib/mk/base-common.inc b/repos/base-sel4/lib/mk/base-common.inc
index 9907bc746d..61de46cecc 100644
--- a/repos/base-sel4/lib/mk/base-common.inc
+++ b/repos/base-sel4/lib/mk/base-common.inc
@@ -21,7 +21,7 @@ SRC_CC += server/server.cc server/common.cc
SRC_CC += thread/thread.cc
SRC_CC += thread/trace.cc
SRC_CC += thread/myself.cc
-SRC_CC += thread/context_allocator.cc
+SRC_CC += thread/stack_allocator.cc
SRC_CC += thread/thread_bootstrap.cc
SRC_CC += env/capability.cc
SRC_CC += sleep.cc
diff --git a/repos/base-sel4/lib/mk/base.mk b/repos/base-sel4/lib/mk/base.mk
index 3e7838faba..f2bd01200b 100644
--- a/repos/base-sel4/lib/mk/base.mk
+++ b/repos/base-sel4/lib/mk/base.mk
@@ -7,7 +7,7 @@
LIBS += base-common syscall
SRC_CC += console/log_console.cc
-SRC_CC += env/env.cc env/context_area.cc env/reinitialize.cc
+SRC_CC += env/env.cc env/stack_area.cc env/reinitialize.cc
SRC_CC += env/capability_space.cc
SRC_CC += thread/thread_start.cc thread/thread_init.cc
SRC_CC += irq/platform.cc
diff --git a/repos/base-sel4/lib/mk/core.mk b/repos/base-sel4/lib/mk/core.mk
index 6801ce336c..f1f123a5b1 100644
--- a/repos/base-sel4/lib/mk/core.mk
+++ b/repos/base-sel4/lib/mk/core.mk
@@ -30,7 +30,7 @@ SRC_CC += \
core_mem_alloc.cc \
core_rpc_cap_alloc.cc \
dump_alloc.cc \
- context_area.cc \
+ stack_area.cc \
capability_space.cc \
pager.cc \
pager_ep.cc
diff --git a/repos/base-sel4/src/base/thread/thread_bootstrap.cc b/repos/base-sel4/src/base/thread/thread_bootstrap.cc
index f47c97336b..ea0cf35ce7 100644
--- a/repos/base-sel4/src/base/thread/thread_bootstrap.cc
+++ b/repos/base-sel4/src/base/thread/thread_bootstrap.cc
@@ -15,6 +15,9 @@
#include
#include
+/* base-internal includes */
+#include
+
/*****************************
** Startup library support **
@@ -32,6 +35,6 @@ void prepare_reinit_main_thread() { prepare_init_main_thread(); }
void Genode::Thread_base::_thread_bootstrap()
{
if (tid().ep_sel == 0) {
- tid().ep_sel = _context->utcb.ep_sel;
+ tid().ep_sel = _stack->utcb().ep_sel;
}
}
diff --git a/repos/base-sel4/src/core/include/platform_thread.h b/repos/base-sel4/src/core/include/platform_thread.h
index 6ca0358f99..8b2cced225 100644
--- a/repos/base-sel4/src/core/include/platform_thread.h
+++ b/repos/base-sel4/src/core/include/platform_thread.h
@@ -45,7 +45,7 @@ class Genode::Platform_thread : public List::Element
* Virtual address of the IPC buffer within the PDs address space
*
* The value is 0 for the PD's main thread. For all other threads,
- * the value is somewhere within the context area.
+ * the value is somewhere within the stack area.
*/
addr_t const _utcb;
diff --git a/repos/base-sel4/src/core/platform.cc b/repos/base-sel4/src/core/platform.cc
index 0366741781..5e77b83302 100644
--- a/repos/base-sel4/src/core/platform.cc
+++ b/repos/base-sel4/src/core/platform.cc
@@ -155,9 +155,9 @@ void Platform::_init_allocators()
core_virt_beg, core_virt_end, core_size);
}
- /* preserve context area in core's virtual address space */
- _core_mem_alloc.virt_alloc()->remove_range(Native_config::context_area_virtual_base(),
- Native_config::context_area_virtual_size());
+ /* preserve stack area in core's virtual address space */
+ _core_mem_alloc.virt_alloc()->remove_range(Native_config::stack_area_virtual_base(),
+ Native_config::stack_area_virtual_size());
}
diff --git a/repos/base-sel4/src/core/platform_pd.cc b/repos/base-sel4/src/core/platform_pd.cc
index 3108e6b9cf..8340ac9373 100644
--- a/repos/base-sel4/src/core/platform_pd.cc
+++ b/repos/base-sel4/src/core/platform_pd.cc
@@ -65,7 +65,7 @@ int Platform_pd::bind_thread(Platform_thread *thread)
* 'Vm_space'. In contrast to mapping that are created as a result of
* the RM-session's page-fault resolution, the IPC buffer's mapping
* won't be recoverable once flushed. For this reason, it is important
- * to attach the UTCB as a dataspace to the context-area to make the RM
+ * to attach the UTCB as a dataspace to the stack area to make the RM
* session aware to the mapping. This code is missing.
*/
if (thread->_utcb) {
diff --git a/repos/base-sel4/src/core/context_area.cc b/repos/base-sel4/src/core/stack_area.cc
similarity index 75%
rename from repos/base-sel4/src/core/context_area.cc
rename to repos/base-sel4/src/core/stack_area.cc
index 61b6c8cd68..9b210a8db0 100644
--- a/repos/base-sel4/src/core/context_area.cc
+++ b/repos/base-sel4/src/core/stack_area.cc
@@ -29,18 +29,17 @@ using namespace Genode;
/**
- * Region-manager session for allocating thread contexts
+ * Region-manager session for allocating stacks
*
- * This class corresponds to the managed dataspace that is normally
- * used for organizing thread contexts with the thread context area.
- * In contrast to the ordinary implementation, core's version does
- * not split between allocation of memory and virtual memory management.
- * Due to the missing availability of "real" dataspaces and capabilities
- * refering to it without having an entrypoint in place, the allocation
- * of a dataspace has no effect, but the attachment of the thereby "empty"
- * dataspace is doing both: allocation and attachment.
+ * This class corresponds to the managed dataspace that is normally used for
+ * organizing stacks with the stack area. In contrast to the ordinary
+ * implementation, core's version does not split between allocation of memory
+ * and virtual memory management. Due to the missing availability of "real"
+ * dataspaces and capabilities refering to it without having an entrypoint in
+ * place, the allocation of a dataspace has no effect, but the attachment of
+ * the thereby "empty" dataspace is doing both: allocation and attachment.
*/
-class Context_area_rm_session : public Rm_session
+class Stack_area_rm_session : public Rm_session
{
private:
@@ -54,7 +53,7 @@ class Context_area_rm_session : public Rm_session
public:
/**
- * Allocate and attach on-the-fly backing store to thread-context area
+ * Allocate and attach on-the-fly backing store to the stack area
*/
Local_addr attach(Dataspace_capability ds_cap, /* ignored capability */
size_t size, off_t offset,
@@ -72,12 +71,12 @@ class Context_area_rm_session : public Rm_session
Dataspace_component *ds = new (&_ds_slab)
Dataspace_component(size, 0, phys, CACHED, true, 0);
if (!ds) {
- PERR("dataspace for core context does not exist");
+ PERR("dataspace for core stack does not exist");
return (addr_t)0;
}
addr_t const core_local_addr =
- Native_config::context_area_virtual_base() + (addr_t)local_addr;
+ Native_config::stack_area_virtual_base() + (addr_t)local_addr;
if (verbose)
PDBG("core_local_addr = %lx, phys_addr = %lx, size = 0x%zx",
@@ -110,7 +109,7 @@ class Context_area_rm_session : public Rm_session
};
-class Context_area_ram_session : public Ram_session
+class Stack_area_ram_session : public Ram_session
{
public:
@@ -136,15 +135,15 @@ class Context_area_ram_session : public Ram_session
*/
namespace Genode {
- Rm_session *env_context_area_rm_session()
+ Rm_session *env_stack_area_rm_session()
{
- static Context_area_rm_session inst;
+ static Stack_area_rm_session inst;
return &inst;
}
- Ram_session *env_context_area_ram_session()
+ Ram_session *env_stack_area_ram_session()
{
- static Context_area_ram_session inst;
+ static Stack_area_ram_session inst;
return &inst;
}
}
diff --git a/repos/base-sel4/src/core/thread_start.cc b/repos/base-sel4/src/core/thread_start.cc
index dcd6b8f71a..d2b331d1a9 100644
--- a/repos/base-sel4/src/core/thread_start.cc
+++ b/repos/base-sel4/src/core/thread_start.cc
@@ -16,6 +16,9 @@
#include
#include
+/* base-internal includes */
+#include
+
/* core includes */
#include
#include
@@ -26,7 +29,7 @@ using namespace Genode;
void Thread_base::_init_platform_thread(size_t, Type type)
{
- addr_t const utcb_virt_addr = (addr_t)&_context->utcb;
+ addr_t const utcb_virt_addr = (addr_t)&_stack->utcb();
if (type == MAIN) {
_tid.tcb_sel = seL4_CapInitThreadTCB;
diff --git a/repos/base/include/base/env.h b/repos/base/include/base/env.h
index 2af7ef55c5..d0b9bec531 100644
--- a/repos/base/include/base/env.h
+++ b/repos/base/include/base/env.h
@@ -107,14 +107,14 @@ struct Genode::Env
/**
* Reinitialize main-thread object
*
- * \param context_area_rm new RM session of the context area
+ * \param stack_area_rm new RM session of the context area
*
* This function is solely used for implementing fork semantics
* as provided by the Noux environment.
*
* \noapi
*/
- virtual void reinit_main_thread(Rm_session_capability &) = 0;
+ virtual void reinit_main_thread(Rm_session_capability &stack_area_rm) = 0;
};
diff --git a/repos/base/include/base/thread.h b/repos/base/include/base/thread.h
index 3f8841b6b3..85c230923d 100644
--- a/repos/base/include/base/thread.h
+++ b/repos/base/include/base/thread.h
@@ -2,50 +2,10 @@
* \brief Thread interface
* \author Norman Feske
* \date 2006-04-28
- *
- * For storing thread-specific data (called thread context) such as the stack
- * and thread-local data, there is a dedicated portion of the virtual address
- * space. This portion is called thread-context area. Within the thread-context
- * area, each thread has a fixed-sized slot, a thread context. The layout of
- * each thread context looks as follows
- *
- * ; lower address
- * ; ...
- * ; ============================ <- aligned at the virtual context size
- * ;
- * ; empty
- * ;
- * ; ----------------------------
- * ;
- * ; stack
- * ; (top) <- initial stack pointer
- * ; ---------------------------- <- address of 'Context' object
- * ; additional context members
- * ; ----------------------------
- * ; UTCB
- * ; ============================ <- aligned at the virtual context size
- * ; ...
- * ; higher address
- *
- * On some platforms, a user-level thread-control block (UTCB) area contains
- * data shared between the user-level thread and the kernel. It is typically
- * used for transferring IPC message payload or for system-call arguments.
- * The additional context members are a reference to the corresponding
- * 'Thread_base' object and the name of the thread.
- *
- * The thread context is a virtual memory area, initially not backed by real
- * memory. When a new thread is created, an empty thread context gets assigned
- * to the new thread and populated with memory pages for the stack and the
- * additional context members. Note that this memory is allocated from the RAM
- * session of the process environment and not accounted for when using the
- * 'sizeof()' operand on a 'Thread_base' object.
- *
- * A thread may be associated with more than one stack. Additional secondary
- * stacks can be associated with a thread, and used for user level scheduling.
*/
/*
- * Copyright (C) 2006-2013 Genode Labs GmbH
+ * Copyright (C) 2006-2016 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.
@@ -70,6 +30,7 @@ namespace Genode {
class Rm_session;
class Thread_base;
+ class Stack;
template class Thread;
}
@@ -84,174 +45,24 @@ class Genode::Thread_base
{
public:
- class Context_alloc_failed : public Exception { };
- class Stack_too_large : public Exception { };
- class Stack_alloc_failed : public Exception { };
-
- /**
- * Thread context located within the thread-context area
- *
- * The end of a thread context is placed virtual size aligned.
- */
- struct Context
- {
- private:
-
- /**
- * Top of the stack is accessible via stack_top()
- *
- * Context provides the first word of the stack to prevent the
- * overlapping of stack top and the 'stack_base' member.
- */
- addr_t _stack[1];
-
- public:
-
- /**
- * Top of stack
- *
- * The alignment constrains are enforced by the CPU-specific ABI.
- */
- addr_t stack_top() const { return Abi::stack_align((addr_t)_stack); }
-
- /**
- * Ensure that the stack has a given size at the minimum
- *
- * \param size minimum stack size
- *
- * \throw Stack_too_large
- * \throw Stack_alloc_failed
- */
- void stack_size(size_t const size);
-
- /**
- * Virtual address of the start of the stack
- *
- * This address is pointing to the begin of the dataspace used
- * for backing the thread context except for the UTCB (which is
- * managed by the kernel).
- */
- addr_t stack_base;
-
- /**
- * Pointer to corresponding 'Thread_base' object
- */
- Thread_base *thread_base;
-
- /**
- * Dataspace containing the backing store for the thread context
- *
- * We keep the dataspace capability to be able to release the
- * backing store on thread destruction.
- */
- Ram_dataspace_capability ds_cap;
-
- /**
- * Maximum length of thread name, including null-termination
- */
- enum { NAME_LEN = 64 };
-
- /**
- * Thread name, used for debugging
- */
- char name[NAME_LEN];
-
- /*
- * <- end of regular memory area
- *
- * The following part of the thread context is backed by
- * kernel-managed memory. No member variables are allowed
- * beyond this point.
- */
-
- /**
- * Kernel-specific user-level thread control block
- */
- Native_utcb utcb;
- };
+ class Out_of_stack_space : public Exception { };
+ class Stack_too_large : public Exception { };
+ class Stack_alloc_failed : public Exception { };
private:
/**
- * Manage the allocation of thread contexts
- *
- * There exists only one instance of this class per process.
- */
- class Context_allocator
- {
- private:
-
- static constexpr size_t MAX_THREADS =
- Native_config::context_area_virtual_size() /
- Native_config::context_virtual_size();
-
- struct Context_bit_allocator : Bit_allocator
- {
- Context_bit_allocator()
- {
- /* the first index is used by main thread */
- _reserve(0, 1);
- }
- } _alloc;
-
- Lock _threads_lock;
-
- public:
-
- /**
- * Allocate thread context for specified thread
- *
- * \param thread thread for which to allocate the new context
- * \param main_thread wether to alloc for the main thread
- *
- * \return virtual address of new thread context, or
- * 0 if the allocation failed
- */
- Context *alloc(Thread_base *thread, bool main_thread);
-
- /**
- * Release thread context
- */
- void free(Context *thread);
-
- /**
- * Return 'Context' object for a given base address
- */
- static Context *base_to_context(addr_t base);
-
- /**
- * Return base address of context containing the specified address
- */
- static addr_t addr_to_base(void *addr);
-
- /**
- * Return index in context area for a given base address
- */
- static size_t base_to_idx(addr_t base);
-
- /**
- * Return base address of context given index in context area
- */
- static addr_t idx_to_base(size_t idx);
- };
-
- /**
- * Return thread-context allocator
- */
- static Context_allocator *_context_allocator();
-
- /**
- * Allocate and locally attach a new thread context
+ * Allocate and locally attach a new stack
*
* \param stack_size size of this threads stack
* \param main_thread wether this is the main thread
*/
- Context *_alloc_context(size_t stack_size, bool main_thread);
+ Stack *_alloc_stack(size_t stack_size, char const *name, bool main_thread);
/**
- * Detach and release thread context of the thread
+ * Detach and release stack of the thread
*/
- void _free_context(Context *context);
+ void _free_stack(Stack *stack);
/**
* Platform-specific thread-startup code
@@ -297,9 +108,9 @@ class Genode::Thread_base
Trace::Control *_trace_control;
/**
- * Pointer to primary thread context
+ * Pointer to primary stack
*/
- Context *_context;
+ Stack *_stack;
/**
* Physical thread ID
@@ -345,10 +156,10 @@ class Genode::Thread_base
*
* \noapi
*
- * FIXME: With type = Forked_main_thread the whole
- * Context::_alloc_context call gets skipped but we should
- * at least set Context::ds_cap in a way that it references
- * the dataspace of the already attached stack.
+ * FIXME: With type = Forked_main_thread the stack allocation
+ * gets skipped but we should at least set Stack::ds_cap in a
+ * way that it references the dataspace of the already attached
+ * stack.
*/
Thread_base(size_t weight, const char *name, size_t stack_size,
Type type);
@@ -362,12 +173,12 @@ class Genode::Thread_base
*
* \throw Stack_too_large
* \throw Stack_alloc_failed
- * \throw Context_alloc_failed
+ * \throw Out_of_stack_space
*
* The stack for the new thread will be allocated from the RAM session
- * of the process environment. A small portion of the stack size is
- * internally used by the framework for storing thread-context
- * information such as the thread's name ('Context').
+ * of the component environment. A small portion of the stack size is
+ * internally used by the framework for storing thread-specific
+ * information such as the thread's name.
*/
Thread_base(size_t weight, const char *name, size_t stack_size)
: Thread_base(weight, name, stack_size, NORMAL) { }
@@ -389,7 +200,7 @@ class Genode::Thread_base
*
* \throw Stack_too_large
* \throw Stack_alloc_failed
- * \throw Context_alloc_failed
+ * \throw Out_of_stack_space
*/
Thread_base(size_t weight, const char *name, size_t stack_size,
Type type, Cpu_session *);
@@ -422,13 +233,12 @@ class Genode::Thread_base
*
* \throw Stack_too_large
* \throw Stack_alloc_failed
- * \throw Context_alloc_failed
+ * \throw Out_of_stack_space
*
* The stack for the new thread will be allocated from the RAM
- * session of the process environment. A small portion of the
+ * session of the component environment. A small portion of the
* stack size is internally used by the framework for storing
- * thread-context information such as the thread's name (see
- * 'struct Context').
+ * thread-specific information such as the thread's name.
*
* \return pointer to the new stack's top
*/
@@ -461,14 +271,14 @@ class Genode::Thread_base
*
* \return pointer just after first stack element
*/
- void *stack_top() const { return (void *)_context->stack_top(); }
+ void *stack_top() const;
/**
* Return base of stack
*
* \return pointer to last stack element
*/
- void *stack_base() { return (void*)_context->stack_base; }
+ void *stack_base() const;
/**
* Return 'Thread_base' object corresponding to the calling thread
@@ -482,10 +292,10 @@ class Genode::Thread_base
*
* \param size minimum stack size
*
- * \throw Context::Stack_too_large
- * \throw Context::Stack_alloc_failed
+ * \throw Stack_too_large
+ * \throw Stack_alloc_failed
*/
- void stack_size(size_t const size) { _context->stack_size(size); }
+ void stack_size(size_t const size);
/**
* Return user-level thread control block
diff --git a/repos/base/include/spec/arm/cpu/consts.h b/repos/base/include/spec/arm/cpu/consts.h
index 19a3bc5e42..a0354b954e 100644
--- a/repos/base/include/spec/arm/cpu/consts.h
+++ b/repos/base/include/spec/arm/cpu/consts.h
@@ -22,7 +22,7 @@ namespace Abi {
* On ARM we align the stack top to 16-byte. As a call (or branch) will not
* change the stack pointer, we need no further stack adjustment.
*/
- static Genode::addr_t stack_align(Genode::addr_t addr) {
+ static inline Genode::addr_t stack_align(Genode::addr_t addr) {
return (addr & ~0xf); }
/**
diff --git a/repos/base/include/spec/x86/cpu/consts.h b/repos/base/include/spec/x86/cpu/consts.h
index 4c67311872..f7dbd87c24 100644
--- a/repos/base/include/spec/x86/cpu/consts.h
+++ b/repos/base/include/spec/x86/cpu/consts.h
@@ -41,7 +41,7 @@ namespace Abi {
* growth of the stack, we further adjust the stack-top address to comply
* to the AMD64 ABI rule "stack top + adjustment is 16-byte aligned".
*/
- static Genode::addr_t stack_align(Genode::addr_t addr) {
+ inline Genode::addr_t stack_align(Genode::addr_t addr) {
return (addr & ~0xf) - sizeof(Genode::addr_t); }
/**
diff --git a/repos/base/lib/mk/ldso.inc b/repos/base/lib/mk/ldso.inc
index 1ae57f3ea2..04603b980c 100644
--- a/repos/base/lib/mk/ldso.inc
+++ b/repos/base/lib/mk/ldso.inc
@@ -13,7 +13,7 @@ LD_OPT += -Bsymbolic-functions --version-script=$(DIR)/symbol.map
ifneq ($(filter linux, $(SPECS)),)
ENTRY_POINT = _start_initial_stack
-LD_OPT += -T$(call select_from_repositories,src/ld/context_area.nostdlib.ld) \
+LD_OPT += -T$(call select_from_repositories,src/ld/stack_area.nostdlib.ld) \
ifneq ($(filter x86_32, $(SPECS)),)
LD_OPT += -T$(DIR)/linux-32.ld
diff --git a/repos/base/src/base/env/reinitialize.cc b/repos/base/src/base/env/reinitialize.cc
index 6436bf13a1..6190d1fd4d 100644
--- a/repos/base/src/base/env/reinitialize.cc
+++ b/repos/base/src/base/env/reinitialize.cc
@@ -28,7 +28,7 @@ namespace Genode
{
extern bool inhibit_tracing;
- Rm_session * env_context_area_rm_session();
+ Rm_session * env_stack_area_rm_session();
}
@@ -83,12 +83,12 @@ void Genode::Platform_env::reinit(Native_capability::Dst dst,
void
Genode::Platform_env::
-reinit_main_thread(Rm_session_capability & context_area_rm)
+reinit_main_thread(Rm_session_capability & stack_area_rm)
{
- /* reinitialize context area RM session */
- Rm_session * const rms = env_context_area_rm_session();
+ /* reinitialize stack area RM session */
+ Rm_session * const rms = env_stack_area_rm_session();
Rm_session_client * const rmc = dynamic_cast(rms);
- construct_at(rmc, context_area_rm);
+ construct_at(rmc, stack_area_rm);
/* reinitialize main-thread object */
::reinit_main_thread();
diff --git a/repos/base/src/base/env/context_area.cc b/repos/base/src/base/env/stack_area.cc
similarity index 68%
rename from repos/base/src/base/env/context_area.cc
rename to repos/base/src/base/env/stack_area.cc
index c4047b3fc1..3542f5b712 100644
--- a/repos/base/src/base/env/context_area.cc
+++ b/repos/base/src/base/env/stack_area.cc
@@ -1,5 +1,5 @@
/*
- * \brief Process-local thread-context area
+ * \brief Component-local stack area
* \author Norman Feske
* \date 2010-01-19
*/
@@ -36,13 +36,13 @@ struct Expanding_rm_connection : Connection, Expanding_rm_session_cl
};
-struct Context_area_rm_session : Expanding_rm_connection
+struct Stack_area_rm_session : Expanding_rm_connection
{
- Context_area_rm_session()
- : Expanding_rm_connection(0, Native_config::context_area_virtual_size())
+ Stack_area_rm_session()
+ : Expanding_rm_connection(0, Native_config::stack_area_virtual_size())
{
- addr_t local_base = Native_config::context_area_virtual_base();
- size_t size = Native_config::context_area_virtual_size();
+ addr_t local_base = Native_config::stack_area_virtual_base();
+ size_t size = Native_config::stack_area_virtual_size();
env()->rm_session()->attach_at(dataspace(), local_base, size);
}
@@ -51,13 +51,13 @@ struct Context_area_rm_session : Expanding_rm_connection
namespace Genode {
- Rm_session *env_context_area_rm_session()
+ Rm_session *env_stack_area_rm_session()
{
- static Context_area_rm_session inst;
+ static Stack_area_rm_session inst;
return &inst;
}
- Ram_session *env_context_area_ram_session()
+ Ram_session *env_stack_area_ram_session()
{
return env()->ram_session();
}
diff --git a/repos/base/src/base/thread/context_allocator.cc b/repos/base/src/base/thread/context_allocator.cc
deleted file mode 100644
index 1d6a72d892..0000000000
--- a/repos/base/src/base/thread/context_allocator.cc
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * \brief Context-allocator implementation for the Genode Thread API
- * \author Norman Feske
- * \author Martin Stein
- * \date 2014-01-26
- */
-
-/*
- * Copyright (C) 2010-2014 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.
- */
-
-/* Genode includes */
-#include
-
-using namespace Genode;
-
-
-Thread_base::Context *Thread_base::Context_allocator::base_to_context(addr_t base)
-{
- addr_t result = base + Native_config::context_virtual_size()
- - sizeof(Context);
- return reinterpret_cast(result);
-}
-
-
-addr_t Thread_base::Context_allocator::addr_to_base(void *addr)
-{
- return ((addr_t)addr) & ~(Native_config::context_virtual_size() - 1);
-}
-
-
-size_t Thread_base::Context_allocator::base_to_idx(addr_t base)
-{
- return (base - Native_config::context_area_virtual_base()) /
- Native_config::context_virtual_size();
-}
-
-
-addr_t Thread_base::Context_allocator::idx_to_base(size_t idx)
-{
- return Native_config::context_area_virtual_base() +
- idx * Native_config::context_virtual_size();
-}
-
-
-Thread_base::Context *
-Thread_base::Context_allocator::alloc(Thread_base *thread_base, bool main_thread)
-{
- if (main_thread)
- /* the main-thread context is the first one */
- return base_to_context(Native_config::context_area_virtual_base());
-
- try {
- Lock::Guard _lock_guard(_threads_lock);
- return base_to_context(idx_to_base(_alloc.alloc()));
- } catch(Bit_allocator::Out_of_indices) {
- return 0;
- }
-}
-
-
-void Thread_base::Context_allocator::free(Context *context)
-{
- addr_t const base = addr_to_base(context);
-
- Lock::Guard _lock_guard(_threads_lock);
- _alloc.free(base_to_idx(base));
-}
-
-
-Thread_base::Context_allocator *Thread_base::_context_allocator()
-{
- static Context_allocator context_allocator_inst;
- return &context_allocator_inst;
-}
diff --git a/repos/base/src/base/thread/myself.cc b/repos/base/src/base/thread/myself.cc
index e731d8702b..e5ffad045d 100644
--- a/repos/base/src/base/thread/myself.cc
+++ b/repos/base/src/base/thread/myself.cc
@@ -11,24 +11,28 @@
* under the terms of the GNU General Public License version 2.
*/
+/* Genode includes */
#include
+/* base-internal includes */
+#include
+
Genode::Thread_base *Genode::Thread_base::myself()
{
int dummy = 0; /* used for determining the stack pointer */
/*
- * If the stack pointer is outside the thread-context area, we assume that
+ * If the stack pointer is outside the stack area, we assume that
* we are the main thread because this condition can never met by any other
* thread.
*/
addr_t sp = (addr_t)(&dummy);
- if (sp < Native_config::context_area_virtual_base() ||
- sp >= Native_config::context_area_virtual_base() +
- Native_config::context_area_virtual_size())
+ if (sp < Native_config::stack_area_virtual_base() ||
+ sp >= Native_config::stack_area_virtual_base() +
+ Native_config::stack_area_virtual_size())
return 0;
- addr_t base = Context_allocator::addr_to_base(&dummy);
- return Context_allocator::base_to_context(base)->thread_base;
+ addr_t base = Stack_allocator::addr_to_base(&dummy);
+ return &Stack_allocator::base_to_stack(base)->thread();
}
diff --git a/repos/base/src/base/thread/stack_allocator.cc b/repos/base/src/base/thread/stack_allocator.cc
new file mode 100644
index 0000000000..56562801b4
--- /dev/null
+++ b/repos/base/src/base/thread/stack_allocator.cc
@@ -0,0 +1,78 @@
+/*
+ * \brief Stack-allocator implementation for the Genode Thread API
+ * \author Norman Feske
+ * \author Martin Stein
+ * \date 2014-01-26
+ */
+
+/*
+ * Copyright (C) 2010-2014 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.
+ */
+
+/* base-internal includes */
+#include
+
+using namespace Genode;
+
+
+Stack *Stack_allocator::base_to_stack(addr_t base)
+{
+ addr_t result = base + Native_config::stack_virtual_size()
+ - sizeof(Stack);
+ return reinterpret_cast(result);
+}
+
+
+addr_t Stack_allocator::addr_to_base(void *addr)
+{
+ return ((addr_t)addr) & ~(Native_config::stack_virtual_size() - 1);
+}
+
+
+size_t Stack_allocator::base_to_idx(addr_t base)
+{
+ return (base - Native_config::stack_area_virtual_base()) /
+ Native_config::stack_virtual_size();
+}
+
+
+addr_t Stack_allocator::idx_to_base(size_t idx)
+{
+ return Native_config::stack_area_virtual_base() +
+ idx * Native_config::stack_virtual_size();
+}
+
+
+Stack *
+Stack_allocator::alloc(Thread_base *thread_base, bool main_thread)
+{
+ if (main_thread)
+ /* the main-thread stack is the first one */
+ return base_to_stack(Native_config::stack_area_virtual_base());
+
+ try {
+ Lock::Guard _lock_guard(_threads_lock);
+ return base_to_stack(idx_to_base(_alloc.alloc()));
+ } catch(Bit_allocator::Out_of_indices) {
+ return 0;
+ }
+}
+
+
+void Stack_allocator::free(Stack *stack)
+{
+ addr_t const base = addr_to_base(stack);
+
+ Lock::Guard _lock_guard(_threads_lock);
+ _alloc.free(base_to_idx(base));
+}
+
+
+Stack_allocator &Stack_allocator::stack_allocator()
+{
+ static Stack_allocator inst;
+ return inst;
+}
diff --git a/repos/base/src/base/thread/thread.cc b/repos/base/src/base/thread/thread.cc
index 9ff2713cda..c62711627c 100644
--- a/repos/base/src/base/thread/thread.cc
+++ b/repos/base/src/base/thread/thread.cc
@@ -11,93 +11,102 @@
* under the terms of the GNU General Public License version 2.
*/
+/* Genode includes */
+#include
+#include
+#include
#include
#include
#include
#include
-#include
-#include
+
+/* base-internal includes */
+#include
using namespace Genode;
/**
- * Return the managed dataspace holding the thread context area
+ * Return the managed dataspace holding the stack area
*
* This function is provided by the process environment.
*/
namespace Genode {
- Rm_session *env_context_area_rm_session();
- Ram_session *env_context_area_ram_session();
+ Rm_session *env_stack_area_rm_session();
+ Ram_session *env_stack_area_ram_session();
}
-void Thread_base::Context::stack_size(size_t const size)
+void Stack::size(size_t const size)
{
/* check if the stack needs to be enhanced */
- size_t const stack_size = (addr_t)_stack - stack_base;
+ size_t const stack_size = (addr_t)_stack - _base;
if (stack_size >= size) { return; }
- /* check if the stack enhancement fits the context region */
+ /* check if the stack enhancement fits the stack region */
enum {
- CONTEXT_SIZE = Native_config::context_virtual_size(),
UTCB_SIZE = sizeof(Native_utcb),
PAGE_SIZE_LOG2 = 12,
PAGE_SIZE = (1UL << PAGE_SIZE_LOG2),
};
- addr_t const context_base = Context_allocator::addr_to_base(this);
+ addr_t const stack_slot_base = Stack_allocator::addr_to_base(this);
size_t const ds_size = align_addr(size - stack_size, PAGE_SIZE_LOG2);
- if (stack_base - ds_size < context_base) { throw Stack_too_large(); }
+ if (_base - ds_size < stack_slot_base)
+ throw Thread_base::Stack_too_large();
/* allocate and attach backing store for the stack enhancement */
- addr_t const ds_addr = stack_base - ds_size -
- Native_config::context_area_virtual_base();
+ addr_t const ds_addr = _base - ds_size -
+ Native_config::stack_area_virtual_base();
try {
- Ram_session * const ram = env_context_area_ram_session();
+ Ram_session * const ram = env_stack_area_ram_session();
Ram_dataspace_capability const ds_cap = ram->alloc(ds_size);
- Rm_session * const rm = env_context_area_rm_session();
+ Rm_session * const rm = env_stack_area_rm_session();
void * const attach_addr = rm->attach_at(ds_cap, ds_addr, ds_size);
- if (ds_addr != (addr_t)attach_addr) { throw Stack_alloc_failed(); }
- }
- catch (Ram_session::Alloc_failed) { throw Stack_alloc_failed(); }
- /* update context information */
- stack_base -= ds_size;
+ if (ds_addr != (addr_t)attach_addr)
+ throw Thread_base::Out_of_stack_space();
+ }
+ catch (Ram_session::Alloc_failed) {
+ throw Thread_base::Stack_alloc_failed();
+ }
+
+ /* update stack information */
+ _base -= ds_size;
}
-Thread_base::Context *
-Thread_base::_alloc_context(size_t stack_size, bool main_thread)
+Stack *
+Thread_base::_alloc_stack(size_t stack_size, char const *name, bool main_thread)
{
/*
- * Synchronize context list when creating new threads from multiple threads
+ * Synchronize stack list when creating new threads from multiple threads
*
* XXX: remove interim fix
*/
static Lock alloc_lock;
Lock::Guard _lock_guard(alloc_lock);
- /* allocate thread context */
- Context *context = _context_allocator()->alloc(this, main_thread);
- if (!context)
- throw Context_alloc_failed();
+ /* allocate stack */
+ Stack *stack = Stack_allocator::stack_allocator().alloc(this, main_thread);
+ if (!stack)
+ throw Out_of_stack_space();
- /* determine size of dataspace to allocate for context members and stack */
+ /* determine size of dataspace to allocate for the stack */
enum { PAGE_SIZE_LOG2 = 12 };
size_t ds_size = align_addr(stack_size, PAGE_SIZE_LOG2);
- if (stack_size >= Native_config::context_virtual_size() -
+ if (stack_size >= Native_config::stack_virtual_size() -
sizeof(Native_utcb) - (1UL << PAGE_SIZE_LOG2))
throw Stack_too_large();
/*
* Calculate base address of the stack
*
- * The stack is always located at the top of the context.
+ * The stack pointer is always located at the top of the stack header.
*/
- addr_t ds_addr = Context_allocator::addr_to_base(context) +
- Native_config::context_virtual_size() -
+ addr_t ds_addr = Stack_allocator::addr_to_base(stack) +
+ Native_config::stack_virtual_size() -
ds_size;
/* add padding for UTCB if defined for the platform */
@@ -107,50 +116,46 @@ Thread_base::_alloc_context(size_t stack_size, bool main_thread)
/* allocate and attach backing store for the stack */
Ram_dataspace_capability ds_cap;
try {
- ds_cap = env_context_area_ram_session()->alloc(ds_size);
- addr_t attach_addr = ds_addr - Native_config::context_area_virtual_base();
- if (attach_addr != (addr_t)env_context_area_rm_session()->attach_at(ds_cap, attach_addr, ds_size))
+ ds_cap = env_stack_area_ram_session()->alloc(ds_size);
+ addr_t attach_addr = ds_addr - Native_config::stack_area_virtual_base();
+ if (attach_addr != (addr_t)env_stack_area_rm_session()->attach_at(ds_cap, attach_addr, ds_size))
throw Stack_alloc_failed();
}
catch (Ram_session::Alloc_failed) { throw Stack_alloc_failed(); }
/*
- * Now the thread context is backed by memory, so it is safe to access its
- * members.
+ * Now the stack is backed by memory, so it is safe to access its members.
*
- * We need to initialize the context object's memory with zeroes,
- * otherwise the ds_cap isn't invalid. That would cause trouble
- * when the assignment operator of Native_capability is used.
+ * We need to initialize the stack object's memory with zeroes, otherwise
+ * the ds_cap isn't invalid. That would cause trouble when the assignment
+ * operator of Native_capability is used.
*/
- memset(context, 0, sizeof(Context) - sizeof(Context::utcb));
- context->thread_base = this;
- context->stack_base = ds_addr;
- context->ds_cap = ds_cap;
+ construct_at(stack, name, *this, ds_addr, ds_cap);
- Abi::init_stack(context->stack_top());
- return context;
+ Abi::init_stack(stack->top());
+ return stack;
}
-void Thread_base::_free_context(Context* context)
+void Thread_base::_free_stack(Stack *stack)
{
- addr_t ds_addr = context->stack_base - Native_config::context_area_virtual_base();
- Ram_dataspace_capability ds_cap = context->ds_cap;
+ addr_t ds_addr = stack->base() - Native_config::stack_area_virtual_base();
+ Ram_dataspace_capability ds_cap = stack->ds_cap();
/* call de-constructor explicitly before memory gets detached */
- context->~Context();
+ stack->~Stack();
- Genode::env_context_area_rm_session()->detach((void *)ds_addr);
- Genode::env_context_area_ram_session()->free(ds_cap);
+ Genode::env_stack_area_rm_session()->detach((void *)ds_addr);
+ Genode::env_stack_area_ram_session()->free(ds_cap);
- /* context area ready for reuse */
- _context_allocator()->free(context);
+ /* stack ready for reuse */
+ Stack_allocator::stack_allocator().free(stack);
}
void Thread_base::name(char *dst, size_t dst_len)
{
- snprintf(dst, min(dst_len, (size_t)Context::NAME_LEN), "%s", _context->name);
+ snprintf(dst, dst_len, "%s", _stack->name().string());
}
@@ -159,29 +164,36 @@ void Thread_base::join() { _join_lock.lock(); }
void* Thread_base::alloc_secondary_stack(char const *name, size_t stack_size)
{
- Context *context = _alloc_context(stack_size, false);
- strncpy(context->name, name, sizeof(context->name));
- return (void *)context->stack_top();
+ Stack *stack = _alloc_stack(stack_size, name, false);
+ return (void *)stack->top();
}
void Thread_base::free_secondary_stack(void* stack_addr)
{
- addr_t base = Context_allocator::addr_to_base(stack_addr);
- _free_context(Context_allocator::base_to_context(base));
+ addr_t base = Stack_allocator::addr_to_base(stack_addr);
+ _free_stack(Stack_allocator::base_to_stack(base));
}
+void *Thread_base::stack_top() const { return (void *)_stack->top(); }
+
+
+void *Thread_base::stack_base() const { return (void*)_stack->base(); }
+
+
+void Thread_base::stack_size(size_t const size) { _stack->size(size); }
+
+
Thread_base::Thread_base(size_t weight, const char *name, size_t stack_size,
Type type, Cpu_session *cpu_session)
:
_cpu_session(cpu_session),
_trace_control(nullptr),
- _context(type == REINITIALIZED_MAIN ?
- _context : _alloc_context(stack_size, type == MAIN)),
+ _stack(type == REINITIALIZED_MAIN ?
+ _stack : _alloc_stack(stack_size, name, type == MAIN)),
_join_lock(Lock::LOCKED)
{
- strncpy(_context->name, name, sizeof(_context->name));
_init_platform_thread(weight, type);
if (_cpu_session) {
@@ -201,12 +213,12 @@ Thread_base::~Thread_base()
{
if (Thread_base::myself() == this) {
PERR("thread '%s' tried to self de-struct - sleeping forever.",
- _context->name);
+ _stack->name().string());
sleep_forever();
}
_deinit_platform_thread();
- _free_context(_context);
+ _free_stack(_stack);
/*
* We have to detach the trace control dataspace last because
diff --git a/repos/base/src/base/thread/thread_start.cc b/repos/base/src/base/thread/thread_start.cc
index 35399093b2..3ea6bca610 100644
--- a/repos/base/src/base/thread/thread_start.cc
+++ b/repos/base/src/base/thread/thread_start.cc
@@ -17,6 +17,9 @@
#include
#include
+/* base-internal includes */
+#include
+
using namespace Genode;
@@ -55,7 +58,7 @@ void Thread_base::start()
char buf[48];
name(buf, sizeof(buf));
enum { WEIGHT = Cpu_session::DEFAULT_WEIGHT };
- addr_t const utcb = (addr_t)&_context->utcb;
+ addr_t const utcb = (addr_t)&_stack->utcb();
_thread_cap = _cpu_session->create_thread(WEIGHT, buf, utcb);
if (!_thread_cap.valid())
throw Cpu_session::Thread_creation_failed();
@@ -72,7 +75,7 @@ void Thread_base::start()
_cpu_session->set_pager(_thread_cap, pager_cap);
/* register initial IP and SP at core */
- _cpu_session->start(_thread_cap, (addr_t)_thread_start, _context->stack_top());
+ _cpu_session->start(_thread_cap, (addr_t)_thread_start, _stack->top());
}
diff --git a/repos/base/src/base/thread/thread_utcb.cc b/repos/base/src/base/thread/thread_utcb.cc
new file mode 100644
index 0000000000..a55273809b
--- /dev/null
+++ b/repos/base/src/base/thread/thread_utcb.cc
@@ -0,0 +1,26 @@
+/*
+ * \brief Fiasco-specific implementation of the thread API
+ * \author Norman Feske
+ * \date 2016-01-23
+ */
+
+/*
+ * Copyright (C) 2016 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.
+ */
+
+/* Genode includes */
+#include
+
+/* base-internal includes */
+#include
+
+using namespace Genode;
+
+
+Native_utcb *Thread_base::utcb()
+{
+ return &_stack->utcb();
+}
diff --git a/repos/base/src/core/context_area.cc b/repos/base/src/core/stack_area.cc
similarity index 76%
rename from repos/base/src/core/context_area.cc
rename to repos/base/src/core/stack_area.cc
index 3c9a30e2bf..3ebb37b34f 100644
--- a/repos/base/src/core/context_area.cc
+++ b/repos/base/src/core/stack_area.cc
@@ -28,18 +28,18 @@ using namespace Genode;
/**
- * Region-manager session for allocating thread contexts
+ * Region-manager session for allocating stacks
*
* This class corresponds to the managed dataspace that is normally
- * used for organizing thread contexts with the thread context area.
+ * used for organizing stacks within the stack area.
* In contrast to the ordinary implementation, core's version does
* not split between allocation of memory and virtual memory management.
* Due to the missing availability of "real" dataspaces and capabilities
- * refering to it without having an entrypoint in place, the allocation
+ * referring to it without having an entrypoint in place, the allocation
* of a dataspace has no effect, but the attachment of the thereby "empty"
* dataspace is doing both: allocation and attachment.
*/
-class Context_area_rm_session : public Rm_session
+class Stack_area_rm_session : public Rm_session
{
private:
@@ -53,7 +53,7 @@ class Context_area_rm_session : public Rm_session
public:
/**
- * Allocate and attach on-the-fly backing store to thread-context area
+ * Allocate and attach on-the-fly backing store to stack area
*/
Local_addr attach(Dataspace_capability ds_cap, /* ignored capability */
size_t size, off_t offset,
@@ -66,7 +66,7 @@ class Context_area_rm_session : public Rm_session
Range_allocator *ra = platform_specific()->ram_alloc();
if (ra->alloc_aligned(size, &phys_base,
get_page_size_log2()).is_error()) {
- PERR("could not allocate backing store for new context");
+ PERR("could not allocate backing store for new stack");
return (addr_t)0;
}
@@ -76,11 +76,11 @@ class Context_area_rm_session : public Rm_session
Dataspace_component *ds = new (&_ds_slab)
Dataspace_component(size, 0, (addr_t)phys_base, CACHED, true, 0);
if (!ds) {
- PERR("dataspace for core context does not exist");
+ PERR("dataspace for core stack does not exist");
return (addr_t)0;
}
- addr_t core_local_addr = Native_config::context_area_virtual_base() +
+ addr_t core_local_addr = Native_config::stack_area_virtual_base() +
(addr_t)local_addr;
if (verbose)
@@ -103,15 +103,14 @@ class Context_area_rm_session : public Rm_session
{
using Genode::addr_t;
- if ((addr_t)local_addr >= Native_config::context_area_virtual_size())
+ if ((addr_t)local_addr >= Native_config::stack_area_virtual_size())
return;
- addr_t const detach = Native_config::context_area_virtual_base() +
+ addr_t const detach = Native_config::stack_area_virtual_base() +
(addr_t)local_addr;
- addr_t const thread_context = Native_config::context_virtual_size();
- addr_t const pages = ((detach & ~(thread_context - 1))
- + thread_context
- - detach) >> get_page_size_log2();
+ addr_t const stack = Native_config::stack_virtual_size();
+ addr_t const pages = ((detach & ~(stack - 1)) + stack - detach)
+ >> get_page_size_log2();
unmap_local(detach, pages);
}
@@ -129,7 +128,7 @@ class Context_area_rm_session : public Rm_session
};
-class Context_area_ram_session : public Ram_session
+class Stack_area_ram_session : public Ram_session
{
public:
@@ -154,15 +153,15 @@ class Context_area_ram_session : public Ram_session
*/
namespace Genode {
- Rm_session *env_context_area_rm_session()
+ Rm_session *env_stack_area_rm_session()
{
- static Context_area_rm_session inst;
+ static Stack_area_rm_session inst;
return &inst;
}
- Ram_session *env_context_area_ram_session()
+ Ram_session *env_stack_area_ram_session()
{
- static Context_area_ram_session inst;
+ static Stack_area_ram_session inst;
return &inst;
}
}
diff --git a/repos/base/src/include/base/internal/stack.h b/repos/base/src/include/base/internal/stack.h
new file mode 100644
index 0000000000..c084e939a6
--- /dev/null
+++ b/repos/base/src/include/base/internal/stack.h
@@ -0,0 +1,178 @@
+/*
+ * \brief Stack layout and organization
+ * \author Norman Feske
+ * \date 2006-04-28
+ *
+ * For storing thread-specific data such as the stack and thread-local data,
+ * there is a dedicated portion of the virtual address space. This portion is
+ * called stack area. Within this area, each thread has
+ * a fixed-sized slot. The layout of each slot looks as follows
+ *
+ * ; lower address
+ * ; ...
+ * ; ============================ <- aligned at the slot size
+ * ;
+ * ; empty
+ * ;
+ * ; ----------------------------
+ * ;
+ * ; stack
+ * ; (top) <- initial stack pointer
+ * ; ---------------------------- <- address of 'Stack' object
+ * ; thread-specific data
+ * ; ----------------------------
+ * ; UTCB
+ * ; ============================ <- aligned at the slot size
+ * ; ...
+ * ; higher address
+ *
+ * On some platforms, a user-level thread-control block (UTCB) contains
+ * data shared between the user-level thread and the kernel. It is typically
+ * used for transferring IPC message payload or for system-call arguments.
+ * The additional stack members are a reference to the corresponding
+ * 'Thread_base' object and the name of the thread.
+ *
+ * The stack area is a virtual memory area, initially not backed by real
+ * memory. When a new thread is created, an empty slot gets assigned to the new
+ * thread and populated with memory pages for the stack and thread-specific
+ * data. Note that this memory is allocated from the RAM session of the
+ * component environment and not accounted for when using the 'sizeof()'
+ * operand on a 'Thread_base' object.
+ *
+ * A thread may be associated with more than one stack. Additional secondary
+ * stacks can be associated with a thread, and used for user level scheduling.
+ */
+
+/*
+ * Copyright (C) 2006-2016 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 _INCLUDE__BASE__INTERNAL__STACK_H_
+#define _INCLUDE__BASE__INTERNAL__STACK_H_
+
+/* Genode includes */
+#include
+#include /* for 'Native_utcb' */
+#include
+#include /* for 'Ram_dataspace_capability' type */
+
+namespace Genode { class Stack; }
+
+
+/**
+ * Stack located within the stack area
+ *
+ * The end of a stack is placed virtual size aligned.
+ */
+class Genode::Stack
+{
+ public:
+
+ typedef String<64> Name;
+
+ private:
+
+ /**
+ * Top of the stack is accessible via stack_top()
+ *
+ * Context provides the first word of the stack to prevent the
+ * overlapping of stack top and the 'stack_base' member.
+ */
+ addr_t _stack[1];
+
+ /**
+ * Thread name, used for debugging
+ */
+ Name const _name;
+
+ /**
+ * Pointer to corresponding 'Thread_base' object
+ */
+ Thread_base &_thread;
+
+ /**
+ * Virtual address of the start of the stack
+ *
+ * This address is pointing to the begin of the dataspace used for backing
+ * the stack except for the UTCB (which is managed by the kernel).
+ */
+ addr_t _base = 0;
+
+ /**
+ * Dataspace containing the backing store for the stack
+ *
+ * We keep the dataspace capability to be able to release the
+ * backing store on thread destruction.
+ */
+ Ram_dataspace_capability _ds_cap;
+
+ /*
+ * <- end of regular memory area
+ *
+ * The following part of the stack is backed by kernel-managed memory.
+ * No member variables are allowed beyond this point.
+ */
+
+ /**
+ * Kernel-specific user-level thread control block
+ */
+ Native_utcb _utcb;
+
+ public:
+
+ /**
+ * Constructor
+ */
+ Stack(Name const &name, Thread_base &thread, addr_t base,
+ Ram_dataspace_capability ds_cap)
+ :
+ _name(name), _thread(thread), _base(base), _ds_cap(ds_cap)
+ { }
+
+ /**
+ * Top of stack
+ *
+ * The alignment constrains are enforced by the CPU-specific ABI.
+ */
+ addr_t top() const { return Abi::stack_align((addr_t)_stack); }
+
+ /**
+ * Return base (the "end") of stack
+ */
+ addr_t base() const { return _base; }
+
+ /**
+ * Ensure that the stack has a given minimum size
+ *
+ * \param size minimum stack size
+ *
+ * \throw Stack_too_large
+ * \throw Stack_alloc_failed
+ */
+ void size(size_t const size);
+
+ /**
+ * Return UTCB of the stack's thread
+ */
+ Native_utcb &utcb() { return _utcb; }
+
+ /**
+ * Return thread name
+ */
+ Name name() const { return _name; }
+
+ /**
+ * Return 'Thread_base' object of the stack's thread
+ */
+ Thread_base &thread() { return _thread; }
+
+ /**
+ * Return dataspace used as the stack's backing storage
+ */
+ Ram_dataspace_capability ds_cap() const { return _ds_cap; }
+};
+
+#endif /* _INCLUDE__BASE__INTERNAL__STACK_H_ */
diff --git a/repos/base/src/include/base/internal/stack_allocator.h b/repos/base/src/include/base/internal/stack_allocator.h
new file mode 100644
index 0000000000..4cce2554d0
--- /dev/null
+++ b/repos/base/src/include/base/internal/stack_allocator.h
@@ -0,0 +1,92 @@
+/*
+ * \brief Stack allocator
+ * \author Norman Feske
+ * \date 2006-04-28
+ */
+
+/*
+ * Copyright (C) 2006-2016 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 _INCLUDE__BASE__INTERNAL__STACK_ALLOCATOR_H_
+#define _INCLUDE__BASE__INTERNAL__STACK_ALLOCATOR_H_
+
+/* base-internal includes */
+#include
+
+namespace Genode { class Stack_allocator; }
+
+
+/**
+ * Manage the allocation of stacks within the stack area
+ *
+ * There exists only one instance of this class per process.
+ */
+class Genode::Stack_allocator
+{
+ private:
+
+ static constexpr size_t MAX_THREADS =
+ Native_config::stack_area_virtual_size() /
+ Native_config::stack_virtual_size();
+
+ struct Stack_bit_allocator : Bit_allocator
+ {
+ Stack_bit_allocator()
+ {
+ /* the first index is used by main thread */
+ _reserve(0, 1);
+ }
+ } _alloc;
+
+ Lock _threads_lock;
+
+ public:
+
+ /**
+ * Allocate stack for specified thread
+ *
+ * \param thread thread for which to allocate the new stack
+ * \param main_thread wether to alloc for the main thread
+ *
+ * \return virtual address of new stack, or
+ * 0 if the allocation failed
+ */
+ Stack *alloc(Thread_base *thread, bool main_thread);
+
+ /**
+ * Release stack
+ */
+ void free(Stack *);
+
+ /**
+ * Return 'Stack' object for a given base address
+ */
+ static Stack *base_to_stack(addr_t base);
+
+ /**
+ * Return base address of stack containing the specified address
+ */
+ static addr_t addr_to_base(void *addr);
+
+ /**
+ * Return index in stack area for a given base address
+ */
+ static size_t base_to_idx(addr_t base);
+
+ /**
+ * Return base address of stack given index in stack area
+ */
+ static addr_t idx_to_base(size_t idx);
+
+ /**
+ * Return singleton thread allocator
+ */
+ static Stack_allocator &stack_allocator();
+};
+
+
+#endif /* _INCLUDE__BASE__INTERNAL__STACK_ALLOCATOR_H_ */
diff --git a/repos/base/src/lib/ldso/main.cc b/repos/base/src/lib/ldso/main.cc
index 110f4d826a..8161e5536f 100644
--- a/repos/base/src/lib/ldso/main.cc
+++ b/repos/base/src/lib/ldso/main.cc
@@ -572,9 +572,9 @@ int main()
/* print loaded object information */
try {
if (Genode::config()->xml_node().attribute("ld_verbose").has_value("yes")) {
- PINF(" %lx .. %lx: context area", Genode::Native_config::context_area_virtual_base(),
- Genode::Native_config::context_area_virtual_base() +
- Genode::Native_config::context_area_virtual_size() - 1);
+ PINF(" %lx .. %lx: stack area", Genode::Native_config::stack_area_virtual_base(),
+ Genode::Native_config::stack_area_virtual_base() +
+ Genode::Native_config::stack_area_virtual_size() - 1);
dump_loaded();
}
} catch (...) { }
diff --git a/repos/base/src/lib/startup/init_main_thread.cc b/repos/base/src/lib/startup/init_main_thread.cc
index 18184f5d5f..c8c2f15f30 100644
--- a/repos/base/src/lib/startup/init_main_thread.cc
+++ b/repos/base/src/lib/startup/init_main_thread.cc
@@ -25,7 +25,7 @@ addr_t init_main_thread_result;
extern void init_exception_handling();
-namespace Genode { Rm_session * env_context_area_rm_session(); }
+namespace Genode { Rm_session * env_stack_area_rm_session(); }
void prepare_init_main_thread();
@@ -97,7 +97,7 @@ extern "C" void init_main_thread()
* We create the thread-context area as early as possible to prevent other
* mappings from occupying the predefined virtual-memory region.
*/
- env_context_area_rm_session();
+ env_stack_area_rm_session();
/*
* Trigger first exception. This step has two purposes.
@@ -112,7 +112,7 @@ extern "C" void init_main_thread()
* Genode's heap and, in some corner cases, consumes several KB of stack.
* This is usually not a problem when the first exception is triggered from
* the main thread but it becomes an issue when the first exception is
- * thrown from the context of a thread with a specially tailored (and
+ * thrown from the stack of a thread with a specially tailored (and
* otherwise sufficient) stack size. By throwing an exception here, we
* mitigate this issue by eagerly performing those allocations.
*/
diff --git a/repos/base/src/test/thread/main.cc b/repos/base/src/test/thread/main.cc
index 2b1268818d..fcf90d7e12 100644
--- a/repos/base/src/test/thread/main.cc
+++ b/repos/base/src/test/thread/main.cc
@@ -22,9 +22,9 @@
using namespace Genode;
-/*********************+********************
- ** Thread-context allocator concurrency **
- ******************************************/
+/*********************************
+ ** Stack-allocator concurrency **
+ *********************************/
template
struct Helper : Thread<0x2000>
@@ -33,25 +33,25 @@ struct Helper : Thread<0x2000>
Helper() : Thread<0x2000>("helper") { }
- void *context() const { return _context; }
+ void *stack() const { return _stack; }
void entry()
{
Helper helper[CHILDREN];
for (unsigned i = 0; i < CHILDREN; ++i)
- child[i] = helper[i].context();
+ child[i] = helper[i].stack();
}
};
-static void test_context_alloc()
+static void test_stack_alloc()
{
printf("running '%s'\n", __func__);
/*
* Create HELPER threads, which concurrently create CHILDREN threads each.
- * This most likely triggers any race in the thread-context allocation.
+ * This most likely triggers any race in the stack allocation.
*/
enum { HELPER = 10, CHILDREN = 9 };
@@ -135,16 +135,19 @@ static void test_main_thread()
if (!myself) { throw -1; }
printf("thread base %p\n", myself);
- /* check wether my stack is inside the first context region */
- addr_t const context_base = Native_config::context_area_virtual_base();
- addr_t const context_size = Native_config::context_area_virtual_size();
- addr_t const context_top = context_base + context_size;
+ /* check whether my stack is inside the first stack region */
+ addr_t const stack_slot_base = Native_config::stack_area_virtual_base();
+ addr_t const stack_slot_size = Native_config::stack_area_virtual_size();
+ addr_t const stack_slot_top = stack_slot_base + stack_slot_size;
+
addr_t const stack_top = (addr_t)myself->stack_top();
addr_t const stack_base = (addr_t)myself->stack_base();
- if (stack_top <= context_base) { throw -2; }
- if (stack_top > context_top) { throw -3; }
- if (stack_base >= context_top) { throw -4; }
- if (stack_base < context_base) { throw -5; }
+
+ if (stack_top <= stack_slot_base) { throw -2; }
+ if (stack_top > stack_slot_top) { throw -3; }
+ if (stack_base >= stack_slot_top) { throw -4; }
+ if (stack_base < stack_slot_base) { throw -5; }
+
printf("thread stack top %p\n", myself->stack_top());
printf("thread stack bottom %p\n", myself->stack_base());
@@ -168,7 +171,10 @@ struct Cpu_helper : Thread<0x2000>
void entry()
{
- printf("%s : _cpu_session=0x%p env()->cpu_session()=0x%p\n", _context->name, _cpu_session, env()->cpu_session());
+ char name[64];
+ Thread_base::name(name, sizeof(name));
+ printf("%s : _cpu_session=0x%p env()->cpu_session()=0x%p\n",
+ name, _cpu_session, env()->cpu_session());
}
};
@@ -265,8 +271,8 @@ static void test_create_as_many_threads()
{
printf("running '%s'\n", __func__);
- addr_t const max = Native_config::context_area_virtual_size() /
- Native_config::context_virtual_size();
+ addr_t const max = Native_config::stack_area_virtual_size() /
+ Native_config::stack_virtual_size();
static Cpu_helper * threads[max];
static char thread_name[8];
@@ -281,8 +287,8 @@ static void test_create_as_many_threads()
threads[i]->join();
} catch (Cpu_session::Thread_creation_failed) {
throw "Thread_creation_failed";
- } catch (Thread_base::Context_alloc_failed) {
- throw "Context_alloc_failed";
+ } catch (Thread_base::Out_of_stack_space) {
+ throw "Out_of_stack_space";
}
}
} catch (const char * ex) {
@@ -295,7 +301,7 @@ static void test_create_as_many_threads()
}
/*
- * We have to get a context_alloc_failed message, because we can't create
+ * We have to get a Out_of_stack_space message, because we can't create
* up to max threads, because already the main thread is running ...
*/
throw -21;
@@ -306,7 +312,7 @@ int main()
printf("--- thread test started ---\n");
try {
- test_context_alloc();
+ test_stack_alloc();
test_stack_alignment();
test_main_thread();
test_cpu_session();
diff --git a/repos/libports/src/lib/pthread/thread.cc b/repos/libports/src/lib/pthread/thread.cc
index 8972aa3ae3..1ea386ccef 100644
--- a/repos/libports/src/lib/pthread/thread.cc
+++ b/repos/libports/src/lib/pthread/thread.cc
@@ -140,7 +140,7 @@ extern "C" {
*/
if (!_pthread_main_np()) {
- char name[Thread_base::Context::NAME_LEN];
+ char name[64];
myself->name(name, sizeof(name));
PERR("pthread_self() called from alien thread named '%s'", name);
diff --git a/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc b/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc
index ac70bee2fb..9efb5b4d71 100644
--- a/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc
+++ b/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc
@@ -63,7 +63,7 @@ struct SDL_PrivateAudioData {
/*
* The first 'Signal_receiver' object in a process creates a signal receiver
* thread. Currently this must not happen before the main program has started
- * or else the thread's context area would get overmapped on Genode/Linux when
+ * or else the thread's stack area would get overmapped on Genode/Linux when
* the main program calls 'main_thread_bootstrap()' from '_main()'.
*/
static Signal_receiver *signal_receiver()
diff --git a/repos/ports-foc/src/lib/l4lx/include/vcpu.h b/repos/ports-foc/src/lib/l4lx/include/vcpu.h
index cadba62112..f0ab185e04 100644
--- a/repos/ports-foc/src/lib/l4lx/include/vcpu.h
+++ b/repos/ports-foc/src/lib/l4lx/include/vcpu.h
@@ -43,6 +43,7 @@ namespace L4lx {
Genode::addr_t _vcpu_state;
Timer::Connection _timer;
unsigned _cpu_nr;
+ Fiasco::l4_utcb_t * const _utcb;
public:
@@ -57,12 +58,13 @@ namespace L4lx {
_func(func),
_data(data ? *data : 0),
_vcpu_state(vcpu_state),
- _cpu_nr(cpu_nr)
+ _cpu_nr(cpu_nr),
+ _utcb((Fiasco::l4_utcb_t *)_cpu_session->state(cap()).utcb)
{
start();
/* set l4linux specific utcb entry: L4X_UTCB_TCR_ID */
- l4_utcb_tcr_u(utcb())->user[0] = tid();
+ l4_utcb_tcr_u(_utcb)->user[0] = tid().kcap;
/* enable vcpu functionality respectively */
if (_vcpu_state)
@@ -81,11 +83,11 @@ namespace L4lx {
void unblock() { _lock.unlock(); }
- Genode::addr_t sp() { return _context->stack_top(); }
+ Genode::addr_t sp() { return (Genode::addr_t)stack_top(); }
Genode::addr_t ip() { return (Genode::addr_t)_func; }
- Fiasco::l4_utcb_t *utcb() { return _context->utcb; };
+ Fiasco::l4_utcb_t *utcb() { return _utcb; };
Timer::Connection* timer() { return &_timer; }
diff --git a/repos/ports-foc/src/lib/l4lx/l4lx_thread.cc b/repos/ports-foc/src/lib/l4lx/l4lx_thread.cc
index 7358a2008f..3d622dd1b8 100644
--- a/repos/ports-foc/src/lib/l4lx/l4lx_thread.cc
+++ b/repos/ports-foc/src/lib/l4lx/l4lx_thread.cc
@@ -212,7 +212,7 @@ l4_cap_idx_t l4lx_thread_get_cap(l4lx_thread_t t)
PWRN("Invalid utcb %lx", (unsigned long) t);
return L4_INVALID_CAP;
}
- return vcpus[thread_id(t)]->tid();
+ return vcpus[thread_id(t)]->tid().kcap;
}
diff --git a/repos/ports-foc/src/lib/l4lx/startup.cc b/repos/ports-foc/src/lib/l4lx/startup.cc
index b1b429ab78..03a2d412af 100644
--- a/repos/ports-foc/src/lib/l4lx/startup.cc
+++ b/repos/ports-foc/src/lib/l4lx/startup.cc
@@ -127,9 +127,9 @@ static void register_reserved_areas()
size_t bin_sz = (addr_t)&_prog_img_end - (addr_t)&_prog_img_beg;
L4lx::Env::env()->rm()->reserve_range((addr_t)&_prog_img_beg, bin_sz, "Binary");
- L4lx::Env::env()->rm()->reserve_range(Native_config::context_area_virtual_base(),
- Native_config::context_area_virtual_size(),
- "Thread Context Area");
+ L4lx::Env::env()->rm()->reserve_range(Native_config::stack_area_virtual_base(),
+ Native_config::stack_area_virtual_size(),
+ "Stack Area");
}
diff --git a/repos/ports/run/virtualbox.run b/repos/ports/run/virtualbox.run
index eab4eb5c50..13d74332a7 100644
--- a/repos/ports/run/virtualbox.run
+++ b/repos/ports/run/virtualbox.run
@@ -142,6 +142,7 @@ lappend_if [have_spec x86] boot_modules rtc_drv
append boot_modules {
ld.lib.so libc.lib.so libm.lib.so pthread.lib.so libc_lock_pipe.lib.so
libc_terminal.lib.so libiconv.lib.so stdcxx.lib.so
+ qemu-usb.lib.so
}
append_if [expr $use_net] boot_modules { nic_drv }
diff --git a/repos/ports/src/app/seoul/main.cc b/repos/ports/src/app/seoul/main.cc
index 240b678357..3ec6d3e584 100644
--- a/repos/ports/src/app/seoul/main.cc
+++ b/repos/ports/src/app/seoul/main.cc
@@ -1408,13 +1408,13 @@ int main(int argc, char **argv)
{
/*
* Reserve complete lower address space so that nobody else can take
- * it. The context area is moved as far as possible to a high virtual
+ * it. The stack area is moved as far as possible to a high virtual
* address. So we can use its base address as upper bound. The
* reservation will be dropped when this scope is left and re-acquired
* with the actual VM size which is determined below inside this scope.
*/
Vmm::Virtual_reservation
- reservation(Genode::Native_config::context_area_virtual_base());
+ reservation(Genode::Native_config::stack_area_virtual_base());
Genode::printf("--- Vancouver VMM starting ---\n");
@@ -1467,10 +1467,10 @@ int main(int argc, char **argv)
guest_memory.backing_store_fb_local_base() + fb_size,
fb_size / 1024 / 1024);
- Genode::printf("[0x%012lx, 0x%012lx) - Genode thread context area\n",
- Genode::Native_config::context_area_virtual_base(),
- Genode::Native_config::context_area_virtual_base() +
- Genode::Native_config::context_area_virtual_size());
+ Genode::printf("[0x%012lx, 0x%012lx) - Genode stack area\n",
+ Genode::Native_config::stack_area_virtual_base(),
+ Genode::Native_config::stack_area_virtual_base() +
+ Genode::Native_config::stack_area_virtual_size());
Genode::printf("[0x%012lx, 0x%012lx) - VMM program image\n",
(Genode::addr_t)&_prog_img_beg,
diff --git a/repos/ports/src/lib/libc_noux/plugin.cc b/repos/ports/src/lib/libc_noux/plugin.cc
index 7c1dd81d35..88c6cf9958 100644
--- a/repos/ports/src/lib/libc_noux/plugin.cc
+++ b/repos/ports/src/lib/libc_noux/plugin.cc
@@ -94,12 +94,14 @@ class Noux_connection
Noux_connection() : _sysio(_obtain_sysio()) { }
/**
- * Return the capability of the local context-area RM session
+ * Return the capability of the local stack-area RM session
*
- * \param ptr some address within the context-area
+ * \param ptr some address within the stack-area
*/
- Genode::Rm_session_capability context_area_rm_session(void * const ptr) {
- return _connection.lookup_rm_session((Genode::addr_t)ptr); }
+ Genode::Rm_session_capability stack_area_rm_session(void * const ptr)
+ {
+ return _connection.lookup_rm_session((Genode::addr_t)ptr);
+ }
Noux::Session *session() { return &_connection; }
Noux::Sysio *sysio() { return _sysio; }
@@ -506,7 +508,7 @@ extern "C" int select(int nfds, fd_set *readfds, fd_set *writefds,
#include
-static void * stack_in_context_area;
+static void * in_stack_area;
static jmp_buf fork_jmp_buf;
static Genode::Capability::Raw new_parent;
@@ -532,9 +534,9 @@ extern "C" void fork_trampoline()
/* reinitialize noux connection */
construct_at(noux_connection());
- /* reinitialize main-thread object which implies reinit of context area */
- auto context_area_rm = noux_connection()->context_area_rm_session(stack_in_context_area);
- Genode::env()->reinit_main_thread(context_area_rm);
+ /* reinitialize main-thread object which implies reinit of stack area */
+ auto stack_area_rm = noux_connection()->stack_area_rm_session(in_stack_area);
+ Genode::env()->reinit_main_thread(stack_area_rm);
/* apply processor state that the forker had when he did the fork */
longjmp(fork_jmp_buf, 1);
@@ -558,10 +560,10 @@ extern "C" pid_t fork(void)
/*
* save the current stack address used for re-initializing
- * the context-area during process bootstrap
+ * the stack area during process bootstrap
*/
int dummy;
- stack_in_context_area = &dummy;
+ in_stack_area = &dummy;
/* got here during the normal control flow of the fork call */
sysio()->fork_in.ip = (Genode::addr_t)(&fork_trampoline);
diff --git a/repos/ports/src/virtualbox/spec/nova/vcpu.h b/repos/ports/src/virtualbox/spec/nova/vcpu.h
index 524d86f7c2..3bdbc01015 100644
--- a/repos/ports/src/virtualbox/spec/nova/vcpu.h
+++ b/repos/ports/src/virtualbox/spec/nova/vcpu.h
@@ -82,8 +82,7 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher,
X86FXSTATE _guest_fpu_state __attribute__((aligned(0x10)));
X86FXSTATE _emt_fpu_state __attribute__((aligned(0x10)));
- Genode::Cap_connection _cap_connection;
- Vmm::Vcpu_other_pd _vcpu;
+ Vmm::Vcpu_other_pd _vcpu;
Genode::addr_t _ec_sel;
bool _irq_win;
@@ -713,7 +712,7 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher,
Genode::Affinity::Location location,
unsigned int cpu_id)
:
- Vmm::Vcpu_dispatcher(stack_size, _cap_connection,
+ Vmm::Vcpu_dispatcher(stack_size, *Genode::env()->pd_session(),
cpu_session, location,
attr ? *attr : 0, start_routine, arg),
_vcpu(cpu_session, location),
diff --git a/repos/ports/src/virtualbox/thread.cc b/repos/ports/src/virtualbox/thread.cc
index d607a24e2c..05d6cfd213 100644
--- a/repos/ports/src/virtualbox/thread.cc
+++ b/repos/ports/src/virtualbox/thread.cc
@@ -68,7 +68,7 @@ static int create_thread(pthread_t *thread, const pthread_attr_t *attr,
Assert(rtthread);
- size_t stack_size = Genode::Native_config::context_virtual_size() -
+ size_t stack_size = Genode::Native_config::stack_virtual_size() -
sizeof(Genode::Native_utcb) - 2 * (1UL << 12);
if (rtthread->cbStack < stack_size)