NOVA: Use everywhere same value for a invalid cap

This commit is contained in:
Alexander Boettcher 2012-08-02 10:10:48 +02:00 committed by Norman Feske
parent e44648e1ab
commit e3a7d2220d
4 changed files with 23 additions and 8 deletions

View File

@ -183,7 +183,7 @@ namespace Genode {
if (_rcv_pt_sel_cnt < _rcv_pt_sel_max)
return _rcv_pt_sel[_rcv_pt_sel_cnt++].sel;
else
return 0;
return ~0UL;
}
/**
@ -294,7 +294,8 @@ namespace Genode {
if (!item) break;
if (_rcv_pt_sel_max >= MAX_CAP_ARGS) break;
_rcv_pt_sel[_rcv_pt_sel_max].sel = item->crd >> 12;
Nova::Crd cap = Nova::Crd(item->crd);
_rcv_pt_sel[_rcv_pt_sel_max].sel = cap.is_null() ? ~0UL : cap.base();
_rcv_pt_sel[_rcv_pt_sel_max++].del = item->is_del();
}
}

View File

@ -26,8 +26,13 @@ namespace Genode {
struct Native_thread
{
enum { INVALID_INDEX = ~0UL };
addr_t ec_sel; /* NOVA cap selector for execution context */
addr_t exc_pt_sel; /* base of event portal window */
Native_thread() : ec_sel(INVALID_INDEX),
exc_pt_sel (INVALID_INDEX) { }
};
typedef Native_thread Native_thread_id;
@ -92,6 +97,7 @@ namespace Genode {
bool _trans_map;
void * _ptr;
enum { INVALID_INDEX = ~0UL };
protected:
explicit
@ -123,18 +129,24 @@ namespace Genode {
bool valid() const
{
return !_cap.dst.is_null() &&
_cap.dst.base() != ~0UL;
_cap.dst.base() != INVALID_INDEX;
}
Dst dst() const { return _cap.dst; }
void * local() const { return _ptr; }
addr_t local_name() const { return _cap.dst.base(); }
addr_t local_name() const {
if (valid())
return _cap.dst.base();
else
return INVALID_INDEX;
}
static Dst invalid() { return Dst(); }
static Native_capability invalid_cap()
{
return Native_capability(~0UL);
return Native_capability(INVALID_INDEX);
}
/** Invoke map syscall instead of translate_map call */

View File

@ -63,7 +63,9 @@ static inline Genode::Native_thread_id thread_get_my_native_id()
Genode::Thread_base *myself = Genode::Thread_base::myself();
if (myself == 0) {
Genode::Native_thread_id main_tid = { 0, 0 };
Genode::Native_thread_id main_tid;
main_tid.ec_sel = 0;
main_tid.exc_pt_sel = 0;
return main_tid;
} else
return myself->tid();
@ -72,7 +74,7 @@ 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 = { ~0UL, ~0UL };
Genode::Native_thread_id tid;
return tid;
}

View File

@ -24,7 +24,7 @@ Cpu_session_component::native_cap(Thread_capability thread_cap)
{
Cpu_thread_component *thread = _lookup_thread(thread_cap);
if (!thread)
return Native_capability(0, 0);
return Native_capability::invalid_cap();
return thread->platform_thread()->native_cap();
}