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.
This commit is contained in:
Norman Feske 2015-05-13 11:27:45 +02:00 committed by Christian Helmuth
parent acd7a2f1c4
commit 1ea22f82fa
3 changed files with 55 additions and 7 deletions

View File

@ -22,6 +22,8 @@
#include <address_space.h> #include <address_space.h>
#include <vm_space.h> #include <vm_space.h>
/* base-internal includes */
#include <internal/capability_space_sel4.h>
namespace Genode { class Platform_pd; } namespace Genode { class Platform_pd; }
@ -48,20 +50,25 @@ class Genode::Platform_pd : public Address_space
Cnode _cspace_cnode; Cnode _cspace_cnode;
enum { CSPACE_SIZE_LOG2 = 12 }; Native_capability _parent;
/* /*
* Allocator for core-managed selectors within the PD's CSpace * 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_SEL_LOG2>
{
struct Sel_alloc : Bit_allocator<1 << NUM_CORE_MANAGED_SELECTORS_LOG2> { }; Sel_alloc() { _reserve(0, INITIAL_SEL_END); }
};
Sel_alloc _sel_alloc; Sel_alloc _sel_alloc;
Lock _sel_alloc_lock; Lock _sel_alloc_lock;
bool _initial_ipc_buffer_mapped = false;
public: public:
enum { INITIAL_IPC_BUFFER_VIRT = 0x1000 };
/** /**
* Constructors * Constructors
*/ */
@ -91,7 +98,7 @@ class Genode::Platform_pd : public Address_space
/** /**
* Assign parent interface to protection domain * 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; } size_t cspace_size_log2() { return CSPACE_SIZE_LOG2; }
void install_mapping(Mapping const &mapping); void install_mapping(Mapping const &mapping);
void map_ipc_buffer_of_initial_thread(addr_t ipc_buffer_phys);
}; };
#endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */ #endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */

View File

@ -21,6 +21,9 @@
#include <core_cspace.h> #include <core_cspace.h>
#include <kernel_object.h> #include <kernel_object.h>
/* base-internal includes */
#include <internal/capability_space_sel4.h>
using namespace Genode; 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() Untyped_address Platform_pd::_init_page_directory()
{ {
using namespace Kernel_object; 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, Platform_pd::Platform_pd(Allocator * md_alloc, size_t ram_quota,
char const *, signed pd_id, bool create) 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_cnode(platform_specific()->core_cnode().sel(), _cspace_cnode_sel,
CSPACE_SIZE_LOG2, CSPACE_SIZE_LOG2,
*platform()->ram_alloc()) *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() Platform_pd::~Platform_pd()

View File

@ -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, _pd->cspace_cnode().copy(platform_specific()->core_cnode(), pager_sel,
_fault_handler_sel); _fault_handler_sel);
_pd->map_ipc_buffer_of_initial_thread(_info.ipc_buffer_phys);
/* bind thread to PD and CSpace */ /* bind thread to PD and CSpace */
seL4_CapData_t const guard_cap_data = seL4_CapData_t const guard_cap_data =
seL4_CapData_Guard_new(0, 32 - _pd->cspace_size_log2()); 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()) _pager_obj_sel(platform_specific()->alloc_core_sel())
{ {
_info.init(utcb); _info.init(Platform_pd::INITIAL_IPC_BUFFER_VIRT);
platform_thread_registry().insert(*this); platform_thread_registry().insert(*this);
} }