From 80f4c9d267f3f2638fc8614f309aaa9d9137b775 Mon Sep 17 00:00:00 2001 From: Axel Heider Date: Mon, 3 Oct 2022 16:09:11 +0200 Subject: [PATCH] cmake: make calculation arch specific - KernelMaxNumNodes is always defined, it's at lest 1 - CONFIGURE_NUM_PPI might be defined Signed-off-by: Axel Heider --- config.cmake | 14 +++++++++----- configs/seL4Config.cmake | 13 +++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/config.cmake b/config.cmake index 5e458ae63b..a0a963783d 100644 --- a/config.cmake +++ b/config.cmake @@ -51,15 +51,19 @@ if(DEFINED CALLED_declare_default_headers) # calculate the irq cnode size based on MAX_NUM_IRQ if(KernelArchRiscV) math(EXPR MAX_NUM_IRQ "${CONFIGURE_PLIC_MAX_NUM_INT} + 2") - else() - if(DEFINED KernelMaxNumNodes AND CONFIGURE_NUM_PPI GREATER "0" AND KernelArchARM) + elseif(KernelArchARM) + set(MAX_NUM_IRQ "${CONFIGURE_MAX_IRQ}") + if(DEFINED CONFIGURE_NUM_PPI) + # The PPIs are a part of CONFIGURE_MAX_IRQ, but they are separate + # for each core. math( EXPR MAX_NUM_IRQ - "(${KernelMaxNumNodes}-1)*${CONFIGURE_NUM_PPI} + ${CONFIGURE_MAX_IRQ}" + "${MAX_NUM_IRQ} + ((${KernelMaxNumNodes} - 1) * ${CONFIGURE_NUM_PPI})" ) - else() - set(MAX_NUM_IRQ "${CONFIGURE_MAX_IRQ}") endif() + else() + # Don't make any assumption about other architectures. + message(FATAL_ERROR "unsupported architecture: '${KernelArch}'") endif() set(BITS "0") while(MAX_NUM_IRQ GREATER "0") diff --git a/configs/seL4Config.cmake b/configs/seL4Config.cmake index cb8b818516..22a2f0b728 100644 --- a/configs/seL4Config.cmake +++ b/configs/seL4Config.cmake @@ -124,6 +124,19 @@ macro(declare_default_headers) "" ${ARGN} ) + + if(NOT KernelArchARM AND DEFINED CONFIGURE_NUM_PPI) + message(FATAL_ERROR "NUM_PPI is for ARM only") + endif() + + if(KernelArchRiscV) + if(DEFINED CONFIGURE_MAX_IRQ) + message(FATAL_ERROR "Use PLIC_MAX_NUM_INT instead MAX_IRQ on RISC-V") + endif() + elseif(DEFINED CONFIGURE_PLIC_MAX_NUM_INT) + message(FATAL_ERROR "PLIC_MAX_NUM_INT is for RISC-V only") + endif() + set(CALLED_declare_default_headers 1) endmacro()