From e44648e1ab4c54a1d5b32abb80ab001e81823264 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Wed, 1 Aug 2012 17:04:43 +0200 Subject: [PATCH] NOVA: remove pd selector from non Core code Pd selector isn't used beside core anymore - remove all occurrences inside base code. --- base-nova/include/base/cap_sel_alloc.h | 7 ------- base-nova/include/base/native_types.h | 20 ++++++++++--------- base-nova/src/base/env/cap_sel_alloc.cc | 5 +---- base-nova/src/base/lock/lock_helper.h | 6 +++--- base-nova/src/base/pager/pager.cc | 1 + base-nova/src/base/thread/thread_nova.cc | 1 - base-nova/src/core/echo.cc | 6 +++++- .../src/core/include/cap_session_component.h | 3 +++ base-nova/src/core/include/platform_pd.h | 14 +++++++++++++ base-nova/src/core/platform.cc | 10 +++++----- base-nova/src/core/platform_pd.cc | 1 - base-nova/src/core/platform_thread.cc | 2 +- base-nova/src/core/signal_source_component.cc | 5 +++-- base-nova/src/core/thread_start.cc | 5 +++-- base-nova/src/platform/_main_helper.h | 9 +-------- 15 files changed, 51 insertions(+), 44 deletions(-) diff --git a/base-nova/include/base/cap_sel_alloc.h b/base-nova/include/base/cap_sel_alloc.h index b7b4a4e9c..2aed41f88 100644 --- a/base-nova/include/base/cap_sel_alloc.h +++ b/base-nova/include/base/cap_sel_alloc.h @@ -56,13 +56,6 @@ namespace Genode { */ void free(addr_t cap, size_t num_caps_log2); - /** - * Capability selector of local protection domain - * - * \return PD selector - */ - static unsigned pd_sel(); - }; /** diff --git a/base-nova/include/base/native_types.h b/base-nova/include/base/native_types.h index f923f745e..bc07136e1 100644 --- a/base-nova/include/base/native_types.h +++ b/base-nova/include/base/native_types.h @@ -26,20 +26,21 @@ namespace Genode { struct Native_thread { - addr_t ec_sel; /* NOVA cap selector for execution context */ - addr_t pd_sel; /* NOVA cap selector of protection domain */ - addr_t exc_pt_sel; /* base of event portal window */ + addr_t ec_sel; /* NOVA cap selector for execution context */ + addr_t exc_pt_sel; /* base of event portal window */ }; typedef Native_thread Native_thread_id; inline bool operator == (Native_thread_id t1, Native_thread_id t2) { - return (t1.ec_sel == t2.ec_sel) && (t1.pd_sel == t2.pd_sel); + return (t1.ec_sel == t2.ec_sel) && + (t1.exc_pt_sel == t2.exc_pt_sel); } inline bool operator != (Native_thread_id t1, Native_thread_id t2) { - return (t1.ec_sel != t2.ec_sel) && (t1.pd_sel != t2.pd_sel); + return (t1.ec_sel != t2.ec_sel) && + (t1.exc_pt_sel != t2.exc_pt_sel); } class Native_utcb @@ -47,16 +48,17 @@ namespace Genode { private: /** - * Size of the NOVA-specific user-level thread-control block + * Size of the NOVA-specific user-level thread-control + * block */ enum { UTCB_SIZE = 4096 }; /** * User-level thread control block * - * The UTCB is one 4K page, shared between the kernel and the - * user process. It is not backed by a dataspace but provided - * by the kernel. + * The UTCB is one 4K page, shared between the kernel + * and the user process. It is not backed by a + * dataspace but provided by the kernel. */ addr_t _utcb[UTCB_SIZE/sizeof(addr_t)]; }; diff --git a/base-nova/src/base/env/cap_sel_alloc.cc b/base-nova/src/base/env/cap_sel_alloc.cc index 03a328304..3a9443b62 100644 --- a/base-nova/src/base/env/cap_sel_alloc.cc +++ b/base-nova/src/base/env/cap_sel_alloc.cc @@ -30,7 +30,6 @@ using namespace Genode; * Must be initialized by the startup code */ int __first_free_cap_selector; -int __local_pd_sel; /** * Low-level lock to protect the allocator @@ -86,9 +85,7 @@ void Cap_selector_allocator::free(addr_t cap, size_t num_caps_log2) } -unsigned Cap_selector_allocator::pd_sel() { return __local_pd_sel; } - -Cap_selector_allocator::Cap_selector_allocator() : Bit_allocator<4096>() +Cap_selector_allocator::Cap_selector_allocator() { /* initialize lock */ alloc_lock(); diff --git a/base-nova/src/base/lock/lock_helper.h b/base-nova/src/base/lock/lock_helper.h index d7241fdff..44d97c028 100644 --- a/base-nova/src/base/lock/lock_helper.h +++ b/base-nova/src/base/lock/lock_helper.h @@ -45,7 +45,7 @@ static inline void thread_yield() { } static bool thread_check_stopped_and_restart(Genode::Native_thread_id tid) { - Genode::addr_t sem = tid.pd_sel == 0 ? + Genode::addr_t sem = (tid.ec_sel == 0 && tid.exc_pt_sel == 0) ? main_thread_running_semaphore() : tid.exc_pt_sel + Nova::SM_SEL_EC; @@ -72,14 +72,14 @@ static inline Genode::Native_thread_id thread_get_my_native_id() static inline Genode::Native_thread_id thread_invalid_id() { - Genode::Native_thread_id tid = { 0, ~0UL }; + Genode::Native_thread_id tid = { ~0UL, ~0UL }; return tid; } static inline bool thread_id_valid(Genode::Native_thread_id tid) { - return tid.pd_sel != ~0UL; + return !(tid.ec_sel == ~0UL && tid.exc_pt_sel == ~0UL); } diff --git a/base-nova/src/base/pager/pager.cc b/base-nova/src/base/pager/pager.cc index 5528940f0..511d707bc 100644 --- a/base-nova/src/base/pager/pager.cc +++ b/base-nova/src/base/pager/pager.cc @@ -25,6 +25,7 @@ using namespace Genode; using namespace Nova; enum { PF_HANDLER_STACK_SIZE = sizeof(addr_t) * 1024 }; +extern Genode::addr_t __core_pd_sel; void Pager_object::_page_fault_handler() { diff --git a/base-nova/src/base/thread/thread_nova.cc b/base-nova/src/base/thread/thread_nova.cc index 00e59d787..1f8fd1132 100644 --- a/base-nova/src/base/thread/thread_nova.cc +++ b/base-nova/src/base/thread/thread_nova.cc @@ -54,7 +54,6 @@ void Thread_base::_init_platform_thread() * running semaphore and exception handler portals. */ _tid.ec_sel = ~0UL; - _tid.pd_sel = cap_selector_allocator()->pd_sel(); _tid.exc_pt_sel = cap_selector_allocator()->alloc(NUM_INITIAL_PT_LOG2); /* create thread at core */ diff --git a/base-nova/src/core/echo.cc b/base-nova/src/core/echo.cc index b76c62957..5b2bc2e84 100644 --- a/base-nova/src/core/echo.cc +++ b/base-nova/src/core/echo.cc @@ -1,6 +1,7 @@ /* * \brief Echo implementation * \author Norman Feske + * \author Alexander Boettcher * \date 2010-01-19 */ @@ -14,6 +15,9 @@ /* Genode includes */ #include +/* Core includes */ +#include + /* local includes */ #include @@ -65,7 +69,7 @@ Echo::Echo(Genode::addr_t utcb_addr) using namespace Nova; /* create echo EC */ - int pd_sel = Genode::Cap_selector_allocator::pd_sel(); + Genode::addr_t pd_sel = Genode::Platform_pd::pd_core_sel(); uint8_t res = create_ec(_ec_sel, pd_sel, ECHO_CPU_NO, utcb_addr, (mword_t)echo_stack_top(), ECHO_EXC_BASE, ECHO_GLOBAL); diff --git a/base-nova/src/core/include/cap_session_component.h b/base-nova/src/core/include/cap_session_component.h index 0dabf05ea..bc8f03f1d 100644 --- a/base-nova/src/core/include/cap_session_component.h +++ b/base-nova/src/core/include/cap_session_component.h @@ -18,6 +18,9 @@ #include #include +/* core includes */ +#include + namespace Genode { class Cap_session_component : public Rpc_object diff --git a/base-nova/src/core/include/platform_pd.h b/base-nova/src/core/include/platform_pd.h index a652cf098..ec41c01c4 100644 --- a/base-nova/src/core/include/platform_pd.h +++ b/base-nova/src/core/include/platform_pd.h @@ -16,6 +16,12 @@ #include +/* + * Must be initialized by the startup code, + * only valid in core + */ +extern Genode::addr_t __core_pd_sel; + namespace Genode { class Platform_thread; @@ -73,6 +79,14 @@ namespace Genode { addr_t pd_sel() { return _pd_sel; } int id() { return _id; } + + /** + * Capability selector of core protection domain + * + * \return PD selector + */ + static addr_t pd_core_sel() { return __core_pd_sel; } + }; } diff --git a/base-nova/src/core/platform.cc b/base-nova/src/core/platform.cc index 53f1809e9..4a0401e6e 100644 --- a/base-nova/src/core/platform.cc +++ b/base-nova/src/core/platform.cc @@ -64,7 +64,7 @@ extern unsigned _prog_img_beg, _prog_img_end; /** * Capability selector of root PD */ -extern int __local_pd_sel; +addr_t __core_pd_sel; /** * Preserve physical page for the exclusive (read-only) use by core @@ -161,7 +161,7 @@ static void init_core_page_fault_handler() PDBG("create_ec returned %u", ret); /* set up page-fault portal */ - create_pt(PT_SEL_PAGE_FAULT, __local_pd_sel, ec_sel, + create_pt(PT_SEL_PAGE_FAULT, __core_pd_sel, ec_sel, Mtd(Mtd::QUAL | Mtd::ESP | Mtd::EIP), (addr_t)page_fault_handler); } @@ -185,11 +185,11 @@ Platform::Platform() : __first_free_cap_selector = hip->sel_exc + hip->sel_gsi + 3; /* set core pd selector */ - __local_pd_sel = hip->sel_exc; + __core_pd_sel = hip->sel_exc; /* create lock used by capability allocator */ - Nova::create_sm(Nova::PD_SEL_CAP_LOCK, __local_pd_sel, 1); - Nova::create_sm(Nova::SM_SEL_EC, __local_pd_sel, 0); + Nova::create_sm(Nova::PD_SEL_CAP_LOCK, __core_pd_sel, 1); + Nova::create_sm(Nova::SM_SEL_EC, __core_pd_sel, 0); /* locally map the whole I/O port range */ enum { ORDER_64K = 16 }; diff --git a/base-nova/src/core/platform_pd.cc b/base-nova/src/core/platform_pd.cc index 99b1294f2..1c7cd069e 100644 --- a/base-nova/src/core/platform_pd.cc +++ b/base-nova/src/core/platform_pd.cc @@ -19,7 +19,6 @@ using namespace Genode; - /*************************** ** Public object members ** ***************************/ diff --git a/base-nova/src/core/platform_thread.cc b/base-nova/src/core/platform_thread.cc index 0bbe46d39..9467e9153 100644 --- a/base-nova/src/core/platform_thread.cc +++ b/base-nova/src/core/platform_thread.cc @@ -98,7 +98,7 @@ int Platform_thread::start(void *ip, void *sp, addr_t exc_base) */ _pager->initial_esp(PD_UTCB + get_page_size()); - addr_t pd_sel = cap_selector_allocator()->pd_sel(); + addr_t pd_sel = Platform_pd::pd_core_sel(); addr_t exc_base_sel = cap_selector_allocator()->alloc(Nova::NUM_INITIAL_PT_LOG2); addr_t sm_alloc_sel = exc_base_sel + PD_SEL_CAP_LOCK; addr_t sm_ec_sel = exc_base_sel + SM_SEL_EC; diff --git a/base-nova/src/core/signal_source_component.cc b/base-nova/src/core/signal_source_component.cc index e0f19be4d..097720f49 100644 --- a/base-nova/src/core/signal_source_component.cc +++ b/base-nova/src/core/signal_source_component.cc @@ -18,6 +18,7 @@ /* core includes */ #include +#include /* NOVA includes */ #include @@ -67,9 +68,9 @@ Signal_source_component::Signal_source_component(Rpc_entrypoint *ep) /* initialized blocking semaphore */ addr_t sem_sel = cap_selector_allocator()->alloc(); uint8_t ret = Nova::create_sm(sem_sel, - cap_selector_allocator()->pd_sel(), 0); + Platform_pd::pd_core_sel(), 0); if (ret) - PERR("create_sm returned %d", ret); + PERR("create_sm returned %u", ret); _blocking_semaphore = Native_capability(sem_sel); } diff --git a/base-nova/src/core/thread_start.cc b/base-nova/src/core/thread_start.cc index 67b99c008..16e9e6d60 100644 --- a/base-nova/src/core/thread_start.cc +++ b/base-nova/src/core/thread_start.cc @@ -25,6 +25,7 @@ /* core includes */ #include +#include using namespace Genode; @@ -44,7 +45,7 @@ void Thread_base::_init_platform_thread() /* create running semaphore required for locking */ addr_t rs_sel =_tid.exc_pt_sel + SM_SEL_EC; - uint8_t res = create_sm(rs_sel, _tid.pd_sel, 0); + uint8_t res = create_sm(rs_sel, pd_sel, 0); if (res != NOVA_OK) { PERR("create_sm returned %u", res); throw Cpu_session::Thread_creation_failed(); @@ -55,7 +56,7 @@ void Thread_base::_init_platform_thread() /* create local EC */ enum { CPU_NO = 0, GLOBAL = false }; - res = create_ec(_tid.ec_sel, Cap_selector_allocator::pd_sel(), CPU_NO, + res = create_ec(_tid.ec_sel, pd_sel, CPU_NO, utcb, sp, _tid.exc_pt_sel, GLOBAL); if (res != NOVA_OK) { PERR("%p - create_ec returned %d", this, res); diff --git a/base-nova/src/platform/_main_helper.h b/base-nova/src/platform/_main_helper.h index 0b3871b3f..f65a9845e 100644 --- a/base-nova/src/platform/_main_helper.h +++ b/base-nova/src/platform/_main_helper.h @@ -16,6 +16,7 @@ #define _PLATFORM___MAIN_HELPER_H_ #include +#include /** * Location of the main thread's UTCB, initialized by the startup code @@ -34,11 +35,6 @@ extern long __initial_sp; */ extern int __first_free_cap_selector; -/** - * Selector of local protection domain - */ -extern int __local_pd_sel; - static void main_thread_bootstrap() { /* register UTCB of main thread */ @@ -50,9 +46,6 @@ static void main_thread_bootstrap() /* this variable may be set by the dynamic linker (ldso) */ if (!__first_free_cap_selector) __first_free_cap_selector = FIRST_FREE_PORTAL; - - /* register pd selector at cap allocator */ - __local_pd_sel = Nova::PD_SEL; } #endif /* _PLATFORM___MAIN_HELPER_H_ */