mirror of
https://github.com/genodelabs/genode.git
synced 2025-03-22 03:55:26 +00:00
Cleanup: cap allocation
Allocate exc_pt_sel inside Thread_base object instead of pager object, since it is a thread specific characteristic. Same for freeing of the thread capabilities: - ec, sc, rs, exc_pt_sel is thread specific and has nothing to do in server nor pager object.
This commit is contained in:
parent
4d5d91efef
commit
1d6a00f01a
@ -44,7 +44,6 @@ namespace Genode {
|
||||
*/
|
||||
Signal_context_capability _exception_sigh;
|
||||
|
||||
unsigned _exc_pt_sel; /* base of event portal window */
|
||||
unsigned _pt_sel; /* portal selector for object identity */
|
||||
unsigned _pt_cleanup; /* portal selector for object cleanup/destruction */
|
||||
|
||||
@ -76,7 +75,7 @@ namespace Genode {
|
||||
/**
|
||||
* Return base of initial portal window
|
||||
*/
|
||||
unsigned exc_pt_sel() { return _exc_pt_sel; }
|
||||
unsigned exc_pt_sel() { return _tid.exc_pt_sel; }
|
||||
|
||||
/**
|
||||
* Set initial stack pointer used by the startup handler
|
||||
|
@ -87,7 +87,7 @@ void Pager_object::_invoke_handler()
|
||||
utcb->set_msg_word(0);
|
||||
|
||||
if (event == PT_SEL_STARTUP || event == PT_SEL_PAGE_FAULT)
|
||||
utcb->append_item(Obj_crd(obj->_exc_pt_sel + event, 0), 0);
|
||||
utcb->append_item(Obj_crd(obj->exc_pt_sel() + event, 0), 0);
|
||||
|
||||
reply(Thread_base::myself()->stack_top());
|
||||
}
|
||||
@ -112,13 +112,10 @@ Pager_object::Pager_object(unsigned long badge)
|
||||
(mword_t)thread_sp, /* <- delivered to the startup handler */
|
||||
EXC_BASE, GLOBAL);
|
||||
if (res)
|
||||
PDBG("create_ec returned %d", res);
|
||||
|
||||
/* allocate capability-selector range for event portals */
|
||||
_exc_pt_sel = cap_selector_allocator()->alloc(NUM_INITIAL_PT_LOG2);
|
||||
PERR("create_ec returned %d - utcb 0x%lx", res, thread_utcb);
|
||||
|
||||
/* create portal for page-fault handler */
|
||||
res = create_pt(_exc_pt_sel + PT_SEL_PAGE_FAULT, pd_sel, _tid.ec_sel,
|
||||
res = create_pt(exc_pt_sel() + PT_SEL_PAGE_FAULT, pd_sel, _tid.ec_sel,
|
||||
Mtd(Mtd::QUAL | Mtd::EIP), (mword_t)_page_fault_handler);
|
||||
if (res) {
|
||||
PERR("could not create page-fault portal, create_pt returned %d\n",
|
||||
@ -128,7 +125,7 @@ Pager_object::Pager_object(unsigned long badge)
|
||||
}
|
||||
|
||||
/* create portal for startup handler */
|
||||
res = create_pt(_exc_pt_sel + PT_SEL_STARTUP, pd_sel, _tid.ec_sel,
|
||||
res = create_pt(exc_pt_sel() + PT_SEL_STARTUP, pd_sel, _tid.ec_sel,
|
||||
Mtd(Mtd::ESP | Mtd::EIP), (mword_t)_startup_handler);
|
||||
if (res) {
|
||||
PERR("could not create startup portal, create_pt returned %d\n",
|
||||
@ -157,7 +154,7 @@ Pager_object::Pager_object(unsigned long badge)
|
||||
Pager_object::~Pager_object()
|
||||
{
|
||||
/* Revoke thread portals serving exceptions */
|
||||
revoke(Obj_crd(_exc_pt_sel,NUM_INITIAL_PT_LOG2), true);
|
||||
revoke(Obj_crd(exc_pt_sel(), NUM_INITIAL_PT_LOG2), true);
|
||||
/* Revoke portal used as identity object */
|
||||
revoke(Obj_crd(_pt_sel, 0), true);
|
||||
|
||||
@ -174,7 +171,6 @@ Pager_object::~Pager_object()
|
||||
/* Revoke portal used for the cleanup call */
|
||||
revoke(Obj_crd(_pt_cleanup, 0), true);
|
||||
|
||||
cap_selector_allocator()->free(_exc_pt_sel, NUM_INITIAL_PT_LOG2);
|
||||
cap_selector_allocator()->free(_pt_sel, 0);
|
||||
cap_selector_allocator()->free(_pt_cleanup, 0);
|
||||
|
||||
|
@ -104,6 +104,12 @@ void Thread_base::_deinit_platform_thread()
|
||||
Nova::revoke(Nova::Obj_crd(_tid.sc_sel, 0));
|
||||
Nova::revoke(Nova::Obj_crd(_tid.ec_sel, 0));
|
||||
Nova::revoke(Nova::Obj_crd(_tid.rs_sel, 0));
|
||||
Nova::revoke(Nova::Obj_crd(_tid.exc_pt_sel, Nova::NUM_INITIAL_PT_LOG2));
|
||||
|
||||
cap_selector_allocator()->free(_tid.ec_sel, 0);
|
||||
cap_selector_allocator()->free(_tid.sc_sel, 0);
|
||||
cap_selector_allocator()->free(_tid.rs_sel, 0);
|
||||
cap_selector_allocator()->free(_tid.exc_pt_sel, Nova::NUM_INITIAL_PT_LOG2);
|
||||
|
||||
/* revoke utcb */
|
||||
Nova::Rights rwx(true, true, true);
|
||||
|
@ -39,6 +39,7 @@ void Thread_base::_init_platform_thread()
|
||||
_tid.sc_sel = ~0; /* not needed within core */
|
||||
_tid.rs_sel = cap_selector_allocator()->alloc();
|
||||
_tid.pd_sel = cap_selector_allocator()->pd_sel();
|
||||
_tid.exc_pt_sel = cap_selector_allocator()->alloc(Nova::NUM_INITIAL_PT_LOG2);
|
||||
|
||||
/* create running semaphore required for locking */
|
||||
uint8_t res = Nova::create_sm(_tid.rs_sel, _tid.pd_sel, 0);
|
||||
@ -51,9 +52,11 @@ void Thread_base::_deinit_platform_thread()
|
||||
{
|
||||
unmap_local(Nova::Obj_crd(_tid.ec_sel, 0));
|
||||
unmap_local(Nova::Obj_crd(_tid.rs_sel, 0));
|
||||
unmap_local(Nova::Obj_crd(_tid.exc_pt_sel, Nova::NUM_INITIAL_PT_LOG2));
|
||||
|
||||
cap_selector_allocator()->free(_tid.ec_sel, 0);
|
||||
cap_selector_allocator()->free(_tid.rs_sel, 0);
|
||||
cap_selector_allocator()->free(_tid.exc_pt_sel, Nova::NUM_INITIAL_PT_LOG2);
|
||||
|
||||
/* revoke utcb */
|
||||
Nova::Rights rwx(true, true, true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user