From 4b224dd67e7317512a5a0feed8a25495227cc3e5 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Fri, 22 Feb 2013 10:30:48 +0100 Subject: [PATCH] base-hw: store Platform_pd pointer in Kernel::Pd This enables the kernel to print out the label of the program a thread belongs to. fix #662 --- base-hw/include/kernel/syscalls.h | 7 +++++-- base-hw/src/core/include/platform_pd.h | 19 +++++++++++++------ base-hw/src/core/kernel.cc | 14 +++++++++----- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/base-hw/include/kernel/syscalls.h b/base-hw/include/kernel/syscalls.h index 49ffdadd0..17121d875 100644 --- a/base-hw/include/kernel/syscalls.h +++ b/base-hw/include/kernel/syscalls.h @@ -20,6 +20,7 @@ namespace Genode { class Platform_thread; + class Platform_pd; class Tlb; } @@ -29,6 +30,7 @@ namespace Kernel typedef Genode::addr_t addr_t; typedef Genode::size_t size_t; typedef Genode::Platform_thread Platform_thread; + typedef Genode::Platform_pd Platform_pd; /** * Unique opcodes of all syscalls supported by the kernel @@ -143,6 +145,7 @@ namespace Kernel * * \param dst physical base of an appropriate portion of memory * that is thereupon allocated to the kernel + * \param pd core local Platform_pd object * * \retval >0 ID of the new PD * \retval 0 if no new PD was created @@ -150,8 +153,8 @@ namespace Kernel * Restricted to core threads. Regaining of the supplied memory is not * supported by now. */ - inline int new_pd(void * const dst) { - return syscall(NEW_PD, (Syscall_arg)dst); } + inline int new_pd(void * const dst, Platform_pd * const pd) { + return syscall(NEW_PD, (Syscall_arg)dst, (Syscall_arg)pd); } /** diff --git a/base-hw/src/core/include/platform_pd.h b/base-hw/src/core/include/platform_pd.h index 251dab8f0..f546ef651 100644 --- a/base-hw/src/core/include/platform_pd.h +++ b/base-hw/src/core/include/platform_pd.h @@ -37,11 +37,11 @@ namespace Genode */ class Platform_pd : public Address_space { - unsigned _id; /* ID of our kernel object */ - Native_capability _parent; /* our parent interface */ - Native_thread_id _main_thread; /* the first thread that gets - * executed in this PD */ - char const * _label; /* PD-connection label */ + unsigned _id; /* ID of our kernel object */ + Native_capability _parent; /* our parent interface */ + Native_thread_id _main_thread; /* the first thread that gets + * executed in this PD */ + char const * const _label; /* PD-connection label */ public: @@ -57,7 +57,7 @@ namespace Genode Kernel::pd_alignm_log2()).is_ok()) /* create kernel object */ - _id = Kernel::new_pd(kernel_pd); + _id = Kernel::new_pd(kernel_pd, this); assert(_id); } @@ -102,6 +102,13 @@ namespace Genode } + /*************** + ** Accessors ** + ***************/ + + char const * const label() { return _label; } + + /***************************** ** Address-space interface ** *****************************/ diff --git a/base-hw/src/core/kernel.cc b/base-hw/src/core/kernel.cc index d595e60ab..38ec98415 100644 --- a/base-hw/src/core/kernel.cc +++ b/base-hw/src/core/kernel.cc @@ -29,6 +29,7 @@ /* core includes */ #include +#include #include #include @@ -268,7 +269,8 @@ namespace Kernel */ class Pd : public Object { - Tlb * const _tlb; + Tlb * const _tlb; + Platform_pd * const _platform_pd; /* keep ready memory for size aligned extra costs at construction */ enum { EXTRA_SPACE_SIZE = 2*Tlb::MAX_COSTS_PER_TRANSLATION }; @@ -279,7 +281,8 @@ namespace Kernel /** * Constructor */ - Pd(Tlb * const t) : _tlb(t) + Pd(Tlb * const t, Platform_pd * const platform_pd) + : _tlb(t), _platform_pd(platform_pd) { /* try to add translation for mode transition region */ Page_flags::access_t const flags = Page_flags::mode_transition(); @@ -322,7 +325,8 @@ namespace Kernel ** Accessors ** ***************/ - Tlb * tlb() { return _tlb; } + Tlb * const tlb() { return _tlb; } + Platform_pd * const platform_pd() { return _platform_pd; } }; @@ -404,7 +408,7 @@ namespace Kernel static Pd * core() { static Core_tlb tlb; - static Pd _pd(&tlb); + static Pd _pd(&tlb, 0); return &_pd; } @@ -833,7 +837,7 @@ namespace Kernel void * dst = (void *)user->user_arg_1(); Tlb * const tlb = new (dst) Tlb(); dst = (void *)((addr_t)dst + sizeof(Tlb)); - Pd * const pd = new (dst) Pd(tlb); + Pd * const pd = new (dst) Pd(tlb, (Platform_pd *)user->user_arg_2()); /* return success */ user->user_arg_0(pd->id());