sel4: use first free cap index reported by kernel

required to bootstrap scenarios with more rom binaries, e.g. noux

Issue #2044
This commit is contained in:
Alexander Boettcher 2016-07-07 13:49:35 +02:00 committed by Christian Helmuth
parent 99b8fc4408
commit 3a9c6eab17
5 changed files with 28 additions and 28 deletions

View File

@ -14,6 +14,8 @@
#ifndef _CORE__INCLUDE__CORE_CSPACE_H_
#define _CORE__INCLUDE__CORE_CSPACE_H_
#include <sel4_boot_info.h>
namespace Genode { class Core_cspace; }
@ -30,15 +32,13 @@ class Genode::Core_cspace
NUM_CORE_PAD_SEL_LOG2 = 32UL - NUM_TOP_SEL_LOG2 - NUM_CORE_SEL_LOG2,
};
/* selectors for statically created CNodes */
enum Static_cnode_sel {
TOP_CNODE_SEL = 0xa00,
CORE_PAD_CNODE_SEL = 0xa01,
CORE_CNODE_SEL = 0xa02,
PHYS_CNODE_SEL = 0xa03,
UNTYPED_CNODE_SEL = 0xa04,
CORE_STATIC_SEL_END,
};
/* selectors for initially created CNodes during core bootup */
static inline unsigned long top_cnode_sel() { return sel4_boot_info().empty.start; }
static inline unsigned long core_pad_cnode_sel() { return top_cnode_sel() + 1; }
static inline unsigned long core_cnode_sel() { return core_pad_cnode_sel() + 1; }
static inline unsigned long phys_cnode_sel() { return core_cnode_sel() + 1; }
static inline unsigned long untyped_cnode_sel() { return phys_cnode_sel() + 1; }
static unsigned long core_static_sel_end() { return untyped_cnode_sel() + 1; }
/* indices within top-level CNode */
enum Top_cnode_idx {

View File

@ -174,7 +174,7 @@ class Genode::Initial_untyped_pool
seL4_Untyped const service = range.sel;
int const type = seL4_UntypedObject;
int const size_bits = get_page_size_log2();
seL4_CNode const root = Core_cspace::TOP_CNODE_SEL;
seL4_CNode const root = Core_cspace::top_cnode_sel();
int const node_index = Core_cspace::TOP_CNODE_UNTYPED_IDX;
int const node_depth = Core_cspace::NUM_TOP_SEL_LOG2;
int const node_offset = phys_addr >> get_page_size_log2();

View File

@ -67,29 +67,29 @@ class Genode::Platform : public Platform_generic
/* allocate 1st-level CNode */
Cnode _top_cnode { Cap_sel(seL4_CapInitThreadCNode),
Cnode_index(Core_cspace::TOP_CNODE_SEL),
Cnode_index(Core_cspace::top_cnode_sel()),
Core_cspace::NUM_TOP_SEL_LOG2,
_initial_untyped_pool };
/* allocate 2nd-level CNode to align core's CNode with the LSB of the CSpace*/
Cnode _core_pad_cnode { Cap_sel(seL4_CapInitThreadCNode),
Cnode_index(Core_cspace::CORE_PAD_CNODE_SEL),
Cnode_index(Core_cspace::core_pad_cnode_sel()),
Core_cspace::NUM_CORE_PAD_SEL_LOG2,
_initial_untyped_pool };
/* allocate 3rd-level CNode for core's objects */
Cnode _core_cnode { Cap_sel(seL4_CapInitThreadCNode),
Cnode_index(Core_cspace::CORE_CNODE_SEL),
Cnode_index(Core_cspace::core_cnode_sel()),
Core_cspace::NUM_CORE_SEL_LOG2, _initial_untyped_pool };
/* allocate 2nd-level CNode for storing page-frame cap selectors */
Cnode _phys_cnode { Cap_sel(seL4_CapInitThreadCNode),
Cnode_index(Core_cspace::PHYS_CNODE_SEL),
Cnode_index(Core_cspace::phys_cnode_sel()),
Core_cspace::NUM_PHYS_SEL_LOG2, _initial_untyped_pool };
/* allocate 2nd-level CNode for storing cap selectors for untyped pages */
Cnode _untyped_cnode { Cap_sel(seL4_CapInitThreadCNode),
Cnode_index(Core_cspace::UNTYPED_CNODE_SEL),
Cnode_index(Core_cspace::untyped_cnode_sel()),
Core_cspace::NUM_PHYS_SEL_LOG2, _initial_untyped_pool };
/*
@ -102,7 +102,7 @@ class Genode::Platform : public Platform_generic
{
Lock _lock;
Core_sel_alloc() { _reserve(0, Core_cspace::CORE_STATIC_SEL_END); }
Core_sel_alloc() { _reserve(0, Core_cspace::core_static_sel_end()); }
Cap_sel alloc() override
{

View File

@ -95,7 +95,7 @@ struct Genode::Untyped_memory
seL4_Untyped const service = untyped_sel(phys_addr).value();
int const type = seL4_X86_4K;
int const size_bits = 0;
seL4_CNode const root = Core_cspace::TOP_CNODE_SEL;
seL4_CNode const root = Core_cspace::top_cnode_sel();
int const node_index = Core_cspace::TOP_CNODE_PHYS_IDX;
int const node_depth = Core_cspace::NUM_TOP_SEL_LOG2;
int const node_offset = phys_addr >> get_page_size_log2();
@ -125,7 +125,7 @@ struct Genode::Untyped_memory
static inline void convert_to_untyped_frames(addr_t const phys_addr,
addr_t const phys_size)
{
seL4_Untyped const service = Core_cspace::PHYS_CNODE_SEL;
seL4_Untyped const service = Core_cspace::phys_cnode_sel();
int const space_size = Core_cspace::NUM_PHYS_SEL_LOG2;
for (addr_t phys = phys_addr; phys < phys_addr + phys_size;

View File

@ -207,7 +207,7 @@ void Platform::_switch_to_core_cspace()
_core_cnode.copy(initial_cspace, Cnode_index(seL4_CapDomain));
/* replace seL4_CapInitThreadCNode with new top-level CNode */
_core_cnode.copy(initial_cspace, Cnode_index(Core_cspace::TOP_CNODE_SEL),
_core_cnode.copy(initial_cspace, Cnode_index(Core_cspace::top_cnode_sel()),
Cnode_index(seL4_CapInitThreadCNode));
/* copy untyped memory selectors to core's CNode */
@ -235,29 +235,29 @@ void Platform::_switch_to_core_cspace()
_core_cnode.copy(initial_cspace, Cnode_index(sel));
/* copy statically created CNode selectors to core's CNode */
_core_cnode.copy(initial_cspace, Cnode_index(Core_cspace::TOP_CNODE_SEL));
_core_cnode.copy(initial_cspace, Cnode_index(Core_cspace::CORE_PAD_CNODE_SEL));
_core_cnode.copy(initial_cspace, Cnode_index(Core_cspace::CORE_CNODE_SEL));
_core_cnode.copy(initial_cspace, Cnode_index(Core_cspace::PHYS_CNODE_SEL));
_core_cnode.copy(initial_cspace, Cnode_index(Core_cspace::top_cnode_sel()));
_core_cnode.copy(initial_cspace, Cnode_index(Core_cspace::core_pad_cnode_sel()));
_core_cnode.copy(initial_cspace, Cnode_index(Core_cspace::core_cnode_sel()));
_core_cnode.copy(initial_cspace, Cnode_index(Core_cspace::phys_cnode_sel()));
/*
* Construct CNode hierarchy of core's CSpace
*/
/* insert 3rd-level core CNode into 2nd-level core-pad CNode */
_core_pad_cnode.copy(initial_cspace, Cnode_index(Core_cspace::CORE_CNODE_SEL),
_core_pad_cnode.copy(initial_cspace, Cnode_index(Core_cspace::core_cnode_sel()),
Cnode_index(0));
/* insert 2nd-level core-pad CNode into 1st-level CNode */
_top_cnode.copy(initial_cspace, Cnode_index(Core_cspace::CORE_PAD_CNODE_SEL),
_top_cnode.copy(initial_cspace, Cnode_index(Core_cspace::core_pad_cnode_sel()),
Cnode_index(Core_cspace::TOP_CNODE_CORE_IDX));
/* insert 2nd-level phys-mem CNode into 1st-level CNode */
_top_cnode.copy(initial_cspace, Cnode_index(Core_cspace::PHYS_CNODE_SEL),
_top_cnode.copy(initial_cspace, Cnode_index(Core_cspace::phys_cnode_sel()),
Cnode_index(Core_cspace::TOP_CNODE_PHYS_IDX));
/* insert 2nd-level untyped-pages CNode into 1st-level CNode */
_top_cnode.copy(initial_cspace, Cnode_index(Core_cspace::UNTYPED_CNODE_SEL),
_top_cnode.copy(initial_cspace, Cnode_index(Core_cspace::untyped_cnode_sel()),
Cnode_index(Core_cspace::TOP_CNODE_UNTYPED_IDX));
/* activate core's CSpace */
@ -266,7 +266,7 @@ void Platform::_switch_to_core_cspace()
int const ret = seL4_TCB_SetSpace(seL4_CapInitThreadTCB,
seL4_CapNull, /* fault_ep */
Core_cspace::TOP_CNODE_SEL, null_data,
Core_cspace::top_cnode_sel(), null_data,
seL4_CapInitThreadPD, null_data);
if (ret != seL4_NoError)