mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 18:56:29 +00:00
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:
parent
99b8fc4408
commit
3a9c6eab17
@ -14,6 +14,8 @@
|
|||||||
#ifndef _CORE__INCLUDE__CORE_CSPACE_H_
|
#ifndef _CORE__INCLUDE__CORE_CSPACE_H_
|
||||||
#define _CORE__INCLUDE__CORE_CSPACE_H_
|
#define _CORE__INCLUDE__CORE_CSPACE_H_
|
||||||
|
|
||||||
|
#include <sel4_boot_info.h>
|
||||||
|
|
||||||
namespace Genode { class Core_cspace; }
|
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,
|
NUM_CORE_PAD_SEL_LOG2 = 32UL - NUM_TOP_SEL_LOG2 - NUM_CORE_SEL_LOG2,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* selectors for statically created CNodes */
|
/* selectors for initially created CNodes during core bootup */
|
||||||
enum Static_cnode_sel {
|
static inline unsigned long top_cnode_sel() { return sel4_boot_info().empty.start; }
|
||||||
TOP_CNODE_SEL = 0xa00,
|
static inline unsigned long core_pad_cnode_sel() { return top_cnode_sel() + 1; }
|
||||||
CORE_PAD_CNODE_SEL = 0xa01,
|
static inline unsigned long core_cnode_sel() { return core_pad_cnode_sel() + 1; }
|
||||||
CORE_CNODE_SEL = 0xa02,
|
static inline unsigned long phys_cnode_sel() { return core_cnode_sel() + 1; }
|
||||||
PHYS_CNODE_SEL = 0xa03,
|
static inline unsigned long untyped_cnode_sel() { return phys_cnode_sel() + 1; }
|
||||||
UNTYPED_CNODE_SEL = 0xa04,
|
static unsigned long core_static_sel_end() { return untyped_cnode_sel() + 1; }
|
||||||
CORE_STATIC_SEL_END,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* indices within top-level CNode */
|
/* indices within top-level CNode */
|
||||||
enum Top_cnode_idx {
|
enum Top_cnode_idx {
|
||||||
|
@ -174,7 +174,7 @@ class Genode::Initial_untyped_pool
|
|||||||
seL4_Untyped const service = range.sel;
|
seL4_Untyped const service = range.sel;
|
||||||
int const type = seL4_UntypedObject;
|
int const type = seL4_UntypedObject;
|
||||||
int const size_bits = get_page_size_log2();
|
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_index = Core_cspace::TOP_CNODE_UNTYPED_IDX;
|
||||||
int const node_depth = Core_cspace::NUM_TOP_SEL_LOG2;
|
int const node_depth = Core_cspace::NUM_TOP_SEL_LOG2;
|
||||||
int const node_offset = phys_addr >> get_page_size_log2();
|
int const node_offset = phys_addr >> get_page_size_log2();
|
||||||
|
@ -67,29 +67,29 @@ class Genode::Platform : public Platform_generic
|
|||||||
|
|
||||||
/* allocate 1st-level CNode */
|
/* allocate 1st-level CNode */
|
||||||
Cnode _top_cnode { Cap_sel(seL4_CapInitThreadCNode),
|
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,
|
Core_cspace::NUM_TOP_SEL_LOG2,
|
||||||
_initial_untyped_pool };
|
_initial_untyped_pool };
|
||||||
|
|
||||||
/* allocate 2nd-level CNode to align core's CNode with the LSB of the CSpace*/
|
/* allocate 2nd-level CNode to align core's CNode with the LSB of the CSpace*/
|
||||||
Cnode _core_pad_cnode { Cap_sel(seL4_CapInitThreadCNode),
|
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,
|
Core_cspace::NUM_CORE_PAD_SEL_LOG2,
|
||||||
_initial_untyped_pool };
|
_initial_untyped_pool };
|
||||||
|
|
||||||
/* allocate 3rd-level CNode for core's objects */
|
/* allocate 3rd-level CNode for core's objects */
|
||||||
Cnode _core_cnode { Cap_sel(seL4_CapInitThreadCNode),
|
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 };
|
Core_cspace::NUM_CORE_SEL_LOG2, _initial_untyped_pool };
|
||||||
|
|
||||||
/* allocate 2nd-level CNode for storing page-frame cap selectors */
|
/* allocate 2nd-level CNode for storing page-frame cap selectors */
|
||||||
Cnode _phys_cnode { Cap_sel(seL4_CapInitThreadCNode),
|
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 };
|
Core_cspace::NUM_PHYS_SEL_LOG2, _initial_untyped_pool };
|
||||||
|
|
||||||
/* allocate 2nd-level CNode for storing cap selectors for untyped pages */
|
/* allocate 2nd-level CNode for storing cap selectors for untyped pages */
|
||||||
Cnode _untyped_cnode { Cap_sel(seL4_CapInitThreadCNode),
|
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 };
|
Core_cspace::NUM_PHYS_SEL_LOG2, _initial_untyped_pool };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -102,7 +102,7 @@ class Genode::Platform : public Platform_generic
|
|||||||
{
|
{
|
||||||
Lock _lock;
|
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
|
Cap_sel alloc() override
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ struct Genode::Untyped_memory
|
|||||||
seL4_Untyped const service = untyped_sel(phys_addr).value();
|
seL4_Untyped const service = untyped_sel(phys_addr).value();
|
||||||
int const type = seL4_X86_4K;
|
int const type = seL4_X86_4K;
|
||||||
int const size_bits = 0;
|
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_index = Core_cspace::TOP_CNODE_PHYS_IDX;
|
||||||
int const node_depth = Core_cspace::NUM_TOP_SEL_LOG2;
|
int const node_depth = Core_cspace::NUM_TOP_SEL_LOG2;
|
||||||
int const node_offset = phys_addr >> get_page_size_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,
|
static inline void convert_to_untyped_frames(addr_t const phys_addr,
|
||||||
addr_t const phys_size)
|
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;
|
int const space_size = Core_cspace::NUM_PHYS_SEL_LOG2;
|
||||||
|
|
||||||
for (addr_t phys = phys_addr; phys < phys_addr + phys_size;
|
for (addr_t phys = phys_addr; phys < phys_addr + phys_size;
|
||||||
|
@ -207,7 +207,7 @@ void Platform::_switch_to_core_cspace()
|
|||||||
_core_cnode.copy(initial_cspace, Cnode_index(seL4_CapDomain));
|
_core_cnode.copy(initial_cspace, Cnode_index(seL4_CapDomain));
|
||||||
|
|
||||||
/* replace seL4_CapInitThreadCNode with new top-level CNode */
|
/* 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));
|
Cnode_index(seL4_CapInitThreadCNode));
|
||||||
|
|
||||||
/* copy untyped memory selectors to core's CNode */
|
/* 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));
|
_core_cnode.copy(initial_cspace, Cnode_index(sel));
|
||||||
|
|
||||||
/* copy statically created CNode selectors to core's CNode */
|
/* 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::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_pad_cnode_sel()));
|
||||||
_core_cnode.copy(initial_cspace, Cnode_index(Core_cspace::CORE_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::phys_cnode_sel()));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Construct CNode hierarchy of core's CSpace
|
* Construct CNode hierarchy of core's CSpace
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* insert 3rd-level core CNode into 2nd-level core-pad CNode */
|
/* 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));
|
Cnode_index(0));
|
||||||
|
|
||||||
/* insert 2nd-level core-pad CNode into 1st-level CNode */
|
/* 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));
|
Cnode_index(Core_cspace::TOP_CNODE_CORE_IDX));
|
||||||
|
|
||||||
/* insert 2nd-level phys-mem CNode into 1st-level CNode */
|
/* 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));
|
Cnode_index(Core_cspace::TOP_CNODE_PHYS_IDX));
|
||||||
|
|
||||||
/* insert 2nd-level untyped-pages CNode into 1st-level CNode */
|
/* 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));
|
Cnode_index(Core_cspace::TOP_CNODE_UNTYPED_IDX));
|
||||||
|
|
||||||
/* activate core's CSpace */
|
/* activate core's CSpace */
|
||||||
@ -266,7 +266,7 @@ void Platform::_switch_to_core_cspace()
|
|||||||
|
|
||||||
int const ret = seL4_TCB_SetSpace(seL4_CapInitThreadTCB,
|
int const ret = seL4_TCB_SetSpace(seL4_CapInitThreadTCB,
|
||||||
seL4_CapNull, /* fault_ep */
|
seL4_CapNull, /* fault_ep */
|
||||||
Core_cspace::TOP_CNODE_SEL, null_data,
|
Core_cspace::top_cnode_sel(), null_data,
|
||||||
seL4_CapInitThreadPD, null_data);
|
seL4_CapInitThreadPD, null_data);
|
||||||
|
|
||||||
if (ret != seL4_NoError)
|
if (ret != seL4_NoError)
|
||||||
|
Loading…
Reference in New Issue
Block a user