diff --git a/repos/base-hw/src/core/kernel/main.cc b/repos/base-hw/src/core/kernel/main.cc index 2aa2676440..df1e45f338 100644 --- a/repos/base-hw/src/core/kernel/main.cc +++ b/repos/base-hw/src/core/kernel/main.cc @@ -12,6 +12,9 @@ * under the terms of the GNU Affero General Public License version 3. */ +/* base includes */ +#include + /* base-hw Core includes */ #include #include @@ -37,8 +40,9 @@ class Kernel::Main static Main *_instance; - Lock _data_lock { }; - Cpu_pool _cpu_pool { }; + Lock _data_lock { }; + Cpu_pool _cpu_pool { }; + Genode::Constructible _core_main_thread { }; void _handle_kernel_entry(); }; @@ -122,7 +126,12 @@ void Kernel::main_initialize_and_handle_kernel_entry() Genode::log(""); Genode::log("kernel initialized"); - Core_main_thread::initialize_instance(Main::_instance->_cpu_pool); + Main::_instance->_core_main_thread.construct( + Main::_instance->_cpu_pool); + + boot_info.core_main_thread_utcb = + (addr_t)Main::_instance->_core_main_thread->utcb(); + kernel_ready = true; } else { /* secondary cpus spin until the kernel is initialized */ diff --git a/repos/base-hw/src/core/kernel/thread.cc b/repos/base-hw/src/core/kernel/thread.cc index e88fcc227a..3578cffaf8 100644 --- a/repos/base-hw/src/core/kernel/thread.cc +++ b/repos/base-hw/src/core/kernel/thread.cc @@ -898,13 +898,3 @@ Core_main_thread::Core_main_thread(Cpu_pool &cpu_pool) Thread::_pd = &core_pd(); _become_active(); } - - -Core_main_thread *Core_main_thread::_instance; - - -void Core_main_thread::initialize_instance(Cpu_pool &cpu_pool) -{ - static Core_main_thread instance { cpu_pool }; - _instance = &instance; -} diff --git a/repos/base-hw/src/core/kernel/thread.h b/repos/base-hw/src/core/kernel/thread.h index d8777df296..23b916e5d8 100644 --- a/repos/base-hw/src/core/kernel/thread.h +++ b/repos/base-hw/src/core/kernel/thread.h @@ -438,17 +438,9 @@ class Kernel::Thread : private Kernel::Object, public Cpu_job, private Timeout */ class Kernel::Core_main_thread : public Core_object { - private: - - static Core_main_thread *_instance; - public: Core_main_thread(Cpu_pool &cpu_pool); - - static void initialize_instance(Cpu_pool &cpu_pool); - - static Thread &instance() { return *_instance; }; }; #endif /* _CORE__KERNEL__THREAD_H_ */ diff --git a/repos/base-hw/src/core/platform.cc b/repos/base-hw/src/core/platform.cc index 42d3dcd883..3f8dc39a56 100644 --- a/repos/base-hw/src/core/platform.cc +++ b/repos/base-hw/src/core/platform.cc @@ -63,6 +63,11 @@ Hw::Page_table::Allocator & Platform::core_page_table_allocator() } +addr_t Platform::core_main_thread_phys_utcb() +{ + return core_phys_addr(_boot_info().core_main_thread_utcb); +} + void Platform::_init_io_mem_alloc() { /* add entire adress space minus the RAM memory regions */ diff --git a/repos/base-hw/src/core/platform.h b/repos/base-hw/src/core/platform.h index c10c8d8a10..49d8477615 100644 --- a/repos/base-hw/src/core/platform.h +++ b/repos/base-hw/src/core/platform.h @@ -143,6 +143,8 @@ class Genode::Platform : public Genode::Platform_generic * by core's local capability space. */ size_t max_caps() const override { return Kernel::Pd::max_cap_ids; } + + static addr_t core_main_thread_phys_utcb(); }; #endif /* _CORE__PLATFORM_H_ */ diff --git a/repos/base-hw/src/core/thread_start.cc b/repos/base-hw/src/core/thread_start.cc index e6d30f31b5..c057c44b7a 100644 --- a/repos/base-hw/src/core/thread_start.cc +++ b/repos/base-hw/src/core/thread_start.cc @@ -93,7 +93,7 @@ void Thread::_init_platform_thread(size_t, Type type) } /* remap initial main-thread UTCB according to stack-area spec */ - Genode::map_local(Platform::core_phys_addr((addr_t)Kernel::Core_main_thread::instance().utcb()), + Genode::map_local(Platform::core_main_thread_phys_utcb(), (addr_t)&_stack->utcb(), max(sizeof(Native_utcb) / get_page_size(), (size_t)1)); diff --git a/repos/base-hw/src/include/hw/boot_info.h b/repos/base-hw/src/include/hw/boot_info.h index 395455dd7c..d7c1c50ebb 100644 --- a/repos/base-hw/src/include/hw/boot_info.h +++ b/repos/base-hw/src/include/hw/boot_info.h @@ -27,6 +27,7 @@ struct Hw::Boot_info addr_t const table; addr_t const table_allocator; + addr_t core_main_thread_utcb { 0 }; Mapping_pool const elf_mappings; Kernel_irqs kernel_irqs { }; Mapping const boot_modules;