@@ -127,6 +127,10 @@ subdirs-y += util/checklist util/testing
127127# ######################################################################
128128# Add source classes and their build options
129129classes-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
219223decompressor-generic-ccopts += -D__DECOMPRESSOR__
220224bootblock-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
221230romstage-generic-ccopts += -D__ROMSTAGE__
222231ramstage-generic-ccopts += -D__RAMSTAGE__
223232ifeq ($(CONFIG_COVERAGE ) ,y)
@@ -834,6 +843,13 @@ verstage-y += $(CONFIG_MEMLAYOUT_LD_FILE)
834843postcar-y += $(CONFIG_MEMLAYOUT_LD_FILE )
835844decompressor-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
839855clean-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+
925947else # 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+
931959endif # 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+
937971ifneq ($(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
940978endif
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
13031349ifneq ($(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 $@
13101361else # ifneq ($(CONFIG_UPDATE_IMAGE),y)
0 commit comments