Skip to content

Commit 83ae553

Browse files
committed
Makefile.mk: redundant bootblock init WIP
Signed-off-by: Filip Lewiński <filip.lewinski@3mdeb.com>
1 parent 4eed42d commit 83ae553

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

Makefile.mk

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ subdirs-y += util/checklist util/testing
127127
#######################################################################
128128
# Add source classes and their build options
129129
classes-y := ramstage romstage bootblock decompressor postcar smm smmstub cpu_microcode verstage
130+
# when building redundant bootblock, we create a second class alias for Slot B
131+
ifeq ($(CONFIG_REDUNDANT_BOOTBLOCK),y)
132+
classes-y += bootblock_b
133+
endif
130134

131135
# Add a special 'all' class to add sources to all stages
132136
$(call add-special-class,all)
@@ -218,6 +222,11 @@ ramstage-postprocess=$$(eval DEPENDENCIES+=$$(addsuffix .d,$$(basename $(1)))) \
218222

219223
decompressor-generic-ccopts += -D__DECOMPRESSOR__
220224
bootblock-generic-ccopts += -D__BOOTBLOCK__
225+
bootblock_b-generic-ccopts += -D__BOOTBLOCK__
226+
ifeq ($(CONFIG_BOOTBLOCK_SLOT_VARIANTS),y)
227+
bootblock-generic-ccopts += -DSLOT_A
228+
bootblock_b-generic-ccopts += -DSLOT_B
229+
endif
221230
romstage-generic-ccopts += -D__ROMSTAGE__
222231
ramstage-generic-ccopts += -D__RAMSTAGE__
223232
ifeq ($(CONFIG_COVERAGE),y)
@@ -834,6 +843,13 @@ verstage-y += $(CONFIG_MEMLAYOUT_LD_FILE)
834843
postcar-y += $(CONFIG_MEMLAYOUT_LD_FILE)
835844
decompressor-y += $(CONFIG_MEMLAYOUT_LD_FILE)
836845

846+
# Make bootblock_b sources mirror bootblock (alias)
847+
ifeq ($(CONFIG_REDUNDANT_BOOTBLOCK),y)
848+
bootblock_b-y += $(bootblock-y)
849+
bootblock_b-c-deps += $(bootblock-c-deps)
850+
bootblock_b-c-gen-deps += $(bootblock-c-gen-deps)
851+
endif
852+
837853
#######################################################################
838854
# Clean up rules
839855
clean-abuild:
@@ -922,26 +938,56 @@ $(objcbfs)/bootblock.raw.elf: $(objcbfs)/decompressor.elf
922938
@printf " OBJCOPY $(notdir $(@))\n"
923939
$(OBJCOPY_bootblock) $(preserve-bss-flags) $< $@
924940

941+
ifeq ($(CONFIG_REDUNDANT_BOOTBLOCK),y)
942+
$(objcbfs)/bootblock_b.raw.elf: $(objcbfs)/decompressor.elf
943+
@printf " OBJCOPY $(notdir $(@))\n"
944+
$(OBJCOPY_bootblock_b) $(preserve-bss-flags) $< $@
945+
endif
946+
925947
else # CONFIG_COMPRESS_BOOTBLOCK
926948

927949
$(objcbfs)/bootblock.raw.elf: $(objcbfs)/bootblock.elf
928950
@printf " OBJCOPY $(notdir $(@))\n"
929951
$(OBJCOPY_bootblock) $(preserve-bss-flags) $< $@
930952

953+
ifeq ($(CONFIG_REDUNDANT_BOOTBLOCK),y)
954+
$(objcbfs)/bootblock_b.raw.elf: $(objcbfs)/bootblock_b.elf
955+
@printf " OBJCOPY $(notdir $(@))\n"
956+
$(OBJCOPY_bootblock_b) $(preserve-bss-flags) $< $@
957+
endif
958+
931959
endif # CONFIG_COMPRESS_BOOTBLOCK
932960

933961
$(objcbfs)/bootblock.raw.bin: $(objcbfs)/bootblock.raw.elf
934962
@printf " OBJCOPY $(notdir $(@))\n"
935963
$(OBJCOPY_bootblock) -O binary $< $@
936964

