From 1ea22f82fa25432bfb9ff979a8f59a64ef46d193 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 13 May 2015 11:27:45 +0200 Subject: [PATCH] sel4: core support for IPC of non-core PDs This patch installs the parent endpoint selector and the PD's CNode into a PD at its creation time. Furthermore, it initializes the IPC buffer for the main thread of the new component. --- .../base-sel4/src/core/include/platform_pd.h | 19 ++++++--- repos/base-sel4/src/core/platform_pd.cc | 39 ++++++++++++++++++- repos/base-sel4/src/core/platform_thread.cc | 4 +- 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/repos/base-sel4/src/core/include/platform_pd.h b/repos/base-sel4/src/core/include/platform_pd.h index b00445579..8537c50d5 100644 --- a/repos/base-sel4/src/core/include/platform_pd.h +++ b/repos/base-sel4/src/core/include/platform_pd.h @@ -22,6 +22,8 @@ #include #include +/* base-internal includes */ +#include namespace Genode { class Platform_pd; } @@ -48,20 +50,25 @@ class Genode::Platform_pd : public Address_space Cnode _cspace_cnode; - enum { CSPACE_SIZE_LOG2 = 12 }; + Native_capability _parent; /* * Allocator for core-managed selectors within the PD's CSpace */ - enum { NUM_CORE_MANAGED_SELECTORS_LOG2 = 10 }; - - struct Sel_alloc : Bit_allocator<1 << NUM_CORE_MANAGED_SELECTORS_LOG2> { }; + struct Sel_alloc : Bit_allocator<1 << NUM_CORE_MANAGED_SEL_LOG2> + { + Sel_alloc() { _reserve(0, INITIAL_SEL_END); } + }; Sel_alloc _sel_alloc; Lock _sel_alloc_lock; + bool _initial_ipc_buffer_mapped = false; + public: + enum { INITIAL_IPC_BUFFER_VIRT = 0x1000 }; + /** * Constructors */ @@ -91,7 +98,7 @@ class Genode::Platform_pd : public Address_space /** * Assign parent interface to protection domain */ - int assign_parent(Native_capability parent) { return 0; } + int assign_parent(Native_capability parent); /***************************** @@ -116,6 +123,8 @@ class Genode::Platform_pd : public Address_space size_t cspace_size_log2() { return CSPACE_SIZE_LOG2; } void install_mapping(Mapping const &mapping); + + void map_ipc_buffer_of_initial_thread(addr_t ipc_buffer_phys); }; #endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */ diff --git a/repos/base-sel4/src/core/platform_pd.cc b/repos/base-sel4/src/core/platform_pd.cc index d81ea92ba..d114fb8f8 100644 --- a/repos/base-sel4/src/core/platform_pd.cc +++ b/repos/base-sel4/src/core/platform_pd.cc @@ -21,6 +21,9 @@ #include #include +/* base-internal includes */ +#include + using namespace Genode; @@ -64,6 +67,24 @@ void Platform_pd::unbind_thread(Platform_thread *thread) } +int Platform_pd::assign_parent(Native_capability parent) +{ + Capability_space::Ipc_cap_data const ipc_cap_data = + Capability_space::ipc_cap_data(parent); + + _parent = parent; + + /* + * Install parent endpoint selector at the predefined position + * INITIAL_SEL_PARENT within the PD's CSpace. + */ + _cspace_cnode.copy(platform_specific()->core_cnode(), + ipc_cap_data.sel, + INITIAL_SEL_PARENT); + return 0; +} + + Untyped_address Platform_pd::_init_page_directory() { using namespace Kernel_object; @@ -95,6 +116,17 @@ void Platform_pd::install_mapping(Mapping const &mapping) } +void Platform_pd::map_ipc_buffer_of_initial_thread(addr_t ipc_buffer_phys) +{ + if (_initial_ipc_buffer_mapped) + return; + + _vm_space.map(ipc_buffer_phys, INITIAL_IPC_BUFFER_VIRT, 1); + + _initial_ipc_buffer_mapped = true; +} + + Platform_pd::Platform_pd(Allocator * md_alloc, size_t ram_quota, char const *, signed pd_id, bool create) : @@ -116,7 +148,12 @@ Platform_pd::Platform_pd(Allocator * md_alloc, size_t ram_quota, _cspace_cnode(platform_specific()->core_cnode().sel(), _cspace_cnode_sel, CSPACE_SIZE_LOG2, *platform()->ram_alloc()) -{ } +{ + /* install CSpace selector at predefined position in the PD's CSpace */ + _cspace_cnode.copy(platform_specific()->core_cnode(), + _cspace_cnode_sel, + INITIAL_SEL_CNODE); +} Platform_pd::~Platform_pd() diff --git a/repos/base-sel4/src/core/platform_thread.cc b/repos/base-sel4/src/core/platform_thread.cc index 3a88ce4ca..ee5cc5b0b 100644 --- a/repos/base-sel4/src/core/platform_thread.cc +++ b/repos/base-sel4/src/core/platform_thread.cc @@ -94,6 +94,8 @@ int Platform_thread::start(void *ip, void *sp, unsigned int cpu_no) _pd->cspace_cnode().copy(platform_specific()->core_cnode(), pager_sel, _fault_handler_sel); + _pd->map_ipc_buffer_of_initial_thread(_info.ipc_buffer_phys); + /* bind thread to PD and CSpace */ seL4_CapData_t const guard_cap_data = seL4_CapData_Guard_new(0, 32 - _pd->cspace_size_log2()); @@ -162,7 +164,7 @@ Platform_thread::Platform_thread(size_t, const char *name, unsigned priority, _pager_obj_sel(platform_specific()->alloc_core_sel()) { - _info.init(utcb); + _info.init(Platform_pd::INITIAL_IPC_BUFFER_VIRT); platform_thread_registry().insert(*this); }