Stefan Reinauer | 9aea04a | 2012-03-30 12:01:06 -0700 | [diff] [blame] | 1 | ## |
| 2 | ## This file is part of the coreboot project. |
| 3 | ## |
| 4 | ## Copyright (C) 2011 The ChromiumOS Authors. All rights reserved. |
| 5 | ## |
| 6 | ## This program is free software; you can redistribute it and/or modify |
| 7 | ## it under the terms of the GNU General Public License as published by |
| 8 | ## the Free Software Foundation; version 2 of the License. |
| 9 | ## |
| 10 | ## This program is distributed in the hope that it will be useful, |
| 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | ## GNU General Public License for more details. |
| 14 | ## |
Stefan Reinauer | 9aea04a | 2012-03-30 12:01:06 -0700 | [diff] [blame] | 15 | |
Daisuke Nojiri | 54af625 | 2014-11-04 12:32:29 -0800 | [diff] [blame] | 16 | bootblock-y += chromeos.c |
| 17 | verstage-y += chromeos.c |
| 18 | romstage-y += chromeos.c |
| 19 | ramstage-y += chromeos.c |
| 20 | |
David Hendricks | 739e6a8 | 2014-05-13 20:28:49 -0700 | [diff] [blame] | 21 | ramstage-$(CONFIG_ELOG) += elog.c |
Furquan Shaikh | aed887f | 2014-11-08 17:32:38 -0800 | [diff] [blame] | 22 | ramstage-$(CONFIG_HAVE_ACPI_TABLES) += gnvs.c |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 23 | ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c |
Aaron Durbin | 06ece7d | 2014-02-14 00:30:04 -0600 | [diff] [blame] | 24 | ramstage-$(CONFIG_CHROMEOS_RAMOOPS) += ramoops.c |
Hung-Te Lin | b15a0d0 | 2015-07-13 15:49:57 +0800 | [diff] [blame] | 25 | romstage-y += vpd_decode.c |
Stephen Barber | b396a66 | 2015-03-11 15:53:10 -0700 | [diff] [blame] | 26 | ramstage-y += vpd_decode.c cros_vpd.c vpd_mac.c vpd_serialno.c vpd_calibration.c |
Felix Durairaj | 5d935b3 | 2015-11-20 16:18:42 -0800 | [diff] [blame] | 27 | ramstage-$(CONFIG_HAVE_REGULATORY_DOMAIN) += wrdd.c |
Robbie Zhang | ed84002 | 2016-12-23 11:43:07 -0800 | [diff] [blame] | 28 | ramstage-$(CONFIG_USE_SAR) += sar.c |
Furquan Shaikh | 0d9cd92 | 2016-07-25 17:00:07 -0700 | [diff] [blame] | 29 | ifeq ($(CONFIG_ARCH_MIPS),) |
Julius Werner | 105f5b7 | 2015-01-21 17:39:49 -0800 | [diff] [blame] | 30 | bootblock-y += watchdog.c |
| 31 | ramstage-y += watchdog.c |
| 32 | endif |
Aaron Durbin | fd79562 | 2013-03-01 17:12:26 -0600 | [diff] [blame] | 33 | |
Aaron Durbin | 0703ec4 | 2013-03-27 00:16:11 -0500 | [diff] [blame] | 34 | ifeq ($(MOCK_TPM),1) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 35 | CFLAGS_common += -DMOCK_TPM=1 |
Aaron Durbin | 0703ec4 | 2013-03-27 00:16:11 -0500 | [diff] [blame] | 36 | else |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 37 | CFLAGS_common += -DMOCK_TPM=0 |
Aaron Durbin | 0703ec4 | 2013-03-27 00:16:11 -0500 | [diff] [blame] | 38 | endif |
| 39 | |
Patrick Georgi | 0db0e61 | 2016-02-02 14:43:56 +0100 | [diff] [blame] | 40 | CONFIG_GBB_HWID := $(call strip_quotes,$(CONFIG_GBB_HWID)) |
| 41 | CONFIG_GBB_BMPFV_FILE := $(call strip_quotes,$(CONFIG_GBB_BMPFV_FILE)) |
Patrick Georgi | 71ea717 | 2016-02-02 17:52:09 +0100 | [diff] [blame] | 42 | CONFIG_VBOOT_KEYBLOCK := $(call strip_quotes,$(CONFIG_VBOOT_KEYBLOCK)) |
| 43 | CONFIG_VBOOT_FIRMWARE_PRIVKEY := $(call strip_quotes,$(CONFIG_VBOOT_FIRMWARE_PRIVKEY)) |
| 44 | CONFIG_VBOOT_KERNEL_KEY := $(call strip_quotes,$(CONFIG_VBOOT_KERNEL_KEY)) |
Patrick Georgi | 4399b85 | 2016-12-06 21:59:23 +0100 | [diff] [blame] | 45 | CONFIG_CHROMEOS_FWID_MODEL := $(call strip_quotes,$(CONFIG_CHROMEOS_FWID_MODEL)) |
| 46 | CONFIG_CHROMEOS_FWID_VERSION := $(call strip_quotes,$(CONFIG_CHROMEOS_FWID_VERSION)) |
Patrick Georgi | 0db0e61 | 2016-02-02 14:43:56 +0100 | [diff] [blame] | 47 | |
Patrick Georgi | 5ea87ff | 2016-02-02 15:05:57 +0100 | [diff] [blame] | 48 | # bool-to-mask(var, value) |
| 49 | # return "value" if var is "y", 0 otherwise |
| 50 | bool-to-mask = $(if $(filter y,$(1)),$(2),0) |
| 51 | |
| 52 | GBB_FLAGS := $(call int-add, \ |
| 53 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_DEV_SCREEN_SHORT_DELAY),0x1) \ |
| 54 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_LOAD_OPTION_ROMS),0x2) \ |
| 55 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_ENABLE_ALTERNATE_OS),0x4) \ |
| 56 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_FORCE_DEV_SWITCH_ON),0x8) \ |
| 57 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_FORCE_DEV_BOOT_USB),0x10) \ |
| 58 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_DISABLE_FW_ROLLBACK_CHECK),0x20) \ |
| 59 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_ENTER_TRIGGERS_TONORM),0x40) \ |
| 60 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_FORCE_DEV_BOOT_LEGACY),0x80) \ |
| 61 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_FAFT_KEY_OVERIDE),0x100) \ |
| 62 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC),0x200) \ |
| 63 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY),0x400) \ |
| 64 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC),0x800) \ |
| 65 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_DISABLE_LID_SHUTDOWN),0x1000) \ |
Patrick Georgi | 85cc5fd | 2016-03-31 12:34:32 +0200 | [diff] [blame] | 66 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP),0x2000) \ |
| 67 | $(call bool-to-mask,$(CONFIG_GBB_FLAG_ENABLE_SERIAL),0x4000) \ |
| 68 | ) |
Patrick Georgi | 5ea87ff | 2016-02-02 15:05:57 +0100 | [diff] [blame] | 69 | |
Patrick Georgi | 0db0e61 | 2016-02-02 14:43:56 +0100 | [diff] [blame] | 70 | ifneq ($(CONFIG_GBB_BMPFV_FILE),) |
Patrick Georgi | fcc4347 | 2016-03-31 13:08:42 +0200 | [diff] [blame] | 71 | $(obj)/gbb.sizetmp: $(obj)/coreboot.rom |
| 72 | $(CBFSTOOL) $< read -r GBB -f $@ |
| 73 | |
| 74 | $(obj)/gbb.stub: $(obj)/coreboot.rom $(FUTILITY) $(obj)/gbb.sizetmp |
Patrick Georgi | 0db0e61 | 2016-02-02 14:43:56 +0100 | [diff] [blame] | 75 | @printf " CREATE GBB (with BMPFV)\n" |
Patrick Georgi | fcc4347 | 2016-03-31 13:08:42 +0200 | [diff] [blame] | 76 | $(FUTILITY) gbb_utility -c 0x100,0x1000,$(call int-subtract,$(call file-size,$(obj)/gbb.sizetmp) 0x2180),0x1000 $@.tmp |
Patrick Georgi | 0db0e61 | 2016-02-02 14:43:56 +0100 | [diff] [blame] | 77 | mv $@.tmp $@ |
| 78 | else |
| 79 | $(obj)/gbb.stub: $(obj)/coreboot.rom $(FUTILITY) |
| 80 | @printf " CREATE GBB (without BMPFV)\n" |
| 81 | $(FUTILITY) gbb_utility -c 0x100,0x1000,0,0x1000 $@.tmp |
| 82 | mv $@.tmp $@ |
| 83 | endif |
| 84 | |
| 85 | $(obj)/gbb.region: $(obj)/gbb.stub |
| 86 | @printf " SETUP GBB\n" |
| 87 | cp $< $@.tmp |
| 88 | $(FUTILITY) gbb_utility -s \ |
| 89 | --hwid="$(CONFIG_GBB_HWID)" \ |
| 90 | --rootkey="$(CONFIG_VBOOT_ROOT_KEY)" \ |
| 91 | --recoverykey="$(CONFIG_VBOOT_RECOVERY_KEY)" \ |
Patrick Georgi | 5ea87ff | 2016-02-02 15:05:57 +0100 | [diff] [blame] | 92 | --flags=$(GBB_FLAGS) \ |
Patrick Georgi | 0db0e61 | 2016-02-02 14:43:56 +0100 | [diff] [blame] | 93 | $@.tmp |
Patrick Georgi | fcc4347 | 2016-03-31 13:08:42 +0200 | [diff] [blame] | 94 | ifneq ($(CONFIG_GBB_BMPFV_FILE),) |
| 95 | $(FUTILITY) gbb_utility -s \ |
| 96 | --bmpfv="$(CONFIG_GBB_BMPFV_FILE)" \ |
| 97 | $@.tmp |
| 98 | endif |
Patrick Georgi | 0db0e61 | 2016-02-02 14:43:56 +0100 | [diff] [blame] | 99 | mv $@.tmp $@ |
| 100 | |
Patrick Georgi | 4399b85 | 2016-12-06 21:59:23 +0100 | [diff] [blame] | 101 | $(obj)/fwid.region: |
| 102 | printf "$(CONFIG_CHROMEOS_FWID_MODEL)$(CONFIG_CHROMEOS_FWID_VERSION)\0" > $@ |
| 103 | |
| 104 | build_complete:: $(obj)/gbb.region $(obj)/fwid.region |
Patrick Georgi | 0db0e61 | 2016-02-02 14:43:56 +0100 | [diff] [blame] | 105 | @printf " WRITE GBB\n" |
Patrick Georgi | 4399b85 | 2016-12-06 21:59:23 +0100 | [diff] [blame] | 106 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r GBB -i 0 -f $(obj)/gbb.region |
| 107 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r RO_FRID -i 0 -f $(obj)/fwid.region |
| 108 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r RW_FWID_A -i 0 -f $(obj)/fwid.region |
| 109 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r RW_FWID_B -i 0 -f $(obj)/fwid.region |
Patrick Georgi | 71ea717 | 2016-02-02 17:52:09 +0100 | [diff] [blame] | 110 | |
Patrick Georgi | 0803ba4 | 2016-12-07 12:12:59 +0100 | [diff] [blame] | 111 | ifneq ($(shell grep "SHARED_DATA" "$(CONFIG_FMDFILE)"),) |
| 112 | build_complete:: |
| 113 | printf "\0" > $(obj)/shared_data.region |
| 114 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r SHARED_DATA -i 0 -f $(obj)/shared_data.region |
| 115 | endif |
| 116 | |
Patrick Georgi | 71ea717 | 2016-02-02 17:52:09 +0100 | [diff] [blame] | 117 | # Extract FW_MAIN_? region and minimize it if the last file is empty, so it |
| 118 | # doesn't contain this empty file (that can have a significant size), |
| 119 | # improving a lot on hash times due to a smaller amount of data loaded from |
| 120 | # firmware storage. |
| 121 | # When passing the minimized image to vbutil_firmware, its length is recorded |
| 122 | # in the keyblock, and coreboot's vboot code clips the region_device to match, |
| 123 | # which prevents any potential extension attacks. |
| 124 | $(obj)/FW_MAIN_%.bin: $(obj)/coreboot.rom |
| 125 | $(CBFSTOOL) $< read -r $(basename $(notdir $@)) -f $@.tmp |
| 126 | $(CBFSTOOL) $(obj)/coreboot.rom print -k -r $(basename $(notdir $@)) | \ |
| 127 | tail -1 | \ |
| 128 | sed "s,^(empty)[[:space:]]\(0x[0-9a-f]*\)\tnull\t.*$$,\1," \ |
| 129 | > $@.tmp.size |
Paul Kocialkowski | 36d7418 | 2016-04-22 11:10:03 +0200 | [diff] [blame] | 130 | if [ -n "$$(cat $@.tmp.size)" ] && [ $$( printf "%d" $$(cat $@.tmp.size)) -gt 0 ]; then \ |
Patrick Georgi | 71ea717 | 2016-02-02 17:52:09 +0100 | [diff] [blame] | 131 | head -c $$( printf "%d" $$(cat $@.tmp.size)) $@.tmp > $@.tmp2 && \ |
| 132 | mv $@.tmp2 $@; \ |
| 133 | else \ |
| 134 | mv $@.tmp $@; \ |
| 135 | fi |
| 136 | |
| 137 | $(obj)/VBLOCK_%.bin: $(obj)/FW_MAIN_%.bin $(FUTILITY) |
| 138 | $(FUTILITY) vbutil_firmware \ |
| 139 | --vblock $@ \ |
| 140 | --keyblock "$(CONFIG_VBOOT_KEYBLOCK)" \ |
| 141 | --signprivate "$(CONFIG_VBOOT_FIRMWARE_PRIVKEY)" \ |
| 142 | --version $(CONFIG_VBOOT_KEYBLOCK_VERSION) \ |
| 143 | --fv $< \ |
| 144 | --kernelkey "$(CONFIG_VBOOT_KERNEL_KEY)" \ |
| 145 | --flags $(CONFIG_VBOOT_KEYBLOCK_PREAMBLE_FLAGS) |
| 146 | |
Paul Kocialkowski | 580db7f | 2016-07-12 00:29:37 +0200 | [diff] [blame] | 147 | $(obj)/RO_FRID.bin: $(obj)/coreboot.rom |
| 148 | $(CBFSTOOL) $(obj)/coreboot.rom read -r $(basename $(notdir $@)) -f $@ |
| 149 | printf $(KERNELVERSION) > $@.tmp |
| 150 | objcopy -I binary -O binary --pad-to=$$( stat --printf="%s" $@ ) --gap-fill=0 $@.tmp $@ |
| 151 | |
| 152 | $(obj)/RW_FWID_%.bin: $(obj)/coreboot.rom |
| 153 | $(CBFSTOOL) $(obj)/coreboot.rom read -r $(basename $(notdir $@)) -f $@ |
| 154 | printf $(KERNELVERSION) > $@.tmp |
| 155 | objcopy -I binary -O binary --pad-to=$$( stat --printf="%s" $@ ) --gap-fill=0 $@.tmp $@ |
| 156 | |
| 157 | files_added:: $(obj)/VBLOCK_A.bin $(obj)/VBLOCK_B.bin $(obj)/RO_FRID.bin $(obj)/RW_FWID_A.bin $(obj)/RW_FWID_B.bin |
Patrick Georgi | 71ea717 | 2016-02-02 17:52:09 +0100 | [diff] [blame] | 158 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r VBLOCK_A -f $(obj)/VBLOCK_A.bin |
| 159 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r VBLOCK_B -f $(obj)/VBLOCK_B.bin |
Paul Kocialkowski | 580db7f | 2016-07-12 00:29:37 +0200 | [diff] [blame] | 160 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r RO_FRID -f $(obj)/RO_FRID.bin |
| 161 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r RW_FWID_A -f $(obj)/RW_FWID_A.bin |
| 162 | $(CBFSTOOL) $(obj)/coreboot.rom write -u -r RW_FWID_B -f $(obj)/RW_FWID_B.bin |