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
This commit is contained in:
Martin Stein 2021-07-09 14:25:46 +02:00 committed by Norman Feske
parent 8b69bc96f9
commit aa6a7db50a
3 changed files with 15 additions and 5 deletions

View File

@ -20,6 +20,7 @@
#include <platform_pd.h>
#include <board.h>
#include <platform_thread.h>
#include <hw/boot_info.h>
/* base includes */
#include <base/internal/unmanaged_singleton.h>
@ -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<Board::Boot_info>;
Boot_info &boot_info {
*reinterpret_cast<Boot_info*>(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");

View File

@ -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;
}

View File

@ -23,10 +23,12 @@ template <typename PLAT_INFO>
struct Hw::Boot_info
{
using Mapping_pool = Genode::Array<Mapping, 32>;
using Kernel_irqs = Genode::Array<unsigned, NR_OF_CPUS + 1>;
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 { };