From e3a7d2220dba26534d16e3df71a7b280a6400f0f Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Thu, 2 Aug 2012 10:10:48 +0200 Subject: [PATCH] NOVA: Use everywhere same value for a invalid cap --- base-nova/include/base/ipc_msgbuf.h | 5 +++-- base-nova/include/base/native_types.h | 18 +++++++++++++++--- base-nova/src/base/lock/lock_helper.h | 6 ++++-- base-nova/src/core/cpu_session_extension.cc | 2 +- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/base-nova/include/base/ipc_msgbuf.h b/base-nova/include/base/ipc_msgbuf.h index 8a32327ec0..845ca4dae5 100644 --- a/base-nova/include/base/ipc_msgbuf.h +++ b/base-nova/include/base/ipc_msgbuf.h @@ -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(); } } diff --git a/base-nova/include/base/native_types.h b/base-nova/include/base/native_types.h index bc07136e1c..1b4afecbd7 100644 --- a/base-nova/include/base/native_types.h +++ b/base-nova/include/base/native_types.h @@ -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 */ diff --git a/base-nova/src/base/lock/lock_helper.h b/base-nova/src/base/lock/lock_helper.h index 44d97c0287..3709227712 100644 --- a/base-nova/src/base/lock/lock_helper.h +++ b/base-nova/src/base/lock/lock_helper.h @@ -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; } diff --git a/base-nova/src/core/cpu_session_extension.cc b/base-nova/src/core/cpu_session_extension.cc index 48439d1f4e..4340cc8262 100644 --- a/base-nova/src/core/cpu_session_extension.cc +++ b/base-nova/src/core/cpu_session_extension.cc @@ -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(); }