1*b9411a12SAndroid Build Coastguard Worker# SPDX-License-Identifier: GPL-2.0-only 2*b9411a12SAndroid Build Coastguard Worker 3*b9411a12SAndroid Build Coastguard Workerifneq ($(NOCOMPILE),1) 4*b9411a12SAndroid Build Coastguard WorkerGIT:=$(shell git -C "$(top)" rev-parse --git-dir 1>/dev/null 2>&1 \ 5*b9411a12SAndroid Build Coastguard Worker && command -v git) 6*b9411a12SAndroid Build Coastguard Workerelse 7*b9411a12SAndroid Build Coastguard WorkerGIT:= 8*b9411a12SAndroid Build Coastguard Workerendif 9*b9411a12SAndroid Build Coastguard Worker 10*b9411a12SAndroid Build Coastguard Worker####################################################################### 11*b9411a12SAndroid Build Coastguard Worker# normalize Kconfig variables in a central place 12*b9411a12SAndroid Build Coastguard WorkerCONFIG_CBFS_PREFIX:=$(call strip_quotes,$(CONFIG_CBFS_PREFIX)) 13*b9411a12SAndroid Build Coastguard WorkerCONFIG_FMDFILE:=$(call strip_quotes,$(CONFIG_FMDFILE)) 14*b9411a12SAndroid Build Coastguard WorkerCONFIG_DEVICETREE:=$(call strip_quotes, $(CONFIG_DEVICETREE)) 15*b9411a12SAndroid Build Coastguard WorkerCONFIG_OVERRIDE_DEVICETREE:=$(call strip_quotes, $(CONFIG_OVERRIDE_DEVICETREE)) 16*b9411a12SAndroid Build Coastguard WorkerCONFIG_CHIPSET_DEVICETREE:=$(call strip_quotes, $(CONFIG_CHIPSET_DEVICETREE)) 17*b9411a12SAndroid Build Coastguard WorkerCONFIG_MEMLAYOUT_LD_FILE:=$(call strip_quotes, $(CONFIG_MEMLAYOUT_LD_FILE)) 18*b9411a12SAndroid Build Coastguard Worker 19*b9411a12SAndroid Build Coastguard Worker####################################################################### 20*b9411a12SAndroid Build Coastguard Worker# misleadingly named, this is the coreboot version 21*b9411a12SAndroid Build Coastguard Workerifeq ($(KERNELVERSION),) 22*b9411a12SAndroid Build Coastguard Workerifeq ($(BUILD_TIMELESS),1) 23*b9411a12SAndroid Build Coastguard WorkerKERNELVERSION := -TIMELESS--LESSTIME- 24*b9411a12SAndroid Build Coastguard Workerelse 25*b9411a12SAndroid Build Coastguard WorkerKERNELVERSION := $(strip $(if $(GIT),\ 26*b9411a12SAndroid Build Coastguard Worker $(shell git describe --abbrev=12 --dirty --always || git describe),\ 27*b9411a12SAndroid Build Coastguard Worker $(if $(wildcard $(top)/.coreboot-version),\ 28*b9411a12SAndroid Build Coastguard Worker $(shell cat $(top)/.coreboot-version),\ 29*b9411a12SAndroid Build Coastguard Worker coreboot-unknown$(KERNELREVISION)))) 30*b9411a12SAndroid Build Coastguard Workerendif 31*b9411a12SAndroid Build Coastguard Workerendif 32*b9411a12SAndroid Build Coastguard WorkerCOREBOOT_EXPORTS += KERNELVERSION 33*b9411a12SAndroid Build Coastguard Worker 34*b9411a12SAndroid Build Coastguard Worker####################################################################### 35*b9411a12SAndroid Build Coastguard Worker# Basic component discovery 36*b9411a12SAndroid Build Coastguard WorkerMAINBOARDDIR=$(call strip_quotes,$(CONFIG_MAINBOARD_DIR)) 37*b9411a12SAndroid Build Coastguard WorkerVARIANT_DIR:=$(call strip_quotes,$(CONFIG_VARIANT_DIR)) 38*b9411a12SAndroid Build Coastguard WorkerCARRIER_DIR:=$(call strip_quotes,$(CONFIG_CARRIER_DIR)) 39*b9411a12SAndroid Build Coastguard WorkerCOREBOOT_EXPORTS += MAINBOARDDIR VARIANT_DIR CARRIER_DIR 40*b9411a12SAndroid Build Coastguard Worker 41*b9411a12SAndroid Build Coastguard Worker## Final build results, which CBFSTOOL uses to create the final 42*b9411a12SAndroid Build Coastguard Worker## rom image file, are placed under $(objcbfs). 43*b9411a12SAndroid Build Coastguard Worker## These typically have suffixes .debug .elf .bin and .map 44*b9411a12SAndroid Build Coastguard Workerobjcbfs := $(obj)/cbfs/$(CONFIG_CBFS_PREFIX) 45*b9411a12SAndroid Build Coastguard Workeradditional-dirs += $(objcbfs) 46*b9411a12SAndroid Build Coastguard WorkerCOREBOOT_EXPORTS += objcbfs 47*b9411a12SAndroid Build Coastguard Worker 48*b9411a12SAndroid Build Coastguard Worker## Based on the active configuration, Makefile conditionally collects 49*b9411a12SAndroid Build Coastguard Worker## the required assembly includes and saves them in a file. 50*b9411a12SAndroid Build Coastguard Worker## Such files that do not have a clear one-to-one relation to a source 51*b9411a12SAndroid Build Coastguard Worker## file under src/ are placed and built under $(objgenerated) 52*b9411a12SAndroid Build Coastguard Workerobjgenerated := $(obj)/generated 53*b9411a12SAndroid Build Coastguard Workeradditional-dirs += $(objgenerated) 54*b9411a12SAndroid Build Coastguard WorkerCOREBOOT_EXPORTS += objgenerated 55*b9411a12SAndroid Build Coastguard Worker 56*b9411a12SAndroid Build Coastguard Worker## CCACHE_EXTRAFILES can be set by individual rules to help CCACHE 57*b9411a12SAndroid Build Coastguard Worker## discover dependencies it might not notice on its own (e.g. asm (".incbin")). 58*b9411a12SAndroid Build Coastguard WorkerCOREBOOT_EXPORTS += CCACHE_EXTRAFILES 59*b9411a12SAndroid Build Coastguard Worker 60*b9411a12SAndroid Build Coastguard Worker####################################################################### 61*b9411a12SAndroid Build Coastguard Worker# root rule to resolve if in build mode (ie. configuration exists) 62*b9411a12SAndroid Build Coastguard Workerreal-target: $(obj)/config.h coreboot files_added show_coreboot show_notices 63*b9411a12SAndroid Build Coastguard Workercoreboot: $(obj)/coreboot.rom $(obj)/cbfstool $(obj)/rmodtool $(obj)/ifwitool $(obj)/cse_fpt $(obj)/cse_serger 64*b9411a12SAndroid Build Coastguard Worker 65*b9411a12SAndroid Build Coastguard Worker# This target can be used to run scripts or additional targets 66*b9411a12SAndroid Build Coastguard Worker# after the build completes by creating a target named 'build_complete::' 67*b9411a12SAndroid Build Coastguard Worker.PHONY: build_complete 68*b9411a12SAndroid Build Coastguard Workerbuild_complete:: | coreboot 69*b9411a12SAndroid Build Coastguard Worker 70*b9411a12SAndroid Build Coastguard Worker# This target can be used to run rules after all files were added to CBFS, 71*b9411a12SAndroid Build Coastguard Worker# for example to process FMAP regions or the entire image. 72*b9411a12SAndroid Build Coastguard Worker.PHONY: files_added 73*b9411a12SAndroid Build Coastguard Workerfiles_added:: | build_complete 74*b9411a12SAndroid Build Coastguard Worker 75*b9411a12SAndroid Build Coastguard Worker# This target should come just before the show_notices target. If there 76*b9411a12SAndroid Build Coastguard Worker# are no notices, the build should finish with the text of what was just 77*b9411a12SAndroid Build Coastguard Worker# built. 78*b9411a12SAndroid Build Coastguard Worker.PHONY: show_coreboot 79*b9411a12SAndroid Build Coastguard Workershow_coreboot: | files_added 80*b9411a12SAndroid Build Coastguard Worker $(CBFSTOOL) $(obj)/coreboot.rom print -r $(subst $(spc),$(comma),$(all-regions)) 81*b9411a12SAndroid Build Coastguard Worker printf "\nBuilt %s (%s)\n" $(MAINBOARDDIR) $(CONFIG_MAINBOARD_PART_NUMBER) 82*b9411a12SAndroid Build Coastguard Worker if [ -f "$(CCACHE_STATSLOG)" ]; then \ 83*b9411a12SAndroid Build Coastguard Worker printf "\nccache statistics\n"; \ 84*b9411a12SAndroid Build Coastguard Worker $(CCACHE) --show-log-stats -v; \ 85*b9411a12SAndroid Build Coastguard Worker fi 86*b9411a12SAndroid Build Coastguard Worker 87*b9411a12SAndroid Build Coastguard Worker# This is intended to run at the *very end* of the build to show warnings 88*b9411a12SAndroid Build Coastguard Worker# notices and the like. If another target needs to be added, add it 89*b9411a12SAndroid Build Coastguard Worker# BEFORE this target. 90*b9411a12SAndroid Build Coastguard Worker.PHONY: show_notices 91*b9411a12SAndroid Build Coastguard Workershow_notices:: | show_coreboot 92*b9411a12SAndroid Build Coastguard Worker 93*b9411a12SAndroid Build Coastguard Worker# This rule allows the site-local makefile to run before starting the actual 94*b9411a12SAndroid Build Coastguard Worker# coreboot build. It should not be used in the regular coreboot makefiles. 95*b9411a12SAndroid Build Coastguard Worker# Note: This gets run after the immediate makefile code like updating the 96*b9411a12SAndroid Build Coastguard Worker# submodules, but before any other targets. 97*b9411a12SAndroid Build Coastguard Worker.PHONY: site-local-target 98*b9411a12SAndroid Build Coastguard Workersite-local-target:: 99*b9411a12SAndroid Build Coastguard Worker 100*b9411a12SAndroid Build Coastguard Worker####################################################################### 101*b9411a12SAndroid Build Coastguard Worker# our phony targets 102*b9411a12SAndroid Build Coastguard WorkerPHONY+= clean-abuild coreboot check-style build_complete 103*b9411a12SAndroid Build Coastguard Worker 104*b9411a12SAndroid Build Coastguard Worker####################################################################### 105*b9411a12SAndroid Build Coastguard Worker# root source directories of coreboot 106*b9411a12SAndroid Build Coastguard Worker# site-local Makefile.mk must go first to override default locations (for binaries etc.) 107*b9411a12SAndroid Build Coastguard Workersubdirs-y := site-local 108*b9411a12SAndroid Build Coastguard Worker 109*b9411a12SAndroid Build Coastguard Workersubdirs-y += src/lib src/commonlib/ src/console src/device src/acpi src/superio/common 110*b9411a12SAndroid Build Coastguard Workersubdirs-$(CONFIG_EC_ACPI) += src/ec/intel 111*b9411a12SAndroid Build Coastguard Workersubdirs-y += src/ec/acpi $(wildcard src/ec/*/*) $(wildcard src/southbridge/*/*) 112*b9411a12SAndroid Build Coastguard Workersubdirs-y += $(wildcard src/soc/*) $(wildcard src/soc/*/common) $(filter-out $(wildcard src/soc/*/common),$(wildcard src/soc/*/*)) 113*b9411a12SAndroid Build Coastguard Workersubdirs-y += $(wildcard src/northbridge/*/*) 114*b9411a12SAndroid Build Coastguard Workersubdirs-y += $(filter-out src/superio/common,$(wildcard src/superio/*)) $(wildcard src/superio/*/*) 115*b9411a12SAndroid Build Coastguard Workersubdirs-y += $(wildcard src/drivers/*) $(wildcard src/drivers/*/*) $(wildcard src/drivers/*/*/*) 116*b9411a12SAndroid Build Coastguard Workersubdirs-y += src/cpu src/vendorcode 117*b9411a12SAndroid Build Coastguard Workersubdirs-y += util/cbfstool util/sconfig util/nvramtool util/pgtblgen util/amdfwtool 118*b9411a12SAndroid Build Coastguard Workersubdirs-y += util/futility util/marvell util/bincfg util/supermicro util/qemu 119*b9411a12SAndroid Build Coastguard Workersubdirs-y += util/ifdtool 120*b9411a12SAndroid Build Coastguard Workersubdirs-y += $(wildcard src/arch/*) 121*b9411a12SAndroid Build Coastguard Workersubdirs-y += src/mainboard/$(MAINBOARDDIR) 122*b9411a12SAndroid Build Coastguard Workersubdirs-y += src/security 123*b9411a12SAndroid Build Coastguard Workersubdirs-y += payloads payloads/external 124*b9411a12SAndroid Build Coastguard Workersubdirs-$(CONFIG_SBOM) += src/sbom 125*b9411a12SAndroid Build Coastguard Workersubdirs-y += util/checklist util/testing 126*b9411a12SAndroid Build Coastguard Worker 127*b9411a12SAndroid Build Coastguard Worker####################################################################### 128*b9411a12SAndroid Build Coastguard Worker# Add source classes and their build options 129*b9411a12SAndroid Build Coastguard Workerclasses-y := ramstage romstage bootblock decompressor postcar smm smmstub cpu_microcode verstage 130*b9411a12SAndroid Build Coastguard Worker 131*b9411a12SAndroid Build Coastguard Worker# Add a special 'all' class to add sources to all stages 132*b9411a12SAndroid Build Coastguard Worker$(call add-special-class,all) 133*b9411a12SAndroid Build Coastguard Workerall-handler = $(foreach class,bootblock verstage romstage postcar ramstage,$(eval $(class)-y += $(2))) 134*b9411a12SAndroid Build Coastguard Worker 135*b9411a12SAndroid Build Coastguard Worker$(call add-special-class,all_x86) 136*b9411a12SAndroid Build Coastguard Workerall_x86-handler = $(foreach class,bootblock verstage_x86 romstage postcar ramstage,$(eval $(class)-y += $(2))) 137*b9411a12SAndroid Build Coastguard Worker 138*b9411a12SAndroid Build Coastguard Worker$(call add-special-class,verstage_x86) 139*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_ARCH_VERSTAGE_X86_32)$(CONFIG_ARCH_VERSTAGE_X86_64),y) 140*b9411a12SAndroid Build Coastguard Workerverstage_x86-handler = $(eval verstage-y += $(2)) 141*b9411a12SAndroid Build Coastguard Workerelse 142*b9411a12SAndroid Build Coastguard Workerverstage_x86-handler = 143*b9411a12SAndroid Build Coastguard Workerendif 144*b9411a12SAndroid Build Coastguard Worker 145*b9411a12SAndroid Build Coastguard Worker# Add dynamic classes for rmodules 146*b9411a12SAndroid Build Coastguard Worker$(foreach supported_arch,$(ARCH_SUPPORTED), \ 147*b9411a12SAndroid Build Coastguard Worker $(eval $(call define_class,rmodules_$(supported_arch),$(supported_arch)))) 148*b9411a12SAndroid Build Coastguard Worker# Provide a macro to determine environment for free standing rmodules. 149*b9411a12SAndroid Build Coastguard Worker$(foreach supported_arch,$(ARCH_SUPPORTED), \ 150*b9411a12SAndroid Build Coastguard Worker $(eval rmodules_$(supported_arch)-generic-ccopts += -D__RMODULE__)) 151*b9411a12SAndroid Build Coastguard Worker 152*b9411a12SAndroid Build Coastguard Worker####################################################################### 153*b9411a12SAndroid Build Coastguard Worker# Helper functions for math, strings, and various file placement matters. 154*b9411a12SAndroid Build Coastguard Worker# macros work on all formats understood by printf(1) 155*b9411a12SAndroid Build Coastguard Worker# values are space separated if using more than one value 156*b9411a12SAndroid Build Coastguard Worker# 157*b9411a12SAndroid Build Coastguard Worker# int-add: adds an arbitrary length list of integers 158*b9411a12SAndroid Build Coastguard Worker# int-subtract: subtracts the second of two integers from the first 159*b9411a12SAndroid Build Coastguard Worker# int-multiply: multiplies an arbitrary length list of integers 160*b9411a12SAndroid Build Coastguard Worker# int-divide: divides the first integer by the second 161*b9411a12SAndroid Build Coastguard Worker# int-remainder: arithmetic remainder of the first number divided by the second 162*b9411a12SAndroid Build Coastguard Worker# int-shift-left: Shift $1 left by $2 bits 163*b9411a12SAndroid Build Coastguard Worker# int-lt: 1 if the first value is less than the second. 0 otherwise 164*b9411a12SAndroid Build Coastguard Worker# int-gt: 1 if the first values is greater than the second. 0 otherwise 165*b9411a12SAndroid Build Coastguard Worker# int-eq: 1 if the two values are equal. 0 otherwise 166*b9411a12SAndroid Build Coastguard Worker# int-align: align $1 to $2 units 167*b9411a12SAndroid Build Coastguard Worker# file-size: returns the filesize of the given file 168*b9411a12SAndroid Build Coastguard Worker# tolower: returns the value in all lowercase 169*b9411a12SAndroid Build Coastguard Worker# toupper: returns the value in all uppercase 170*b9411a12SAndroid Build Coastguard Worker# ws_to_under: returns the value with any whitespace changed to underscores 171*b9411a12SAndroid Build Coastguard Worker# get_fmap_value returns the value of a given FMAP field from fmap_config.h 172*b9411a12SAndroid Build Coastguard Worker_toint=$(shell printf "%d" $1) 173*b9411a12SAndroid Build Coastguard Worker_tohex=$(shell printf 0x"%x" $1) 174*b9411a12SAndroid Build Coastguard Worker_int-add2=$(shell expr $(call _toint,$1) + $(call _toint,$2)) 175*b9411a12SAndroid Build Coastguard Workerint-add=$(if $(filter 1,$(words $1)),$(strip $1),$(call int-add,$(call _int-add2,$(word 1,$1),$(word 2,$1)) $(wordlist 3,$(words $1),$1))) 176*b9411a12SAndroid Build Coastguard Workerint-subtract=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) - $(call _toint,$(word 2,$1)))) 177*b9411a12SAndroid Build Coastguard Worker_int-multiply2=$(shell expr $(call _toint,$1) \* $(call _toint,$2)) 178*b9411a12SAndroid Build Coastguard Workerint-multiply=$(if $(filter 1,$(words $1)),$(strip $1),$(call int-multiply,$(call _int-multiply2,$(word 1,$1),$(word 2,$1)) $(wordlist 3,$(words $1),$1))) 179*b9411a12SAndroid Build Coastguard Workerint-divide=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) / $(call _toint,$(word 2,$1)))) 180*b9411a12SAndroid Build Coastguard Workerint-remainder=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) % $(call _toint,$(word 2,$1)))) 181*b9411a12SAndroid Build Coastguard Workerint-shift-left=$(shell echo -n $$(($(call _toint,$(word 1, $1)) << $(call _toint,$(word 2, $1))))) 182*b9411a12SAndroid Build Coastguard Workerint-lt=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) \< $(call _toint,$(word 2,$1)))) 183*b9411a12SAndroid Build Coastguard Workerint-gt=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) \> $(call _toint,$(word 2,$1)))) 184*b9411a12SAndroid Build Coastguard Workerint-eq=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) = $(call _toint,$(word 2,$1)))) 185*b9411a12SAndroid Build Coastguard Workerint-align=$(shell A=$(call _toint,$1) B=$(call _toint,$2); expr $$A + \( \( $$B - \( $$A % $$B \) \) % $$B \) ) 186*b9411a12SAndroid Build Coastguard Workerint-align-down=$(shell A=$(call _toint,$1) B=$(call _toint,$2); expr $$A - \( $$A % $$B \) ) 187*b9411a12SAndroid Build Coastguard Workerfile-size=$(strip $(shell wc -c "$1" | cut -f 1 -d ' ')) 188*b9411a12SAndroid Build Coastguard Workertolower=$(shell echo '$1' | tr '[:upper:]' '[:lower:]') 189*b9411a12SAndroid Build Coastguard Workertoupper=$(shell echo '$1' | tr '[:lower:]' '[:upper:]') 190*b9411a12SAndroid Build Coastguard Workerws_to_under=$(shell echo '$1' | tr ' \t' '_') 191*b9411a12SAndroid Build Coastguard Workerget_fmap_value=$(shell awk '$$2 == "$1" {print $$3}' $(obj)/fmap_config.h) 192*b9411a12SAndroid Build Coastguard Worker 193*b9411a12SAndroid Build Coastguard Worker####################################################################### 194*b9411a12SAndroid Build Coastguard Worker# Helper functions for ramstage postprocess 195*b9411a12SAndroid Build Coastguard Workerspc := 196*b9411a12SAndroid Build Coastguard Workerspc := $(spc) $(spc) 197*b9411a12SAndroid Build Coastguard Workercomma := , 198*b9411a12SAndroid Build Coastguard Worker 199*b9411a12SAndroid Build Coastguard Worker# Returns all files and dirs below `dir` (recursively). 200*b9411a12SAndroid Build Coastguard Worker# files-below-dir,dir,files 201*b9411a12SAndroid Build Coastguard Workerfiles-below-dir=$(filter $(1)%,$(2)) 202*b9411a12SAndroid Build Coastguard Worker 203*b9411a12SAndroid Build Coastguard Worker# Returns all dirs below `dir` (recursively). 204*b9411a12SAndroid Build Coastguard Worker# dirs-below-dir,dir,files 205*b9411a12SAndroid Build Coastguard Workerdirs-below-dir=$(filter-out $(1),$(sort $(dir $(call files-below-dir,$(1),$(2))))) 206*b9411a12SAndroid Build Coastguard Worker 207*b9411a12SAndroid Build Coastguard Worker# Returns all files directly in `dir` (non-recursively). 208*b9411a12SAndroid Build Coastguard Worker# files-in-dir,dir,files 209*b9411a12SAndroid Build Coastguard Workerfiles-in-dir=$(filter-out $(addsuffix %,$(call dirs-below-dir,$(1),$(2))),$(call files-below-dir,$(1),$(2))) 210*b9411a12SAndroid Build Coastguard Worker 211*b9411a12SAndroid Build Coastguard Worker####################################################################### 212*b9411a12SAndroid Build Coastguard Worker# reduce command line length by linking the objects of each 213*b9411a12SAndroid Build Coastguard Worker# directory into an intermediate file 214*b9411a12SAndroid Build Coastguard Workerramstage-postprocess=$$(eval DEPENDENCIES+=$$(addsuffix .d,$$(basename $(1)))) \ 215*b9411a12SAndroid Build Coastguard Worker $(foreach d,$(sort $(dir $(filter-out %.ld,$(1)))), \ 216*b9411a12SAndroid Build Coastguard Worker $(eval $(d)ramstage.a: $(call files-in-dir,$(d),$(filter-out %.ld,$(1))); rm -f $$@ && $(AR_ramstage) rcsT $$@ $$^ ) \ 217*b9411a12SAndroid Build Coastguard Worker $(eval ramstage-objs:=$(d)ramstage.a $(filter-out $(filter-out %.ld, $(call files-in-dir,$(d),$(1))),$(ramstage-objs)))) 218*b9411a12SAndroid Build Coastguard Worker 219*b9411a12SAndroid Build Coastguard Workerdecompressor-generic-ccopts += -D__DECOMPRESSOR__ 220*b9411a12SAndroid Build Coastguard Workerbootblock-generic-ccopts += -D__BOOTBLOCK__ 221*b9411a12SAndroid Build Coastguard Workerromstage-generic-ccopts += -D__ROMSTAGE__ 222*b9411a12SAndroid Build Coastguard Workerramstage-generic-ccopts += -D__RAMSTAGE__ 223*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_COVERAGE),y) 224*b9411a12SAndroid Build Coastguard Workerramstage-c-ccopts += -fprofile-arcs -ftest-coverage 225*b9411a12SAndroid Build Coastguard Workerendif 226*b9411a12SAndroid Build Coastguard Workerifneq ($(GIT),) 227*b9411a12SAndroid Build Coastguard Workerifneq ($(UPDATED_SUBMODULES),1) 228*b9411a12SAndroid Build Coastguard Worker$(info Updating git submodules.) 229*b9411a12SAndroid Build Coastguard Worker# try to fetch non-optional submodules if the source is under git 230*b9411a12SAndroid Build Coastguard Workerforgetthis:=$(shell git submodule update --init $(quiet_errors)) 231*b9411a12SAndroid Build Coastguard Worker# Checkout Cmocka repository 232*b9411a12SAndroid Build Coastguard Workerforgetthis:=$(shell git submodule update --init --checkout 3rdparty/cmocka $(quiet_errors)) 233*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_USE_BLOBS),y) 234*b9411a12SAndroid Build Coastguard Worker# These items are necessary because each has update=none in .gitmodules. They are ignored 235*b9411a12SAndroid Build Coastguard Worker# until expressly requested and enabled with --checkout 236*b9411a12SAndroid Build Coastguard Workerforgetthis:=$(shell git submodule update --init --checkout 3rdparty/blobs $(quiet_errors)) 237*b9411a12SAndroid Build Coastguard Workerforgetthis:=$(shell git submodule update --init --checkout 3rdparty/intel-microcode $(quiet_errors)) 238*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_FSP_USE_REPO),y) 239*b9411a12SAndroid Build Coastguard Workerforgetthis:=$(shell git submodule update --init --checkout 3rdparty/fsp $(quiet_errors)) 240*b9411a12SAndroid Build Coastguard Workerendif 241*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_USE_AMD_BLOBS),y) 242*b9411a12SAndroid Build Coastguard Workerforgetthis:=$(shell git submodule update --init --checkout 3rdparty/amd_blobs $(quiet_errors)) 243*b9411a12SAndroid Build Coastguard Workerendif 244*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_USE_QC_BLOBS),y) 245*b9411a12SAndroid Build Coastguard Workerforgetthis:=$(shell git submodule update --init --checkout 3rdparty/qc_blobs $(quiet_errors)) 246*b9411a12SAndroid Build Coastguard Workerendif 247*b9411a12SAndroid Build Coastguard Workerendif 248*b9411a12SAndroid Build Coastguard WorkerUPDATED_SUBMODULES:=1 249*b9411a12SAndroid Build Coastguard WorkerCOREBOOT_EXPORTS += UPDATED_SUBMODULES 250*b9411a12SAndroid Build Coastguard Worker 251*b9411a12SAndroid Build Coastguard Workerendif 252*b9411a12SAndroid Build Coastguard Workerendif # GIT != "" 253*b9411a12SAndroid Build Coastguard Worker 254*b9411a12SAndroid Build Coastguard Workerpostcar-c-deps:=$$(OPTION_TABLE_H) 255*b9411a12SAndroid Build Coastguard Workerramstage-c-deps:=$$(OPTION_TABLE_H) 256*b9411a12SAndroid Build Coastguard Workerromstage-c-deps:=$$(OPTION_TABLE_H) 257*b9411a12SAndroid Build Coastguard Workerverstage-c-deps:=$$(OPTION_TABLE_H) 258*b9411a12SAndroid Build Coastguard Workerbootblock-c-deps:=$$(OPTION_TABLE_H) 259*b9411a12SAndroid Build Coastguard Worker$(foreach type,ads adb, \ 260*b9411a12SAndroid Build Coastguard Worker $(foreach stage,$(COREBOOT_STANDARD_STAGES), \ 261*b9411a12SAndroid Build Coastguard Worker $(eval $(stage)-$(type)-deps := \ 262*b9411a12SAndroid Build Coastguard Worker $(obj)/$(stage)/$(notdir $(KCONFIG_AUTOADS)) \ 263*b9411a12SAndroid Build Coastguard Worker $(obj)/libgnat-$(ARCH-$(stage)-y)/libgnat.a))) 264*b9411a12SAndroid Build Coastguard Worker 265*b9411a12SAndroid Build Coastguard Worker# Add handler to copy linker scripts 266*b9411a12SAndroid Build Coastguard Workerdefine generic-objs_ld_template_gen 267*b9411a12SAndroid Build Coastguard Workerde$(EMPTY)fine $(1)-objs_ld_template 268*b9411a12SAndroid Build Coastguard Worker$$(call src-to-obj,$1,$$(1).ld): $$(1).ld $(obj)/config.h $(obj)/fmap_config.h 269*b9411a12SAndroid Build Coastguard Worker @printf " CP $$$$(subst $$$$(obj)/,,$$$$(@))\n" 270*b9411a12SAndroid Build Coastguard Worker $$(CC_$(1)) -MMD $$(CPPFLAGS_$(1)) $$($(1)-ld-ccopts) $(PREPROCESS_ONLY) -include $(obj)/config.h -MT $$$$@ -o $$$$@ $$$$< 271*b9411a12SAndroid Build Coastguard Workeren$(EMPTY)def 272*b9411a12SAndroid Build Coastguard Workerendef 273*b9411a12SAndroid Build Coastguard Worker 274*b9411a12SAndroid Build Coastguard Worker# Add handler to deal with archives 275*b9411a12SAndroid Build Coastguard Workerdefine generic-objs_a_template_gen 276*b9411a12SAndroid Build Coastguard Workerde$(EMPTY)fine $(1)-objs_a_template 277*b9411a12SAndroid Build Coastguard Worker$$(call src-to-obj,$1,$$(1).a): $$(1).a 278*b9411a12SAndroid Build Coastguard Worker @printf " AR $$$$(subst $$$$(obj)/,,$$$$(@))\n" 279*b9411a12SAndroid Build Coastguard Worker $$$$(AR_$(1)) rcsT $$$$@.tmp $$$$< 280*b9411a12SAndroid Build Coastguard Worker mv $$$$@.tmp $$$$@ 281*b9411a12SAndroid Build Coastguard Workeren$(EMPTY)def 282*b9411a12SAndroid Build Coastguard Workerendef 283*b9411a12SAndroid Build Coastguard Worker 284*b9411a12SAndroid Build Coastguard Worker# Add handler to add no rules for manual files 285*b9411a12SAndroid Build Coastguard Workerdefine generic-objs_manual_template_gen 286*b9411a12SAndroid Build Coastguard Worker# do nothing 287*b9411a12SAndroid Build Coastguard Workerendef 288*b9411a12SAndroid Build Coastguard Worker 289*b9411a12SAndroid Build Coastguard Worker####################################################################### 290*b9411a12SAndroid Build Coastguard Worker# Add handler to compile ACPI's ASL 291*b9411a12SAndroid Build Coastguard Worker# arg1: base file name 292*b9411a12SAndroid Build Coastguard Worker# arg2: y or n for including in cbfs. defaults to y 293*b9411a12SAndroid Build Coastguard Worker 294*b9411a12SAndroid Build Coastguard Worker# Empty resource templates were marked as a warning in IASL with the comment 295*b9411a12SAndroid Build Coastguard Worker# "This would appear to be worthless in real-world ASL code.", which is 296*b9411a12SAndroid Build Coastguard Worker# possibly true in many cases. In other cases it seems that an empty 297*b9411a12SAndroid Build Coastguard Worker# ResourceTemplate is the correct code. 298*b9411a12SAndroid Build Coastguard Worker# As it's valid ASL, disable the warning. 299*b9411a12SAndroid Build Coastguard WorkerEMPTY_RESOURCE_TEMPLATE_WARNING = 3150 300*b9411a12SAndroid Build Coastguard Worker 301*b9411a12SAndroid Build Coastguard WorkerIASL_WARNINGS_LIST = $(EMPTY_RESOURCE_TEMPLATE_WARNING) 302*b9411a12SAndroid Build Coastguard Worker 303*b9411a12SAndroid Build Coastguard WorkerIGNORED_IASL_WARNINGS = $(addprefix -vw , $(IASL_WARNINGS_LIST)) 304*b9411a12SAndroid Build Coastguard Worker 305*b9411a12SAndroid Build Coastguard Workerdefine asl_template 306*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/$(1).aml-file = $(obj)/$(1).aml 307*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/$(1).aml-type = raw 308*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/$(1).aml-compression = none 309*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA),y) 310*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/$(1).aml-align = 64 311*b9411a12SAndroid Build Coastguard Workerendif 312*b9411a12SAndroid Build Coastguard Workercbfs-files-$(if $(2),$(2),y) += $(CONFIG_CBFS_PREFIX)/$(1).aml 313*b9411a12SAndroid Build Coastguard Worker$(eval DEPENDENCIES += $(obj)/$(1).d) 314*b9411a12SAndroid Build Coastguard Worker$(obj)/$(1).aml: $(src)/mainboard/$(MAINBOARDDIR)/$(1).asl $(obj)/config.h 315*b9411a12SAndroid Build Coastguard Worker @printf " IASL $$(subst $(top)/,,$$(@))\n" 316*b9411a12SAndroid Build Coastguard Worker $(CC_ramstage) -x assembler-with-cpp -E -MMD -MT $$(@) $$(CPPFLAGS_ramstage) -D__ACPI__ -P -include $(src)/include/kconfig.h -I$(obj) -I$(src) -I$(src)/include -I$(src)/arch/$(ARCHDIR-$(ARCH-ramstage-y))/include -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $(obj)/$(1).asl 317*b9411a12SAndroid Build Coastguard Worker cd $$(dir $$@); $(IASL) $(IGNORED_IASL_WARNINGS) -we -p $$(notdir $$@) $(1).asl 318*b9411a12SAndroid Build Coastguard Worker echo " IASL "$(IASL_WARNINGS_LIST)" warning types were ignored!" 319*b9411a12SAndroid Build Coastguard Worker if ! $(IASL) -d $$@ 2>&1 | grep -Eq 'ACPI (Warning|Error)'; then \ 320*b9411a12SAndroid Build Coastguard Worker echo " IASL $$@ disassembled correctly."; \ 321*b9411a12SAndroid Build Coastguard Worker true; \ 322*b9411a12SAndroid Build Coastguard Worker else \ 323*b9411a12SAndroid Build Coastguard Worker echo "Error: Could not correctly disassemble $$@"; \ 324*b9411a12SAndroid Build Coastguard Worker $(IASL) -d $$@; \ 325*b9411a12SAndroid Build Coastguard Worker false; \ 326*b9411a12SAndroid Build Coastguard Worker fi 327*b9411a12SAndroid Build Coastguard Workerendef 328*b9411a12SAndroid Build Coastguard Worker 329*b9411a12SAndroid Build Coastguard Worker####################################################################### 330*b9411a12SAndroid Build Coastguard Worker# Parse plaintext CMOS defaults into binary format 331*b9411a12SAndroid Build Coastguard Worker# arg1: source file 332*b9411a12SAndroid Build Coastguard Worker# arg2: binary file name 333*b9411a12SAndroid Build Coastguard Workercbfs-files-processor-nvramtool= \ 334*b9411a12SAndroid Build Coastguard Worker $(eval $(2): $(1) $(top)/$(call strip_quotes,$(CONFIG_CMOS_LAYOUT_FILE)) | $(objutil)/nvramtool/nvramtool ; \ 335*b9411a12SAndroid Build Coastguard Worker printf " CREATE $(2) (from $(1))\n"; \ 336*b9411a12SAndroid Build Coastguard Worker $(objutil)/nvramtool/nvramtool -y $(top)/$(call strip_quotes,$(CONFIG_CMOS_LAYOUT_FILE)) -D $(2).tmp -p $(1) && \ 337*b9411a12SAndroid Build Coastguard Worker mv $(2).tmp $(2)) 338*b9411a12SAndroid Build Coastguard Worker 339*b9411a12SAndroid Build Coastguard Worker####################################################################### 340*b9411a12SAndroid Build Coastguard Worker# Reduce a .config file by removing lines about default unset booleans 341*b9411a12SAndroid Build Coastguard Worker# arg1: input 342*b9411a12SAndroid Build Coastguard Worker# arg2: output 343*b9411a12SAndroid Build Coastguard Workerdefine cbfs-files-processor-config 344*b9411a12SAndroid Build Coastguard Worker $(eval $(2): $(1) $(obj)/build.h $(objutil)/kconfig/conf; \ 345*b9411a12SAndroid Build Coastguard Worker +printf " CREATE $(2) (from $(1))\n"; \ 346*b9411a12SAndroid Build Coastguard Worker printf "# This image was built using coreboot " > $(2).tmp && \ 347*b9411a12SAndroid Build Coastguard Worker grep "\<COREBOOT_VERSION\>" $(obj)/build.h |cut -d\" -f2 >> $(2).tmp && \ 348*b9411a12SAndroid Build Coastguard Worker $(MAKE) DOTCONFIG=$(1) DEFCONFIG=$(2).tmp2 savedefconfig && \ 349*b9411a12SAndroid Build Coastguard Worker cat $(2).tmp2 >> $(2).tmp && \ 350*b9411a12SAndroid Build Coastguard Worker printf "# End of defconfig. Derivable values start here.\n" >> $(2).tmp && \ 351*b9411a12SAndroid Build Coastguard Worker grep "^CONFIG" $(1) | grep -F -v -f $(2).tmp2 >> $(2).tmp && \ 352*b9411a12SAndroid Build Coastguard Worker rm -f $(2).tmp2 && \ 353*b9411a12SAndroid Build Coastguard Worker mv -f $(2).tmp $(2)) 354*b9411a12SAndroid Build Coastguard Workerendef 355*b9411a12SAndroid Build Coastguard Worker 356*b9411a12SAndroid Build Coastguard Worker####################################################################### 357*b9411a12SAndroid Build Coastguard Worker# Add a file to CBFS with just type and compression values 358*b9411a12SAndroid Build Coastguard Worker# arg1: name in CBFS 359*b9411a12SAndroid Build Coastguard Worker# arg2: filename and path 360*b9411a12SAndroid Build Coastguard Worker# arg3: type in CBFS 361*b9411a12SAndroid Build Coastguard Worker# arg4: compression type 362*b9411a12SAndroid Build Coastguard Workerdefine add-cbfs-file-simple 363*b9411a12SAndroid Build Coastguard Worker $(eval cbfs-files-y += $(1)) 364*b9411a12SAndroid Build Coastguard Worker $(eval $(1)-file := $(2)) 365*b9411a12SAndroid Build Coastguard Worker $(eval $(1)-type := $(3)) 366*b9411a12SAndroid Build Coastguard Worker $(eval $(1)-compression := $(4)) 367*b9411a12SAndroid Build Coastguard Workerendef 368*b9411a12SAndroid Build Coastguard Worker 369*b9411a12SAndroid Build Coastguard Worker####################################################################### 370*b9411a12SAndroid Build Coastguard Worker# Compile a C file with a bare struct definition into binary 371*b9411a12SAndroid Build Coastguard Worker# arg1: C source file 372*b9411a12SAndroid Build Coastguard Worker# arg2: binary file 373*b9411a12SAndroid Build Coastguard Workercbfs-files-processor-struct= \ 374*b9411a12SAndroid Build Coastguard Worker $(eval $(2): $(1) $(obj)/build.h $(obj)/fmap_config.h $(KCONFIG_AUTOHEADER); \ 375*b9411a12SAndroid Build Coastguard Worker printf " CC+STRIP $(1)\n"; \ 376*b9411a12SAndroid Build Coastguard Worker $(CC_ramstage) -MMD $(CPPFLAGS_ramstage) $(CFLAGS_ramstage) --param asan-globals=0 $$(ramstage-c-ccopts) -include $(KCONFIG_AUTOHEADER) -MT $(2) -o $(2).tmp -c $(1) && \ 377*b9411a12SAndroid Build Coastguard Worker $(OBJCOPY_ramstage) -O binary --only-section='.*data*' --only-section='.*bss*' \ 378*b9411a12SAndroid Build Coastguard Worker --set-section-flags .*bss*=alloc,contents,load $(2).tmp $(2); \ 379*b9411a12SAndroid Build Coastguard Worker rm -f $(2).tmp) \ 380*b9411a12SAndroid Build Coastguard Worker $(eval DEPENDENCIES += $(2).d) 381*b9411a12SAndroid Build Coastguard Worker 382*b9411a12SAndroid Build Coastguard Worker####################################################################### 383*b9411a12SAndroid Build Coastguard Worker# Convert image to YCC 4:2:0 JPEG 384*b9411a12SAndroid Build Coastguard Worker# 385*b9411a12SAndroid Build Coastguard Worker# In two steps: 386*b9411a12SAndroid Build Coastguard Worker# 1. Convert to RGB colors, optionally resize and store as BMP. 387*b9411a12SAndroid Build Coastguard Worker# 2. Round final size to multiples of 16, optionally swap colors, 388*b9411a12SAndroid Build Coastguard Worker# convert (back) to sRGB and store as JPEG. 389*b9411a12SAndroid Build Coastguard Worker# The split is necessary because we don't know the exact, scaled 390*b9411a12SAndroid Build Coastguard Worker# size due to aspect-ratio. Note: IM v7 would allow us to do the 391*b9411a12SAndroid Build Coastguard Worker# calculations in one command using %[fx:...] syntax. 392*b9411a12SAndroid Build Coastguard Worker# 393*b9411a12SAndroid Build Coastguard Worker# arg1: image input file 394*b9411a12SAndroid Build Coastguard Worker# arg2: output jpg 395*b9411a12SAndroid Build Coastguard Workercbfs-files-processor-jpg420= \ 396*b9411a12SAndroid Build Coastguard Worker $(eval $(2): $(1) $(KCONFIG_AUTOCONFIG); \ 397*b9411a12SAndroid Build Coastguard Worker printf " CONVERT $$<\n"; \ 398*b9411a12SAndroid Build Coastguard Worker res=$(CONFIG_BOOTSPLASH_CONVERT_RESOLUTION); \ 399*b9411a12SAndroid Build Coastguard Worker res=$$$$(convert $$< \ 400*b9411a12SAndroid Build Coastguard Worker -colorspace RGB \ 401*b9411a12SAndroid Build Coastguard Worker $$(BOOTSPLASH_RESIZE-y) \ 402*b9411a12SAndroid Build Coastguard Worker -format '%wx%h' -write info: \ 403*b9411a12SAndroid Build Coastguard Worker bmp:$$@); \ 404*b9411a12SAndroid Build Coastguard Worker convert $$@ \ 405*b9411a12SAndroid Build Coastguard Worker $$(BOOTSPLASH_ROUND16) \ 406*b9411a12SAndroid Build Coastguard Worker $$(BOOTSPLASH_COLORSWAP-y) \ 407*b9411a12SAndroid Build Coastguard Worker -colorspace sRGB \ 408*b9411a12SAndroid Build Coastguard Worker -quality $$(CONFIG_BOOTSPLASH_CONVERT_QUALITY)% \ 409*b9411a12SAndroid Build Coastguard Worker -interlace none -colorspace YCC -sampling-factor 4:2:0 \ 410*b9411a12SAndroid Build Coastguard Worker jpg:$$@) 411*b9411a12SAndroid Build Coastguard WorkerBOOTSPLASH_FLOOR = $$(($${res%%x*} & ~15))x$$(($${res\#\#*x} & ~15)) 412*b9411a12SAndroid Build Coastguard WorkerBOOTSPLASH_RESIZE-$(CONFIG_BOOTSPLASH_CONVERT_RESIZE) = -resize $(BOOTSPLASH_FLOOR) 413*b9411a12SAndroid Build Coastguard WorkerBOOTSPLASH_CEIL = $$((($${res%%x*} + 15) & ~15))x$$((($${res\#\#*x} + 15) & ~15)) 414*b9411a12SAndroid Build Coastguard WorkerBOOTSPLASH_ROUND16 = -background black -gravity center -extent $(BOOTSPLASH_CEIL) 415*b9411a12SAndroid Build Coastguard WorkerBOOTSPLASH_COLORSWAP-$(CONFIG_BOOTSPLASH_CONVERT_COLORSWAP) := -channel-fx 'red<=>blue' 416*b9411a12SAndroid Build Coastguard Worker 417*b9411a12SAndroid Build Coastguard Worker####################################################################### 418*b9411a12SAndroid Build Coastguard Worker# Add handler for arbitrary files in CBFS 419*b9411a12SAndroid Build Coastguard Worker$(call add-special-class,cbfs-files) 420*b9411a12SAndroid Build Coastguard Workercbfs-files-handler= \ 421*b9411a12SAndroid Build Coastguard Worker $(eval tmp-cbfs-method:=$(word 2, $(subst :, ,$($(2)-file)))) \ 422*b9411a12SAndroid Build Coastguard Worker $(eval $(2)-file:=$(call strip_quotes,$(word 1, $(subst :, ,$($(2)-file))))) \ 423*b9411a12SAndroid Build Coastguard Worker $(eval tmp-cbfs-file:= ) \ 424*b9411a12SAndroid Build Coastguard Worker $(if $($(2)-file), \ 425*b9411a12SAndroid Build Coastguard Worker $(if $(wildcard $(1)$($(2)-file)), \ 426*b9411a12SAndroid Build Coastguard Worker $(eval tmp-cbfs-file:= $(wildcard $(1)$($(2)-file))), \ 427*b9411a12SAndroid Build Coastguard Worker $(eval tmp-cbfs-file:= $($(2)-file)))) \ 428*b9411a12SAndroid Build Coastguard Worker $(if $(strip $($(2)-required)), \ 429*b9411a12SAndroid Build Coastguard Worker $(if $(wildcard $(tmp-cbfs-file)),, \ 430*b9411a12SAndroid Build Coastguard Worker $(info This build configuration requires $($(2)-required)) \ 431*b9411a12SAndroid Build Coastguard Worker $(eval FAILBUILD:=1) \ 432*b9411a12SAndroid Build Coastguard Worker )) \ 433*b9411a12SAndroid Build Coastguard Worker $(if $(strip $($(2)-align)), \ 434*b9411a12SAndroid Build Coastguard Worker $(if $(strip $($(2)-position)), \ 435*b9411a12SAndroid Build Coastguard Worker $(info ERROR: It is not allowed to specify both alignment and position for $($(2)-file)) \ 436*b9411a12SAndroid Build Coastguard Worker $(eval FAILBUILD:=1) \ 437*b9411a12SAndroid Build Coastguard Worker )) \ 438*b9411a12SAndroid Build Coastguard Worker $(if $(tmp-cbfs-method), \ 439*b9411a12SAndroid Build Coastguard Worker $(eval tmp-old-cbfs-file:=$(tmp-cbfs-file)) \ 440*b9411a12SAndroid Build Coastguard Worker $(eval tmp-cbfs-file:=$(shell mkdir -p $(obj)/mainboard/$(MAINBOARDDIR); mktemp $(obj)/mainboard/$(MAINBOARDDIR)/cbfs-file.XXXXXX).out) \ 441*b9411a12SAndroid Build Coastguard Worker $(call cbfs-files-processor-$(tmp-cbfs-method),$(tmp-old-cbfs-file),$(tmp-cbfs-file))) \ 442*b9411a12SAndroid Build Coastguard Worker $(if $(tmp-cbfs-file), \ 443*b9411a12SAndroid Build Coastguard Worker $(eval cbfs-files += $(subst $(spc),*,$(tmp-cbfs-file)|$(2)|$($(2)-type)|$($(2)-compression)|$(strip $($(2)-position))|$($(2)-align)|$($(2)-options)))) \ 444*b9411a12SAndroid Build Coastguard Worker $(eval $(2)-name:=) \ 445*b9411a12SAndroid Build Coastguard Worker $(eval $(2)-type:=) \ 446*b9411a12SAndroid Build Coastguard Worker $(eval $(2)-compression:=) \ 447*b9411a12SAndroid Build Coastguard Worker $(eval $(2)-position:=) \ 448*b9411a12SAndroid Build Coastguard Worker $(eval $(2)-required:=) \ 449*b9411a12SAndroid Build Coastguard Worker $(eval $(2)-options:=) \ 450*b9411a12SAndroid Build Coastguard Worker $(eval $(2)-align:=) 451*b9411a12SAndroid Build Coastguard Worker 452*b9411a12SAndroid Build Coastguard Worker####################################################################### 453*b9411a12SAndroid Build Coastguard Worker# a variety of flags for our build 454*b9411a12SAndroid Build Coastguard WorkerCBFS_COMPRESS_FLAG:=none 455*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_COMPRESS_RAMSTAGE_LZMA),y) 456*b9411a12SAndroid Build Coastguard WorkerCBFS_COMPRESS_FLAG:=LZMA 457*b9411a12SAndroid Build Coastguard Workerendif 458*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_COMPRESS_RAMSTAGE_LZ4),y) 459*b9411a12SAndroid Build Coastguard WorkerCBFS_COMPRESS_FLAG:=LZ4 460*b9411a12SAndroid Build Coastguard Workerendif 461*b9411a12SAndroid Build Coastguard Worker 462*b9411a12SAndroid Build Coastguard WorkerCBFS_PAYLOAD_COMPRESS_FLAG:=none 463*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y) 464*b9411a12SAndroid Build Coastguard WorkerCBFS_PAYLOAD_COMPRESS_FLAG:=LZMA 465*b9411a12SAndroid Build Coastguard Workerendif 466*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZ4),y) 467*b9411a12SAndroid Build Coastguard WorkerCBFS_PAYLOAD_COMPRESS_FLAG:=LZ4 468*b9411a12SAndroid Build Coastguard Workerendif 469*b9411a12SAndroid Build Coastguard Worker 470*b9411a12SAndroid Build Coastguard WorkerCBFS_SECONDARY_PAYLOAD_COMPRESS_FLAG:=none 471*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_COMPRESS_SECONDARY_PAYLOAD),y) 472*b9411a12SAndroid Build Coastguard WorkerCBFS_SECONDARY_PAYLOAD_COMPRESS_FLAG:=LZMA 473*b9411a12SAndroid Build Coastguard Workerendif 474*b9411a12SAndroid Build Coastguard Worker 475*b9411a12SAndroid Build Coastguard WorkerCBFS_PRERAM_COMPRESS_FLAG:=none 476*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_COMPRESS_PRERAM_STAGES),y) 477*b9411a12SAndroid Build Coastguard WorkerCBFS_PRERAM_COMPRESS_FLAG:=LZ4 478*b9411a12SAndroid Build Coastguard Workerendif 479*b9411a12SAndroid Build Coastguard Worker 480*b9411a12SAndroid Build Coastguard Workerifneq ($(CONFIG_LOCALVERSION),"") 481*b9411a12SAndroid Build Coastguard WorkerCOREBOOT_EXTRA_VERSION := -$(call strip_quotes,$(CONFIG_LOCALVERSION)) 482*b9411a12SAndroid Build Coastguard WorkerCOREBOOT_EXPORTS += COREBOOT_EXTRA_VERSION 483*b9411a12SAndroid Build Coastguard Workerendif 484*b9411a12SAndroid Build Coastguard Worker 485*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_common := -Isrc 486*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_common += -Isrc/include 487*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_common += -Isrc/commonlib/include 488*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_common += -Isrc/commonlib/bsd/include 489*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_common += -I$(obj) 490*b9411a12SAndroid Build Coastguard WorkerVBOOT_SOURCE ?= 3rdparty/vboot 491*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_common += -I$(VBOOT_SOURCE)/firmware/include 492*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_common += -include $(src)/include/kconfig.h 493*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_common += -include $(src)/include/rules.h 494*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_common += -include $(src)/commonlib/bsd/include/commonlib/bsd/compiler.h 495*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_common += -I3rdparty 496*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_common += -D__BUILD_DIR__=\"$(obj)\" 497*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_common += -D__COREBOOT__ 498*b9411a12SAndroid Build Coastguard Worker 499*b9411a12SAndroid Build Coastguard Workerifeq ($(BUILD_TIMELESS),1) 500*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_common += -D__TIMELESS__ 501*b9411a12SAndroid Build Coastguard Workerendif 502*b9411a12SAndroid Build Coastguard Worker 503*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_PCI_OPTION_ROM_RUN_YABEL)$(CONFIG_PCI_OPTION_ROM_RUN_REALMODE),y) 504*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_ramstage += -Isrc/device/oprom/include 505*b9411a12SAndroid Build Coastguard Workerendif 506*b9411a12SAndroid Build Coastguard Worker 507*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -pipe 508*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -g 509*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -nostdinc 510*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -std=gnu11 511*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -nostdlib 512*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wall 513*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wundef 514*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wstrict-prototypes 515*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wmissing-prototypes 516*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wwrite-strings 517*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wredundant-decls 518*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wno-trigraphs 519*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wimplicit-fallthrough 520*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wshadow 521*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wdate-time 522*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wtype-limits 523*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wvla 524*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wold-style-definition 525*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wdangling-else 526*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wmissing-include-dirs 527*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -fno-common 528*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -ffreestanding 529*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -fno-builtin 530*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -fomit-frame-pointer 531*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -fstrict-aliasing 532*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -ffunction-sections 533*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -fdata-sections 534*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -fno-pie 535*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wstring-compare 536*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_COMPILER_GCC),y) 537*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wold-style-declaration 538*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wcast-function-type 539*b9411a12SAndroid Build Coastguard Worker# Don't add these GCC specific flags when running scan-build 540*b9411a12SAndroid Build Coastguard Workerifeq ($(CCC_ANALYZER_OUTPUT_FORMAT),) 541*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wno-packed-not-aligned 542*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -fconserve-stack 543*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wnull-dereference 544*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wlogical-op 545*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wduplicated-cond 546*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Wno-array-compare 547*b9411a12SAndroid Build Coastguard Workerendif 548*b9411a12SAndroid Build Coastguard Workerendif 549*b9411a12SAndroid Build Coastguard Worker 550*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -gnatp 551*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -Wuninitialized 552*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -Wall 553*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -Werror 554*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -pipe 555*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -g 556*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -nostdinc 557*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -Wstrict-aliasing 558*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -Wshadow 559*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -fno-common 560*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -fomit-frame-pointer 561*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -ffunction-sections 562*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -fdata-sections 563*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -fno-pie 564*b9411a12SAndroid Build Coastguard Worker# Ada warning options: 565*b9411a12SAndroid Build Coastguard Worker# 566*b9411a12SAndroid Build Coastguard Worker# a Activate most optional warnings. 567*b9411a12SAndroid Build Coastguard Worker# .e Activate every optional warnings. 568*b9411a12SAndroid Build Coastguard Worker# e Treat warnings and style checks as errors. 569*b9411a12SAndroid Build Coastguard Worker# 570*b9411a12SAndroid Build Coastguard Worker# D Suppress warnings on implicit dereferences: 571*b9411a12SAndroid Build Coastguard Worker# As SPARK does not accept access types we have to map the 572*b9411a12SAndroid Build Coastguard Worker# dynamically chosen register locations to a static SPARK 573*b9411a12SAndroid Build Coastguard Worker# variable. 574*b9411a12SAndroid Build Coastguard Worker# 575*b9411a12SAndroid Build Coastguard Worker# .H Suppress warnings on holes/gaps in records: 576*b9411a12SAndroid Build Coastguard Worker# We are modelling hardware here! 577*b9411a12SAndroid Build Coastguard Worker# 578*b9411a12SAndroid Build Coastguard Worker# H Suppress warnings on hiding: 579*b9411a12SAndroid Build Coastguard Worker# It's too annoying, you run out of ideas for identifiers fast. 580*b9411a12SAndroid Build Coastguard Worker# 581*b9411a12SAndroid Build Coastguard Worker# T Suppress warnings for tracking of deleted conditional code: 582*b9411a12SAndroid Build Coastguard Worker# We use static options to select code paths at compile time. 583*b9411a12SAndroid Build Coastguard Worker# 584*b9411a12SAndroid Build Coastguard Worker# U Suppress warnings on unused entities: 585*b9411a12SAndroid Build Coastguard Worker# Would have lots of warnings for unused register definitions, 586*b9411a12SAndroid Build Coastguard Worker# `withs` for debugging etc. 587*b9411a12SAndroid Build Coastguard Worker# 588*b9411a12SAndroid Build Coastguard Worker# .U Deactivate warnings on unordered enumeration types: 589*b9411a12SAndroid Build Coastguard Worker# As SPARK doesn't support `pragma Ordered` by now, we don't 590*b9411a12SAndroid Build Coastguard Worker# use that, yet. 591*b9411a12SAndroid Build Coastguard Worker# 592*b9411a12SAndroid Build Coastguard Worker# .W Suppress warnings on unnecessary Warnings Off pragmas: 593*b9411a12SAndroid Build Coastguard Worker# Things get really messy when you use different compiler 594*b9411a12SAndroid Build Coastguard Worker# versions, otherwise. 595*b9411a12SAndroid Build Coastguard Worker# .Y Disable information messages for why package spec needs body: 596*b9411a12SAndroid Build Coastguard Worker# Those messages are annoying. But don't forget to enable those, 597*b9411a12SAndroid Build Coastguard Worker# if you need the information. 598*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -gnatwa.eeD.HHTU.U.W.Y 599*b9411a12SAndroid Build Coastguard Worker# Disable style checks for now 600*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -gnatyN 601*b9411a12SAndroid Build Coastguard Worker 602*b9411a12SAndroid Build Coastguard WorkerLDFLAGS_common := --gc-sections 603*b9411a12SAndroid Build Coastguard WorkerLDFLAGS_common += -nostdlib 604*b9411a12SAndroid Build Coastguard WorkerLDFLAGS_common += --nmagic 605*b9411a12SAndroid Build Coastguard WorkerLDFLAGS_common += -static 606*b9411a12SAndroid Build Coastguard Worker 607*b9411a12SAndroid Build Coastguard Worker# Workaround for RISC-V linker bug, merge back into above line when fixed. 608*b9411a12SAndroid Build Coastguard Worker# https://sourceware.org/bugzilla/show_bug.cgi?id=27180 609*b9411a12SAndroid Build Coastguard Workerifneq ($(CONFIG_ARCH_RISCV),y) 610*b9411a12SAndroid Build Coastguard WorkerLDFLAGS_common += --emit-relocs 611*b9411a12SAndroid Build Coastguard Workerendif 612*b9411a12SAndroid Build Coastguard Worker 613*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y) 614*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Werror 615*b9411a12SAndroid Build Coastguard Workerendif 616*b9411a12SAndroid Build Coastguard Workerifneq ($(GDB_DEBUG),) 617*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Og 618*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -Og 619*b9411a12SAndroid Build Coastguard Workerelse 620*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common += -Os 621*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -Os 622*b9411a12SAndroid Build Coastguard Workerendif 623*b9411a12SAndroid Build Coastguard Worker 624*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_DEBUG_ADA_CODE),y) 625*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_common += -gnata 626*b9411a12SAndroid Build Coastguard Workerendif 627*b9411a12SAndroid Build Coastguard Worker 628*b9411a12SAndroid Build Coastguard Workeradditional-dirs += $(objutil)/cbfstool $(objutil)/ifdtool \ 629*b9411a12SAndroid Build Coastguard Worker $(objutil)/options $(objutil)/amdfwtool \ 630*b9411a12SAndroid Build Coastguard Worker $(objutil)/cbootimage 631*b9411a12SAndroid Build Coastguard Worker 632*b9411a12SAndroid Build Coastguard Workerexport $(COREBOOT_EXPORTS) 633*b9411a12SAndroid Build Coastguard Worker 634*b9411a12SAndroid Build Coastguard Worker####################################################################### 635*b9411a12SAndroid Build Coastguard Worker# generate build support files 636*b9411a12SAndroid Build Coastguard Worker 637*b9411a12SAndroid Build Coastguard Workerbuild_h := $(obj)/build.h 638*b9411a12SAndroid Build Coastguard Worker 639*b9411a12SAndroid Build Coastguard Worker# We have to manually export variables that `genbuild_h.sh` uses 640*b9411a12SAndroid Build Coastguard Worker# when we call it through the `$(shell)` function. This is fragile 641*b9411a12SAndroid Build Coastguard Worker# but as variables newly added to `genbuild_h.sh` would just not 642*b9411a12SAndroid Build Coastguard Worker# work, we'd notice that instantly at least. 643*b9411a12SAndroid Build Coastguard Workerbuild_h_exports := BUILD_TIMELESS KERNELVERSION COREBOOT_EXTRA_VERSION 644*b9411a12SAndroid Build Coastguard Worker 645*b9411a12SAndroid Build Coastguard Worker# Report new `build.ht` as dependency if `build.h` differs. 646*b9411a12SAndroid Build Coastguard Workerbuild_h_check := \ 647*b9411a12SAndroid Build Coastguard Worker export $(foreach exp,$(build_h_exports),$(exp)="$($(exp))"); \ 648*b9411a12SAndroid Build Coastguard Worker util/genbuild_h/genbuild_h.sh $(xcompile) \ 649*b9411a12SAndroid Build Coastguard Worker >$(build_h)t 2>/dev/null; \ 650*b9411a12SAndroid Build Coastguard Worker cmp -s $(build_h)t $(build_h) >/dev/null 2>&1 || echo $(build_h)t 651*b9411a12SAndroid Build Coastguard Worker 652*b9411a12SAndroid Build Coastguard Worker$(build_h): $$(shell $$(build_h_check)) 653*b9411a12SAndroid Build Coastguard Worker @printf " GEN build.h\n" 654*b9411a12SAndroid Build Coastguard Worker mv $< $@ 655*b9411a12SAndroid Build Coastguard Worker 656*b9411a12SAndroid Build Coastguard Worker$(obj)/build_info: 657*b9411a12SAndroid Build Coastguard Worker @echo 'COREBOOT_VERSION: $(call strip_quotes,$(KERNELVERSION))' > $@.tmp 658*b9411a12SAndroid Build Coastguard Worker @echo 'MAINBOARD_VENDOR: $(call strip_quotes,$(CONFIG_MAINBOARD_VENDOR))' >> $@.tmp 659*b9411a12SAndroid Build Coastguard Worker @echo 'MAINBOARD_PART_NUMBER: $(call strip_quotes,$(CONFIG_MAINBOARD_PART_NUMBER))' >> $@.tmp 660*b9411a12SAndroid Build Coastguard Worker mv $@.tmp $@ 661*b9411a12SAndroid Build Coastguard Worker 662*b9411a12SAndroid Build Coastguard Worker####################################################################### 663*b9411a12SAndroid Build Coastguard Worker# Build the tools 664*b9411a12SAndroid Build Coastguard WorkerCBFSTOOL:=$(objutil)/cbfstool/cbfstool 665*b9411a12SAndroid Build Coastguard WorkerFMAPTOOL:=$(objutil)/cbfstool/fmaptool 666*b9411a12SAndroid Build Coastguard WorkerRMODTOOL:=$(objutil)/cbfstool/rmodtool 667*b9411a12SAndroid Build Coastguard WorkerIFWITOOL:=$(objutil)/cbfstool/ifwitool 668*b9411a12SAndroid Build Coastguard WorkerIFITTOOL:=$(objutil)/cbfstool/ifittool 669*b9411a12SAndroid Build Coastguard WorkerAMDCOMPRESS:=$(objutil)/cbfstool/amdcompress 670*b9411a12SAndroid Build Coastguard WorkerCSE_FPT:=$(objutil)/cbfstool/cse_fpt 671*b9411a12SAndroid Build Coastguard WorkerCSE_SERGER:=$(objutil)/cbfstool/cse_serger 672*b9411a12SAndroid Build Coastguard Worker 673*b9411a12SAndroid Build Coastguard Worker$(obj)/cbfstool: $(CBFSTOOL) 674*b9411a12SAndroid Build Coastguard Worker cp $< $@ 675*b9411a12SAndroid Build Coastguard Worker 676*b9411a12SAndroid Build Coastguard Worker$(obj)/fmaptool: $(FMAPTOOL) 677*b9411a12SAndroid Build Coastguard Worker cp $< $@ 678*b9411a12SAndroid Build Coastguard Worker 679*b9411a12SAndroid Build Coastguard Worker$(obj)/rmodtool: $(RMODTOOL) 680*b9411a12SAndroid Build Coastguard Worker cp $< $@ 681*b9411a12SAndroid Build Coastguard Worker 682*b9411a12SAndroid Build Coastguard Worker$(obj)/ifwitool: $(IFWITOOL) 683*b9411a12SAndroid Build Coastguard Worker cp $< $@ 684*b9411a12SAndroid Build Coastguard Worker 685*b9411a12SAndroid Build Coastguard Worker$(obj)/ifittool: $(IFITTOOL) 686*b9411a12SAndroid Build Coastguard Worker cp $< $@ 687*b9411a12SAndroid Build Coastguard Worker 688*b9411a12SAndroid Build Coastguard Worker$(obj)/amdcompress: $(AMDCOMPRESS) 689*b9411a12SAndroid Build Coastguard Worker cp $< $@ 690*b9411a12SAndroid Build Coastguard Worker 691*b9411a12SAndroid Build Coastguard Worker$(obj)/cse_fpt: $(CSE_FPT) 692*b9411a12SAndroid Build Coastguard Worker cp $< $@ 693*b9411a12SAndroid Build Coastguard Worker 694*b9411a12SAndroid Build Coastguard Worker$(obj)/cse_serger: $(CSE_SERGER) 695*b9411a12SAndroid Build Coastguard Worker cp $< $@ 696*b9411a12SAndroid Build Coastguard Worker 697*b9411a12SAndroid Build Coastguard Worker_WINCHECK=$(shell uname -o 2> /dev/null) 698*b9411a12SAndroid Build Coastguard WorkerSTACK= 699*b9411a12SAndroid Build Coastguard Workerifeq ($(_WINCHECK),Msys) 700*b9411a12SAndroid Build Coastguard Worker STACK=-Wl,--stack,16384000 701*b9411a12SAndroid Build Coastguard Workerendif 702*b9411a12SAndroid Build Coastguard Workerifeq ($(_WINCHECK),Cygwin) 703*b9411a12SAndroid Build Coastguard Worker STACK=-Wl,--stack,16384000 704*b9411a12SAndroid Build Coastguard Workerendif 705*b9411a12SAndroid Build Coastguard Worker 706*b9411a12SAndroid Build Coastguard WorkerBINCFG:=$(objutil)/bincfg/bincfg 707*b9411a12SAndroid Build Coastguard Worker 708*b9411a12SAndroid Build Coastguard WorkerIFDTOOL:=$(objutil)/ifdtool/ifdtool 709*b9411a12SAndroid Build Coastguard Worker 710*b9411a12SAndroid Build Coastguard WorkerAMDFWTOOL:=$(objutil)/amdfwtool/amdfwtool 711*b9411a12SAndroid Build Coastguard WorkerAMDFWREAD:=$(objutil)/amdfwtool/amdfwread 712*b9411a12SAndroid Build Coastguard Worker 713*b9411a12SAndroid Build Coastguard WorkerAPCB_EDIT_TOOL:=$(top)/util/apcb/apcb_edit.py 714*b9411a12SAndroid Build Coastguard Worker 715*b9411a12SAndroid Build Coastguard WorkerAPCB_V3_EDIT_TOOL:=$(top)/util/apcb/apcb_v3_edit.py 716*b9411a12SAndroid Build Coastguard Worker 717*b9411a12SAndroid Build Coastguard WorkerAPCB_V3A_EDIT_TOOL:=$(top)/util/apcb/apcb_v3a_edit.py 718*b9411a12SAndroid Build Coastguard Worker 719*b9411a12SAndroid Build Coastguard WorkerCBOOTIMAGE:=$(objutil)/cbootimage/cbootimage 720*b9411a12SAndroid Build Coastguard Worker 721*b9411a12SAndroid Build Coastguard WorkerFUTILITY?=$(objutil)/futility/futility 722*b9411a12SAndroid Build Coastguard Worker 723*b9411a12SAndroid Build Coastguard Workersubdirs-y += util/nvidia 724*b9411a12SAndroid Build Coastguard Worker 725*b9411a12SAndroid Build Coastguard Worker$(obj)/config.h: $(objutil)/kconfig/conf 726*b9411a12SAndroid Build Coastguard Worker 727*b9411a12SAndroid Build Coastguard Worker####################################################################### 728*b9411a12SAndroid Build Coastguard Worker# needed objects that every mainboard uses 729*b9411a12SAndroid Build Coastguard Worker# Creation of these is architecture and mainboard independent 730*b9411a12SAndroid Build Coastguard WorkerDEVICETREE_FILE := $(src)/mainboard/$(MAINBOARDDIR)/$(CONFIG_DEVICETREE) 731*b9411a12SAndroid Build Coastguard Worker 732*b9411a12SAndroid Build Coastguard WorkerSCONFIG_OPTIONS := --mainboard_devtree=$(DEVICETREE_FILE) 733*b9411a12SAndroid Build Coastguard Worker 734*b9411a12SAndroid Build Coastguard Workerifneq ($(CONFIG_OVERRIDE_DEVICETREE),) 735*b9411a12SAndroid Build Coastguard WorkerOVERRIDE_DEVICETREE_FILE := $(src)/mainboard/$(MAINBOARDDIR)/$(CONFIG_OVERRIDE_DEVICETREE) 736*b9411a12SAndroid Build Coastguard WorkerSCONFIG_OPTIONS += --override_devtree=$(OVERRIDE_DEVICETREE_FILE) 737*b9411a12SAndroid Build Coastguard Workerendif 738*b9411a12SAndroid Build Coastguard Worker 739*b9411a12SAndroid Build Coastguard Workerifneq ($(CONFIG_CHIPSET_DEVICETREE),) 740*b9411a12SAndroid Build Coastguard WorkerCHIPSET_DEVICETREE_FILE := $(src)/$(CONFIG_CHIPSET_DEVICETREE) 741*b9411a12SAndroid Build Coastguard WorkerSCONFIG_OPTIONS += --chipset_devtree=$(CHIPSET_DEVICETREE_FILE) 742*b9411a12SAndroid Build Coastguard Workerendif 743*b9411a12SAndroid Build Coastguard Worker 744*b9411a12SAndroid Build Coastguard WorkerDEVICETREE_STATIC_C := $(obj)/mainboard/$(MAINBOARDDIR)/static.c 745*b9411a12SAndroid Build Coastguard WorkerSCONFIG_OPTIONS += --output_c=$(DEVICETREE_STATIC_C) 746*b9411a12SAndroid Build Coastguard Worker 747*b9411a12SAndroid Build Coastguard WorkerDEVICETREE_STATIC_H := $(obj)/static.h 748*b9411a12SAndroid Build Coastguard WorkerSCONFIG_OPTIONS += --output_h=$(DEVICETREE_STATIC_H) 749*b9411a12SAndroid Build Coastguard Worker 750*b9411a12SAndroid Build Coastguard WorkerDEVICETREE_DEVICENAMES_H := $(obj)/static_devices.h 751*b9411a12SAndroid Build Coastguard WorkerSCONFIG_OPTIONS += --output_d=$(DEVICETREE_DEVICENAMES_H) 752*b9411a12SAndroid Build Coastguard Worker 753*b9411a12SAndroid Build Coastguard WorkerDEVICETREE_FWCONFIG_H := $(obj)/static_fw_config.h 754*b9411a12SAndroid Build Coastguard WorkerSCONFIG_OPTIONS += --output_f=$(DEVICETREE_FWCONFIG_H) 755*b9411a12SAndroid Build Coastguard Worker 756*b9411a12SAndroid Build Coastguard Worker$(DEVICETREE_STATIC_C): $(DEVICETREE_FILE) $(OVERRIDE_DEVICETREE_FILE) $(CHIPSET_DEVICETREE_FILE) $(objutil)/sconfig/sconfig 757*b9411a12SAndroid Build Coastguard Worker @printf " SCONFIG $(subst $(src)/,,$(<))\n" 758*b9411a12SAndroid Build Coastguard Worker mkdir -p $(dir $(DEVICETREE_STATIC_C)) 759*b9411a12SAndroid Build Coastguard Worker $(objutil)/sconfig/sconfig $(SCONFIG_OPTIONS) 760*b9411a12SAndroid Build Coastguard Worker 761*b9411a12SAndroid Build Coastguard Workerramstage-y+=$(DEVICETREE_STATIC_C) 762*b9411a12SAndroid Build Coastguard Workerromstage-y+=$(DEVICETREE_STATIC_C) 763*b9411a12SAndroid Build Coastguard Workerverstage-y+=$(DEVICETREE_STATIC_C) 764*b9411a12SAndroid Build Coastguard Workerbootblock-y+=$(DEVICETREE_STATIC_C) 765*b9411a12SAndroid Build Coastguard Workerpostcar-y+=$(DEVICETREE_STATIC_C) 766*b9411a12SAndroid Build Coastguard Workersmm-y+=$(DEVICETREE_STATIC_C) 767*b9411a12SAndroid Build Coastguard Worker 768*b9411a12SAndroid Build Coastguard Worker# Ensure static.c and static.h are created before any objects are compiled 769*b9411a12SAndroid Build Coastguard Workerramstage-c-deps+=$(DEVICETREE_STATIC_C) 770*b9411a12SAndroid Build Coastguard Workerromstage-c-deps+=$(DEVICETREE_STATIC_C) 771*b9411a12SAndroid Build Coastguard Workerverstage-c-deps+=$(DEVICETREE_STATIC_C) 772*b9411a12SAndroid Build Coastguard Workerbootblock-c-deps+=$(DEVICETREE_STATIC_C) 773*b9411a12SAndroid Build Coastguard Workerpostcar-c-deps+=$(DEVICETREE_STATIC_C) 774*b9411a12SAndroid Build Coastguard Workersmm-c-deps+=$(DEVICETREE_STATIC_C) 775*b9411a12SAndroid Build Coastguard Worker 776*b9411a12SAndroid Build Coastguard Worker# Ensure fmap_config.h are created before any objects are compiled 777*b9411a12SAndroid Build Coastguard Workerramstage-c-deps+=$(obj)/fmap_config.h 778*b9411a12SAndroid Build Coastguard Workerromstage-c-deps+=$(obj)/fmap_config.h 779*b9411a12SAndroid Build Coastguard Workerverstage-c-deps+=$(obj)/fmap_config.h 780*b9411a12SAndroid Build Coastguard Workerbootblock-c-deps+=$(obj)/fmap_config.h 781*b9411a12SAndroid Build Coastguard Workerpostcar-c-deps+=$(obj)/fmap_config.h 782*b9411a12SAndroid Build Coastguard Workersmm-c-deps+=$(obj)/fmap_config.h 783*b9411a12SAndroid Build Coastguard Worker 784*b9411a12SAndroid Build Coastguard Worker.PHONY: devicetree 785*b9411a12SAndroid Build Coastguard Workerdevicetree: $(DEVICETREE_STATIC_C) 786*b9411a12SAndroid Build Coastguard Worker 787*b9411a12SAndroid Build Coastguard Workerramstage-y += $(CONFIG_MEMLAYOUT_LD_FILE) 788*b9411a12SAndroid Build Coastguard Workerromstage-y += $(CONFIG_MEMLAYOUT_LD_FILE) 789*b9411a12SAndroid Build Coastguard Workerbootblock-y += $(CONFIG_MEMLAYOUT_LD_FILE) 790*b9411a12SAndroid Build Coastguard Workerverstage-y += $(CONFIG_MEMLAYOUT_LD_FILE) 791*b9411a12SAndroid Build Coastguard Workerpostcar-y += $(CONFIG_MEMLAYOUT_LD_FILE) 792*b9411a12SAndroid Build Coastguard Workerdecompressor-y += $(CONFIG_MEMLAYOUT_LD_FILE) 793*b9411a12SAndroid Build Coastguard Worker 794*b9411a12SAndroid Build Coastguard Worker####################################################################### 795*b9411a12SAndroid Build Coastguard Worker# Clean up rules 796*b9411a12SAndroid Build Coastguard Workerclean-abuild: 797*b9411a12SAndroid Build Coastguard Worker rm -rf coreboot-builds 798*b9411a12SAndroid Build Coastguard Worker 799*b9411a12SAndroid Build Coastguard Worker####################################################################### 800*b9411a12SAndroid Build Coastguard Worker# Development utilities 801*b9411a12SAndroid Build Coastguard Workerprintcrt0s: 802*b9411a12SAndroid Build Coastguard Worker @echo crt0s=$(crt0s) 803*b9411a12SAndroid Build Coastguard Worker @echo ldscripts=$(ldscripts) 804*b9411a12SAndroid Build Coastguard Worker 805*b9411a12SAndroid Build Coastguard Workerupdate: 806*b9411a12SAndroid Build Coastguard Worker dongle.py -c /dev/term/1 $(obj)/coreboot.rom EOF 807*b9411a12SAndroid Build Coastguard Worker 808*b9411a12SAndroid Build Coastguard Workercheck-style: 809*b9411a12SAndroid Build Coastguard Worker grep "^# DESCR:" util/lint/check-style | sed "s,.*DESCR: *,," 810*b9411a12SAndroid Build Coastguard Worker echo "========" 811*b9411a12SAndroid Build Coastguard Worker util/lint/check-style 812*b9411a12SAndroid Build Coastguard Worker echo "========" 813*b9411a12SAndroid Build Coastguard Worker 814*b9411a12SAndroid Build Coastguard Workergitconfig: 815*b9411a12SAndroid Build Coastguard Worker util/gitconfig/gitconfig.sh "$(MAKE)" 816*b9411a12SAndroid Build Coastguard Worker 817*b9411a12SAndroid Build Coastguard Workerinstall-git-commit-clangfmt: 818*b9411a12SAndroid Build Coastguard Worker cp util/scripts/prepare-commit-msg.clang-format .git/hooks/prepare-commit-msg 819*b9411a12SAndroid Build Coastguard Worker 820*b9411a12SAndroid Build Coastguard Workerinclude util/crossgcc/Makefile.mk 821*b9411a12SAndroid Build Coastguard Worker 822*b9411a12SAndroid Build Coastguard Worker.PHONY: tools 823*b9411a12SAndroid Build Coastguard Workertools: $(objutil)/kconfig/conf $(objutil)/kconfig/toada $(CBFSTOOL) $(objutil)/cbfstool/cbfs-compression-tool $(FMAPTOOL) $(RMODTOOL) $(IFWITOOL) $(objutil)/nvramtool/nvramtool $(objutil)/sconfig/sconfig $(IFDTOOL) $(CBOOTIMAGE) $(AMDFWTOOL) $(AMDCOMPRESS) $(FUTILITY) $(BINCFG) $(IFITTOOL) $(objutil)/supermicro/smcbiosinfo $(CSE_FPT) $(CSE_SERGER) $(AMDFWREAD) 824*b9411a12SAndroid Build Coastguard Worker 825*b9411a12SAndroid Build Coastguard Worker########################################################################### 826*b9411a12SAndroid Build Coastguard Worker# Common recipes for all stages 827*b9411a12SAndroid Build Coastguard Worker########################################################################### 828*b9411a12SAndroid Build Coastguard Worker 829*b9411a12SAndroid Build Coastguard Worker# loadaddr can determine the load address of a stage, which may be needed for 830*b9411a12SAndroid Build Coastguard Worker# platform-specific image headers (only works *after* the stage has been built) 831*b9411a12SAndroid Build Coastguard Workerloadaddr = $(shell $(OBJDUMP_$(1)) -p $(objcbfs)/$(1).debug | \ 832*b9411a12SAndroid Build Coastguard Worker sed -ne '/LOAD/s/^.*vaddr 0x\([0-9a-fA-F]\{8\}\).*$$/0x\1/p') 833*b9411a12SAndroid Build Coastguard Worker 834*b9411a12SAndroid Build Coastguard Worker# find-substr is required for stages like romstage_null and romstage_xip to 835*b9411a12SAndroid Build Coastguard Worker# eliminate the _* part of the string 836*b9411a12SAndroid Build Coastguard Workerfind-substr = $(word 1,$(subst _, ,$(1))) 837*b9411a12SAndroid Build Coastguard Worker 838*b9411a12SAndroid Build Coastguard Worker# find-class is used to identify the class from the name of the stage 839*b9411a12SAndroid Build Coastguard Worker# The input to this macro can be something like romstage.x or romstage.x.y 840*b9411a12SAndroid Build Coastguard Worker# find-class recursively strips off the suffixes to extract the exact class name 841*b9411a12SAndroid Build Coastguard Worker# e.g.: if romstage.x is provided to find-class, it will remove .x and return romstage 842*b9411a12SAndroid Build Coastguard Worker# if romstage.x.y is provided, it will first remove .y, call find-class with romstage.x 843*b9411a12SAndroid Build Coastguard Worker# and remove .x the next time and finally return romstage 844*b9411a12SAndroid Build Coastguard Workerfind-class = $(if $(filter $(1),$(basename $(1))),$(if $(CC_$(1)), $(1), $(call find-substr,$(1))),$(call find-class,$(basename $(1)))) 845*b9411a12SAndroid Build Coastguard Worker 846*b9411a12SAndroid Build Coastguard Worker# Bootblocks are not CBFS stages. coreboot is currently expecting the bss to 847*b9411a12SAndroid Build Coastguard Worker# be cleared by the loader of the stage. For ARM SoCs that means one needs to 848*b9411a12SAndroid Build Coastguard Worker# include the bss section in the binary so the BootROM clears the bss on 849*b9411a12SAndroid Build Coastguard Worker# loading of the bootblock stage. Achieve this by marking the bss section 850*b9411a12SAndroid Build Coastguard Worker# loadable,allocatable, and data. Do the same for the .data section in case 851*b9411a12SAndroid Build Coastguard Worker# the linker marked it NOBITS automatically because there are only zeroes in it. 852*b9411a12SAndroid Build Coastguard Workerpreserve-bss-flags := --set-section-flags .bss=load,alloc,data --set-section-flags .data=load,alloc,data 853*b9411a12SAndroid Build Coastguard Worker 854*b9411a12SAndroid Build Coastguard Worker# For Intel TXT files in the CBFS needs to be marked as 'Initial Boot Block'. 855*b9411a12SAndroid Build Coastguard Worker# As CBFS attributes aren't cheap, only mark them if TXT is enabled. 856*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_INTEL_TXT),y) 857*b9411a12SAndroid Build Coastguard Worker 858*b9411a12SAndroid Build Coastguard WorkerTXTIBB := --ibb 859*b9411a12SAndroid Build Coastguard Worker 860*b9411a12SAndroid Build Coastguard Workerelse 861*b9411a12SAndroid Build Coastguard Worker 862*b9411a12SAndroid Build Coastguard WorkerTXTIBB := 863*b9411a12SAndroid Build Coastguard Worker 864*b9411a12SAndroid Build Coastguard Workerendif 865*b9411a12SAndroid Build Coastguard Worker 866*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_COMPRESS_BOOTBLOCK),y) 867*b9411a12SAndroid Build Coastguard Worker 868*b9411a12SAndroid Build Coastguard Worker$(objcbfs)/bootblock.lz4: $(objcbfs)/bootblock.elf $(objutil)/cbfstool/cbfs-compression-tool 869*b9411a12SAndroid Build Coastguard Worker @printf " LZ4 $(subst $(obj)/,,$(@))\n" 870*b9411a12SAndroid Build Coastguard Worker $(OBJCOPY_bootblock) $(preserve-bss-flags) $< $@.tmp 871*b9411a12SAndroid Build Coastguard Worker $(OBJCOPY_bootblock) -O binary $@.tmp 872*b9411a12SAndroid Build Coastguard Worker $(objutil)/cbfstool/cbfs-compression-tool rawcompress $@.tmp $@.tmp2 lz4 873*b9411a12SAndroid Build Coastguard Worker rm -f $@.tmp 874*b9411a12SAndroid Build Coastguard Worker mv $@.tmp2 $@ 875*b9411a12SAndroid Build Coastguard Worker 876*b9411a12SAndroid Build Coastguard Worker# Put assembled decompressor+bootblock into bootblock.raw.elf so that SoC 877*b9411a12SAndroid Build Coastguard Worker# Makefiles wrapping the bootblock in a header can always key off the same file. 878*b9411a12SAndroid Build Coastguard Worker$(objcbfs)/bootblock.raw.elf: $(objcbfs)/decompressor.elf 879*b9411a12SAndroid Build Coastguard Worker @printf " OBJCOPY $(notdir $(@))\n" 880*b9411a12SAndroid Build Coastguard Worker $(OBJCOPY_bootblock) $(preserve-bss-flags) $< $@ 881*b9411a12SAndroid Build Coastguard Worker 882*b9411a12SAndroid Build Coastguard Workerelse # CONFIG_COMPRESS_BOOTBLOCK 883*b9411a12SAndroid Build Coastguard Worker 884*b9411a12SAndroid Build Coastguard Worker$(objcbfs)/bootblock.raw.elf: $(objcbfs)/bootblock.elf 885*b9411a12SAndroid Build Coastguard Worker @printf " OBJCOPY $(notdir $(@))\n" 886*b9411a12SAndroid Build Coastguard Worker $(OBJCOPY_bootblock) $(preserve-bss-flags) $< $@ 887*b9411a12SAndroid Build Coastguard Worker 888*b9411a12SAndroid Build Coastguard Workerendif # CONFIG_COMPRESS_BOOTBLOCK 889*b9411a12SAndroid Build Coastguard Worker 890*b9411a12SAndroid Build Coastguard Worker$(objcbfs)/bootblock.raw.bin: $(objcbfs)/bootblock.raw.elf 891*b9411a12SAndroid Build Coastguard Worker @printf " OBJCOPY $(notdir $(@))\n" 892*b9411a12SAndroid Build Coastguard Worker $(OBJCOPY_bootblock) -O binary $< $@ 893*b9411a12SAndroid Build Coastguard Worker 894*b9411a12SAndroid Build Coastguard Workerifneq ($(CONFIG_HAVE_BOOTBLOCK),y) 895*b9411a12SAndroid Build Coastguard Worker$(objcbfs)/bootblock.bin: 896*b9411a12SAndroid Build Coastguard Worker dd if=/dev/zero of=$@ bs=64 count=1 897*b9411a12SAndroid Build Coastguard Workerendif 898*b9411a12SAndroid Build Coastguard Worker 899*b9411a12SAndroid Build Coastguard Worker$(objcbfs)/%.bin: $(objcbfs)/%.raw.bin 900*b9411a12SAndroid Build Coastguard Worker cp $< $@ 901*b9411a12SAndroid Build Coastguard Worker 902*b9411a12SAndroid Build Coastguard Worker$(objcbfs)/%.map: $(objcbfs)/%.debug 903*b9411a12SAndroid Build Coastguard Worker $(eval class := $(call find-class,$(@F))) 904*b9411a12SAndroid Build Coastguard Worker $(NM_$(class)) -n $< | sort > $(basename $@).map 905*b9411a12SAndroid Build Coastguard Worker 906*b9411a12SAndroid Build Coastguard Worker$(objcbfs)/%.elf: $(objcbfs)/%.debug $(objcbfs)/%.map 907*b9411a12SAndroid Build Coastguard Worker $(eval class := $(call find-class,$(@F))) 908*b9411a12SAndroid Build Coastguard Worker @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" 909*b9411a12SAndroid Build Coastguard Worker cp $< $@.tmp 910*b9411a12SAndroid Build Coastguard Worker $(OBJCOPY_$(class)) --strip-debug $@.tmp 911*b9411a12SAndroid Build Coastguard Worker $(OBJCOPY_$(class)) --add-gnu-debuglink=$< $@.tmp 912*b9411a12SAndroid Build Coastguard Worker mv $@.tmp $@ 913*b9411a12SAndroid Build Coastguard Worker 914*b9411a12SAndroid Build Coastguard Worker 915*b9411a12SAndroid Build Coastguard Worker########################################################################### 916*b9411a12SAndroid Build Coastguard Worker# Build the final rom image 917*b9411a12SAndroid Build Coastguard Worker########################################################################### 918*b9411a12SAndroid Build Coastguard Worker 919*b9411a12SAndroid Build Coastguard Worker# extract_nth - Return a subsection of the $file string 920*b9411a12SAndroid Build Coastguard Worker# 921*b9411a12SAndroid Build Coastguard Worker# the input string looks like this: 922*b9411a12SAndroid Build Coastguard Worker# ./build/cbfs/fallback/romstage.elf|fallback/romstage|stage|none||64|--xip*-S*.car.data*-P*0x10000 923*b9411a12SAndroid Build Coastguard Worker# 924*b9411a12SAndroid Build Coastguard Worker# Sections: 925*b9411a12SAndroid Build Coastguard Worker# 1 - Path and name of file [FILENAME: Added to cbfs-files-y list variable] 926*b9411a12SAndroid Build Coastguard Worker# 2 - Name of file in cbfs [$(FILENAME)-file] 927*b9411a12SAndroid Build Coastguard Worker# 3 - File type: [$(FILENAME)-type] 928*b9411a12SAndroid Build Coastguard Worker# bootblock, cbfs header, stage, payload, optionrom, bootsplash, raw, vsa, 929*b9411a12SAndroid Build Coastguard Worker# mbi, microcode, fsp, mrc, cmos_default, cmos_layout, spd, mrc_cache, 930*b9411a12SAndroid Build Coastguard Worker# mma, efi, deleted, null 931*b9411a12SAndroid Build Coastguard Worker# 4 - Compression type [$(FILENAME)-compression] 932*b9411a12SAndroid Build Coastguard Worker# none, LZMA 933*b9411a12SAndroid Build Coastguard Worker# 5 - Base address [$(FILENAME)-position] 934*b9411a12SAndroid Build Coastguard Worker# 6 - Alignment [$(FILENAME)-align] 935*b9411a12SAndroid Build Coastguard Worker# 7 - cbfstool flags [$(FILENAME)-options] 936*b9411a12SAndroid Build Coastguard Worker# 937*b9411a12SAndroid Build Coastguard Worker# Input: 938*b9411a12SAndroid Build Coastguard Worker# $(1) = Section to extract 939*b9411a12SAndroid Build Coastguard Worker# $(2) = Input string 940*b9411a12SAndroid Build Coastguard Worker# 941*b9411a12SAndroid Build Coastguard Worker# Steps: 942*b9411a12SAndroid Build Coastguard Worker# 1) replace all '|' characters with the sequence '- -' within the full string, prepended and appended with the character '-' 943*b9411a12SAndroid Build Coastguard Worker# 2) extract the specified section from the string - this gets us the section surrounded by '-' characters 944*b9411a12SAndroid Build Coastguard Worker# 3) remove the leading and trailing '-' characters 945*b9411a12SAndroid Build Coastguard Worker# 4) replace all '*' characters with spaces 946*b9411a12SAndroid Build Coastguard Workerextract_nth=$(subst *,$(spc),$(patsubst -%-,%,$(word $(1), $(subst |,- -,-$(2)-)))) 947*b9411a12SAndroid Build Coastguard Worker 948*b9411a12SAndroid Build Coastguard Worker# regions-for-file - Returns a cbfstool regions parameter 949*b9411a12SAndroid Build Coastguard Worker# $(call regions-for-file,$(filename)) 950*b9411a12SAndroid Build Coastguard Worker# returns "REGION1,REGION2,..." 951*b9411a12SAndroid Build Coastguard Worker# 952*b9411a12SAndroid Build Coastguard Worker# This is the default implementation. When using a boot strategy employing 953*b9411a12SAndroid Build Coastguard Worker# multiple CBFSes in fmap regions, override it. 954*b9411a12SAndroid Build Coastguard Workerregions-for-file ?= $(if $(value regions-for-file-$(1)), $(regions-for-file-$(1)), COREBOOT) 955*b9411a12SAndroid Build Coastguard Worker 956*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_CBFS_AUTOGEN_ATTRIBUTES),y) 957*b9411a12SAndroid Build Coastguard Worker cbfs-autogen-attributes=-g 958*b9411a12SAndroid Build Coastguard Workerendif 959*b9411a12SAndroid Build Coastguard Worker 960*b9411a12SAndroid Build Coastguard Worker# cbfs-add-cmd-for-region 961*b9411a12SAndroid Build Coastguard Worker# $(call cbfs-add-cmd-for-region,file in extract_nth format,region name) 962*b9411a12SAndroid Build Coastguard Worker# 963*b9411a12SAndroid Build Coastguard Worker# CBFSTOOL_ADD_CMD_OPTIONS can be used by arch/SoC/mainboard to supply 964*b9411a12SAndroid Build Coastguard Worker# add commands with any additional arguments for cbfstool. 965*b9411a12SAndroid Build Coastguard Worker# Example: --ext-win-base <base> --ext-win-size <size> 966*b9411a12SAndroid Build Coastguard Workerdefine cbfs-add-cmd-for-region 967*b9411a12SAndroid Build Coastguard Worker $(CBFSTOOL) $@.tmp \ 968*b9411a12SAndroid Build Coastguard Worker add$(if $(filter stage,$(call extract_nth,3,$(1))),-stage)$(if \ 969*b9411a12SAndroid Build Coastguard Worker $(filter payload,$(call extract_nth,3,$(1))),-payload)$(if \ 970*b9411a12SAndroid Build Coastguard Worker $(filter flat-binary,$(call extract_nth,3,$(1))),-flat-binary) \ 971*b9411a12SAndroid Build Coastguard Worker -f $(call extract_nth,1,$(1)) \ 972*b9411a12SAndroid Build Coastguard Worker -n $(call extract_nth,2,$(1)) \ 973*b9411a12SAndroid Build Coastguard Worker $(if $(filter-out flat-binary payload stage,$(call \ 974*b9411a12SAndroid Build Coastguard Worker extract_nth,3,$(1))),-t $(call extract_nth,3,$(1))) \ 975*b9411a12SAndroid Build Coastguard Worker $(if $(call extract_nth,4,$(1)),-c $(call extract_nth,4,$(1))) \ 976*b9411a12SAndroid Build Coastguard Worker $(cbfs-autogen-attributes) \ 977*b9411a12SAndroid Build Coastguard Worker -r $(2) \ 978*b9411a12SAndroid Build Coastguard Worker $(if $(call extract_nth,6,$(1)),-a $(call extract_nth,6,$(file)), \ 979*b9411a12SAndroid Build Coastguard Worker $(if $(call extract_nth,5,$(file)),-b $(call extract_nth,5,$(file)))) \ 980*b9411a12SAndroid Build Coastguard Worker $(call extract_nth,7,$(1)) \ 981*b9411a12SAndroid Build Coastguard Worker $(CBFSTOOL_ADD_CMD_OPTIONS) 982*b9411a12SAndroid Build Coastguard Worker 983*b9411a12SAndroid Build Coastguard Workerendef 984*b9411a12SAndroid Build Coastguard Worker# Empty line before endef is necessary so cbfs-add-cmd-for-region ends in a 985*b9411a12SAndroid Build Coastguard Worker# newline 986*b9411a12SAndroid Build Coastguard Worker 987*b9411a12SAndroid Build Coastguard Worker# cbfs-add-cmd 988*b9411a12SAndroid Build Coastguard Worker# $(call cbfs-add-cmd, 989*b9411a12SAndroid Build Coastguard Worker# file in extract_nth format, 990*b9411a12SAndroid Build Coastguard Worker# region name, 991*b9411a12SAndroid Build Coastguard Worker# non-empty if file removal requested) 992*b9411a12SAndroid Build Coastguard Workerdefine cbfs-add-cmd 993*b9411a12SAndroid Build Coastguard Worker printf " CBFS $(call extract_nth,2,$(1))\n" 994*b9411a12SAndroid Build Coastguard Worker $(if $(3),-$(CBFSTOOL) $@.tmp remove -n $(call extract_nth,2,$(file)) 2>/dev/null) 995*b9411a12SAndroid Build Coastguard Worker $(call cbfs-add-cmd-for-region,$(1),$(2)) 996*b9411a12SAndroid Build Coastguard Workerendef 997*b9411a12SAndroid Build Coastguard Worker 998*b9411a12SAndroid Build Coastguard Worker# list of files to add (using their file system names, not CBFS names), 999*b9411a12SAndroid Build Coastguard Worker# for dependencies etc. 1000*b9411a12SAndroid Build Coastguard Workerprebuilt-files = $(foreach file,$(cbfs-files), $(call extract_nth,1,$(file))) 1001*b9411a12SAndroid Build Coastguard Worker 1002*b9411a12SAndroid Build Coastguard Worker# $(all-regions) 1003*b9411a12SAndroid Build Coastguard Worker# returns full list of fmap regions that we add files to 1004*b9411a12SAndroid Build Coastguard Workerall-regions = $(sort $(subst $(comma),$(spc), \ 1005*b9411a12SAndroid Build Coastguard Worker $(foreach file,$(cbfs-files), \ 1006*b9411a12SAndroid Build Coastguard Worker $(call regions-for-file,$(call extract_nth,2,$(file)))))) 1007*b9411a12SAndroid Build Coastguard Worker 1008*b9411a12SAndroid Build Coastguard Worker# $(call all-files-in-region,region name) 1009*b9411a12SAndroid Build Coastguard Worker# returns elements in $(cbfs-files) that end up in that region, in the order 1010*b9411a12SAndroid Build Coastguard Worker# they appear in $(cbfs-files) 1011*b9411a12SAndroid Build Coastguard Workerall-files-in-region = $(foreach file,$(cbfs-files), \ 1012*b9411a12SAndroid Build Coastguard Worker $(if $(filter $(1), \ 1013*b9411a12SAndroid Build Coastguard Worker $(subst $(comma),$(spc),$(call regions-for-file,$(call extract_nth,2,$(file))))), \ 1014*b9411a12SAndroid Build Coastguard Worker $(file))) 1015*b9411a12SAndroid Build Coastguard Worker 1016*b9411a12SAndroid Build Coastguard Worker# $(call update-file-for-region,file string from $(cbfs-files),region name) 1017*b9411a12SAndroid Build Coastguard Worker# Update position and alignment according to overrides for region 1018*b9411a12SAndroid Build Coastguard Worker# Doesn't check for invalid configurations (eg. resetting neither or both 1019*b9411a12SAndroid Build Coastguard Worker# position and align) 1020*b9411a12SAndroid Build Coastguard Worker# Returns the updated file string 1021*b9411a12SAndroid Build Coastguard Workerupdate-file-for-region = \ 1022*b9411a12SAndroid Build Coastguard Worker $(subst $(spc),*,$(call extract_nth,1,$(1))|$(call extract_nth,2,$(1))|$(call extract_nth,3,$(1))|$(call extract_nth,4,$(1))|$($(call extract_nth,2,$(1))-$(2)-position)|$($(call extract_nth,2,$(1))-$(2)-align)|$(call extract_nth,7,$(1))) 1023*b9411a12SAndroid Build Coastguard Worker 1024*b9411a12SAndroid Build Coastguard Worker# $(call placed-files-in-region,region name) 1025*b9411a12SAndroid Build Coastguard Worker# like all-files-in-region, but updates the files to contain region overrides 1026*b9411a12SAndroid Build Coastguard Worker# to position or alignment. 1027*b9411a12SAndroid Build Coastguard Workerplaced-files-in-region = $(foreach file,$(call all-files-in-region,$(1)), \ 1028*b9411a12SAndroid Build Coastguard Worker $(if $($(call extract_nth,2,$(file))-$(1)-position), \ 1029*b9411a12SAndroid Build Coastguard Worker $(if $($(call extract_nth,2,$(file))-$(1)-align), \ 1030*b9411a12SAndroid Build Coastguard Worker $(error It is not allowed to specify both alignment and position for $(call extract_nth,2,$(file))-$(1))) \ 1031*b9411a12SAndroid Build Coastguard Worker $(call update-file-for-region,$(file),$(1)), \ 1032*b9411a12SAndroid Build Coastguard Worker $(if $($(call extract_nth,2,$(file))-$(1)-align), \ 1033*b9411a12SAndroid Build Coastguard Worker $(call update-file-for-region,$(file),$(1)), \ 1034*b9411a12SAndroid Build Coastguard Worker $(file)))) 1035*b9411a12SAndroid Build Coastguard Worker 1036*b9411a12SAndroid Build Coastguard Worker# $(call sort-files,subset of $(cbfs-files)) 1037*b9411a12SAndroid Build Coastguard Worker# reorders the files in the given set to list files at fixed positions first, 1038*b9411a12SAndroid Build Coastguard Worker# followed by aligned files and finally those with no constraints. 1039*b9411a12SAndroid Build Coastguard Workersort-files = \ 1040*b9411a12SAndroid Build Coastguard Worker $(eval _tmp_fixed:=) \ 1041*b9411a12SAndroid Build Coastguard Worker $(eval _tmp_aligned:=) \ 1042*b9411a12SAndroid Build Coastguard Worker $(eval _tmp_regular:=) \ 1043*b9411a12SAndroid Build Coastguard Worker $(foreach file,$(1), \ 1044*b9411a12SAndroid Build Coastguard Worker $(if $(call extract_nth,5,$(file)),\ 1045*b9411a12SAndroid Build Coastguard Worker $(eval _tmp_fixed += $(file)), \ 1046*b9411a12SAndroid Build Coastguard Worker $(if $(call extract_nth,6,$(file)), \ 1047*b9411a12SAndroid Build Coastguard Worker $(eval _tmp_aligned += $(file)), \ 1048*b9411a12SAndroid Build Coastguard Worker $(eval _tmp_regular += $(file))))) \ 1049*b9411a12SAndroid Build Coastguard Worker $(_tmp_fixed) $(_tmp_aligned) $(_tmp_regular) 1050*b9411a12SAndroid Build Coastguard Worker 1051*b9411a12SAndroid Build Coastguard Worker# command list to add files to CBFS 1052*b9411a12SAndroid Build Coastguard Workerprebuild-files = $(foreach region,$(all-regions), \ 1053*b9411a12SAndroid Build Coastguard Worker $(foreach file, \ 1054*b9411a12SAndroid Build Coastguard Worker $(call sort-files,$(call placed-files-in-region,$(region))), \ 1055*b9411a12SAndroid Build Coastguard Worker $(call cbfs-add-cmd,$(file),$(region),$(CONFIG_UPDATE_IMAGE)))) 1056*b9411a12SAndroid Build Coastguard Worker 1057*b9411a12SAndroid Build Coastguard Worker# If no FMD file (Flashmap) is supplied by mainboard, fall back to a default 1058*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_FMDFILE),) 1059*b9411a12SAndroid Build Coastguard Worker 1060*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_ARCH_X86),y) 1061*b9411a12SAndroid Build Coastguard Worker 1062*b9411a12SAndroid Build Coastguard WorkerDEFAULT_FLASHMAP:=$(top)/util/cbfstool/default-x86.fmd 1063*b9411a12SAndroid Build Coastguard Worker# check if IFD_CHIPSET is set and if yes generate a FMAP template from IFD descriptor 1064*b9411a12SAndroid Build Coastguard Workerifneq ($(CONFIG_IFD_CHIPSET),) 1065*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_HAVE_IFD_BIN),y) 1066*b9411a12SAndroid Build Coastguard WorkerDEFAULT_FLASHMAP:=$(obj)/fmap-template.fmd 1067*b9411a12SAndroid Build Coastguard Worker$(DEFAULT_FLASHMAP): $(call strip_quotes,$(CONFIG_IFD_BIN_PATH)) $(IFDTOOL) 1068*b9411a12SAndroid Build Coastguard Worker echo " IFDTOOL -p $(CONFIG_IFD_CHIPSET) -F $@ $<" 1069*b9411a12SAndroid Build Coastguard Worker $(IFDTOOL) -p $(CONFIG_IFD_CHIPSET) -F $@ $< 1070*b9411a12SAndroid Build Coastguard Workerendif # ifeq($(CONFIG_HAVE_IFD_BIN),y) 1071*b9411a12SAndroid Build Coastguard Workerendif # ifneq($(CONFIG_IFD_CHIPSET),) 1072*b9411a12SAndroid Build Coastguard Worker 1073*b9411a12SAndroid Build Coastguard Worker# entire flash 1074*b9411a12SAndroid Build Coastguard WorkerFMAP_ROM_ADDR := $(call int-subtract, 0x100000000 $(CONFIG_ROM_SIZE)) 1075*b9411a12SAndroid Build Coastguard WorkerFMAP_ROM_SIZE := $(CONFIG_ROM_SIZE) 1076*b9411a12SAndroid Build Coastguard Worker# entire "BIOS" region (everything directly of concern to the host system) 1077*b9411a12SAndroid Build Coastguard Worker# relative to ROM_BASE 1078*b9411a12SAndroid Build Coastguard WorkerFMAP_BIOS_BASE := $(call int-align, $(call int-subtract, $(CONFIG_ROM_SIZE) $(CONFIG_CBFS_SIZE)), 0x10000) 1079*b9411a12SAndroid Build Coastguard WorkerFMAP_BIOS_SIZE := $(call int-align-down, $(shell echo $(CONFIG_CBFS_SIZE) | tr A-F a-f), 0x10000) 1080*b9411a12SAndroid Build Coastguard Worker# position and size of flashmap, relative to BIOS_BASE 1081*b9411a12SAndroid Build Coastguard Worker 1082*b9411a12SAndroid Build Coastguard Worker# 1083*b9411a12SAndroid Build Coastguard Worker# X86 CONSOLE FMAP region 1084*b9411a12SAndroid Build Coastguard Worker# 1085*b9411a12SAndroid Build Coastguard Worker# position, size and entry line of CONSOLE relative to BIOS_BASE, if enabled 1086*b9411a12SAndroid Build Coastguard Worker 1087*b9411a12SAndroid Build Coastguard WorkerFMAP_CURRENT_BASE := 0 1088*b9411a12SAndroid Build Coastguard Worker 1089*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_CONSOLE_SPI_FLASH),y) 1090*b9411a12SAndroid Build Coastguard WorkerFMAP_CONSOLE_BASE := $(FMAP_CURRENT_BASE) 1091*b9411a12SAndroid Build Coastguard WorkerFMAP_CONSOLE_SIZE := $(CONFIG_CONSOLE_SPI_FLASH_BUFFER_SIZE) 1092*b9411a12SAndroid Build Coastguard WorkerFMAP_CONSOLE_ENTRY := CONSOLE@$(FMAP_CONSOLE_BASE) $(FMAP_CONSOLE_SIZE) 1093*b9411a12SAndroid Build Coastguard WorkerFMAP_CURRENT_BASE := $(call int-add, $(FMAP_CONSOLE_BASE) $(FMAP_CONSOLE_SIZE)) 1094*b9411a12SAndroid Build Coastguard Workerelse 1095*b9411a12SAndroid Build Coastguard WorkerFMAP_CONSOLE_ENTRY := 1096*b9411a12SAndroid Build Coastguard Workerendif 1097*b9411a12SAndroid Build Coastguard Worker 1098*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_CACHE_MRC_SETTINGS),y) 1099*b9411a12SAndroid Build Coastguard WorkerFMAP_MRC_CACHE_BASE := $(call int-align, $(FMAP_CURRENT_BASE), 0x10000) 1100*b9411a12SAndroid Build Coastguard WorkerFMAP_MRC_CACHE_SIZE := $(CONFIG_MRC_SETTINGS_CACHE_SIZE) 1101*b9411a12SAndroid Build Coastguard WorkerFMAP_MRC_CACHE_ENTRY := RW_MRC_CACHE@$(FMAP_MRC_CACHE_BASE) $(FMAP_MRC_CACHE_SIZE) 1102*b9411a12SAndroid Build Coastguard WorkerFMAP_CURRENT_BASE := $(call int-add, $(FMAP_MRC_CACHE_BASE) $(FMAP_MRC_CACHE_SIZE)) 1103*b9411a12SAndroid Build Coastguard Workerelse 1104*b9411a12SAndroid Build Coastguard WorkerFMAP_MRC_CACHE_ENTRY := 1105*b9411a12SAndroid Build Coastguard Workerendif 1106*b9411a12SAndroid Build Coastguard Worker 1107*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_SMMSTORE),y) 1108*b9411a12SAndroid Build Coastguard WorkerFMAP_SMMSTORE_BASE := $(call int-align, $(FMAP_CURRENT_BASE), 0x10000) 1109*b9411a12SAndroid Build Coastguard WorkerFMAP_SMMSTORE_SIZE := $(CONFIG_SMMSTORE_SIZE) 1110*b9411a12SAndroid Build Coastguard WorkerFMAP_SMMSTORE_ENTRY := SMMSTORE@$(FMAP_SMMSTORE_BASE) $(FMAP_SMMSTORE_SIZE) 1111*b9411a12SAndroid Build Coastguard WorkerFMAP_CURRENT_BASE := $(call int-add, $(FMAP_SMMSTORE_BASE) $(FMAP_SMMSTORE_SIZE)) 1112*b9411a12SAndroid Build Coastguard Workerelse 1113*b9411a12SAndroid Build Coastguard WorkerFMAP_SMMSTORE_ENTRY := 1114*b9411a12SAndroid Build Coastguard Workerendif 1115*b9411a12SAndroid Build Coastguard Worker 1116*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_SPD_CACHE_IN_FMAP),y) 1117*b9411a12SAndroid Build Coastguard WorkerFMAP_SPD_CACHE_BASE := $(call int-align, $(FMAP_CURRENT_BASE), 0x4000) 1118*b9411a12SAndroid Build Coastguard WorkerFMAP_SPD_CACHE_SIZE := $(call int-multiply, $(CONFIG_DIMM_MAX) $(CONFIG_DIMM_SPD_SIZE)) 1119*b9411a12SAndroid Build Coastguard WorkerFMAP_SPD_CACHE_SIZE := $(call int-align, $(FMAP_SPD_CACHE_SIZE), 0x1000) 1120*b9411a12SAndroid Build Coastguard WorkerFMAP_SPD_CACHE_ENTRY := $(CONFIG_SPD_CACHE_FMAP_NAME)@$(FMAP_SPD_CACHE_BASE) $(FMAP_SPD_CACHE_SIZE) 1121*b9411a12SAndroid Build Coastguard WorkerFMAP_CURRENT_BASE := $(call int-add, $(FMAP_SPD_CACHE_BASE) $(FMAP_SPD_CACHE_SIZE)) 1122*b9411a12SAndroid Build Coastguard Workerelse 1123*b9411a12SAndroid Build Coastguard WorkerFMAP_SPD_CACHE_ENTRY := 1124*b9411a12SAndroid Build Coastguard Workerendif 1125*b9411a12SAndroid Build Coastguard Worker 1126*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_VPD),y) 1127*b9411a12SAndroid Build Coastguard WorkerFMAP_VPD_BASE := $(call int-align, $(FMAP_CURRENT_BASE), 0x4000) 1128*b9411a12SAndroid Build Coastguard WorkerFMAP_VPD_SIZE := $(CONFIG_VPD_FMAP_SIZE) 1129*b9411a12SAndroid Build Coastguard WorkerFMAP_VPD_ENTRY := $(CONFIG_VPD_FMAP_NAME)@$(FMAP_VPD_BASE) $(FMAP_VPD_SIZE) 1130*b9411a12SAndroid Build Coastguard WorkerFMAP_CURRENT_BASE := $(call int-add, $(FMAP_VPD_BASE) $(FMAP_VPD_SIZE)) 1131*b9411a12SAndroid Build Coastguard Workerelse 1132*b9411a12SAndroid Build Coastguard WorkerFMAP_VPD_ENTRY := 1133*b9411a12SAndroid Build Coastguard Workerendif 1134*b9411a12SAndroid Build Coastguard Worker 1135*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_INCLUDE_HSPHY_IN_FMAP),y) 1136*b9411a12SAndroid Build Coastguard WorkerFMAP_HSPHY_FW_BASE := $(call int-align, $(FMAP_CURRENT_BASE), 0x1000) 1137*b9411a12SAndroid Build Coastguard WorkerFMAP_HSPHY_FW_SIZE := $(CONFIG_HSPHY_FW_MAX_SIZE) 1138*b9411a12SAndroid Build Coastguard WorkerFMAP_HSPHY_FW_ENTRY := HSPHY_FW@$(FMAP_HSPHY_FW_BASE) $(FMAP_HSPHY_FW_SIZE) 1139*b9411a12SAndroid Build Coastguard WorkerFMAP_CURRENT_BASE := $(call int-add, $(FMAP_HSPHY_FW_BASE) $(FMAP_HSPHY_FW_SIZE)) 1140*b9411a12SAndroid Build Coastguard Workerelse 1141*b9411a12SAndroid Build Coastguard WorkerFMAP_HSPHY_FW_ENTRY := 1142*b9411a12SAndroid Build Coastguard Workerendif 1143*b9411a12SAndroid Build Coastguard Worker 1144*b9411a12SAndroid Build Coastguard Worker# 1145*b9411a12SAndroid Build Coastguard Worker# X86 FMAP region 1146*b9411a12SAndroid Build Coastguard Worker# 1147*b9411a12SAndroid Build Coastguard Worker# 1148*b9411a12SAndroid Build Coastguard Worker# position, size 1149*b9411a12SAndroid Build Coastguard WorkerFMAP_FMAP_BASE := $(FMAP_CURRENT_BASE) 1150*b9411a12SAndroid Build Coastguard WorkerFMAP_FMAP_SIZE := 0x200 1151*b9411a12SAndroid Build Coastguard Worker 1152*b9411a12SAndroid Build Coastguard Worker# 1153*b9411a12SAndroid Build Coastguard Worker# X86 COREBOOT default cbfs FMAP region 1154*b9411a12SAndroid Build Coastguard Worker# 1155*b9411a12SAndroid Build Coastguard Worker# position and size of CBFS, relative to BIOS_BASE 1156*b9411a12SAndroid Build Coastguard WorkerFMAP_CBFS_BASE := $(call int-add, $(FMAP_FMAP_BASE) $(FMAP_FMAP_SIZE)) 1157*b9411a12SAndroid Build Coastguard WorkerFMAP_CBFS_SIZE := $(call int-subtract, $(FMAP_BIOS_SIZE) $(FMAP_CBFS_BASE)) 1158*b9411a12SAndroid Build Coastguard Worker 1159*b9411a12SAndroid Build Coastguard Workerelse # ifeq ($(CONFIG_ARCH_X86),y) 1160*b9411a12SAndroid Build Coastguard Worker 1161*b9411a12SAndroid Build Coastguard WorkerDEFAULT_FLASHMAP:=$(top)/util/cbfstool/default.fmd 1162*b9411a12SAndroid Build Coastguard Worker# entire flash 1163*b9411a12SAndroid Build Coastguard WorkerFMAP_ROM_ADDR := 0 1164*b9411a12SAndroid Build Coastguard WorkerFMAP_ROM_SIZE := $(CONFIG_ROM_SIZE) 1165*b9411a12SAndroid Build Coastguard Worker# entire "BIOS" region (everything directly of concern to the host system) 1166*b9411a12SAndroid Build Coastguard Worker# relative to ROM_BASE 1167*b9411a12SAndroid Build Coastguard WorkerFMAP_BIOS_BASE := 0 1168*b9411a12SAndroid Build Coastguard WorkerFMAP_BIOS_SIZE := $(CONFIG_CBFS_SIZE) 1169*b9411a12SAndroid Build Coastguard Worker# position and size of flashmap, relative to BIOS_BASE 1170*b9411a12SAndroid Build Coastguard WorkerFMAP_FMAP_BASE := 0x20000 1171*b9411a12SAndroid Build Coastguard WorkerFMAP_FMAP_SIZE := 0x200 1172*b9411a12SAndroid Build Coastguard Worker 1173*b9411a12SAndroid Build Coastguard WorkerFMAP_CURRENT_BASE := $(call int-add, $(FMAP_FMAP_BASE) $(FMAP_FMAP_SIZE)) 1174*b9411a12SAndroid Build Coastguard Worker 1175*b9411a12SAndroid Build Coastguard Worker# 1176*b9411a12SAndroid Build Coastguard Worker# NON-X86 CONSOLE FMAP region 1177*b9411a12SAndroid Build Coastguard Worker# 1178*b9411a12SAndroid Build Coastguard Worker# position, size and entry line of CONSOLE relative to BIOS_BASE, if enabled 1179*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_CONSOLE_SPI_FLASH),y) 1180*b9411a12SAndroid Build Coastguard WorkerFMAP_CONSOLE_BASE := $(FMAP_CURRENT_BASE) 1181*b9411a12SAndroid Build Coastguard WorkerFMAP_CONSOLE_SIZE := $(CONFIG_CONSOLE_SPI_FLASH_BUFFER_SIZE) 1182*b9411a12SAndroid Build Coastguard WorkerFMAP_CONSOLE_ENTRY := CONSOLE@$(FMAP_CONSOLE_BASE) $(FMAP_CONSOLE_SIZE) 1183*b9411a12SAndroid Build Coastguard WorkerFMAP_CURRENT_BASE := $(call int-add, $(FMAP_CONSOLE_BASE) $(FMAP_CONSOLE_SIZE)) 1184*b9411a12SAndroid Build Coastguard Workerelse 1185*b9411a12SAndroid Build Coastguard WorkerFMAP_CONSOLE_ENTRY := 1186*b9411a12SAndroid Build Coastguard Workerendif 1187*b9411a12SAndroid Build Coastguard Worker 1188*b9411a12SAndroid Build Coastguard Worker# 1189*b9411a12SAndroid Build Coastguard Worker# NON-X86 RW_MRC_CACHE FMAP region 1190*b9411a12SAndroid Build Coastguard Worker# 1191*b9411a12SAndroid Build Coastguard Worker# position, size and entry line of MRC_CACHE relative to BIOS_BASE, if enabled 1192*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_CACHE_MRC_SETTINGS),y) 1193*b9411a12SAndroid Build Coastguard WorkerFMAP_MRC_CACHE_BASE := $(call int-align, $(FMAP_CURRENT_BASE), 0x10000) 1194*b9411a12SAndroid Build Coastguard WorkerFMAP_MRC_CACHE_SIZE := $(CONFIG_MRC_SETTINGS_CACHE_SIZE) 1195*b9411a12SAndroid Build Coastguard WorkerFMAP_MRC_CACHE_ENTRY := RW_MRC_CACHE@$(FMAP_MRC_CACHE_BASE) $(FMAP_MRC_CACHE_SIZE) 1196*b9411a12SAndroid Build Coastguard WorkerFMAP_CURRENT_BASE := $(call int-add, $(FMAP_MRC_CACHE_BASE) $(FMAP_MRC_CACHE_SIZE)) 1197*b9411a12SAndroid Build Coastguard Workerelse 1198*b9411a12SAndroid Build Coastguard WorkerFMAP_MRC_CACHE_ENTRY := 1199*b9411a12SAndroid Build Coastguard Workerendif 1200*b9411a12SAndroid Build Coastguard Worker 1201*b9411a12SAndroid Build Coastguard Worker# 1202*b9411a12SAndroid Build Coastguard Worker# NON-X86 COREBOOT default cbfs FMAP region 1203*b9411a12SAndroid Build Coastguard Worker# 1204*b9411a12SAndroid Build Coastguard Worker# position and size of CBFS, relative to BIOS_BASE 1205*b9411a12SAndroid Build Coastguard WorkerFMAP_CBFS_BASE := $(FMAP_CURRENT_BASE) 1206*b9411a12SAndroid Build Coastguard WorkerFMAP_CBFS_SIZE := $(call int-subtract,$(FMAP_BIOS_SIZE) $(FMAP_CBFS_BASE)) 1207*b9411a12SAndroid Build Coastguard Worker 1208*b9411a12SAndroid Build Coastguard Workerendif # ifeq ($(CONFIG_ARCH_X86),y) 1209*b9411a12SAndroid Build Coastguard Worker 1210*b9411a12SAndroid Build Coastguard Worker$(obj)/fmap.fmd: $(top)/Makefile.mk $(DEFAULT_FLASHMAP) $(obj)/config.h 1211*b9411a12SAndroid Build Coastguard Worker sed -e "s,##ROM_BASE##,$(FMAP_ROM_ADDR)," \ 1212*b9411a12SAndroid Build Coastguard Worker -e "s,##ROM_SIZE##,$(FMAP_ROM_SIZE)," \ 1213*b9411a12SAndroid Build Coastguard Worker -e "s,##BIOS_BASE##,$(FMAP_BIOS_BASE)," \ 1214*b9411a12SAndroid Build Coastguard Worker -e "s,##BIOS_SIZE##,$(FMAP_BIOS_SIZE)," \ 1215*b9411a12SAndroid Build Coastguard Worker -e "s,##FMAP_BASE##,$(FMAP_FMAP_BASE)," \ 1216*b9411a12SAndroid Build Coastguard Worker -e "s,##FMAP_SIZE##,$(FMAP_FMAP_SIZE)," \ 1217*b9411a12SAndroid Build Coastguard Worker -e "s,##CONSOLE_ENTRY##,$(FMAP_CONSOLE_ENTRY)," \ 1218*b9411a12SAndroid Build Coastguard Worker -e "s,##MRC_CACHE_ENTRY##,$(FMAP_MRC_CACHE_ENTRY)," \ 1219*b9411a12SAndroid Build Coastguard Worker -e "s,##SMMSTORE_ENTRY##,$(FMAP_SMMSTORE_ENTRY)," \ 1220*b9411a12SAndroid Build Coastguard Worker -e "s,##SPD_CACHE_ENTRY##,$(FMAP_SPD_CACHE_ENTRY)," \ 1221*b9411a12SAndroid Build Coastguard Worker -e "s,##VPD_ENTRY##,$(FMAP_VPD_ENTRY)," \ 1222*b9411a12SAndroid Build Coastguard Worker -e "s,##HSPHY_FW_ENTRY##,$(FMAP_HSPHY_FW_ENTRY)," \ 1223*b9411a12SAndroid Build Coastguard Worker -e "s,##CBFS_BASE##,$(FMAP_CBFS_BASE)," \ 1224*b9411a12SAndroid Build Coastguard Worker -e "s,##CBFS_SIZE##,$(FMAP_CBFS_SIZE)," \ 1225*b9411a12SAndroid Build Coastguard Worker $(DEFAULT_FLASHMAP) > $@.tmp 1226*b9411a12SAndroid Build Coastguard Worker mv $@.tmp $@ 1227*b9411a12SAndroid Build Coastguard Workerelse # ifeq ($(CONFIG_FMDFILE),) 1228*b9411a12SAndroid Build Coastguard Worker$(obj)/fmap.fmd: $(CONFIG_FMDFILE) $(obj)/config.h 1229*b9411a12SAndroid Build Coastguard Worker $(HOSTCC) $(PREPROCESS_ONLY) -include $(obj)/config.h $< -o $@.pre 1230*b9411a12SAndroid Build Coastguard Worker mv $@.pre $@ 1231*b9411a12SAndroid Build Coastguard Workerendif # ifeq ($(CONFIG_FMDFILE),) 1232*b9411a12SAndroid Build Coastguard Worker 1233*b9411a12SAndroid Build Coastguard Worker# generated at the same time as fmap.fmap 1234*b9411a12SAndroid Build Coastguard Worker$(obj)/fmap_config.h: $(obj)/fmap.fmap 1235*b9411a12SAndroid Build Coastguard Worker true 1236*b9411a12SAndroid Build Coastguard Worker$(obj)/fmap.desc: $(obj)/fmap.fmap 1237*b9411a12SAndroid Build Coastguard Worker true 1238*b9411a12SAndroid Build Coastguard Worker 1239*b9411a12SAndroid Build Coastguard Worker$(obj)/fmap.fmap: $(obj)/fmap.fmd $(FMAPTOOL) 1240*b9411a12SAndroid Build Coastguard Worker echo " FMAP $(FMAPTOOL) -h $(obj)/fmap_config.h $< $@" 1241*b9411a12SAndroid Build Coastguard Worker $(FMAPTOOL) -h $(obj)/fmap_config.h -R $(obj)/fmap.desc $< $@ 1242*b9411a12SAndroid Build Coastguard Worker 1243*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_INTEL_ADD_TOP_SWAP_BOOTBLOCK),y) 1244*b9411a12SAndroid Build Coastguard WorkerTS_OPTIONS := -j $(CONFIG_INTEL_TOP_SWAP_BOOTBLOCK_SIZE) 1245*b9411a12SAndroid Build Coastguard Workerendif 1246*b9411a12SAndroid Build Coastguard Worker 1247*b9411a12SAndroid Build Coastguard Workerifneq ($(CONFIG_ARCH_X86),y) 1248*b9411a12SAndroid Build Coastguard Workeradd_bootblock = $(CBFSTOOL) $(1) write -u -r BOOTBLOCK -f $(2) 1249*b9411a12SAndroid Build Coastguard Workerendif 1250*b9411a12SAndroid Build Coastguard Worker 1251*b9411a12SAndroid Build Coastguard Worker# coreboot.pre doesn't follow the standard Make conventions. It gets modified 1252*b9411a12SAndroid Build Coastguard Worker# by multiple rules, and thus we can't compute the dependencies correctly. 1253*b9411a12SAndroid Build Coastguard Worker$(shell rm -f $(obj)/coreboot.pre) 1254*b9411a12SAndroid Build Coastguard Worker 1255*b9411a12SAndroid Build Coastguard Workerifneq ($(CONFIG_UPDATE_IMAGE),y) 1256*b9411a12SAndroid Build Coastguard Worker$(obj)/coreboot.pre: $$(prebuilt-files) $(CBFSTOOL) $(obj)/fmap.fmap $(obj)/fmap.desc $(objcbfs)/bootblock.bin 1257*b9411a12SAndroid Build Coastguard Worker $(CBFSTOOL) $@.tmp create -M $(obj)/fmap.fmap -r $(shell cat $(obj)/fmap.desc) 1258*b9411a12SAndroid Build Coastguard Worker printf " BOOTBLOCK\n" 1259*b9411a12SAndroid Build Coastguard Worker $(call add_bootblock,$@.tmp,$(objcbfs)/bootblock.bin) 1260*b9411a12SAndroid Build Coastguard Worker $(prebuild-files) true 1261*b9411a12SAndroid Build Coastguard Worker mv $@.tmp $@ 1262*b9411a12SAndroid Build Coastguard Workerelse # ifneq ($(CONFIG_UPDATE_IMAGE),y) 1263*b9411a12SAndroid Build Coastguard Worker.PHONY: $(obj)/coreboot.pre 1264*b9411a12SAndroid Build Coastguard Worker$(obj)/coreboot.pre: $$(prebuilt-files) $(CBFSTOOL) 1265*b9411a12SAndroid Build Coastguard Worker mv $(obj)/coreboot.rom $@.tmp || \ 1266*b9411a12SAndroid Build Coastguard Worker (echo "Error: You have UPDATE_IMAGE set in Kconfig, but have no existing image to update." && \ 1267*b9411a12SAndroid Build Coastguard Worker echo "Exiting." && \ 1268*b9411a12SAndroid Build Coastguard Worker false) 1269*b9411a12SAndroid Build Coastguard Worker $(prebuild-files) true 1270*b9411a12SAndroid Build Coastguard Worker mv $@.tmp $@ 1271*b9411a12SAndroid Build Coastguard Workerendif # ifneq ($(CONFIG_UPDATE_IMAGE),y) 1272*b9411a12SAndroid Build Coastguard Worker 1273*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_HAVE_REFCODE_BLOB),y) 1274*b9411a12SAndroid Build Coastguard WorkerREFCODE_BLOB=$(obj)/refcode.rmod 1275*b9411a12SAndroid Build Coastguard Worker$(REFCODE_BLOB): $(RMODTOOL) 1276*b9411a12SAndroid Build Coastguard Worker $(RMODTOOL) -i $(CONFIG_REFCODE_BLOB_FILE) -o $@ 1277*b9411a12SAndroid Build Coastguard Workerendif 1278*b9411a12SAndroid Build Coastguard Worker 1279*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_HAVE_RAMSTAGE),y) 1280*b9411a12SAndroid Build Coastguard WorkerRAMSTAGE=$(objcbfs)/ramstage.elf 1281*b9411a12SAndroid Build Coastguard Workerelse 1282*b9411a12SAndroid Build Coastguard WorkerRAMSTAGE= 1283*b9411a12SAndroid Build Coastguard Workerendif 1284*b9411a12SAndroid Build Coastguard Worker 1285*b9411a12SAndroid Build Coastguard Workeradd_intermediate = \ 1286*b9411a12SAndroid Build Coastguard Worker $(1): $(obj)/coreboot.pre $(2) | $(INTERMEDIATE) \ 1287*b9411a12SAndroid Build Coastguard Worker $(eval INTERMEDIATE+=$(1)) $(eval PHONY+=$(1)) 1288*b9411a12SAndroid Build Coastguard Worker 1289*b9411a12SAndroid Build Coastguard Worker$(obj)/coreboot.rom: $(obj)/coreboot.pre $(CBFSTOOL) $(IFITTOOL) $$(INTERMEDIATE) 1290*b9411a12SAndroid Build Coastguard Worker @printf " CBFS $(subst $(obj)/,,$(@))\n" 1291*b9411a12SAndroid Build Coastguard Worker# The full ROM may be larger than the CBFS part, so create an empty 1292*b9411a12SAndroid Build Coastguard Worker# file (filled with \377 = 0xff) and copy the CBFS image over it. 1293*b9411a12SAndroid Build Coastguard Worker dd if=/dev/zero bs=$(call _toint,$(CONFIG_ROM_SIZE)) count=1 2> /dev/null | tr '\000' '\377' > $@.tmp 1294*b9411a12SAndroid Build Coastguard Worker dd if=$(obj)/coreboot.pre of=$@.tmp bs=8192 conv=notrunc 2> /dev/null 1295*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE),y) 1296*b9411a12SAndroid Build Coastguard Worker# Print final FIT table 1297*b9411a12SAndroid Build Coastguard Worker $(IFITTOOL) -f $@.tmp -D -r COREBOOT 1298*b9411a12SAndroid Build Coastguard Worker# Print final TS BOOTBLOCK FIT table 1299*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_INTEL_ADD_TOP_SWAP_BOOTBLOCK),y) 1300*b9411a12SAndroid Build Coastguard Worker @printf " TOP SWAP FIT table\n" 1301*b9411a12SAndroid Build Coastguard Worker $(IFITTOOL) -f $@.tmp -D $(TS_OPTIONS) -r COREBOOT 1302*b9411a12SAndroid Build Coastguard Workerendif # CONFIG_INTEL_ADD_TOP_SWAP_BOOTBLOCK 1303*b9411a12SAndroid Build Coastguard Workerendif # CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE 1304*b9411a12SAndroid Build Coastguard Worker mv $@.tmp $@ 1305*b9411a12SAndroid Build Coastguard Worker @printf " CBFSLAYOUT $(subst $(obj)/,,$(@))\n\n" 1306*b9411a12SAndroid Build Coastguard Worker $(CBFSTOOL) $@ layout 1307*b9411a12SAndroid Build Coastguard Worker @printf " CBFSPRINT $(subst $(obj)/,,$(@))\n\n" 1308*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_CBFS_VERIFICATION),y) 1309*b9411a12SAndroid Build Coastguard Worker line=$$($(CBFSTOOL) $@ print -kv 2>/dev/null | grep -F '[CBFS VERIFICATION (COREBOOT)]') ;\ 1310*b9411a12SAndroid Build Coastguard Worker if ! printf "$$line" | grep -q 'fully valid'; then \ 1311*b9411a12SAndroid Build Coastguard Worker echo "CBFS verification error: $$line" ;\ 1312*b9411a12SAndroid Build Coastguard Worker exit 1 ;\ 1313*b9411a12SAndroid Build Coastguard Worker fi 1314*b9411a12SAndroid Build Coastguard Workerendif # CONFIG_CBFS_VERIFICATION 1315*b9411a12SAndroid Build Coastguard Worker 1316*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_SEPARATE_ROMSTAGE),y) 1317*b9411a12SAndroid Build Coastguard Workercbfs-files-y += $(CONFIG_CBFS_PREFIX)/romstage 1318*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/romstage-file := $(objcbfs)/romstage.elf 1319*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/romstage-type := stage 1320*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/romstage-compression := $(CBFS_PRERAM_COMPRESS_FLAG) 1321*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_ARCH_ROMSTAGE_ARM),y) 1322*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/romstage-options := -b 0 1323*b9411a12SAndroid Build Coastguard Workerendif 1324*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y) 1325*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_NO_XIP_EARLY_STAGES),y) 1326*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/romstage-options := -S ".car.data" 1327*b9411a12SAndroid Build Coastguard Workerelse 1328*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/romstage-options := -S ".car.data,.data" 1329*b9411a12SAndroid Build Coastguard Workerendif 1330*b9411a12SAndroid Build Coastguard Worker 1331*b9411a12SAndroid Build Coastguard Worker# If CAR does not support execution of code, romstage on x86 is expected to be 1332*b9411a12SAndroid Build Coastguard Worker# xip. 1333*b9411a12SAndroid Build Coastguard Workerifneq ($(CONFIG_NO_XIP_EARLY_STAGES),y) 1334*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/romstage-options += --xip 1335*b9411a12SAndroid Build Coastguard Worker 1336*b9411a12SAndroid Build Coastguard Worker# For efficient MTRR utilisation use natural alignment for romstage. 1337*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_SETUP_XIP_CACHE),y) 1338*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/romstage-options += --pow2page 1339*b9411a12SAndroid Build Coastguard Workerendif # CONFIG_SETUP_XIP_CACHE 1340*b9411a12SAndroid Build Coastguard Worker 1341*b9411a12SAndroid Build Coastguard Workerendif # CONFIG_NO_XIP_EARLY_STAGES 1342*b9411a12SAndroid Build Coastguard Workerendif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64 1343*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_VBOOT_STARTS_IN_ROMSTAGE),y) 1344*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/romstage-options += $(TXTIBB) 1345*b9411a12SAndroid Build Coastguard Workerendif 1346*b9411a12SAndroid Build Coastguard Workerelse # CONFIG_SEPARATE_ROMSTAGE 1347*b9411a12SAndroid Build Coastguard Workerpostinclude-hooks += $$(eval bootblock-srcs += $$(romstage-srcs)) 1348*b9411a12SAndroid Build Coastguard Workerpostinclude-hooks += $$(eval bootblock-libs += $$(romstage-libs)) 1349*b9411a12SAndroid Build Coastguard Workerendif 1350*b9411a12SAndroid Build Coastguard Worker 1351*b9411a12SAndroid Build Coastguard Workercbfs-files-$(CONFIG_HAVE_RAMSTAGE) += $(CONFIG_CBFS_PREFIX)/ramstage 1352*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/ramstage-file := $(RAMSTAGE) 1353*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/ramstage-type := stage 1354*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/ramstage-compression := $(CBFS_COMPRESS_FLAG) 1355*b9411a12SAndroid Build Coastguard Worker# The AMD LPC SPI DMA controller requires source files to be 64 byte aligned. 1356*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA),y) 1357*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/ramstage-align := 64 1358*b9411a12SAndroid Build Coastguard Workerendif 1359*b9411a12SAndroid Build Coastguard Worker 1360*b9411a12SAndroid Build Coastguard Workercbfs-files-$(CONFIG_HAVE_REFCODE_BLOB) += $(CONFIG_CBFS_PREFIX)/refcode 1361*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/refcode-file := $(REFCODE_BLOB) 1362*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/refcode-type := stage 1363*b9411a12SAndroid Build Coastguard Worker$(CONFIG_CBFS_PREFIX)/refcode-compression := $(CBFS_COMPRESS_FLAG) 1364*b9411a12SAndroid Build Coastguard Worker 1365*b9411a12SAndroid Build Coastguard Workercbfs-files-$(CONFIG_SEABIOS_VGA_COREBOOT) += vgaroms/seavgabios.bin 1366*b9411a12SAndroid Build Coastguard Workervgaroms/seavgabios.bin-file := $(CONFIG_PAYLOAD_VGABIOS_FILE) 1367*b9411a12SAndroid Build Coastguard Workervgaroms/seavgabios.bin-type := raw 1368*b9411a12SAndroid Build Coastguard Worker 1369*b9411a12SAndroid Build Coastguard Workercbfs-files-$(CONFIG_INCLUDE_CONFIG_FILE) += config 1370*b9411a12SAndroid Build Coastguard Workerconfig-file := $(DOTCONFIG):config 1371*b9411a12SAndroid Build Coastguard Workerconfig-type := raw 1372*b9411a12SAndroid Build Coastguard Workerconfig-compression := LZMA 1373*b9411a12SAndroid Build Coastguard Worker 1374*b9411a12SAndroid Build Coastguard Workercbfs-files-$(CONFIG_INCLUDE_CONFIG_FILE) += revision 1375*b9411a12SAndroid Build Coastguard Workerrevision-file := $(obj)/build.h 1376*b9411a12SAndroid Build Coastguard Workerrevision-type := raw 1377*b9411a12SAndroid Build Coastguard Worker 1378*b9411a12SAndroid Build Coastguard Workercbfs-files-y += build_info 1379*b9411a12SAndroid Build Coastguard Workerbuild_info-file := $(obj)/build_info 1380*b9411a12SAndroid Build Coastguard Workerbuild_info-type := raw 1381*b9411a12SAndroid Build Coastguard Worker 1382*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_BOOTSPLASH_CONVERT),y) 1383*b9411a12SAndroid Build Coastguard Workerifeq ($(shell command -v convert),) 1384*b9411a12SAndroid Build Coastguard Worker$(error CONFIG_BOOTSPLASH_CONVERT requires the convert program (part of ImageMagick)) 1385*b9411a12SAndroid Build Coastguard Workerendif 1386*b9411a12SAndroid Build Coastguard Workercbfs-files-$(CONFIG_BOOTSPLASH_IMAGE) += bootsplash.jpg 1387*b9411a12SAndroid Build Coastguard Workerbootsplash.jpg-file := $(call strip_quotes,$(CONFIG_BOOTSPLASH_FILE)):jpg420 1388*b9411a12SAndroid Build Coastguard Workerbootsplash.jpg-type := bootsplash 1389*b9411a12SAndroid Build Coastguard Workerelse 1390*b9411a12SAndroid Build Coastguard WorkerBOOTSPLASH_SUFFIX=$(suffix $(call strip_quotes,$(CONFIG_BOOTSPLASH_FILE))) 1391*b9411a12SAndroid Build Coastguard Workercbfs-files-$(CONFIG_BOOTSPLASH_IMAGE) += bootsplash$(BOOTSPLASH_SUFFIX) 1392*b9411a12SAndroid Build Coastguard Workerbootsplash$(BOOTSPLASH_SUFFIX)-file := $(call strip_quotes,$(CONFIG_BOOTSPLASH_FILE)) 1393*b9411a12SAndroid Build Coastguard Workerbootsplash$(BOOTSPLASH_SUFFIX)-type := bootsplash 1394*b9411a12SAndroid Build Coastguard Workerendif 1395*b9411a12SAndroid Build Coastguard Worker 1396*b9411a12SAndroid Build Coastguard Worker# Ensure that no payload segment overlaps with memory regions used by ramstage 1397*b9411a12SAndroid Build Coastguard Worker# (not for x86 since it can relocate itself in that case) 1398*b9411a12SAndroid Build Coastguard Workerifneq ($(CONFIG_ARCH_X86),y) 1399*b9411a12SAndroid Build Coastguard Workercheck-ramstage-overlap-regions := ramstage 1400*b9411a12SAndroid Build Coastguard Workercheck-ramstage-overlap-files := 1401*b9411a12SAndroid Build Coastguard Workerifneq ($(CONFIG_PAYLOAD_NONE),y) 1402*b9411a12SAndroid Build Coastguard Workercheck-ramstage-overlap-files += $(CONFIG_CBFS_PREFIX)/payload 1403*b9411a12SAndroid Build Coastguard Workerendif 1404*b9411a12SAndroid Build Coastguard Worker 1405*b9411a12SAndroid Build Coastguard Worker# will output one or more lines of "<load address in hex> <memlen in decimal>" 1406*b9411a12SAndroid Build Coastguard Workercbfs-get-segments-cmd = $(CBFSTOOL) $(obj)/coreboot.pre print -v | sed -n \ 1407*b9411a12SAndroid Build Coastguard Worker '\%$(1)%,\%^[^ ]\{4\}%s% .*load: \(0x[0-9a-fA-F]*\),.*length: [0-9]*/\([0-9]*\).*%\1 \2%p' 1408*b9411a12SAndroid Build Coastguard Worker 1409*b9411a12SAndroid Build Coastguard Workerramstage-symbol-addr-cmd = $(OBJDUMP_ramstage) -t $(objcbfs)/ramstage.elf | \ 1410*b9411a12SAndroid Build Coastguard Worker sed -n '/ $(1)$$/s/^\([0-9a-fA-F]*\) .*/0x\1/p' | \ 1411*b9411a12SAndroid Build Coastguard Worker uniq 1412*b9411a12SAndroid Build Coastguard Worker 1413*b9411a12SAndroid Build Coastguard Worker$(call add_intermediate, check-ramstage-overlaps) 1414*b9411a12SAndroid Build Coastguard Worker programs=$$($(foreach file,$(check-ramstage-overlap-files), \ 1415*b9411a12SAndroid Build Coastguard Worker $(call cbfs-get-segments-cmd,$(file)) ; )) ; \ 1416*b9411a12SAndroid Build Coastguard Worker regions=$$($(foreach region,$(check-ramstage-overlap-regions), \ 1417*b9411a12SAndroid Build Coastguard Worker echo $(region) ; \ 1418*b9411a12SAndroid Build Coastguard Worker $(call ramstage-symbol-addr-cmd,_$(region)) ; \ 1419*b9411a12SAndroid Build Coastguard Worker $(call ramstage-symbol-addr-cmd,_e$(region)) ; )) ; \ 1420*b9411a12SAndroid Build Coastguard Worker pstart= ; pend= ; \ 1421*b9411a12SAndroid Build Coastguard Worker for x in $$programs; do \ 1422*b9411a12SAndroid Build Coastguard Worker if [ -z $$pstart ]; then pstart=$$(($$x)) ; continue ; fi ; \ 1423*b9411a12SAndroid Build Coastguard Worker pend=$$(($$pstart + $$x)) ; \ 1424*b9411a12SAndroid Build Coastguard Worker rname= ; rstart= ; rend= ; \ 1425*b9411a12SAndroid Build Coastguard Worker for y in $$regions ; do \ 1426*b9411a12SAndroid Build Coastguard Worker if [ -z $$rname ]; then rname=$$y ; continue ; fi ; \ 1427*b9411a12SAndroid Build Coastguard Worker if [ -z $$rstart ]; then rstart=$$(($$y)) ; continue ; fi ; \ 1428*b9411a12SAndroid Build Coastguard Worker rend=$$(($$y)) ; \ 1429*b9411a12SAndroid Build Coastguard Worker if [ $$pstart -lt $$rend -a $$rstart -lt $$pend ]; then \ 1430*b9411a12SAndroid Build Coastguard Worker echo "ERROR: Ramstage region _$$rname@($$rstart,$$rend) overlapped by($$pstart,$$pend):" \ 1431*b9411a12SAndroid Build Coastguard Worker $(check-ramstage-overlap-files) ; \ 1432*b9411a12SAndroid Build Coastguard Worker exit 1 ; \ 1433*b9411a12SAndroid Build Coastguard Worker fi ; \ 1434*b9411a12SAndroid Build Coastguard Worker rname= ; rstart= ; rend= ; \ 1435*b9411a12SAndroid Build Coastguard Worker done ; \ 1436*b9411a12SAndroid Build Coastguard Worker pstart= ; pend= ; \ 1437*b9411a12SAndroid Build Coastguard Worker done 1438*b9411a12SAndroid Build Coastguard Worker 1439*b9411a12SAndroid Build Coastguard Workerendif 1440