NOVA: remove pd selector from non Core code

Pd selector isn't used beside core anymore - remove all occurrences inside base
code.
This commit is contained in:
Alexander Boettcher 2012-08-01 17:04:43 +02:00 committed by Norman Feske
parent b6ea5714d7
commit e44648e1ab
15 changed files with 51 additions and 44 deletions

View File

@ -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();
};
/**

View File

@ -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)];
};

View File

@ -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();

View File

@ -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);
}

View File

@ -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()
{

View File

@ -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 */

View File

@ -1,6 +1,7 @@
/*
* \brief Echo implementation
* \author Norman Feske
* \author Alexander Boettcher
* \date 2010-01-19
*/
@ -14,6 +15,9 @@
/* Genode includes */
#include <base/cap_sel_alloc.h>
/* Core includes */
#include <platform_pd.h>
/* local includes */
#include <echo.h>
@ -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);

View File

@ -18,6 +18,9 @@
#include <base/rpc_server.h>
#include <base/lock.h>
/* core includes */
#include <platform_pd.h>
namespace Genode {
class Cap_session_component : public Rpc_object<Cap_session>

View File

@ -16,6 +16,12 @@
#include <platform_thread.h>
/*
* 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; }
};
}

View File

@ -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 };

View File

@ -19,7 +19,6 @@
using namespace Genode;
/***************************
** Public object members **
***************************/

View File

@ -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;

View File

@ -18,6 +18,7 @@
/* core includes */
#include <signal_session_component.h>
#include <platform_pd.h>
/* NOVA includes */
#include <nova/syscalls.h>
@ -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);
}

View File

@ -25,6 +25,7 @@
/* core includes */
#include <nova_util.h>
#include <platform_pd.h>
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);

View File

@ -16,6 +16,7 @@
#define _PLATFORM___MAIN_HELPER_H_
#include <nova/syscalls.h>
#include <base/stdint.h>
/**
* 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_ */