From 84bfb4c04c95316ac57522b6771b43b60d999b9f Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 8 Mar 2016 17:44:54 +0100 Subject: [PATCH] base: remove 'Native_thread_id' type Issue #1832 --- repos/base-fiasco/include/base/native_types.h | 13 +---- .../base-fiasco/src/core/include/ipc_pager.h | 11 ++-- .../base-fiasco/src/core/include/map_local.h | 2 +- .../src/core/include/platform_thread.h | 24 ++++----- repos/base-fiasco/src/core/include/util.h | 11 +++- repos/base-foc/include/base/native_types.h | 3 -- repos/base-foc/src/core/include/cap_mapping.h | 8 +-- repos/base-foc/src/core/rpc_cap_factory.cc | 6 +-- .../src/include/base/internal/lock_helper.h | 22 ++++---- repos/base-foc/src/test/cap_integrity/main.cc | 4 +- repos/base-hw/include/base/native_types.h | 2 - repos/base-hw/src/base/ipc/ipc.cc | 2 +- .../src/include/base/internal/lock_helper.h | 2 +- repos/base-linux/include/base/native_types.h | 53 ++++++------------- .../base-linux/src/lib/lx_hybrid/lx_hybrid.cc | 24 +++++---- repos/base-nova/include/base/native_types.h | 14 ----- repos/base-okl4/include/base/native_types.h | 28 +--------- .../src/base/thread/thread_bootstrap.cc | 2 +- .../base-okl4/src/core/include/platform_pd.h | 14 +++-- .../src/core/include/platform_thread.h | 24 ++++----- repos/base-okl4/src/core/pager.cc | 3 +- repos/base-okl4/src/core/platform_pd.cc | 1 + .../src/include/base/internal/lock_helper.h | 20 +++---- .../include/base/native_types.h | 4 +- .../src/base/thread/thread_bootstrap.cc | 5 +- .../src/core/include/map_local.h | 2 +- .../src/core/include/platform_thread.h | 32 +++++------ repos/base-pistachio/src/core/include/util.h | 2 +- .../src/include/base/internal/lock_helper.h | 8 +-- repos/base-sel4/include/base/native_types.h | 2 - repos/base-sel4/src/core/include/ipc_pager.h | 2 +- 31 files changed, 145 insertions(+), 205 deletions(-) diff --git a/repos/base-fiasco/include/base/native_types.h b/repos/base-fiasco/include/base/native_types.h index c731d0293e..86705eb556 100644 --- a/repos/base-fiasco/include/base/native_types.h +++ b/repos/base-fiasco/include/base/native_types.h @@ -26,8 +26,6 @@ namespace Genode { class Platform_thread; - typedef Fiasco::l4_threadid_t Native_thread_id; - struct Cap_dst_policy { typedef Fiasco::l4_threadid_t Dst; @@ -42,7 +40,7 @@ namespace Genode { struct Native_thread { - Native_thread_id l4id; + Fiasco::l4_threadid_t l4id; /** * Only used in core @@ -54,15 +52,6 @@ namespace Genode { Platform_thread *pt; }; - inline unsigned long convert_native_thread_id_to_badge(Native_thread_id tid) - { - /* - * Fiasco has no server-defined badges for page-fault messages. - * Therefore, we have to interpret the sender ID as badge. - */ - return tid.raw; - } - typedef Native_capability_tpl Native_capability; typedef Fiasco::l4_threadid_t Native_connection_state; } diff --git a/repos/base-fiasco/src/core/include/ipc_pager.h b/repos/base-fiasco/src/core/include/ipc_pager.h index ace21ed4e7..4a454cbead 100644 --- a/repos/base-fiasco/src/core/include/ipc_pager.h +++ b/repos/base-fiasco/src/core/include/ipc_pager.h @@ -24,6 +24,9 @@ /* base-internal includes */ #include +/* core includes */ +#include + /* Fiasco includes */ namespace Fiasco { #include @@ -91,10 +94,10 @@ namespace Genode { { private: - Native_thread_id _last; /* origin of last fault message */ - addr_t _pf_addr; /* page-fault address */ - addr_t _pf_ip; /* instruction pointer of faulter */ - Mapping _reply_mapping; /* page-fault answer */ + Fiasco::l4_threadid_t _last; /* origin of last fault message */ + addr_t _pf_addr; /* page-fault address */ + addr_t _pf_ip; /* instruction pointer of faulter */ + Mapping _reply_mapping; /* page-fault answer */ public: diff --git a/repos/base-fiasco/src/core/include/map_local.h b/repos/base-fiasco/src/core/include/map_local.h index c911777d23..9a0c30317b 100644 --- a/repos/base-fiasco/src/core/include/map_local.h +++ b/repos/base-fiasco/src/core/include/map_local.h @@ -40,7 +40,7 @@ namespace Genode { */ inline bool map_local(addr_t from_addr, addr_t to_addr, size_t num_pages) { - Native_thread_id core_pager = platform_specific()->core_pager()->native_thread_id(); + Fiasco::l4_threadid_t core_pager = platform_specific()->core_pager()->native_thread_id(); addr_t offset = 0; size_t page_size = get_page_size(); diff --git a/repos/base-fiasco/src/core/include/platform_thread.h b/repos/base-fiasco/src/core/include/platform_thread.h index ad023fccdb..7c741a88b4 100644 --- a/repos/base-fiasco/src/core/include/platform_thread.h +++ b/repos/base-fiasco/src/core/include/platform_thread.h @@ -35,14 +35,14 @@ namespace Genode { { private: - int _thread_id; /* plain thread number */ - Native_thread_id _l4_thread_id; /* L4 thread ID */ - char _name[32]; /* thread name that will be - registered at the kernel - debugger */ - Platform_pd *_platform_pd; /* protection domain thread - is bound to */ - Pager_object *_pager; + int _thread_id; /* plain thread number */ + Fiasco::l4_threadid_t _l4_thread_id; /* L4 thread ID */ + char _name[32]; /* thread name that will be + registered at the kernel + debugger */ + Platform_pd *_platform_pd; /* protection domain thread + is bound to */ + Pager_object *_pager; public: @@ -94,7 +94,7 @@ namespace Genode { * \param l4_thread_id final L4 thread ID * \param pd platform pd, thread is bound to */ - void bind(int thread_id, Native_thread_id l4_thread_id, + void bind(int thread_id, Fiasco::l4_threadid_t l4_thread_id, Platform_pd *pd); /** @@ -165,9 +165,9 @@ namespace Genode { ** Fiasco-specific Accessors ** *******************************/ - int thread_id() const { return _thread_id; } - Native_thread_id native_thread_id() const { return _l4_thread_id; } - const char *name() const { return _name; } + int thread_id() const { return _thread_id; } + Fiasco::l4_threadid_t native_thread_id() const { return _l4_thread_id; } + const char *name() const { return _name; } }; } diff --git a/repos/base-fiasco/src/core/include/util.h b/repos/base-fiasco/src/core/include/util.h index 5d96bba21f..6f927b1545 100644 --- a/repos/base-fiasco/src/core/include/util.h +++ b/repos/base-fiasco/src/core/include/util.h @@ -103,7 +103,7 @@ namespace Genode { Rm_session::Fault_type pf_type, unsigned long badge) { - Native_thread_id tid; + Fiasco::l4_threadid_t tid; tid.raw = badge; printf("%s (%s pf_addr=%p pf_ip=%p from %x.%02x)\n", msg, pf_type == Rm_session::WRITE_FAULT ? "WRITE" : "READ", @@ -115,6 +115,15 @@ namespace Genode { return core_local_addr; } inline size_t constrain_map_size_log2(size_t size_log2) { return size_log2; } + + inline unsigned long convert_native_thread_id_to_badge(Fiasco::l4_threadid_t tid) + { + /* + * Fiasco has no server-defined badges for page-fault messages. + * Therefore, we have to interpret the sender ID as badge. + */ + return tid.raw; + } } #endif /* _CORE__INCLUDE__UTIL_H_ */ diff --git a/repos/base-foc/include/base/native_types.h b/repos/base-foc/include/base/native_types.h index d4d493c088..4c9d8192b5 100644 --- a/repos/base-foc/include/base/native_types.h +++ b/repos/base-foc/include/base/native_types.h @@ -80,9 +80,6 @@ namespace Fiasco { namespace Genode { - typedef Fiasco::l4_cap_idx_t Native_thread_id; - - struct Native_thread { Fiasco::l4_cap_idx_t kcap = 0; diff --git a/repos/base-foc/src/core/include/cap_mapping.h b/repos/base-foc/src/core/include/cap_mapping.h index 064260d776..57d3e944ff 100644 --- a/repos/base-foc/src/core/include/cap_mapping.h +++ b/repos/base-foc/src/core/include/cap_mapping.h @@ -40,13 +40,13 @@ namespace Genode { public: - Native_capability local; /* reference to cap that is mapped */ - Native_thread_id remote; /* index in cap-space of the other pd */ + Native_capability local; /* reference to cap that is mapped */ + Fiasco::l4_cap_idx_t remote; /* index in cap-space of the other pd */ Cap_mapping(bool alloc=false, - Native_thread_id r = Fiasco::L4_INVALID_CAP); + Fiasco::l4_cap_idx_t r = Fiasco::L4_INVALID_CAP); Cap_mapping(Native_capability cap, - Native_thread_id r = Fiasco::L4_INVALID_CAP); + Fiasco::l4_cap_idx_t r = Fiasco::L4_INVALID_CAP); /** * Map the cap in local to corresponding task. diff --git a/repos/base-foc/src/core/rpc_cap_factory.cc b/repos/base-foc/src/core/rpc_cap_factory.cc index 59ab721298..8de3ffbf6c 100644 --- a/repos/base-foc/src/core/rpc_cap_factory.cc +++ b/repos/base-foc/src/core/rpc_cap_factory.cc @@ -58,7 +58,7 @@ Core_cap_index* Cap_mapping::_get_cap() } -void Cap_mapping::map(Native_thread_id task) +void Cap_mapping::map(Fiasco::l4_cap_idx_t task) { using namespace Fiasco; @@ -73,11 +73,11 @@ void Cap_mapping::map(Native_thread_id task) } -Cap_mapping::Cap_mapping(bool alloc, Native_thread_id r) +Cap_mapping::Cap_mapping(bool alloc, Fiasco::l4_cap_idx_t r) : local(alloc ? _get_cap() : 0), remote(r) { } -Cap_mapping::Cap_mapping(Native_capability cap, Native_thread_id r) +Cap_mapping::Cap_mapping(Native_capability cap, Fiasco::l4_cap_idx_t r) : local(cap), remote(r) { } diff --git a/repos/base-foc/src/include/base/internal/lock_helper.h b/repos/base-foc/src/include/base/internal/lock_helper.h index c910b9ded0..4ab55505ab 100644 --- a/repos/base-foc/src/include/base/internal/lock_helper.h +++ b/repos/base-foc/src/include/base/internal/lock_helper.h @@ -47,10 +47,10 @@ static inline void thread_yield() { Fiasco::l4_thread_yield(); } */ static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_base) { - Genode::Native_thread_id tid = thread_base ? - thread_base->tid().kcap : - Fiasco::MAIN_THREAD_CAP; - Genode::Native_thread_id irq = tid + Fiasco::THREAD_IRQ_CAP; + Fiasco::l4_cap_idx_t tid = thread_base ? + thread_base->tid().kcap : + Fiasco::MAIN_THREAD_CAP; + Fiasco::l4_cap_idx_t irq = tid + Fiasco::THREAD_IRQ_CAP; Fiasco::l4_irq_trigger(irq); return true; } @@ -61,9 +61,9 @@ static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_ */ static inline void thread_switch_to(Genode::Thread_base *thread_base) { - Genode::Native_thread_id tid = thread_base ? - thread_base->tid().kcap : - Fiasco::MAIN_THREAD_CAP; + Fiasco::l4_cap_idx_t tid = thread_base ? + thread_base->tid().kcap : + Fiasco::MAIN_THREAD_CAP; Fiasco::l4_thread_switch(tid); } @@ -81,10 +81,10 @@ static void thread_stop_myself() using namespace Fiasco; Genode::Thread_base *myself = Genode::Thread_base::myself(); - Genode::Native_thread_id tid = myself ? - myself->tid().kcap : - Fiasco::MAIN_THREAD_CAP; - Genode::Native_thread_id irq = tid + THREAD_IRQ_CAP; + Fiasco::l4_cap_idx_t tid = myself ? + myself->tid().kcap : + Fiasco::MAIN_THREAD_CAP; + Fiasco::l4_cap_idx_t irq = tid + THREAD_IRQ_CAP; l4_irq_receive(irq, L4_IPC_NEVER); } diff --git a/repos/base-foc/src/test/cap_integrity/main.cc b/repos/base-foc/src/test/cap_integrity/main.cc index cb166db53c..e1e23d2df9 100644 --- a/repos/base-foc/src/test/cap_integrity/main.cc +++ b/repos/base-foc/src/test/cap_integrity/main.cc @@ -25,8 +25,8 @@ int main(int argc, char **argv) enum { COUNT = 1000 }; - Cap_index* idx = cap_idx_alloc()->alloc_range(COUNT); - Native_thread_id tid = env()->ram_session_cap().dst(); + Cap_index* idx = cap_idx_alloc()->alloc_range(COUNT); + Fiasco::l4_cap_idx_t tid = env()->ram_session_cap().dst(); /* try the first 1000 local name IDs */ for (int local_name = 0; local_name < COUNT; local_name++, idx++) { diff --git a/repos/base-hw/include/base/native_types.h b/repos/base-hw/include/base/native_types.h index 932f40bb98..3ba0fdc06a 100644 --- a/repos/base-hw/include/base/native_types.h +++ b/repos/base-hw/include/base/native_types.h @@ -26,8 +26,6 @@ namespace Genode class Platform_thread; class Native_thread; - using Native_thread_id = Kernel::capid_t; - typedef int Native_connection_state; /** diff --git a/repos/base-hw/src/base/ipc/ipc.cc b/repos/base-hw/src/base/ipc/ipc.cc index dd706fb1fa..2d3b78299e 100644 --- a/repos/base-hw/src/base/ipc/ipc.cc +++ b/repos/base-hw/src/base/ipc/ipc.cc @@ -34,7 +34,7 @@ using namespace Genode; enum { /* size of the callee-local name of a targeted RPC object */ - RPC_OBJECT_ID_SIZE = sizeof(Native_thread_id), + RPC_OBJECT_ID_SIZE = sizeof(Kernel::capid_t), /* * The RPC framework marshalls a return value into reply messages to diff --git a/repos/base-hw/src/include/base/internal/lock_helper.h b/repos/base-hw/src/include/base/internal/lock_helper.h index 752f513950..994feafc9d 100644 --- a/repos/base-hw/src/include/base/internal/lock_helper.h +++ b/repos/base-hw/src/include/base/internal/lock_helper.h @@ -32,7 +32,7 @@ static inline void thread_yield() { /** * Return kernel name of thread t */ -static inline Genode::Native_thread_id +static inline Kernel::capid_t native_thread_id(Genode::Thread_base * const t) { return t ? t->tid().cap.dst() : Hw::_main_thread_cap.dst(); diff --git a/repos/base-linux/include/base/native_types.h b/repos/base-linux/include/base/native_types.h index 162b2273a6..e4a3c5f478 100644 --- a/repos/base-linux/include/base/native_types.h +++ b/repos/base-linux/include/base/native_types.h @@ -20,62 +20,39 @@ namespace Genode { - /** - * Thread ID - * - * Unfortunately, both - PID and TID - are needed for lx_tgkill() - */ - struct Native_thread_id - { - unsigned int tid; /* Native thread ID type as returned by the - 'clone' system call */ - unsigned int pid; /* process ID (resp. thread-group ID) */ - - Native_thread_id() : tid(0), pid(0) { } - Native_thread_id(unsigned int tid, unsigned int pid) - : tid(tid), pid(pid) { } - }; - - struct Thread_meta_data; - /** * Native thread contains more thread-local data than just the ID - * - * FIXME doc - * A thread needs two sockets as it may be a server that depends on another - * service during request processing. If the server socket would be used for - * the client call, the server thread may be unblocked by further requests - * from its clients. In other words, the additional client socket provides - * closed-receive semantics in calls. An even better solution is to use - * SCM_RIGHTS messages to send a client socket descriptor with the request. */ - struct Native_thread : Native_thread_id + struct Native_thread { - bool is_ipc_server; + /* + * Unfortunately, both - PID and TID - are needed for lx_tgkill() + */ + unsigned int tid = 0; /* Native thread ID type as returned by the + 'clone' system call */ + unsigned int pid = 0; /* process ID (resp. thread-group ID) */ + + bool is_ipc_server = false; /** * Natively aligned memory location used in the lock implementation */ - int futex_counter __attribute__((aligned(sizeof(Genode::addr_t)))); + int futex_counter __attribute__((aligned(sizeof(Genode::addr_t)))) = 0; + + struct Meta_data; /** * Opaque pointer to additional thread-specific meta data * - * This pointer is used by hybrid Linux/Genode program to maintain + * This pointer is used by hybrid Linux/Genode programs to maintain * POSIX-thread-related meta data. For non-hybrid Genode programs, it * remains unused. */ - Thread_meta_data *meta_data; + Meta_data *meta_data = nullptr; - Native_thread() : is_ipc_server(false), futex_counter(0), meta_data(0) { } + Native_thread() { } }; - inline bool operator == (Native_thread_id t1, Native_thread_id t2) { - return (t1.tid == t2.tid) && (t1.pid == t2.pid); } - - inline bool operator != (Native_thread_id t1, Native_thread_id t2) { - return (t1.tid != t2.tid) || (t1.pid != t2.pid); } - struct Cap_dst_policy { struct Dst diff --git a/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc b/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc index da1c825164..750e8bcec7 100644 --- a/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc +++ b/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc @@ -134,7 +134,7 @@ static pthread_key_t tls_key() namespace Genode { - struct Thread_meta_data + struct Native_thread::Meta_data { /** * Filled out by 'thread_start' function in the stack of the new @@ -152,7 +152,7 @@ namespace Genode { * * \param thread associated 'Thread_base' object */ - Thread_meta_data(Thread_base *thread) : thread_base(thread) { } + Meta_data(Thread_base *thread) : thread_base(thread) { } /** * Used to block the constructor until the new thread has initialized @@ -177,7 +177,7 @@ namespace Genode { /* * Thread meta data for a thread created by Genode */ - class Thread_meta_data_created : public Thread_meta_data + class Thread_meta_data_created : public Native_thread::Meta_data { private: @@ -204,7 +204,8 @@ namespace Genode { public: - Thread_meta_data_created(Thread_base *thread) : Thread_meta_data(thread) { } + Thread_meta_data_created(Thread_base *thread) + : Native_thread::Meta_data(thread) { } void wait_for_construction() { @@ -240,11 +241,12 @@ namespace Genode { /* * Thread meta data for an adopted thread */ - class Thread_meta_data_adopted : public Thread_meta_data + class Thread_meta_data_adopted : public Native_thread::Meta_data { public: - Thread_meta_data_adopted(Thread_base *thread) : Thread_meta_data(thread) { } + Thread_meta_data_adopted(Thread_base *thread) + : Native_thread::Meta_data(thread) { } void wait_for_construction() { @@ -296,7 +298,7 @@ Linux_cpu_session *cpu_session(Cpu_session * cpu_session) } -static void adopt_thread(Thread_meta_data *meta_data) +static void adopt_thread(Native_thread::Meta_data *meta_data) { /* * Set signal handler such that canceled system calls get not @@ -309,7 +311,7 @@ static void adopt_thread(Thread_meta_data *meta_data) */ lx_sigaction(LX_SIGCHLD, (void (*)(int))1); - /* assign 'Thread_meta_data' pointer to TLS entry */ + /* assign 'Native_thread::Meta_data' pointer to TLS entry */ pthread_setspecific(tls_key(), meta_data); /* enable immediate cancellation when calling 'pthread_cancel' */ @@ -326,7 +328,7 @@ static void adopt_thread(Thread_meta_data *meta_data) static void *thread_start(void *arg) { - Thread_meta_data *meta_data = (Thread_meta_data *)arg; + Native_thread::Meta_data *meta_data = (Native_thread::Meta_data *)arg; adopt_thread(meta_data); @@ -351,7 +353,7 @@ Thread_base *Thread_base::myself() void * const tls = pthread_getspecific(tls_key()); if (tls != 0) - return ((Thread_meta_data *)tls)->thread_base; + return ((Native_thread::Meta_data *)tls)->thread_base; bool const is_main_thread = (lx_getpid() == lx_gettid()); if (is_main_thread) @@ -378,7 +380,7 @@ Thread_base *Thread_base::myself() */ Thread_base *thread = (Thread_base *)malloc(sizeof(Thread_base)); memset(thread, 0, sizeof(*thread)); - Thread_meta_data *meta_data = new Thread_meta_data_adopted(thread); + Native_thread::Meta_data *meta_data = new Thread_meta_data_adopted(thread); /* * Initialize 'Thread_base::_tid' using the default constructor of diff --git a/repos/base-nova/include/base/native_types.h b/repos/base-nova/include/base/native_types.h index f5eabe0954..477d570a7f 100644 --- a/repos/base-nova/include/base/native_types.h +++ b/repos/base-nova/include/base/native_types.h @@ -36,20 +36,6 @@ namespace Genode { exc_pt_sel (INVALID_INDEX), is_vcpu(false) {} }; - 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.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.exc_pt_sel != t2.exc_pt_sel); - } - class Native_capability { public: diff --git a/repos/base-okl4/include/base/native_types.h b/repos/base-okl4/include/base/native_types.h index 8b31361b28..d109f7ac65 100644 --- a/repos/base-okl4/include/base/native_types.h +++ b/repos/base-okl4/include/base/native_types.h @@ -31,26 +31,9 @@ namespace Genode { */ enum { UTCB_TCR_THREAD_WORD_MYSELF = 0 }; - namespace Thread_id_bits { - - /* - * L4 thread ID has 18 bits for thread number and 14 bits for - * version info. - */ - enum { PD = 8, THREAD = 5 }; - } - - typedef Okl4::L4_ThreadId_t Native_thread_id; - - inline bool operator == (Native_thread_id t1, Native_thread_id t2) { - return t1.raw == t2.raw; } - - inline bool operator != (Native_thread_id t1, Native_thread_id t2) { - return t1.raw != t2.raw; } - struct Native_thread { - Native_thread_id l4id; + Okl4::L4_ThreadId_t l4id; /** * Only used in core @@ -62,15 +45,6 @@ namespace Genode { Platform_thread *pt; }; - inline unsigned long convert_native_thread_id_to_badge(Native_thread_id tid) - { - /* - * OKL4 has no server-defined badges for page-fault messages. - * Therefore, we have to interpret the sender ID as badge. - */ - return tid.raw; - } - struct Cap_dst_policy { typedef Okl4::L4_ThreadId_t Dst; diff --git a/repos/base-okl4/src/base/thread/thread_bootstrap.cc b/repos/base-okl4/src/base/thread/thread_bootstrap.cc index fe03b53c09..74ef42c0e8 100644 --- a/repos/base-okl4/src/base/thread/thread_bootstrap.cc +++ b/repos/base-okl4/src/base/thread/thread_bootstrap.cc @@ -25,7 +25,7 @@ namespace Okl4 } } -Genode::Native_thread_id main_thread_tid; +Okl4::L4_ThreadId_t main_thread_tid; /******************* diff --git a/repos/base-okl4/src/core/include/platform_pd.h b/repos/base-okl4/src/core/include/platform_pd.h index dca8ca952d..37a3d8e1bb 100644 --- a/repos/base-okl4/src/core/include/platform_pd.h +++ b/repos/base-okl4/src/core/include/platform_pd.h @@ -18,7 +18,6 @@ #include /* core includes */ -#include #include namespace Okl4 { extern "C" { @@ -27,6 +26,15 @@ namespace Okl4 { extern "C" { namespace Genode { + namespace Thread_id_bits { + + /* + * L4 thread ID has 18 bits for thread number and 14 bits for + * version info. + */ + enum { PD = 8, THREAD = 5 }; + } + class Platform_thread; class Platform_pd : public Address_space { @@ -45,8 +53,8 @@ namespace Genode { /** * Manually construct L4 thread ID from its components */ - static Native_thread_id make_l4_id(unsigned space_no, - unsigned thread_no) + static Okl4::L4_ThreadId_t make_l4_id(unsigned space_no, + unsigned thread_no) { /* * On OKL4, version must be set to 1 diff --git a/repos/base-okl4/src/core/include/platform_thread.h b/repos/base-okl4/src/core/include/platform_thread.h index 1c15b277d6..1e930820b0 100644 --- a/repos/base-okl4/src/core/include/platform_thread.h +++ b/repos/base-okl4/src/core/include/platform_thread.h @@ -30,15 +30,15 @@ namespace Genode { { private: - int _thread_id; /* plain thread number */ - Native_thread_id _l4_thread_id; /* L4 thread ID */ - char _name[32]; /* thread name that will be + int _thread_id; /* plain thread number */ + Okl4::L4_ThreadId_t _l4_thread_id; /* L4 thread ID */ + char _name[32]; /* thread name that will be registered at the kernel debugger */ - Platform_pd *_platform_pd; /* protection domain thread - is bound to */ - unsigned _priority; /* thread priority */ - Pager_object *_pager; + Platform_pd *_platform_pd; /* protection domain thread + is bound to */ + unsigned _priority; /* thread priority */ + Pager_object *_pager; public: @@ -91,7 +91,7 @@ namespace Genode { * \param l4_thread_id final L4 thread ID * \param pd platform pd, thread is bound to */ - void bind(int thread_id, Native_thread_id l4_thread_id, + void bind(int thread_id, Okl4::L4_ThreadId_t l4_thread_id, Platform_pd *pd); /** @@ -162,11 +162,11 @@ namespace Genode { ** OKL4-specific Accessors ** *****************************/ - int thread_id() const { return _thread_id; } - Native_thread_id native_thread_id() const { return _l4_thread_id; } - const char *name() const { return _name; } + int thread_id() const { return _thread_id; } + Okl4::L4_ThreadId_t native_thread_id() const { return _l4_thread_id; } + const char *name() const { return _name; } - void set_l4_thread_id(Native_thread_id id) { _l4_thread_id = id; } + void set_l4_thread_id(Okl4::L4_ThreadId_t id) { _l4_thread_id = id; } }; } diff --git a/repos/base-okl4/src/core/pager.cc b/repos/base-okl4/src/core/pager.cc index a92dce4955..6af8e08a0b 100644 --- a/repos/base-okl4/src/core/pager.cc +++ b/repos/base-okl4/src/core/pager.cc @@ -14,9 +14,10 @@ /* Genode includes */ #include -/* Core includes */ +/* core includes */ #include #include +#include namespace Okl4 { extern "C" { #include diff --git a/repos/base-okl4/src/core/platform_pd.cc b/repos/base-okl4/src/core/platform_pd.cc index 4eaedf349c..9511e208b5 100644 --- a/repos/base-okl4/src/core/platform_pd.cc +++ b/repos/base-okl4/src/core/platform_pd.cc @@ -17,6 +17,7 @@ /* core includes */ #include #include +#include #include /* OKL4 includes */ diff --git a/repos/base-okl4/src/include/base/internal/lock_helper.h b/repos/base-okl4/src/include/base/internal/lock_helper.h index 88577f6091..056e0591de 100644 --- a/repos/base-okl4/src/include/base/internal/lock_helper.h +++ b/repos/base-okl4/src/include/base/internal/lock_helper.h @@ -34,7 +34,7 @@ namespace Okl4 { extern "C" { static inline void thread_yield() { Okl4::L4_Yield(); } -extern Genode::Native_thread_id main_thread_tid; +extern Okl4::L4_ThreadId_t main_thread_tid; /** @@ -54,9 +54,9 @@ static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_ L4_ThreadId_t dummy_id; L4_ThreadState_t state; - Genode::Native_thread_id tid = thread_base ? - thread_base->tid().l4id : - main_thread_tid; + Okl4::L4_ThreadId_t tid = thread_base ? + thread_base->tid().l4id : + main_thread_tid; L4_ExchangeRegisters(tid, L4_ExReg_Resume + L4_ExReg_AbortIPC, 0, 0, 0, 0, L4_nilthread, &state.raw, &dummy, &dummy, &dummy, @@ -71,9 +71,9 @@ static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_ */ static inline void thread_switch_to(Genode::Thread_base *thread_base) { - Genode::Native_thread_id tid = thread_base ? - thread_base->tid().l4id : - main_thread_tid; + Okl4::L4_ThreadId_t tid = thread_base ? + thread_base->tid().l4id : + main_thread_tid; Okl4::L4_ThreadSwitch(tid); } @@ -84,9 +84,9 @@ static inline void thread_switch_to(Genode::Thread_base *thread_base) static inline void thread_stop_myself() { Genode::Thread_base *myself = Genode::Thread_base::myself(); - Genode::Native_thread_id tid = myself ? - myself->tid().l4id : - main_thread_tid; + Okl4::L4_ThreadId_t tid = myself ? + myself->tid().l4id : + main_thread_tid; Okl4::L4_Stop(tid); } diff --git a/repos/base-pistachio/include/base/native_types.h b/repos/base-pistachio/include/base/native_types.h index 86a7bd71c0..f56241e096 100644 --- a/repos/base-pistachio/include/base/native_types.h +++ b/repos/base-pistachio/include/base/native_types.h @@ -25,8 +25,6 @@ namespace Genode { class Platform_thread; - typedef Pistachio::L4_ThreadId_t Native_thread_id; - struct Cap_dst_policy { typedef Pistachio::L4_ThreadId_t Dst; @@ -41,7 +39,7 @@ namespace Genode { struct Native_thread { - Native_thread_id l4id; + Pistachio::L4_ThreadId_t l4id; /** * Only used in core diff --git a/repos/base-pistachio/src/base/thread/thread_bootstrap.cc b/repos/base-pistachio/src/base/thread/thread_bootstrap.cc index a9dd917686..9175c9d174 100644 --- a/repos/base-pistachio/src/base/thread/thread_bootstrap.cc +++ b/repos/base-pistachio/src/base/thread/thread_bootstrap.cc @@ -16,12 +16,11 @@ #include /* Pistachio includes */ -namespace Pistachio -{ +namespace Pistachio { #include } -Genode::Native_thread_id main_thread_tid; +Pistachio::L4_ThreadId_t main_thread_tid; /***************************** diff --git a/repos/base-pistachio/src/core/include/map_local.h b/repos/base-pistachio/src/core/include/map_local.h index 4e4b8986da..086233be5d 100644 --- a/repos/base-pistachio/src/core/include/map_local.h +++ b/repos/base-pistachio/src/core/include/map_local.h @@ -42,7 +42,7 @@ namespace Genode { inline static bool map_local(addr_t from_addr, addr_t to_addr, size_t num_pages) { - Native_thread_id core_pager = platform_specific()->core_pager()->native_thread_id(); + Pistachio::L4_ThreadId_t core_pager = platform_specific()->core_pager()->native_thread_id(); addr_t offset = 0; size_t page_size = get_page_size(); diff --git a/repos/base-pistachio/src/core/include/platform_thread.h b/repos/base-pistachio/src/core/include/platform_thread.h index fb382d695a..a47fc9fd91 100644 --- a/repos/base-pistachio/src/core/include/platform_thread.h +++ b/repos/base-pistachio/src/core/include/platform_thread.h @@ -29,7 +29,7 @@ namespace Pistachio { } -inline unsigned long convert_native_thread_id_to_badge(Genode::Native_thread_id tid) +inline unsigned long convert_native_thread_id_to_badge(Pistachio::L4_ThreadId_t tid) { /* * Pistachio has no server-defined badges for page-fault messages. @@ -46,17 +46,17 @@ namespace Genode { { private: - int _thread_id; /* plain thread number */ - Native_thread_id _l4_thread_id; /* L4 thread ID */ - char _name[32]; /* thread name that will be - registered at the kernel - debugger */ - Platform_pd *_platform_pd; /* protection domain thread - is bound to */ - unsigned _priority; /* thread priority */ - Pager_object *_pager; + int _thread_id; /* plain thread number */ + Pistachio::L4_ThreadId_t _l4_thread_id; /* L4 thread ID */ + char _name[32]; /* thread name that will be + registered at the kernel + debugger */ + Platform_pd *_platform_pd; /* protection domain thread + is bound to */ + unsigned _priority; /* thread priority */ + Pager_object *_pager; - Affinity::Location _location; + Affinity::Location _location; public: @@ -107,7 +107,7 @@ namespace Genode { * \param l4_thread_id final L4 thread ID * \param pd platform pd, thread is bound to */ - void bind(int thread_id, Native_thread_id l4_thread_id, + void bind(int thread_id, Pistachio::L4_ThreadId_t l4_thread_id, Platform_pd *pd); /** @@ -174,12 +174,12 @@ namespace Genode { ** Pistachio-specific Accessors ** **********************************/ - int thread_id() const { return _thread_id; } - Native_thread_id native_thread_id() const { return _l4_thread_id; } - const char *name() const { return _name; } + int thread_id() const { return _thread_id; } + Pistachio::L4_ThreadId_t native_thread_id() const { return _l4_thread_id; } + const char *name() const { return _name; } /* use only for core... */ - void set_l4_thread_id(Native_thread_id id) { _l4_thread_id = id; } + void set_l4_thread_id(Pistachio::L4_ThreadId_t id) { _l4_thread_id = id; } }; } diff --git a/repos/base-pistachio/src/core/include/util.h b/repos/base-pistachio/src/core/include/util.h index 9c2f1107d2..a18d392822 100644 --- a/repos/base-pistachio/src/core/include/util.h +++ b/repos/base-pistachio/src/core/include/util.h @@ -110,7 +110,7 @@ namespace Genode { Rm_session::Fault_type pf_type, unsigned long badge) { - Native_thread_id tid; + Pistachio::L4_ThreadId_t tid; tid.raw = badge; printf("%s (%s pf_addr=%p pf_ip=%p from %02lx (raw %08lx))\n", msg, pf_type == Rm_session::WRITE_FAULT ? "WRITE" : "READ", diff --git a/repos/base-pistachio/src/include/base/internal/lock_helper.h b/repos/base-pistachio/src/include/base/internal/lock_helper.h index 814306ebe3..e3affa25b7 100644 --- a/repos/base-pistachio/src/include/base/internal/lock_helper.h +++ b/repos/base-pistachio/src/include/base/internal/lock_helper.h @@ -28,7 +28,7 @@ namespace Pistachio { } -extern Genode::Native_thread_id main_thread_tid; +extern Pistachio::L4_ThreadId_t main_thread_tid; /** @@ -54,7 +54,7 @@ static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_ L4_ThreadId_t dummy_id; L4_ThreadState_t state; - Genode::Native_thread_id tid = thread_base ? + Pistachio::L4_ThreadId_t tid = thread_base ? thread_base->tid().l4id : main_thread_tid; @@ -72,7 +72,7 @@ static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_ */ static inline void thread_switch_to(Genode::Thread_base *thread_base) { - Genode::Native_thread_id tid = thread_base ? + Pistachio::L4_ThreadId_t tid = thread_base ? thread_base->tid().l4id : main_thread_tid; Pistachio::L4_ThreadSwitch(tid); @@ -85,7 +85,7 @@ static inline void thread_switch_to(Genode::Thread_base *thread_base) static inline void thread_stop_myself() { Genode::Thread_base *myself = Genode::Thread_base::myself(); - Genode::Native_thread_id tid = myself ? + Pistachio::L4_ThreadId_t tid = myself ? myself->tid().l4id : main_thread_tid; Pistachio::L4_Stop(tid); diff --git a/repos/base-sel4/include/base/native_types.h b/repos/base-sel4/include/base/native_types.h index 14c33aaa8e..32804afa72 100644 --- a/repos/base-sel4/include/base/native_types.h +++ b/repos/base-sel4/include/base/native_types.h @@ -19,8 +19,6 @@ namespace Genode { - typedef int Native_thread_id; - struct Native_thread { unsigned tcb_sel = 0; diff --git a/repos/base-sel4/src/core/include/ipc_pager.h b/repos/base-sel4/src/core/include/ipc_pager.h index b94d74bdb2..b90475279c 100644 --- a/repos/base-sel4/src/core/include/ipc_pager.h +++ b/repos/base-sel4/src/core/include/ipc_pager.h @@ -75,7 +75,7 @@ namespace Genode { { private: - Native_thread_id _last; /* faulted thread */ + addr_t _last; /* faulted thread ID */ addr_t _pf_addr; /* page-fault address */ addr_t _pf_ip; /* instruction pointer of faulter */ bool _pf_write; /* true on write fault */