Patrick Georgi | c49d7a3 | 2020-05-08 22:50:46 +0200 | [diff] [blame] | 1 | ## SPDX-License-Identifier: GPL-2.0-only |
Daisuke Nojiri | 742fc8d | 2014-10-10 10:51:06 -0700 | [diff] [blame] | 2 | |
Bill XIE | cdf6f3a | 2019-12-17 15:56:43 +0800 | [diff] [blame] | 3 | ifeq ($(CONFIG_VBOOT_LIB),y) |
| 4 | |
Joel Kitching | ec12bd0 | 2020-02-04 17:36:49 +0800 | [diff] [blame] | 5 | bootblock-y += vboot_lib.c |
| 6 | verstage-y += vboot_lib.c |
| 7 | romstage-y += vboot_lib.c |
| 8 | ramstage-y += vboot_lib.c |
| 9 | postcar-y += vboot_lib.c |
| 10 | |
Bill XIE | cdf6f3a | 2019-12-17 15:56:43 +0800 | [diff] [blame] | 11 | vboot-fixup-includes = $(patsubst -I%,-I$(top)/%,\ |
| 12 | $(patsubst $(src)/%.h,$(top)/$(src)/%.h,\ |
| 13 | $(filter-out -I$(obj),$(1)))) |
| 14 | |
| 15 | # call with $1 = stage name to create rules for building the library |
| 16 | # for the stage and adding it to the stage's set of object files. |
| 17 | define vboot-for-stage |
| 18 | VBOOT_LIB_$(1) = $(obj)/external/vboot_reference-$(1)/vboot_fw.a |
| 19 | VBOOT_CFLAGS_$(1) += $$(call vboot-fixup-includes,$$(CPPFLAGS_$(1))) |
| 20 | VBOOT_CFLAGS_$(1) += $$(CFLAGS_$(1)) |
| 21 | VBOOT_CFLAGS_$(1) += $$(call vboot-fixup-includes,$$($(1)-c-ccopts)) |
| 22 | VBOOT_CFLAGS_$(1) += -I$(abspath $(obj)) -Wno-missing-prototypes |
| 23 | VBOOT_CFLAGS_$(1) += -DVBOOT_DEBUG |
| 24 | |
| 25 | $$(VBOOT_LIB_$(1)): $(obj)/config.h |
| 26 | printf " MAKE $(subst $(obj)/,,$(@))\n" |
| 27 | +FIRMWARE_ARCH=$$(ARCHDIR-$$(ARCH-$(1)-y)) \ |
| 28 | CC="$$(CC_$(1))" \ |
| 29 | CFLAGS="$$(VBOOT_CFLAGS_$(1))" VBOOT2="y" \ |
Sam McNally | eded500 | 2020-03-04 16:08:06 +1100 | [diff] [blame] | 30 | EC_EFS="$(CONFIG_VBOOT_EC_EFS)" \ |
Karthikeyan Ramasubramanian | 4f9853a | 2022-10-27 22:49:40 -0600 | [diff] [blame] | 31 | X86_SHA_EXT="$(if $(CONFIG_ARCH_$(call toupper,$(1))_X86_32)$(CONFIG_ARCH_$(call toupper,$(1))_X86_64),$\ |
| 32 | $(CONFIG_VBOOT_X86_SHA256_ACCELERATION))" \ |
Yidi Lin | bd6b81d | 2023-01-31 15:18:57 +0800 | [diff] [blame] | 33 | ARMV8_CRYPTO_EXT="$(if $(CONFIG_ARCH_$(call toupper,$(1))_ARMV8_64),$$(CONFIG_VBOOT_ARMV8_CE_SHA256_ACCELERATION))" \ |
Bill XIE | cdf6f3a | 2019-12-17 15:56:43 +0800 | [diff] [blame] | 34 | $(MAKE) -C $(VBOOT_SOURCE) \ |
| 35 | BUILD=$$(abspath $$(dir $$(VBOOT_LIB_$(1)))) \ |
| 36 | V=$(V) \ |
Brian Norris | 6d301c8 | 2023-02-01 16:38:44 -0800 | [diff] [blame] | 37 | USE_FLASHROM=0 \ |
Maximilian Brune | 1d7a9de | 2022-04-14 14:54:16 +0200 | [diff] [blame] | 38 | fwlib \ |
Maximilian Brune | 5cbf45e | 2022-12-26 06:37:21 +0100 | [diff] [blame] | 39 | $(if $(CONFIG_SBOM_VBOOT),$$(abspath $$(dir $$(VBOOT_LIB_$(1))))/vboot_host.pc) |
Bill XIE | cdf6f3a | 2019-12-17 15:56:43 +0800 | [diff] [blame] | 40 | |
| 41 | $(1)-srcs += $$(VBOOT_LIB_$(1)) |
| 42 | |
| 43 | endef # vboot-for-stage |
| 44 | |
| 45 | $(eval $(call vboot-for-stage,bootblock)) |
| 46 | $(eval $(call vboot-for-stage,romstage)) |
| 47 | $(eval $(call vboot-for-stage,ramstage)) |
| 48 | $(eval $(call vboot-for-stage,postcar)) |
| 49 | |
| 50 | endif # CONFIG_VBOOT_LIB |
| 51 | |
Julius Werner | 5fc7c28 | 2017-03-17 14:29:10 -0700 | [diff] [blame] | 52 | ifeq ($(CONFIG_VBOOT),y) |
| 53 | |
Furquan Shaikh | 0325dc6 | 2016-07-25 13:02:36 -0700 | [diff] [blame] | 54 | bootblock-y += bootmode.c |
| 55 | romstage-y += bootmode.c |
| 56 | ramstage-y += bootmode.c |
| 57 | verstage-y += bootmode.c |
| 58 | postcar-y += bootmode.c |
| 59 | |
Joel Kitching | d6f71d0 | 2019-02-21 12:37:55 +0800 | [diff] [blame] | 60 | verstage-generic-ccopts += -D__VERSTAGE__ |
Daisuke Nojiri | 742fc8d | 2014-10-10 10:51:06 -0700 | [diff] [blame] | 61 | |
Furquan Shaikh | 2a12e2e | 2016-07-25 11:48:03 -0700 | [diff] [blame] | 62 | bootblock-y += vbnv.c |
| 63 | verstage-y += vbnv.c |
| 64 | romstage-y += vbnv.c |
| 65 | ramstage-y += vbnv.c |
Jakub Czapiga | 967a76b | 2022-08-19 12:25:27 +0200 | [diff] [blame] | 66 | postcar-y += vbnv.c |
Furquan Shaikh | 2a12e2e | 2016-07-25 11:48:03 -0700 | [diff] [blame] | 67 | |
Tim Wawrzynczak | d6fc557 | 2019-10-25 14:58:15 -0600 | [diff] [blame] | 68 | romstage-$(CONFIG_VBOOT_EARLY_EC_SYNC) += ec_sync.c |
| 69 | |
Furquan Shaikh | 2a12e2e | 2016-07-25 11:48:03 -0700 | [diff] [blame] | 70 | bootblock-$(CONFIG_VBOOT_VBNV_CMOS) += vbnv_cmos.c |
| 71 | verstage-$(CONFIG_VBOOT_VBNV_CMOS) += vbnv_cmos.c |
| 72 | romstage-$(CONFIG_VBOOT_VBNV_CMOS) += vbnv_cmos.c |
| 73 | ramstage-$(CONFIG_VBOOT_VBNV_CMOS) += vbnv_cmos.c |
Jakub Czapiga | 967a76b | 2022-08-19 12:25:27 +0200 | [diff] [blame] | 74 | postcar-$(CONFIG_VBOOT_VBNV_CMOS) += vbnv_cmos.c |
Furquan Shaikh | 2a12e2e | 2016-07-25 11:48:03 -0700 | [diff] [blame] | 75 | |
Arthur Heymans | 61ef0e4 | 2023-01-12 11:29:57 +0100 | [diff] [blame] | 76 | $(call src-to-obj,bootblock,$(dir)/vbnv_flash.c) : $(obj)/fmap_config.h |
| 77 | $(call src-to-obj,verstage,$(dir)/vbnv_flash.c) : $(obj)/fmap_config.h |
| 78 | $(call src-to-obj,romstage,$(dir)/vbnv_flash.c) : $(obj)/fmap_config.h |
| 79 | $(call src-to-obj,ramstage,$(dir)/vbnv_flash.c) : $(obj)/fmap_config.h |
| 80 | $(call src-to-obj,postcar,$(dir)/vbnv_flash.c) : $(obj)/fmap_config.h |
Furquan Shaikh | 2a12e2e | 2016-07-25 11:48:03 -0700 | [diff] [blame] | 81 | bootblock-$(CONFIG_VBOOT_VBNV_CMOS_BACKUP_TO_FLASH) += vbnv_flash.c |
| 82 | verstage-$(CONFIG_VBOOT_VBNV_CMOS_BACKUP_TO_FLASH) += vbnv_flash.c |
| 83 | romstage-$(CONFIG_VBOOT_VBNV_CMOS_BACKUP_TO_FLASH) += vbnv_flash.c |
| 84 | ramstage-$(CONFIG_VBOOT_VBNV_CMOS_BACKUP_TO_FLASH) += vbnv_flash.c |
Jakub Czapiga | 967a76b | 2022-08-19 12:25:27 +0200 | [diff] [blame] | 85 | postcar-$(CONFIG_VBOOT_VBNV_CMOS_BACKUP_TO_FLASH) += vbnv_flash.c |
Furquan Shaikh | 2a12e2e | 2016-07-25 11:48:03 -0700 | [diff] [blame] | 86 | |
Furquan Shaikh | 2a12e2e | 2016-07-25 11:48:03 -0700 | [diff] [blame] | 87 | bootblock-$(CONFIG_VBOOT_VBNV_FLASH) += vbnv_flash.c |
| 88 | verstage-$(CONFIG_VBOOT_VBNV_FLASH) += vbnv_flash.c |
| 89 | romstage-$(CONFIG_VBOOT_VBNV_FLASH) += vbnv_flash.c |
| 90 | ramstage-$(CONFIG_VBOOT_VBNV_FLASH) += vbnv_flash.c |
Jakub Czapiga | 967a76b | 2022-08-19 12:25:27 +0200 | [diff] [blame] | 91 | postcar-$(CONFIG_VBOOT_VBNV_FLASH) += vbnv_flash.c |
Furquan Shaikh | 2a12e2e | 2016-07-25 11:48:03 -0700 | [diff] [blame] | 92 | |
Aaron Durbin | 17200ad | 2015-05-01 16:48:54 -0500 | [diff] [blame] | 93 | bootblock-y += vboot_loader.c |
| 94 | romstage-y += vboot_loader.c |
| 95 | ramstage-y += vboot_loader.c |
| 96 | verstage-y += vboot_loader.c |
Andrey Petrov | 60c6432 | 2016-04-14 14:12:47 -0700 | [diff] [blame] | 97 | postcar-y += vboot_loader.c |
Aaron Durbin | 17200ad | 2015-05-01 16:48:54 -0500 | [diff] [blame] | 98 | |
Furquan Shaikh | 2a12e2e | 2016-07-25 11:48:03 -0700 | [diff] [blame] | 99 | bootblock-y += vboot_common.c |
| 100 | verstage-y += vboot_common.c |
| 101 | romstage-y += vboot_common.c |
| 102 | ramstage-y += vboot_common.c |
| 103 | postcar-y += vboot_common.c |
Daisuke Nojiri | 742fc8d | 2014-10-10 10:51:06 -0700 | [diff] [blame] | 104 | |
Daisuke Nojiri | 54af625 | 2014-11-04 12:32:29 -0800 | [diff] [blame] | 105 | bootblock-y += common.c |
Julius Werner | e91d170 | 2017-03-20 15:32:15 -0700 | [diff] [blame] | 106 | verstage-y += vboot_logic.c |
Daisuke Nojiri | 5d302c7 | 2015-04-09 08:18:22 -0700 | [diff] [blame] | 107 | verstage-y += common.c |
Martin Roth | 8a3a3c8 | 2020-05-04 10:13:45 -0600 | [diff] [blame] | 108 | ifeq ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),) |
Julius Werner | e91d170 | 2017-03-20 15:32:15 -0700 | [diff] [blame] | 109 | verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += verstage.c |
Martin Roth | 8a3a3c8 | 2020-05-04 10:13:45 -0600 | [diff] [blame] | 110 | endif |
Furquan Shaikh | 2a12e2e | 2016-07-25 11:48:03 -0700 | [diff] [blame] | 111 | ifeq (${CONFIG_VBOOT_MOCK_SECDATA},y) |
Julius Werner | e91d170 | 2017-03-20 15:32:15 -0700 | [diff] [blame] | 112 | verstage-y += secdata_mock.c |
Julius Werner | f0ebaf2 | 2020-04-27 13:57:05 -0700 | [diff] [blame] | 113 | romstage-y += secdata_mock.c |
Sridhar Siricilla | 89ac87a | 2020-04-20 18:45:22 +0530 | [diff] [blame] | 114 | ramstage-y += secdata_mock.c |
Daisuke Nojiri | 5d302c7 | 2015-04-09 08:18:22 -0700 | [diff] [blame] | 115 | else |
Julius Werner | e91d170 | 2017-03-20 15:32:15 -0700 | [diff] [blame] | 116 | verstage-y += secdata_tpm.c |
Julius Werner | f0ebaf2 | 2020-04-27 13:57:05 -0700 | [diff] [blame] | 117 | romstage-y += secdata_tpm.c |
Sridhar Siricilla | 89ac87a | 2020-04-20 18:45:22 +0530 | [diff] [blame] | 118 | ramstage-y += secdata_tpm.c |
Daisuke Nojiri | 5d302c7 | 2015-04-09 08:18:22 -0700 | [diff] [blame] | 119 | endif |
Christian Walter | 0bd84ed | 2019-07-23 10:26:30 +0200 | [diff] [blame] | 120 | |
Kyösti Mälkki | f303b4f | 2021-05-27 19:33:57 +0300 | [diff] [blame] | 121 | verstage-$(CONFIG_TPM) += tpm_common.c |
Christian Walter | 0bd84ed | 2019-07-23 10:26:30 +0200 | [diff] [blame] | 122 | |
Joel Kitching | eb20320 | 2019-06-16 17:26:53 +0800 | [diff] [blame] | 123 | romstage-y += common.c |
Daisuke Nojiri | 742fc8d | 2014-10-10 10:51:06 -0700 | [diff] [blame] | 124 | |
Aaron Durbin | 17200ad | 2015-05-01 16:48:54 -0500 | [diff] [blame] | 125 | ramstage-y += common.c |
Andrey Petrov | 60c6432 | 2016-04-14 14:12:47 -0700 | [diff] [blame] | 126 | postcar-y += common.c |
Aaron Durbin | 17200ad | 2015-05-01 16:48:54 -0500 | [diff] [blame] | 127 | |
Shelley Chen | 9f8ac64 | 2020-10-16 12:20:16 -0700 | [diff] [blame] | 128 | romstage-$(CONFIG_MRC_SAVE_HASH_IN_TPM) += mrc_cache_hash_tpm.c |
Shelley Chen | 1fed53f | 2020-10-16 12:30:05 -0700 | [diff] [blame] | 129 | ramstage-$(CONFIG_MRC_SAVE_HASH_IN_TPM) += mrc_cache_hash_tpm.c |
Philipp Deppenwiese | 80961af | 2018-02-27 22:14:34 +0100 | [diff] [blame] | 130 | |
Matt DeVillier | 9ce755d | 2023-01-23 18:31:27 -0600 | [diff] [blame] | 131 | ramstage-$(CONFIG_SOC_AMD_GFX_CACHE_VBIOS_IN_FMAP) += vbios_cache_hash_tpm.c |
| 132 | |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 133 | ifeq ($(CONFIG_VBOOT_SEPARATE_VERSTAGE),y) |
Furquan Shaikh | b038f41 | 2016-11-07 23:47:11 -0800 | [diff] [blame] | 134 | |
Werner Zeh | 3c6d9e1 | 2018-11-26 06:54:13 +0100 | [diff] [blame] | 135 | $(eval $(call vboot-for-stage,verstage)) |
Furquan Shaikh | b038f41 | 2016-11-07 23:47:11 -0800 | [diff] [blame] | 136 | |
Martin Roth | 8a3a3c8 | 2020-05-04 10:13:45 -0600 | [diff] [blame] | 137 | ifeq ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),) |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 138 | cbfs-files-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += $(CONFIG_CBFS_PREFIX)/verstage |
Patrick Georgi | 1cab012 | 2015-11-26 16:39:23 +0100 | [diff] [blame] | 139 | $(CONFIG_CBFS_PREFIX)/verstage-file := $(objcbfs)/verstage.elf |
| 140 | $(CONFIG_CBFS_PREFIX)/verstage-type := stage |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 141 | $(CONFIG_CBFS_PREFIX)/verstage-compression := $(CBFS_PRERAM_COMPRESS_FLAG) |
Martin Roth | 8a3a3c8 | 2020-05-04 10:13:45 -0600 | [diff] [blame] | 142 | endif # CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK |
Furquan Shaikh | 94b18a1 | 2016-05-04 23:25:16 -0700 | [diff] [blame] | 143 | |
Patrick Georgi | 1cab012 | 2015-11-26 16:39:23 +0100 | [diff] [blame] | 144 | ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32)$(CONFIG_ARCH_VERSTAGE_X86_64),y) |
Furquan Shaikh | 94b18a1 | 2016-05-04 23:25:16 -0700 | [diff] [blame] | 145 | $(CONFIG_CBFS_PREFIX)/verstage-options := -a 64 -S ".car.data" |
| 146 | |
| 147 | # If CAR does not support execution of code, verstage on x86 is expected to be |
| 148 | # xip. |
| 149 | ifneq ($(CONFIG_NO_XIP_EARLY_STAGES),y) |
| 150 | $(CONFIG_CBFS_PREFIX)/verstage-options += --xip |
| 151 | endif |
Patrick Georgi | 1cab012 | 2015-11-26 16:39:23 +0100 | [diff] [blame] | 152 | |
| 153 | endif |
Patrick Rudolph | d9c799c | 2019-02-19 10:57:16 +0100 | [diff] [blame] | 154 | $(CONFIG_CBFS_PREFIX)/verstage-options += $(TXTIBB) |
Patrick Georgi | 1cab012 | 2015-11-26 16:39:23 +0100 | [diff] [blame] | 155 | |
Julius Werner | e91d170 | 2017-03-20 15:32:15 -0700 | [diff] [blame] | 156 | else # CONFIG_VBOOT_SEPARATE_VERSTAGE |
Aaron Durbin | d1cf44c | 2015-05-08 15:58:06 -0500 | [diff] [blame] | 157 | ifeq ($(CONFIG_VBOOT_STARTS_IN_BOOTBLOCK),y) |
Julius Werner | e91d170 | 2017-03-20 15:32:15 -0700 | [diff] [blame] | 158 | postinclude-hooks += $$(eval bootblock-srcs += $$(verstage-srcs)) |
Aaron Durbin | 57e3728 | 2015-04-28 16:17:25 -0500 | [diff] [blame] | 159 | else |
Julius Werner | e91d170 | 2017-03-20 15:32:15 -0700 | [diff] [blame] | 160 | postinclude-hooks += $$(eval romstage-srcs += $$(verstage-srcs)) |
Patrick Georgi | efc6aa0 | 2015-04-27 18:13:50 +0200 | [diff] [blame] | 161 | endif |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 162 | endif # CONFIG_VBOOT_SEPARATE_VERSTAGE |
Patrick Georgi | c8d4abd | 2016-01-20 15:54:31 +0100 | [diff] [blame] | 163 | |
Philipp Deppenwiese | a558ca9 | 2018-07-28 23:30:49 +0200 | [diff] [blame] | 164 | #RO-Partition is always there! |
| 165 | VBOOT_PARTITIONS := COREBOOT |
| 166 | # Check for RW_A partition |
| 167 | ifeq ($(CONFIG_VBOOT_SLOTS_RW_A),y) |
| 168 | VBOOT_PARTITIONS += FW_MAIN_A |
Wim Vervoorn | a1c259b | 2019-11-01 10:47:01 +0100 | [diff] [blame] | 169 | RW_PARTITIONS := FW_MAIN_A |
Philipp Deppenwiese | a558ca9 | 2018-07-28 23:30:49 +0200 | [diff] [blame] | 170 | endif |
| 171 | # Check for RW_B partition |
| 172 | ifeq ($(CONFIG_VBOOT_SLOTS_RW_AB),y) |
| 173 | VBOOT_PARTITIONS += FW_MAIN_B |
Wim Vervoorn | a1c259b | 2019-11-01 10:47:01 +0100 | [diff] [blame] | 174 | RW_PARTITIONS += FW_MAIN_B |
Philipp Deppenwiese | a558ca9 | 2018-07-28 23:30:49 +0200 | [diff] [blame] | 175 | endif |
| 176 | |
Wim Vervoorn | a1c259b | 2019-11-01 10:47:01 +0100 | [diff] [blame] | 177 | # Return the regions a specific file should be placed in. The files listed below and the ones |
Martin Roth | 6303671 | 2020-06-25 17:20:32 -0600 | [diff] [blame] | 178 | # that are specified in CONFIG_RO_REGION_ONLY, are only specified in the RO region. The files |
| 179 | # specified in the CONFIG_RW_REGION_ONLY are placed in all RW regions. Files specified |
| 180 | # in CONFIG_RWA_REGION_ONLY or CONFIG_RWB_REGION_ONLY get placed only in those sections. |
Patrick Georgi | c8d4abd | 2016-01-20 15:54:31 +0100 | [diff] [blame] | 181 | # All other files will be installed into RO and RW regions |
| 182 | # Use $(sort) to cut down on extra spaces that would be translated to commas |
| 183 | regions-for-file = $(subst $(spc),$(comma),$(sort \ |
Sridhar Siricilla | 77025b3 | 2020-07-23 23:41:36 +0530 | [diff] [blame] | 184 | $(if $(value regions-for-file-$(1)), \ |
| 185 | $(regions-for-file-$(1)), \ |
| 186 | $(if $(filter $(if $(filter y,$(CONFIG_VBOOT_STARTS_IN_ROMSTAGE)), \ |
Martin Roth | 8a3a3c8 | 2020-05-04 10:13:45 -0600 | [diff] [blame] | 187 | %/romstage,) \ |
Arthur Heymans | 75226bb | 2022-03-30 20:16:36 +0200 | [diff] [blame] | 188 | header_pointer \ |
| 189 | cbfs_master_header \ |
Patrick Georgi | c8d4abd | 2016-01-20 15:54:31 +0100 | [diff] [blame] | 190 | mts \ |
| 191 | %/verstage \ |
Patrick Georgi | eda794d | 2016-02-05 11:01:24 +0100 | [diff] [blame] | 192 | locales \ |
| 193 | locale_%.bin \ |
| 194 | font.bin \ |
| 195 | vbgfx.bin \ |
Lee Leahy | 5e34752 | 2017-01-04 08:51:52 -0800 | [diff] [blame] | 196 | rmu.bin \ |
Patrick Rudolph | 9554b26 | 2018-06-05 15:12:56 +0200 | [diff] [blame] | 197 | cmos_layout.bin \ |
| 198 | cmos.default \ |
Arthur Heymans | eeacd83 | 2021-02-19 17:14:23 +0100 | [diff] [blame] | 199 | intel_fit \ |
| 200 | intel_fit_ts \ |
Arthur Heymans | d6612a4 | 2021-05-03 13:29:22 +0200 | [diff] [blame] | 201 | fspt.bin \ |
Arthur Heymans | e714fc0 | 2023-04-05 14:24:59 +0200 | [diff] [blame] | 202 | pagetables \ |
Martin Roth | bbd5ee41 | 2017-10-05 13:53:16 -0600 | [diff] [blame] | 203 | $(call strip_quotes,$(CONFIG_RO_REGION_ONLY)) \ |
Wim Vervoorn | a1c259b | 2019-11-01 10:47:01 +0100 | [diff] [blame] | 204 | ,$(1)),COREBOOT,\ |
| 205 | $(if $(filter \ |
Sridhar Siricilla | 77025b3 | 2020-07-23 23:41:36 +0530 | [diff] [blame] | 206 | $(call strip_quotes,$(CONFIG_RWA_REGION_ONLY)) \ |
| 207 | ,$(1)), FW_MAIN_A, \ |
Martin Roth | 6303671 | 2020-06-25 17:20:32 -0600 | [diff] [blame] | 208 | $(if $(filter \ |
| 209 | $(call strip_quotes,$(CONFIG_RWB_REGION_ONLY)) \ |
| 210 | ,$(1)), FW_MAIN_B, \ |
| 211 | $(if $(filter \ |
Wim Vervoorn | a1c259b | 2019-11-01 10:47:01 +0100 | [diff] [blame] | 212 | $(call strip_quotes,$(CONFIG_RW_REGION_ONLY)) \ |
| 213 | ,$(1)), $(RW_PARTITIONS), $(VBOOT_PARTITIONS) ) \ |
Sridhar Siricilla | 77025b3 | 2020-07-23 23:41:36 +0530 | [diff] [blame] | 214 | )))))) |
Furquan Shaikh | 0325dc6 | 2016-07-25 13:02:36 -0700 | [diff] [blame] | 215 | |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 216 | CONFIG_GBB_HWID := $(call strip_quotes,$(CONFIG_GBB_HWID)) |
| 217 | CONFIG_GBB_BMPFV_FILE := $(call strip_quotes,$(CONFIG_GBB_BMPFV_FILE)) |
| 218 | CONFIG_VBOOT_KEYBLOCK := $(call strip_quotes,$(CONFIG_VBOOT_KEYBLOCK)) |
| 219 | CONFIG_VBOOT_FIRMWARE_PRIVKEY := $(call strip_quotes,$(CONFIG_VBOOT_FIRMWARE_PRIVKEY)) |
| 220 | CONFIG_VBOOT_KERNEL_KEY := $(call strip_quotes,$(CONFIG_VBOOT_KERNEL_KEY)) |
| 221 | CONFIG_VBOOT_FWID_MODEL := $(call strip_quotes,$(CONFIG_VBOOT_FWID_MODEL)) |
| 222 | CONFIG_VBOOT_FWID_VERSION := $(call strip_quotes,$(CONFIG_VBOOT_FWID_VERSION)) |
| 223 | |
| 224 | # bool-to-mask(var, value) |
| 225 | # return "value" if var is "y", 0 otherwise |
| 226 | bool-to-mask = $(if $(filter y,$(1)),$(2),0) |
| 227 | |
| 228 | GBB_FLAGS := $(call int-add, \ |
| 229 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_DEV_SCREEN_SHORT_DELAY),0x1) \ |
| 230 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_LOAD_OPTION_ROMS),0x2) \ |
| 231 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_ENABLE_ALTERNATE_OS),0x4) \ |
| 232 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_FORCE_DEV_SWITCH_ON),0x8) \ |
| 233 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_FORCE_DEV_BOOT_USB),0x10) \ |
| 234 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_DISABLE_FW_ROLLBACK_CHECK),0x20) \ |
| 235 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_ENTER_TRIGGERS_TONORM),0x40) \ |
Joel Kitching | a904fd6 | 2021-02-19 18:10:58 +0800 | [diff] [blame] | 236 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_FORCE_DEV_BOOT_ALTFW),0x80) \ |
Joel Kitching | 984d0c6 | 2019-12-04 15:33:57 +0800 | [diff] [blame] | 237 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_RUNNING_FAFT),0x100) \ |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 238 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC),0x200) \ |
Joel Kitching | a904fd6 | 2021-02-19 18:10:58 +0800 | [diff] [blame] | 239 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_DEFAULT_DEV_BOOT_ALTFW),0x400) \ |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 240 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC),0x800) \ |
| 241 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_DISABLE_LID_SHUTDOWN),0x1000) \ |
Julius Werner | ae42385 | 2018-03-23 21:02:48 -0700 | [diff] [blame] | 242 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_FORCE_MANUAL_RECOVERY),0x4000) \ |
| 243 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_DISABLE_FWMP),0x8000) \ |
Eric Lai | 1cf2427 | 2021-01-29 16:14:37 +0800 | [diff] [blame] | 244 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_ENABLE_UDC),0x10000) \ |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 245 | ) |
| 246 | |
| 247 | ifneq ($(CONFIG_GBB_BMPFV_FILE),) |
| 248 | $(obj)/gbb.sizetmp: $(obj)/coreboot.rom |
| 249 | $(CBFSTOOL) $< read -r GBB -f $@ |
| 250 | |
| 251 | $(obj)/gbb.stub: $(obj)/coreboot.rom $(FUTILITY) $(obj)/gbb.sizetmp |
| 252 | @printf " CREATE GBB (with BMPFV)\n" |
| 253 | $(FUTILITY) gbb_utility -c 0x100,0x1000,$(call int-subtract,$(call file-size,$(obj)/gbb.sizetmp) 0x2180),0x1000 $@.tmp |
| 254 | mv $@.tmp $@ |
| 255 | else |
| 256 | $(obj)/gbb.stub: $(obj)/coreboot.rom $(FUTILITY) |
| 257 | @printf " CREATE GBB (without BMPFV)\n" |
| 258 | $(FUTILITY) gbb_utility -c 0x100,0x1000,0,0x1000 $@.tmp |
| 259 | mv $@.tmp $@ |
| 260 | endif |
| 261 | |
Hung-Te Lin | 117453e | 2019-09-27 12:23:20 +0800 | [diff] [blame] | 262 | # Generate a test-only HWID |
| 263 | ifeq ($(CONFIG_GBB_HWID),) |
| 264 | CONFIG_GBB_HWID := $$($(top)/util/chromeos/gen_test_hwid.sh "$(CONFIG_MAINBOARD_PART_NUMBER)") |
| 265 | endif |
| 266 | |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 267 | $(obj)/gbb.region: $(obj)/gbb.stub |
| 268 | @printf " SETUP GBB\n" |
| 269 | cp $< $@.tmp |
| 270 | $(FUTILITY) gbb_utility -s \ |
| 271 | --hwid="$(CONFIG_GBB_HWID)" \ |
| 272 | --rootkey="$(CONFIG_VBOOT_ROOT_KEY)" \ |
| 273 | --recoverykey="$(CONFIG_VBOOT_RECOVERY_KEY)" \ |
| 274 | --flags=$(GBB_FLAGS) \ |
| 275 | $@.tmp |
| 276 | ifneq ($(CONFIG_GBB_BMPFV_FILE),) |
| 277 | $(FUTILITY) gbb_utility -s \ |
| 278 | --bmpfv="$(CONFIG_GBB_BMPFV_FILE)" \ |
| 279 | $@.tmp |
| 280 | endif |
| 281 | mv $@.tmp $@ |
| 282 | |
Raul E Rangel | 8c38a8b | 2018-08-06 16:13:14 -0600 | [diff] [blame] | 283 | $(obj)/fwid.version: |
| 284 | echo -n "$(CONFIG_VBOOT_FWID_VERSION)" > $@ |
| 285 | |
| 286 | $(obj)/fwid.region: $(obj)/fwid.version |
| 287 | printf "%s%s\0" \ |
| 288 | "$(CONFIG_VBOOT_FWID_MODEL)" \ |
Raul E Rangel | 128b0cf | 2018-08-09 12:30:39 -0600 | [diff] [blame] | 289 | "$$(cat "$(obj)/fwid.version")" > $@ |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 290 | |
| 291 | build_complete:: $(obj)/gbb.region $(obj)/fwid.region |
| 292 | @printf " WRITE GBB\n" |
| 293 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r GBB -i 0 -f $(obj)/gbb.region |
| 294 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r RO_FRID -i 0 -f $(obj)/fwid.region |
Philipp Deppenwiese | a558ca9 | 2018-07-28 23:30:49 +0200 | [diff] [blame] | 295 | ifeq ($(CONFIG_VBOOT_SLOTS_RW_A),y) |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 296 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r RW_FWID_A -i 0 -f $(obj)/fwid.region |
Philipp Deppenwiese | a558ca9 | 2018-07-28 23:30:49 +0200 | [diff] [blame] | 297 | endif |
| 298 | ifeq ($(CONFIG_VBOOT_SLOTS_RW_AB),y) |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 299 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r RW_FWID_B -i 0 -f $(obj)/fwid.region |
Philipp Deppenwiese | a558ca9 | 2018-07-28 23:30:49 +0200 | [diff] [blame] | 300 | endif |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 301 | |
| 302 | ifneq ($(shell grep "SHARED_DATA" "$(CONFIG_FMDFILE)"),) |
| 303 | build_complete:: |
| 304 | printf "\0" > $(obj)/shared_data.region |
| 305 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r SHARED_DATA -i 0 -f $(obj)/shared_data.region |
| 306 | endif |
| 307 | |
Julius Werner | 5eda52a | 2022-05-19 14:37:21 -0700 | [diff] [blame] | 308 | fmap-section-offset-cmd = $(FUTILITY) dump_fmap -p $(obj)/coreboot.rom | \ |
| 309 | grep '^$(1) ' | cut '-d ' -f2 |
Julius Werner | 39914a5 | 2022-08-01 15:04:44 -0700 | [diff] [blame] | 310 | fmap-section-size-cmd = $(FUTILITY) dump_fmap -p $(obj)/coreboot.rom | \ |
| 311 | grep '^$(1) ' | cut '-d ' -f3 |
Julius Werner | 5eda52a | 2022-05-19 14:37:21 -0700 | [diff] [blame] | 312 | |
| 313 | ifeq ($(CONFIG_VBOOT_GSCVD),y) |
| 314 | # |
| 315 | # vboot-gscvd-ranges |
| 316 | # |
| 317 | # This variable expands to the list of ranges that will be verified by the GSC |
| 318 | # before releasing the SoC from reset. It needs to cover all security-relevant |
| 319 | # ranges of the flash that CBFS verification cannot cover itself. By default |
| 320 | # this is the `GBB` FMAP section (not handled here but through the special `-G` |
| 321 | # parameter to `futility gscvd` below) and the bootblock. Here we are |
| 322 | # initializing the variable to expansions that produce ranges for both the |
| 323 | # `BOOTBLOCK` FMAP section (filled up to the real size of |
| 324 | # `$(objcbfs)/bootblock.bin`) and the `bootblock` file in the primary CBFS -- |
| 325 | # only one of those two should normally exist on a given platform. |
| 326 | # |
| 327 | # Platforms where the bootblock isn't the first and only thing loaded by the |
| 328 | # hardware or which otherwise have special security-relevant flash areas that |
| 329 | # cannot be covered normally by CBFS verification will need to manually add |
| 330 | # ranges to this variable in their own Makefiles, in the format produced by |
| 331 | # printf("%x:%x", start_offset, size). The variable is only expanded once in a |
| 332 | # recipe of the `files_added` target, so $(shell) expansions that depend on |
| 333 | # inspecting $(obj)/coreboot.rom (or any of its dependencies) are valid. |
| 334 | # |
| 335 | vboot-gscvd-ranges += $(shell ( \ |
| 336 | offset=$$($(call fmap-section-offset-cmd,BOOTBLOCK)) ;\ |
| 337 | if [ -n "$$offset" ]; then \ |
| 338 | size=$$(wc -c < $(objcbfs)/bootblock.bin) ;\ |
| 339 | printf "%x:%x" $$offset $$size ;\ |
| 340 | fi ;\ |
| 341 | )) |
| 342 | vboot-gscvd-ranges += $(shell ( \ |
| 343 | line=$$($(CBFSTOOL) $(obj)/coreboot.rom print -k | grep '^bootblock[[:space:]]') ;\ |
| 344 | if [ -n "$$line" ]; then \ |
| 345 | cbfs_start=$$($(call fmap-section-offset-cmd,COREBOOT)) ;\ |
| 346 | offset=$$(printf "$$line" | cut -f2) ;\ |
| 347 | size=$$(printf "$$line" | cut -f6) ;\ |
| 348 | printf "%x:%x" $$((cbfs_start + offset)) $$size ;\ |
| 349 | fi ;\ |
| 350 | )) |
| 351 | files_added:: $(FUTILITY) |
| 352 | @printf " WRITE GSCVD\n" |
| 353 | gscvd_range_args="$(foreach range,$(vboot-gscvd-ranges),-R $(range))" ;\ |
| 354 | if [ -z "$$gscvd_range_args" ]; then \ |
| 355 | echo "ERROR: No valid GSCVD ranges detected in image!" ;\ |
| 356 | exit 1 ;\ |
| 357 | fi ;\ |
| 358 | $(FUTILITY) gscvd -G $$gscvd_range_args -b $(CONFIG_VBOOT_GSC_BOARD_ID) \ |
| 359 | -r "$(CONFIG_VBOOT_GSCVD_ROOT_PUBKEY)" \ |
| 360 | -p "$(CONFIG_VBOOT_GSCVD_PLATFORM_PRIVKEY)" \ |
| 361 | -k "$(CONFIG_VBOOT_GSCVD_PLATFORM_KEYBLOCK)" \ |
| 362 | $(obj)/coreboot.rom |
| 363 | endif |
| 364 | |
Jakub Czapiga | 190afda | 2022-07-25 14:24:06 +0200 | [diff] [blame] | 365 | ifneq (,$(filter y,$(CONFIG_VBOOT_SLOTS_RW_A) $(CONFIG_VBOOT_SLOTS_RW_AB))) |
| 366 | files_added:: $(obj)/coreboot.rom $(FUTILITY) $(CBFSTOOL) |
| 367 | CBFSTOOL="$(CBFSTOOL)" \ |
| 368 | $(FUTILITY) sign \ |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 369 | --signprivate "$(CONFIG_VBOOT_FIRMWARE_PRIVKEY)" \ |
Jakub Czapiga | 190afda | 2022-07-25 14:24:06 +0200 | [diff] [blame] | 370 | --keyblock "$(CONFIG_VBOOT_KEYBLOCK)" \ |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 371 | --kernelkey "$(CONFIG_VBOOT_KERNEL_KEY)" \ |
Jakub Czapiga | 190afda | 2022-07-25 14:24:06 +0200 | [diff] [blame] | 372 | --version $(CONFIG_VBOOT_KEYBLOCK_VERSION) \ |
| 373 | --flags $(CONFIG_VBOOT_KEYBLOCK_PREAMBLE_FLAGS) \ |
| 374 | $(obj)/coreboot.rom |
| 375 | if [ "$(CONFIG_VBOOT_SLOTS_RW_AB)" = 'y' ]; then \ |
| 376 | printf " FLASHMAP Layout generated for RO, A and B partition.\n"; \ |
| 377 | elif [ "$(CONFIG_VBOOT_SLOTS_RW_A)" = 'y' ]; then \ |
| 378 | printf " FLASHMAP Layout generated for RO and A partition.\n"; \ |
| 379 | fi |
Philipp Deppenwiese | a558ca9 | 2018-07-28 23:30:49 +0200 | [diff] [blame] | 380 | else |
| 381 | files_added:: |
| 382 | @printf " FLASHMAP Layout generated for RO partition only.\n" |
| 383 | @printf " Beware that there is no failure safety in case of update now!\n" |
| 384 | endif |
Julius Werner | 58c3938 | 2017-02-13 17:53:29 -0800 | [diff] [blame] | 385 | |
Furquan Shaikh | 0325dc6 | 2016-07-25 13:02:36 -0700 | [diff] [blame] | 386 | endif # CONFIG_VBOOT |