diff --git a/base-nova/include/nova/syscall-generic.h b/base-nova/include/nova/syscall-generic.h index 3afef635e4..f293429ba0 100644 --- a/base-nova/include/nova/syscall-generic.h +++ b/base-nova/include/nova/syscall-generic.h @@ -516,7 +516,8 @@ namespace Nova { */ enum { NUM_INITIAL_PT_LOG2 = 5, - NUM_INITIAL_PT = 1 << NUM_INITIAL_PT_LOG2 + NUM_INITIAL_PT = 1UL << NUM_INITIAL_PT_LOG2, + NUM_INITIAL_PT_RESERVED = 2 * NUM_INITIAL_PT, }; /** diff --git a/base-nova/src/base/env/cap_sel_alloc.cc b/base-nova/src/base/env/cap_sel_alloc.cc index 2265745a96..0ff94e051e 100644 --- a/base-nova/src/base/env/cap_sel_alloc.cc +++ b/base-nova/src/base/env/cap_sel_alloc.cc @@ -25,13 +25,6 @@ using namespace Genode; -/** - * First available capability selector for custom use - * - * Must be initialized by the startup code - */ -int __first_free_cap_selector; - /** * Low-level lock to protect the allocator * @@ -99,17 +92,16 @@ Cap_selector_allocator::Cap_selector_allocator() /* initialize lock */ alloc_lock(); - /* the first free selector is used for the lock */ - Bit_allocator::_reserve(0, __first_free_cap_selector + 1); + /** + * The first selectors are reserved for exception portals and special + * purpose usage as defined in the nova syscall header file + */ + Bit_allocator::_reserve(0, Nova::NUM_INITIAL_PT_RESERVED); } namespace Genode { - /** - * This function must not be called prior the initialization of - * '__first_free_cap_selector'. - */ Cap_selector_allocator *cap_selector_allocator() { static Cap_selector_allocator inst; diff --git a/base-nova/src/core/platform.cc b/base-nova/src/core/platform.cc index f2c54c8f39..9517fd82dd 100644 --- a/base-nova/src/core/platform.cc +++ b/base-nova/src/core/platform.cc @@ -44,12 +44,6 @@ Native_utcb *main_thread_utcb(); extern long __initial_sp; -/** - * First available capability selector for custom use - */ -extern int __first_free_cap_selector; - - /** * Pointer to the UTCB of the main thread */ @@ -182,9 +176,6 @@ Platform::Platform() : /* register UTCB of main thread */ __main_thread_utcb = (Utcb *)(__initial_sp - get_page_size()); - /* register start of usable capability range */ - __first_free_cap_selector = hip->sel_exc + hip->sel_gsi + 3; - /* set core pd selector */ __core_pd_sel = hip->sel_exc; @@ -200,6 +191,12 @@ Platform::Platform() : * Now that we can access the I/O ports for comport 0, printf works... */ + /* sanity checks */ + if (hip->sel_exc + 3 > NUM_INITIAL_PT_RESERVED) { + printf("configuration error\n"); + nova_die(); + } + /* configure virtual address spaces */ _vm_base = get_page_size(); #ifdef __x86_64__ diff --git a/base-nova/src/platform/_main_helper.h b/base-nova/src/platform/_main_helper.h index b781791c97..2809a68f06 100644 --- a/base-nova/src/platform/_main_helper.h +++ b/base-nova/src/platform/_main_helper.h @@ -16,28 +16,7 @@ #define _PLATFORM___MAIN_HELPER_H_ #include -#include -/** - * Initial value of esp register, saved by the crt0 startup code - * - * This value contains the address of the hypervisor information page. - */ -extern long __initial_sp; - -/** - * First available capability selector for custom use - */ -extern int __first_free_cap_selector; - -static void main_thread_bootstrap() -{ - /* register start of usable capability range */ - enum { FIRST_FREE_PORTAL = 0x1000 }; - - /* this variable may be set by the dynamic linker (ldso) */ - if (!__first_free_cap_selector) - __first_free_cap_selector = FIRST_FREE_PORTAL; -} +static void main_thread_bootstrap() {}; #endif /* _PLATFORM___MAIN_HELPER_H_ */ diff --git a/os/src/lib/ldso/symbol.map b/os/src/lib/ldso/symbol.map index 5f5df8097b..d25a0658a1 100644 --- a/os/src/lib/ldso/symbol.map +++ b/os/src/lib/ldso/symbol.map @@ -75,9 +75,6 @@ __l4_sys_direct_sycalls; l4_atomic_cmpxchg; - /* Nova */ - __first_free_cap_selector; - extern "C++" { main_thread_utcb*; };