From aa6a7db50aa153fabdc45b3541e2faaa33837351 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Fri, 9 Jul 2021 14:25:46 +0200 Subject: [PATCH] base-hw: communicate kernel irqs via boot info Core used to read the kernel-reserved IRQs from the timer objects in the kernel's CPU objects and the PIC class (inter-processor IRQ). Besides not being "good style" to access a kernel object in Core, this becomes a problem when trying to prevent CPU pool from being accessed via global functions. As a solution, this commit extends the boot info to also carry an array of all kernel-reserved IRQs. Ref #4217 --- repos/base-hw/src/core/kernel/init.cc | 10 ++++++++++ repos/base-hw/src/core/platform.cc | 8 +++----- repos/base-hw/src/include/hw/boot_info.h | 2 ++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/repos/base-hw/src/core/kernel/init.cc b/repos/base-hw/src/core/kernel/init.cc index b4ad204f18..ffd514ce8c 100644 --- a/repos/base-hw/src/core/kernel/init.cc +++ b/repos/base-hw/src/core/kernel/init.cc @@ -20,6 +20,7 @@ #include #include #include +#include /* base includes */ #include @@ -71,6 +72,15 @@ extern "C" void kernel_init() if (Cpu::executing_id() == Cpu::primary_id()) { Lock::Guard guard(data_lock()); + using Boot_info = Hw::Boot_info; + Boot_info &boot_info { + *reinterpret_cast(Hw::Mm::boot_info().base) }; + + cpu_pool().for_each_cpu([&] (Kernel::Cpu &cpu) { + boot_info.kernel_irqs.add(cpu.timer().interrupt_id()); + }); + boot_info.kernel_irqs.add((unsigned)Board::Pic::IPI); + Genode::log(""); Genode::log("kernel initialized"); diff --git a/repos/base-hw/src/core/platform.cc b/repos/base-hw/src/core/platform.cc index e54e35e276..cbbbd03f36 100644 --- a/repos/base-hw/src/core/platform.cc +++ b/repos/base-hw/src/core/platform.cc @@ -177,14 +177,12 @@ Platform::Platform() /* make all non-kernel interrupts available to the interrupt allocator */ for (unsigned i = 0; i < Board::Pic::NR_OF_IRQ; i++) { bool kernel_resource = false; - Kernel::cpu_pool().for_each_cpu([&] (Kernel::Cpu & cpu) { - if (i == cpu.timer().interrupt_id()) { + _boot_info().kernel_irqs.for_each([&] (unsigned /*idx*/, + unsigned kernel_irq) { + if (i == kernel_irq) { kernel_resource = true; } }); - if (i == Board::Pic::IPI) { - kernel_resource = true; - } if (kernel_resource) { continue; } diff --git a/repos/base-hw/src/include/hw/boot_info.h b/repos/base-hw/src/include/hw/boot_info.h index d679767f95..395455dd7c 100644 --- a/repos/base-hw/src/include/hw/boot_info.h +++ b/repos/base-hw/src/include/hw/boot_info.h @@ -23,10 +23,12 @@ template struct Hw::Boot_info { using Mapping_pool = Genode::Array; + using Kernel_irqs = Genode::Array; addr_t const table; addr_t const table_allocator; Mapping_pool const elf_mappings; + Kernel_irqs kernel_irqs { }; Mapping const boot_modules; Mmio_space const mmio_space; Memory_region_array ram_regions { };