965+
ifeq ($(CONFIG_REDUNDANT_BOOTBLOCK),y)
966+
$(objcbfs)/bootblock_b.raw.bin: $(objcbfs)/bootblock_b.raw.elf
967+
@printf " OBJCOPY $(notdir $(@))\n"
968+
$(OBJCOPY_bootblock_b) -O binary $< $@
969+
endif
970+
937971
ifneq ($(CONFIG_HAVE_BOOTBLOCK),y)
938972
$(objcbfs)/bootblock.bin:
939973
dd if=/dev/zero of=$@ bs=64 count=1
974+
ifeq ($(CONFIG_REDUNDANT_BOOTBLOCK),y)
975+
$(objcbfs)/bootblock_b.bin:
976+
dd if=/dev/zero of=$@ bs=64 count=1
977+
endif
940978
endif
941979

942980
$(objcbfs)/%.bin: $(objcbfs)/%.raw.bin
943981
cp $< $@
944982

983+
ifeq ($(CONFIG_REDUNDANT_BOOTBLOCK),y)
984+
# If not building slot-specific variants, Slot B is a copy of Slot A
985+
ifeq ($(CONFIG_BOOTBLOCK_SLOT_VARIANTS),)
986+
$(objcbfs)/bootblock_b.bin: $(objcbfs)/bootblock.bin
987+
cp $< $@
988+
endif
989+
endif
990+
945991
$(objcbfs)/%.map: $(objcbfs)/%.debug
946992
$(eval class := $(call find-class,$(@F)))
947993
$(NM_$(class)) -n $< | sort > $(basename $@).map
@@ -1301,10 +1347,15 @@ endif
13011347
$(shell rm -f $(obj)/coreboot.pre)
13021348

13031349
ifneq ($(CONFIG_UPDATE_IMAGE),y)
1304-
$(obj)/coreboot.pre: $$(prebuilt-files) $(CBFSTOOL) $(obj)/fmap.fmap $(obj)/fmap.desc $(objcbfs)/bootblock.bin
1350+
$(obj)/coreboot.pre: $$(prebuilt-files) $(CBFSTOOL) $(obj)/fmap.fmap $(obj)/fmap.desc $(objcbfs)/bootblock.bin \
1351+
$(if $(CONFIG_REDUNDANT_BOOTBLOCK),$(objcbfs)/bootblock_b.bin)
13051352
$(CBFSTOOL) $@.tmp create -M $(obj)/fmap.fmap -r $(shell cat $(obj)/fmap.desc)
13061353
printf " BOOTBLOCK\n"
13071354
$(call add_bootblock,$@.tmp,$(objcbfs)/bootblock.bin)
1355+
ifneq ($(CONFIG_REDUNDANT_BOOTBLOCK),)
1356+
printf " TOPSWAP BB\n"
1357+
$(call add_bootblock_region,$@.tmp,$(objcbfs)/bootblock_b.bin,TOPSWAP)
1358+
endif
13081359
$(prebuild-files) true
13091360
mv $@.tmp $@
13101361
else # ifneq ($(CONFIG_UPDATE_IMAGE),y)

src/Kconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,23 @@ config CCACHE
116116

117117
For details see https://ccache.samba.org.
118118

119+
config REDUNDANT_BOOTBLOCK
120+
bool "Build redundant bootblock (Slot A + Slot B)"
121+
default y
122+
help
123+
Build two bootblock binaries and place them into FMAP regions
124+
BOOTBLOCK (Slot A) and TOPSWAP (Slot B). Required for Intel Top Swap
125+
based redundancy. Logic to choose a slot is out of scope here.
126+
127+
config BOOTBLOCK_SLOT_VARIANTS
128+
bool "Compile bootblock per-slot with distinct defines"
129+
depends on REDUNDANT_BOOTBLOCK
130+
default n
131+
help
132+
If enabled, bootblock for Slot A and Slot B is compiled separately with
133+
-DSLOT_A or -DSLOT_B so later slot-specific logic can be added.
134+
If disabled, Slot B is a byte-for-byte copy of Slot A.
135+
119136
config LTO
120137
bool "Use link time optimization (LTO) (experimental)"
121138
default n

0 commit comments

Comments
 (0)