# NOTE: Define the generic function for Nuclei CPU configuration # Usage: $(eval $(call def_xlcpucfg,CFGNAME[,DEP1,DEP2,...])) # - Defines XLCFG_$(1) with a default empty value using ?= (preserves existing value if set) # - If XLCFG_$(1) is set to a non-empty value and that value >= 1, enables the feature and triggers dependencies # - Dependencies (DEP1, DEP2, etc.) will be set to 1 when main config is active # - Adds -DXLCFG_$(1)=$$(XLCFG_$(1)) to COMMON_FLAGS for C preprocessing # # Example 1: Simple configuration without dependencies # $(eval $(call def_xlcpucfg,CCM)) # - Creates XLCFG_CCM ?= (empty by default) # - If XLCFG_CCM is set to 1 or higher, adds -DXLCFG_CCM=1 to COMMON_FLAGS # # Example 2: Configuration with dependencies # $(eval $(call def_xlcpucfg,SPMP,TEE,PMP)) # - Creates XLCFG_SPMP ?= (empty by default) # - If XLCFG_SPMP is set to 1 or higher: # - Sets XLCFG_TEE := 1 and XLCFG_PMP := 1 # - Adds -DXLCFG_SPMP=$(value_of_XLCFG_SPMP) to COMMON_FLAGS define def_xlcpucfg # Initialize the configuration variable with a default empty value (using ?= preserves existing values) XLCFG_$(1) ?= # Check if the configuration variable has been set to a non-empty value # Use $$ to defer evaluation to the eval phase ifneq (x$$(XLCFG_$(1)),x) # Use $$ for gte call so it checks the value during eval ifeq ($$(call gte,$$(XLCFG_$(1)),1),$$(true)) # Use $$ for foreach so it only runs if ifeq is true # Note: wordlist uses single $ because we want to parse the arguments immediately # Enable all dependent features by setting them to 1 # Process dependencies from argument 2 onwards (wordlist 2,9 gets args 2-9) $$(foreach dep,$(wordlist 2,9,$(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9)),$$(if $$(dep),$$(eval XLCFG_$$(dep) := 1))) endif # Add the configuration as a preprocessor define to COMMON_FLAGS # Use $$ to reference the variable value at the time COMMON_FLAGS is used/evaluated COMMON_FLAGS += -DXLCFG_$(1)=$$(XLCFG_$(1)) endif endef # NOTE: This cpuconfig.mk is only valid when cpufeature.mk is not generated by nuclei_gen # NOTE: These XLCFG_xxx make variables control CPU features and are internally used by Nuclei SDK # Setting these variables affects `cpufeature.h` header file when `cpufeature.h` is not generated # Configuration options with dependencies - when enabled, they automatically enable dependent features # NOTE: Dependent features (such as TEE, PMP, SMODE, etc.) that are triggered by these configurations # also need to be defined separately in the simple configurations section below. # Example: SPMP depends on TEE and PMP, so when XLCFG_SPMP is set to >= 1, it will automatically # set XLCFG_TEE and XLCFG_PMP to 1, which is why TEE and PMP must also be defined below. $(eval $(call def_xlcpucfg,SPMP,TEE,PMP)) $(eval $(call def_xlcpucfg,SMPU,TEE,PMP)) $(eval $(call def_xlcpucfg,PLIC,SMODE)) $(eval $(call def_xlcpucfg,SSTC,SMODE)) $(eval $(call def_xlcpucfg,TEE,SMODE)) $(eval $(call def_xlcpucfg,VNICE,NICE)) $(eval $(call def_xlcpucfg,SMEPMP,PMP)) $(eval $(call def_xlcpucfg,PMP_GRAIN,PMP)) $(eval $(call def_xlcpucfg,PMP_ENTRY_NUM,PMP)) $(eval $(call def_xlcpucfg,PMP,UMODE)) $(eval $(call def_xlcpucfg,PMA_CSR_NUM,PMA)) $(eval $(call def_xlcpucfg,PMA_SEC_CSR_NUM,PMA)) # Simple configurations (no dependencies) # These configurations do not trigger any dependent features when enabled $(eval $(call def_xlcpucfg,CCM)) $(eval $(call def_xlcpucfg,ECLIC)) $(eval $(call def_xlcpucfg,SYSTIMER)) $(eval $(call def_xlcpucfg,SMODE)) $(eval $(call def_xlcpucfg,UMODE)) $(eval $(call def_xlcpucfg,EXCP)) $(eval $(call def_xlcpucfg,CIDU)) $(eval $(call def_xlcpucfg,HPM)) $(eval $(call def_xlcpucfg,SMPCC)) $(eval $(call def_xlcpucfg,ECC)) $(eval $(call def_xlcpucfg,PMA)) $(eval $(call def_xlcpucfg,PMA_MACRO)) $(eval $(call def_xlcpucfg,STACK_CHECK)) $(eval $(call def_xlcpucfg,IRQ_NUM)) $(eval $(call def_xlcpucfg,NICE)) $(eval $(call def_xlcpucfg,ICACHE)) $(eval $(call def_xlcpucfg,DCACHE)) $(eval $(call def_xlcpucfg,ILM)) $(eval $(call def_xlcpucfg,DLM)) $(eval $(call def_xlcpucfg,SRAM)) $(eval $(call def_xlcpucfg,DDR)) $(eval $(call def_xlcpucfg,MISALIGNED_ACCESS)) $(eval $(call def_xlcpucfg,AMO))