1# 2# Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3# 4# SPDX-License-Identifier: BSD-2-Clause 5# 6 7cmake_minimum_required(VERSION 3.8.2) 8include_guard(GLOBAL) 9 10function(ApplyData61ElfLoaderSettings kernel_platform kernel_sel4_arch) 11 set(binary_list "tx1;hikey;odroidc2;imx8mq-evk;rockpro64;zynqmp;imx8mm-evk;hifive") 12 set(efi_list "tk1") 13 set(uimage_list "tx2;am335x") 14 if( 15 ${kernel_platform} IN_LIST efi_list 16 OR (${kernel_platform} STREQUAL "hikey" AND ${kernel_sel4_arch} STREQUAL "aarch64") 17 ) 18 set(ElfloaderImage "efi" CACHE STRING "" FORCE) 19 elseif(${kernel_platform} IN_LIST uimage_list) 20 set(ElfloaderImage "uimage" CACHE STRING "" FORCE) 21 elseif(${kernel_platform} STREQUAL "rpi3" AND ${kernel_sel4_arch} STREQUAL "aarch64") 22 set(ElfloaderImage "binary" CACHE STRING "" FORCE) 23 elseif(${kernel_platform} IN_LIST binary_list) 24 set(ElfloaderImage "binary" CACHE STRING "" FORCE) 25 else() 26 set(ElfloaderImage "elf" CACHE STRING "" FORCE) 27 endif() 28 29 if(${kernel_platform} STREQUAL "tk1" AND ${kernel_sel4_arch} STREQUAL "arm_hyp") 30 set(ElfloaderMode "hypervisor" CACHE STRING "" FORCE) 31 set(ElfloaderMonitorHook ON CACHE BOOL "" FORCE) 32 endif() 33 if((KernelPlatformImx8mm-evk OR KernelPlatformImx8mq-evk) AND KernelSel4ArchAarch32) 34 set(ElfloaderArmV8LeaveAarch64 ON CACHE BOOL "" FORCE) 35 # This applies to imx8mm and imx8mq when in aarch32 configuration 36 # It should be possible to use a uimage format but when tried nothing 37 # runs after uboot. 38 set(IMAGE_START_ADDR 0x41000000 CACHE INTERNAL "" FORCE) 39 endif() 40 if(KernelPlatformHikey AND KernelSel4ArchAarch32) 41 # This is preserving what the Hikey's bootloader requires. 42 set(IMAGE_START_ADDR 0x1000 CACHE INTERNAL "" FORCE) 43 endif() 44 if(KernelPlatformZynqmp AND KernelSel4ArchAarch32) 45 set(IMAGE_START_ADDR 0x8000000 CACHE INTERNAL "" FORCE) 46 endif() 47endfunction() 48 49function(ApplyCommonSimulationSettings kernel_arch) 50 if("${kernel_arch}" STREQUAL "x86") 51 # Generally we cannot simulate some more recent features 52 set(KernelSupportPCID OFF CACHE BOOL "" FORCE) 53 set(KernelFSGSBase msr CACHE STRING "" FORCE) 54 set(KernelIOMMU OFF CACHE BOOL "" FORCE) 55 set(KernelFPU FXSAVE CACHE STRING "" FORCE) 56 endif() 57endfunction() 58 59function(ApplyCommonReleaseVerificationSettings release verification) 60 # Setup flags for different combinations of 'release' (performance optimized builds) and 61 # 'verification' (verification friendly features) builds 62 if(release) 63 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) 64 set(KernelPrinting OFF CACHE BOOL "" FORCE) 65 else() 66 set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "" FORCE) 67 endif() 68 if(verification) 69 set(KernelVerificationBuild ON CACHE BOOL "" FORCE) 70 else() 71 set(KernelVerificationBuild OFF CACHE BOOL "" FORCE) 72 endif() 73 # If neither release nor verification then enable debug facilities, otherwise turn them off 74 if((NOT release) AND (NOT verification)) 75 set(KernelDebugBuild ON CACHE BOOL "" FORCE) 76 set(KernelPrinting ON CACHE BOOL "" FORCE) 77 else() 78 set(KernelDebugBuild OFF CACHE BOOL "" FORCE) 79 endif() 80 mark_as_advanced(CMAKE_BUILD_TYPE) 81endfunction() 82 83# Try and map a PLATFORM value to a valid kernel platform and architecture 84# setting based on some established conventions: 85# - Any previous value taken by KernelARMPlatform 86# - Any value accepted by KernelPlatform 87# - x86_64 and ia32 map to pc99 88# 89# Additionally use the following boolean configs to indicate which seL4 arch 90# to select: 91# - aarch32: ARM, AARCH32, AARCH32HF 92# - arm_hyp: ARM_HYP 93# - aarch64: AARCH64 94# - riscv64: RISCV64 95# - riscv32: RISCV32 96# 97# Calling this function will result in forced updates to the cache. 98function(correct_platform_strings) 99 set(_REWRITE ON) 100 set( 101 correct_platform_strings_platform_aliases 102 sabre 103 wandq 104 kzm 105 rpi3 106 exynos5250 107 exynos5410 108 exynos5422 109 am335x-boneblack 110 am335x-boneblue 111 x86_64 112 ia32 113 ) 114 set( 115 correct_platform_strings_platform_aliases ${correct_platform_strings_platform_aliases} 116 CACHE INTERNAL "" 117 ) 118 if("${PLATFORM}" STREQUAL "sabre") 119 set(KernelPlatform imx6 CACHE STRING "" FORCE) 120 set(KernelARMPlatform sabre CACHE STRING "" FORCE) 121 elseif("${PLATFORM}" STREQUAL "wandq") 122 set(KernelPlatform imx6 CACHE STRING "" FORCE) 123 set(KernelARMPlatform wandq CACHE STRING "" FORCE) 124 elseif("${PLATFORM}" STREQUAL "kzm") 125 set(KernelPlatform imx31 CACHE STRING "" FORCE) 126 elseif("${PLATFORM}" STREQUAL "rpi3") 127 set(KernelPlatform bcm2837 CACHE STRING "" FORCE) 128 elseif("${PLATFORM}" STREQUAL "exynos5250") 129 set(KernelPlatform exynos5 CACHE STRING "" FORCE) 130 set(KernelARMPlatform exynos5250 CACHE STRING "" FORCE) 131 elseif("${PLATFORM}" STREQUAL "exynos5410") 132 set(KernelPlatform exynos5 CACHE STRING "" FORCE) 133 set(KernelARMPlatform exynos5410 CACHE STRING "" FORCE) 134 elseif("${PLATFORM}" STREQUAL "exynos5422") 135 set(KernelPlatform exynos5 CACHE STRING "" FORCE) 136 set(KernelARMPlatform exynos5422 CACHE STRING "" FORCE) 137 elseif("${PLATFORM}" STREQUAL "am335x-boneblack") 138 set(KernelPlatform am335x CACHE STRING "" FORCE) 139 set(KernelARMPlatform am335x-boneblack CACHE STRING "" FORCE) 140 elseif("${PLATFORM}" STREQUAL "am335x-boneblue") 141 set(KernelPlatform am335x CACHE STRING "" FORCE) 142 set(KernelARMPlatform am335x-boneblue CACHE STRING "" FORCE) 143 elseif("${PLATFORM}" STREQUAL "x86_64") 144 set(KernelPlatform pc99 CACHE STRING "" FORCE) 145 set(KernelSel4Arch x86_64 CACHE STRING "" FORCE) 146 elseif("${PLATFORM}" STREQUAL "ia32") 147 set(KernelPlatform pc99 CACHE STRING "" FORCE) 148 set(KernelSel4Arch ia32 CACHE STRING "" FORCE) 149 elseif(NOT "${PLATFORM}" STREQUAL "") 150 set(KernelPlatform ${PLATFORM} CACHE STRING "" FORCE) 151 set(_REWRITE OFF) 152 else() 153 set(_REWRITE OFF) 154 endif() 155 if(_REWRITE AND (NOT correct_platform_strings_no_print)) 156 message("correct_platform_strings: Attempting to correct PLATFORM: ${PLATFORM} 157 to new valid KernelPlatform: ${KernelPlatform}") 158 if("${KernelPlatform}" STREQUAL pc99) 159 message(" KernelSel4Arch: ${KernelSel4Arch}") 160 else() 161 message(" KernelARMPlatform: ${KernelARMPlatform}") 162 endif() 163 endif() 164 set(_REWRITE ON) 165 166 if(ARM OR AARCH32 OR AARCH32HF) 167 if( 168 ARM_HYP 169 OR ("${KernelSel4Arch}" STREQUAL arm_hyp) 170 OR ("${KernelArmSel4Arch}" STREQUAL arm_hyp) 171 ) 172 set(KernelSel4Arch arm_hyp CACHE STRING "" FORCE) 173 else() 174 set(KernelSel4Arch aarch32 CACHE STRING "" FORCE) 175 endif() 176 elseif(AARCH64) 177 set(KernelSel4Arch aarch64 CACHE STRING "" FORCE) 178 elseif(RISCV64) 179 set(KernelSel4Arch riscv64 CACHE STRING "" FORCE) 180 elseif(RISCV32) 181 set(KernelSel4Arch riscv32 CACHE STRING "" FORCE) 182 else() 183 set(_REWRITE OFF) 184 endif() 185 if(_REWRITE AND (NOT correct_platform_strings_no_print)) 186 message( 187 "correct_platform_strings: Based on toolchain, setting KernelSel4Arch: ${KernelSel4Arch}" 188 ) 189 endif() 190 191 # This is a common mechanism for how x86 architectures were selected 192 if("${KernelX86Sel4Arch}" STREQUAL ia32) 193 set(KernelSel4Arch ia32 CACHE STRING "" FORCE) 194 elseif("${KernelX86Sel4Arch}" STREQUAL x86_64) 195 set(KernelSel4Arch x86_64 CACHE STRING "" FORCE) 196 endif() 197 198 # Only print out these info messages on first initialisation 199 # otherwise the ccache gets interrupted with output everytime it is used. 200 # The ccache also has a mechanism for showing what config options get chagned 201 # after a configuration anyway so the user will still be informed. 202 set(correct_platform_strings_no_print ON CACHE INTERNAL "") 203endfunction() 204