coreboot-gerrit
Threads by month
- ----- 2025 -----
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
June 2020
- 1 participants
- 2826 discussions

Change in coreboot[master]: arch,toolchain,xcompile: Use GCC as linker
by Jacob Garber (Code Review) April 4, 2024
by Jacob Garber (Code Review) April 4, 2024
April 4, 2024
Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/40811 )
Change subject: arch,toolchain,xcompile: Use GCC as linker
......................................................................
arch,toolchain,xcompile: Use GCC as linker
Code generation when using LTO is not done until after linking, so the
compiler must be invoked at all linking stages instead of the linker.
Replace $(LD) with GCC, and prefix all linker-specific flags with -Wl so
they will be passed to the linker.
Change-Id: Ia551cf84c8f6eb3b010450fc572876a318a257d1
Signed-off-by: Jacob Garber <jgarber1(a)ualberta.ca>
---
M Makefile.inc
M src/arch/arm/Makefile.inc
M src/arch/arm64/Makefile.inc
M src/arch/ppc64/Makefile.inc
M src/arch/riscv/Makefile.inc
M src/arch/x86/Makefile.inc
M src/cpu/x86/smm/Makefile.inc
M src/lib/Makefile.inc
M toolchain.inc
M util/xcompile/xcompile
10 files changed, 33 insertions(+), 33 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/11/40811/1
diff --git a/Makefile.inc b/Makefile.inc
index e315732..ef95870 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -479,7 +479,7 @@
# Disable style checks for now
ADAFLAGS_common += -gnatyN
-LDFLAGS_common := --gc-sections -nostdlib -nostartfiles -static --emit-relocs
+LDFLAGS_common := -nostdlib -nostartfiles -static -Wl,--emit-relocs,--gc-sections
ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y)
CFLAGS_common += -Werror
diff --git a/src/arch/arm/Makefile.inc b/src/arch/arm/Makefile.inc
index a8abfaf..f13bf1e 100644
--- a/src/arch/arm/Makefile.inc
+++ b/src/arch/arm/Makefile.inc
@@ -54,11 +54,11 @@
$(objcbfs)/bootblock.debug: $$(bootblock-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) -T $(call src-to-obj,bootblock,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) --end-group
+ $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) -T $(call src-to-obj,bootblock,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(bootblock-objs)) -Wl,--end-group
$(objcbfs)/decompressor.debug: $$(decompressor-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) -T $(call src-to-obj,decompressor,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(decompressor-objs)) --end-group
+ $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) -T $(call src-to-obj,decompressor,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(decompressor-objs)) -Wl,--end-group
endif # CONFIG_ARCH_BOOTBLOCK_ARM
@@ -70,7 +70,7 @@
$(objcbfs)/verstage.debug: $$(verstage-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_verstage) $(LDFLAGS_verstage) -o $@ -L$(obj) -T $(call src-to-obj,verstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(verstage-objs)) --end-group
+ $(LD_verstage) $(LDFLAGS_verstage) -o $@ -L$(obj) -T $(call src-to-obj,verstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(verstage-objs)) -Wl,--end-group
verstage-y += boot.c
verstage-y += div0.c
@@ -103,7 +103,7 @@
$(objcbfs)/romstage.debug: $$(romstage-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group
+ $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(romstage-objs)) -Wl,--end-group
endif # CONFIG_ARCH_ROMSTAGE_ARM
@@ -132,6 +132,6 @@
$(objcbfs)/ramstage.debug: $$(ramstage-objs)
@printf " CC $(subst $(obj)/,,$(@))\n"
- $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group
+ $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(ramstage-objs)) -Wl,--end-group
endif # CONFIG_ARCH_RAMSTAGE_ARM
diff --git a/src/arch/arm64/Makefile.inc b/src/arch/arm64/Makefile.inc
index c3d1fe5..e9d6d05 100644
--- a/src/arch/arm64/Makefile.inc
+++ b/src/arch/arm64/Makefile.inc
@@ -50,11 +50,11 @@
$(objcbfs)/bootblock.debug: $$(bootblock-objs) $(obj)/config.h
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) --end-group -T $(call src-to-obj,bootblock,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
+ $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(bootblock-objs)) -Wl,--end-group -T $(call src-to-obj,bootblock,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
$(objcbfs)/decompressor.debug: $$(decompressor-objs) $(obj)/config.h
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(decompressor-objs)) --end-group -T $(call src-to-obj,decompressor,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
+ $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(decompressor-objs)) -Wl,--end-group -T $(call src-to-obj,decompressor,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
endif # CONFIG_ARCH_BOOTBLOCK_ARM64
@@ -66,7 +66,7 @@
$(objcbfs)/verstage.debug: $$(verstage-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_verstage) $(LDFLAGS_verstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(verstage-objs)) --end-group -T $(call src-to-obj,verstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
+ $(LD_verstage) $(LDFLAGS_verstage) -o $@ -L$(obj) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(verstage-objs)) -Wl,--end-group -T $(call src-to-obj,verstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
verstage-y += boot.c
verstage-y += div0.c
@@ -104,7 +104,7 @@
$(objcbfs)/romstage.debug: $$(romstage-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group -T $(call src-to-obj,romstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
+ $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(romstage-objs)) -Wl,--end-group -T $(call src-to-obj,romstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
endif # CONFIG_ARCH_ROMSTAGE_ARM64
@@ -139,7 +139,7 @@
$(objcbfs)/ramstage.debug: $$(ramstage-objs)
@printf " CC $(subst $(obj)/,,$(@))\n"
- $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group -T $(call src-to-obj,ramstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
+ $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(ramstage-objs)) -Wl,--end-group -T $(call src-to-obj,ramstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
# Build ARM Trusted Firmware (BL31)
diff --git a/src/arch/ppc64/Makefile.inc b/src/arch/ppc64/Makefile.inc
index 1c35f6f..b8da940 100644
--- a/src/arch/ppc64/Makefile.inc
+++ b/src/arch/ppc64/Makefile.inc
@@ -29,8 +29,8 @@
$(objcbfs)/bootblock.debug: $$(bootblock-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \
- -T $(call src-to-obj,bootblock,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) \
- $(LIBGCC_FILE_NAME_bootblock) --end-group $(COMPILER_RT_bootblock)
+ -T $(call src-to-obj,bootblock,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(bootblock-objs)) \
+ $(LIBGCC_FILE_NAME_bootblock) -Wl,--end-group $(COMPILER_RT_bootblock)
endif
@@ -55,7 +55,7 @@
$(objcbfs)/romstage.debug: $$(romstage-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group $(COMPILER_RT_romstage)
+ $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(romstage-objs)) -Wl,--end-group $(COMPILER_RT_romstage)
romstage-c-ccopts += $(ppc64_flags)
romstage-S-ccopts += $(ppc64_asm_flags)
@@ -88,7 +88,7 @@
$(objcbfs)/ramstage.debug: $$(ramstage-objs)
@printf " CC $(subst $(obj)/,,$(@))\n"
- $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group $(COMPILER_RT_ramstage)
+ $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(ramstage-objs)) -Wl,--end-group $(COMPILER_RT_ramstage)
ramstage-c-ccopts += $(ppc64_flags)
ramstage-S-ccopts += $(ppc64_asm_flags)
diff --git a/src/arch/riscv/Makefile.inc b/src/arch/riscv/Makefile.inc
index 17f225a..fd18e55 100644
--- a/src/arch/riscv/Makefile.inc
+++ b/src/arch/riscv/Makefile.inc
@@ -69,14 +69,14 @@
$(objcbfs)/bootblock.debug: $$(bootblock-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \
- -T $(call src-to-obj,bootblock,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) \
- $(LIBGCC_FILE_NAME_bootblock) --end-group $(COMPILER_RT_bootblock)
+ -T $(call src-to-obj,bootblock,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(bootblock-objs)) \
+ $(LIBGCC_FILE_NAME_bootblock) -Wl,--end-group $(COMPILER_RT_bootblock)
bootblock-c-ccopts += $(riscv_flags)
bootblock-S-ccopts += $(riscv_asm_flags)
ifeq ($(CONFIG_ARCH_RISCV_RV32),y)
-LDFLAGS_bootblock += -m elf32lriscv
+LDFLAGS_bootblock += -Wl,-m,elf32lriscv
endif #CONFIG_ARCH_RISCV_RV32
endif #CONFIG_ARCH_BOOTBLOCK_RISCV
@@ -104,13 +104,13 @@
$(objcbfs)/romstage.debug: $$(romstage-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group $(COMPILER_RT_romstage)
+ $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(romstage-objs)) -Wl,--end-group $(COMPILER_RT_romstage)
romstage-c-ccopts += $(riscv_flags)
romstage-S-ccopts += $(riscv_asm_flags)
ifeq ($(CONFIG_ARCH_RISCV_RV32),y)
-LDFLAGS_romstage += -m elf32lriscv
+LDFLAGS_romstage += -Wl,-m,elf32lriscv
endif #CONFIG_ARCH_RISCV_RV32
endif #CONFIG_ARCH_ROMSTAGE_RISCV
@@ -153,13 +153,13 @@
$(objcbfs)/ramstage.debug: $$(ramstage-objs)
@printf " CC $(subst $(obj)/,,$(@))\n"
- $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group $(COMPILER_RT_ramstage)
+ $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(ramstage-objs)) -Wl,--end-group $(COMPILER_RT_ramstage)
ramstage-c-ccopts += $(riscv_flags)
ramstage-S-ccopts += $(riscv_asm_flags)
ifeq ($(CONFIG_ARCH_RISCV_RV32),y)
-LDFLAGS_ramstage += -m elf32lriscv
+LDFLAGS_ramstage += -Wl,-m,elf32lriscv
endif #CONFIG_ARCH_RISCV_RV32
endif #CONFIG_ARCH_RAMSTAGE_RISCV
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 2d00709..af52f70 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -77,7 +77,7 @@
$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs)
@printf " LINK $$(subst $$(obj)/,,$$(@))\n"
- $$(LD_$(1)) $$(LDFLAGS_$(1)) -o $$@ -L$$(obj) $$(COMPILER_RT_FLAGS_$(1)) --whole-archive --start-group $$(filter-out %.ld,$$($(1)-objs)) $$($(1)-libs) --no-whole-archive $$(COMPILER_RT_$(1)) --end-group -T $(call src-to-obj,$(1),$(dir)/memlayout.ld) --oformat $(2)
+ $$(LD_$(1)) $$(LDFLAGS_$(1)) -o $$@ -L$$(obj) $$(COMPILER_RT_FLAGS_$(1)) -Wl,--whole-archive,--start-group $$(filter-out %.ld,$$($(1)-objs)) $$($(1)-libs) -Wl,--no-whole-archive $$(COMPILER_RT_$(1)) -Wl,--end-group -T $(call src-to-obj,$(1),$(dir)/memlayout.ld) -Wl,--oformat=$(2)
-LANG=C LC_ALL= $$(OBJCOPY_$(1)) --only-section .illegal_globals $$(@) $$(objcbfs)/$(1)_null.offenders >/dev/null 2>&1
if [ -z "$$$$($$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders 2>&1 | grep 'no symbols')" ];then \
echo "Forbidden global variables in $(1):"; \
@@ -209,11 +209,11 @@
postcar-y += postcar.c
postcar-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
-LDFLAGS_postcar += -Map $(objcbfs)/postcar.map
+LDFLAGS_postcar += -Wl,-Map,$(objcbfs)/postcar.map
$(objcbfs)/postcar.debug: $$(postcar-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_postcar) $(LDFLAGS_postcar) -o $@ -L$(obj) $(COMPILER_RT_FLAGS_postcar) --whole-archive --start-group $(filter-out %.ld,$^) --no-whole-archive $(COMPILER_RT_postcar) --end-group -T $(call src-to-obj,postcar,src/arch/x86/memlayout.ld)
+ $(LD_postcar) $(LDFLAGS_postcar) -o $@ -L$(obj) $(COMPILER_RT_FLAGS_postcar) -Wl,--whole-archive,--start-group $(filter-out %.ld,$^) -Wl,--no-whole-archive $(COMPILER_RT_postcar) -Wl,--end-group -T $(call src-to-obj,postcar,src/arch/x86/memlayout.ld)
$(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod
cp $< $@
@@ -314,9 +314,9 @@
$(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs)
@printf " CC $(subst $(obj)/,,$(@))\n"
ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
- $(LD_ramstage) -m elf_i386 -r -o $@ $(COMPILER_RT_FLAGS_ramstage) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) --no-whole-archive $(COMPILER_RT_ramstage) --end-group
+ $(LD_ramstage) -Wl,-m,elf_i386 -r -o $@ $(COMPILER_RT_FLAGS_ramstage) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) -Wl,--no-whole-archive $(COMPILER_RT_ramstage) -Wl,--end-group
else
- $(LD_ramstage) -m elf_x86_64 -r -o $@ $(COMPILER_RT_FLAGS_ramstage) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) --no-whole-archive $(COMPILER_RT_ramstage) --end-group
+ $(LD_ramstage) -Wl,-m,elf_x86_64 -r -o $@ $(COMPILER_RT_FLAGS_ramstage) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) -Wl,--no-whole-archive $(COMPILER_RT_ramstage) -Wl,--end-group
endif
endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64
diff --git a/src/cpu/x86/smm/Makefile.inc b/src/cpu/x86/smm/Makefile.inc
index 11a4e67..2e63fb3 100644
--- a/src/cpu/x86/smm/Makefile.inc
+++ b/src/cpu/x86/smm/Makefile.inc
@@ -26,7 +26,7 @@
smm-c-deps:=$$(OPTION_TABLE_H)
$(obj)/smm/smm.o: $$(smm-objs) $(COMPILER_RT_smm)
- $(LD_smm) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smm) --whole-archive --start-group $(smm-objs) --no-whole-archive $(COMPILER_RT_smm) --end-group
+ $(LD_smm) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smm) -Wl,--whole-archive,--start-group $(smm-objs) -Wl,--no-whole-archive $(COMPILER_RT_smm) -Wl,--end-group
# change to the target path because objcopy will use the path name in its
# ELF symbol names.
@@ -53,7 +53,7 @@
# SMM Stub Module. The stub is used as a trampoline for relocation and normal
# SMM handling.
$(obj)/smmstub/smmstub.o: $$(smmstub-objs) $(COMPILER_RT_smmstub)
- $(LD_smmstub) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smmstub) --whole-archive --start-group $(smmstub-objs) --no-whole-archive $(COMPILER_RT_smmstub) --end-group
+ $(LD_smmstub) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smmstub) -Wl,--whole-archive,--start-group $(smmstub-objs) -Wl,--no-whole-archive $(COMPILER_RT_smmstub) -Wl,--end-group
# Link the SMM stub module with a 0-byte heap.
ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 085f6b2..adcd16a 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -290,7 +290,7 @@
# rmdoule is named $(1).rmod
define rmodule_link
$(strip $(1)): $(strip $(2)) $$(COMPILER_RT_rmodules_$(4)) $(call src-to-obj,rmodules_$(4),src/lib/rmodule.ld) | $$(RMODTOOL)
- $$(LD_rmodules_$(4)) $$(LDFLAGS_rmodules_$(4)) $(RMODULE_LDFLAGS) -T $(call src-to-obj,rmodules_$(4),src/lib/rmodule.ld) --defsym=__heap_size=$(strip $(3)) -o $$@ --whole-archive --start-group $(filter-out %.ld,$(2)) --end-group
+ $$(LD_rmodules_$(4)) $$(LDFLAGS_rmodules_$(4)) $(RMODULE_LDFLAGS) -T $(call src-to-obj,rmodules_$(4),src/lib/rmodule.ld) -Wl,--defsym=__heap_size=$(strip $(3)) -o $$@ -Wl,--whole-archive,--start-group $(filter-out %.ld,$(2)) -Wl,--end-group
$$(NM_rmodules_$(4)) -n $$@ > $$(basename $$(a)).map
endef
diff --git a/toolchain.inc b/toolchain.inc
index 865227b..f52a518 100644
--- a/toolchain.inc
+++ b/toolchain.inc
@@ -117,7 +117,7 @@
$(error Check your .config file for CONFIG_ARCH_$(1)_* settings))
CC_$(1) := $(CC_$(2))
GCC_$(1) := $(GCC_CC_$(2))
-LD_$(1) := $(LD_$(2))
+LD_$(1) := $(CC_$(2))
NM_$(1) := $(NM_$(2))
AR_$(1) := $(AR_$(2))
GNATBIND_$(1) := $(GNATBIND_$(2))
@@ -130,7 +130,7 @@
CPPFLAGS_$(1) = $$(CPPFLAGS_common) $$(CPPFLAGS_$(2)) -D__ARCH_$(2)__
COMPILER_RT_$(1) := $$(COMPILER_RT_$(2))
COMPILER_RT_FLAGS_$(1) := $$(COMPILER_RT_FLAGS_$(2))
-LDFLAGS_$(1) = $$(LDFLAGS_common) $$(LDFLAGS_$(2))
+LDFLAGS_$(1) = $$(CFLAGS_$(1)) $$(LDFLAGS_common) $$(LDFLAGS_$(2))
endef
# define_class: Allows defining any program as dynamic class and compiler tool
diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile
index 18e08a0..5e32120 100755
--- a/util/xcompile/xcompile
+++ b/util/xcompile/xcompile
@@ -363,7 +363,7 @@
TCLIST="i386 x86_64"
TWIDTH="32"
TABI="elf"
- CC_RT_EXTRA_GCC="--wrap __divdi3 --wrap __udivdi3 --wrap __moddi3 --wrap __umoddi3"
+ CC_RT_EXTRA_GCC="-Wl,--wrap=__divdi3,--wrap=__udivdi3,--wrap=__moddi3,--wrap=__umoddi3"
}
arch_config_ppc64() {
--
To view, visit https://review.coreboot.org/c/coreboot/+/40811
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ia551cf84c8f6eb3b010450fc572876a318a257d1
Gerrit-Change-Number: 40811
Gerrit-PatchSet: 1
Gerrit-Owner: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-Reviewer: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-Reviewer: Philipp Hug <philipp(a)hug.cx>
Gerrit-Reviewer: ron minnich <rminnich(a)gmail.com>
Gerrit-MessageType: newchange
10
49

Change in coreboot[master]: WIP: riscv/mb/qemu: fix DRAM probing
by Philipp Hug (Code Review) March 5, 2024
by Philipp Hug (Code Review) March 5, 2024
March 5, 2024
Philipp Hug has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/36486 )
Change subject: WIP: riscv/mb/qemu: fix DRAM probing
......................................................................
WIP: riscv/mb/qemu: fix DRAM probing
Current version of qemu raise an exception when accessing invalid memory.
Modify the probing code to temporary redirect the exception handler like on
ARM platform.
TEST=qemu detects RAM size correctly
Change-Id: I25860f688c7546714f6fdbce8c8f96da6400813c
Signed-off-by: Philipp Hug <philipp(a)hug.cx>
---
M src/arch/riscv/Makefile.inc
M src/arch/riscv/include/arch/exception.h
A src/arch/riscv/ramdetect.c
M src/arch/riscv/trap_handler.c
M src/arch/riscv/trap_util.S
M src/lib/ramdetect.c
6 files changed, 57 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/36486/1
diff --git a/src/arch/riscv/Makefile.inc b/src/arch/riscv/Makefile.inc
index 0039fab..7465a8f 100644
--- a/src/arch/riscv/Makefile.inc
+++ b/src/arch/riscv/Makefile.inc
@@ -101,6 +101,7 @@
romstage-y += stages.c
romstage-y += misc.c
romstage-$(ARCH_RISCV_PMP) += pmp.c
+romstage-y += ramdetect.c
romstage-y += smp.c
romstage-y += \
$(top)/src/lib/memchr.c \
@@ -142,6 +143,7 @@
ramstage-y += virtual_memory.c
ramstage-y += stages.c
ramstage-y += misc.c
+ramstage-y += ramdetect.c
ramstage-y += smp.c
ramstage-y += boot.c
ramstage-y += tables.c
diff --git a/src/arch/riscv/include/arch/exception.h b/src/arch/riscv/include/arch/exception.h
index 6fbbdf0..cdca582 100644
--- a/src/arch/riscv/include/arch/exception.h
+++ b/src/arch/riscv/include/arch/exception.h
@@ -53,7 +53,7 @@
}
void redirect_trap(void);
-void trap_handler(trapframe *tf);
+void default_trap_handler(trapframe *tf);
void handle_supervisor_call(trapframe *tf);
void handle_misaligned(trapframe *tf);
diff --git a/src/arch/riscv/ramdetect.c b/src/arch/riscv/ramdetect.c
new file mode 100644
index 0000000..47153ab
--- /dev/null
+++ b/src/arch/riscv/ramdetect.c
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <arch/exception.h>
+#include <types.h>
+#include <console/console.h>
+#include <device/mmio.h>
+#include <ramdetect.h>
+#include <arch/smp/spinlock.h>
+
+static enum {
+ ABORT_CHECKER_NOT_TRIGGERED,
+ ABORT_CHECKER_TRIGGERED,
+} abort_state = ABORT_CHECKER_NOT_TRIGGERED;
+
+extern void(*trap_handler)(trapframe *tf);
+
+#define insn_size 4
+static void ramcheck_trap_handler(trapframe *tf)
+{
+ printk(BIOS_DEBUG, "TRAP 0x%lx!!!\n", tf->epc);
+ abort_state = ABORT_CHECKER_TRIGGERED;
+
+ /*
+ * skip read instruction.
+ * currenctly hardcoded to 32bit instruction size
+ */
+ write_csr(mepc, read_csr(mepc) + insn_size);
+}
+
+int probe_mb(const uintptr_t dram_start, const uintptr_t size)
+{
+ uintptr_t addr = dram_start + (size * MiB) - sizeof(uint32_t);
+ void *ptr = (void *)addr;
+
+ abort_state = ABORT_CHECKER_NOT_TRIGGERED;
+ trap_handler = ramcheck_trap_handler;
+ barrier();
+ read32(ptr);
+ trap_handler = default_trap_handler;
+ barrier();
+ return abort_state == ABORT_CHECKER_NOT_TRIGGERED;
+}
diff --git a/src/arch/riscv/trap_handler.c b/src/arch/riscv/trap_handler.c
index 6b39fab..1d51268 100644
--- a/src/arch/riscv/trap_handler.c
+++ b/src/arch/riscv/trap_handler.c
@@ -118,7 +118,10 @@
break;
}
}
-void trap_handler(trapframe *tf)
+
+void(*trap_handler)(trapframe *tf) = default_trap_handler;
+
+void default_trap_handler(trapframe *tf)
{
write_csr(mscratch, tf);
if (tf->cause & 0x8000000000000000ULL) {
diff --git a/src/arch/riscv/trap_util.S b/src/arch/riscv/trap_util.S
index 67e917c..93f5afd 100644
--- a/src/arch/riscv/trap_util.S
+++ b/src/arch/riscv/trap_util.S
@@ -120,7 +120,8 @@
save_tf
mv a0, sp
- jal trap_handler
+ ld t0, trap_handler
+ jalr t0
restore_regs
addi sp, sp, MENTRY_FRAME_SIZE
diff --git a/src/lib/ramdetect.c b/src/lib/ramdetect.c
index 2c83092..eaf6190 100644
--- a/src/lib/ramdetect.c
+++ b/src/lib/ramdetect.c
@@ -58,6 +58,8 @@
if (saved_result)
return saved_result;
+ printk(BIOS_DEBUG, "RAMDETECT: Starting\n");
+
/* Find the MSB + 1. */
size_t tmp = probe_size;
do {
--
To view, visit https://review.coreboot.org/c/coreboot/+/36486
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I25860f688c7546714f6fdbce8c8f96da6400813c
Gerrit-Change-Number: 36486
Gerrit-PatchSet: 1
Gerrit-Owner: Philipp Hug <philipp(a)hug.cx>
Gerrit-MessageType: newchange
8
36

Change in coreboot[master]: [TEST] Add support for link time optimization
by Jacob Garber (Code Review) Feb. 22, 2024
by Jacob Garber (Code Review) Feb. 22, 2024
Feb. 22, 2024
Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/38989 )
Change subject: [TEST] Add support for link time optimization
......................................................................
[TEST] Add support for link time optimization
- Code generation is not done until after linking, so the
compiler must be invoked at all linking stages instead of the linker. As
a consequence all linker arguments must be prefixed with -Wl.
- Partial linking is not supported. Instead, object files are collected
into thin archives that are linked instead.
- The dead_code() macro causes linking errors, since dead functions
aren't optimized out until after linking has begun. This macro could be
replaced with the preprocessor if necessary, or just disabled for LTO
builds.
- Wrapping libgcc functions causes a symbol mismatch when using LTO.
Wrapping these functions was originally done to support alternate
regparam values, though AFAICT this isn't used anywhere.
Using LTO leads to a ~10% decrease in stage size for QEMU and ~18% for
the Thinkpad T500, and both targets boot successfully.
Change-Id: I48c31ea8b1b57276125cffdac44c7c16642547ac
Signed-off-by: Jacob Garber <jgarber1(a)ualberta.ca>
---
M Makefile.inc
M src/Kconfig
M src/arch/x86/Makefile.inc
M src/cpu/x86/smm/Makefile.inc
M src/include/assert.h
M src/lib/Makefile.inc
M src/lib/gcc.c
M toolchain.inc
M util/xcompile/xcompile
9 files changed, 42 insertions(+), 24 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/89/38989/1
diff --git a/Makefile.inc b/Makefile.inc
index 1f18726..b85c11b 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -434,6 +434,10 @@
endif
endif
+ifeq ($(CONFIG_LTO),y)
+CFLAGS_common += -flto -fuse-linker-plugin -fno-fat-lto-objects
+endif
+
ADAFLAGS_common += -gnatp
ADAFLAGS_common += -Wuninitialized -Wall -Werror
ADAFLAGS_common += -pipe -g -nostdinc
@@ -478,7 +482,7 @@
# Disable style checks for now
ADAFLAGS_common += -gnatyN
-LDFLAGS_common := --gc-sections -nostdlib -nostartfiles -static --emit-relocs
+LDFLAGS_common := -nostdlib -nostartfiles -static -Wl,--emit-relocs,--gc-sections
ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y)
CFLAGS_common += -Werror
diff --git a/src/Kconfig b/src/Kconfig
index f75f942..4b81818 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -116,6 +116,15 @@
For details see https://ccache.samba.org.
+config LTO
+ bool "Use link time optimization"
+ # Enable now for testing
+ default y
+ depends on COMPILER_GCC
+ help
+ Compile with link time optimization. This can often decrease the
+ final binary size, but may increase compilation time.
+
config FMD_GENPARSER
bool "Generate flashmap descriptor parser using flex and bison"
default n
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 534f2ce..75f96d2 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -80,7 +80,7 @@
$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs)
@printf " LINK $$(subst $$(obj)/,,$$(@))\n"
- $$(LD_$(1)) $$(LDFLAGS_$(1)) -o $$@ -L$$(obj) $$(COMPILER_RT_FLAGS_$(1)) --whole-archive --start-group $$(filter-out %.ld,$$($(1)-objs)) $$($(1)-libs) --no-whole-archive $$(COMPILER_RT_$(1)) --end-group -T $(call src-to-obj,$(1),$(dir)/memlayout.ld) --oformat $(2)
+ $$(LD_$(1)) $$(LDFLAGS_$(1)) -o $$@ -L$$(obj) $$(COMPILER_RT_FLAGS_$(1)) -Wl,--whole-archive,--start-group $$(filter-out %.ld,$$($(1)-objs)) $$($(1)-libs) -Wl,--no-whole-archive $$(COMPILER_RT_$(1)) -Wl,--end-group -T $(call src-to-obj,$(1),$(dir)/memlayout.ld) -Wl,--oformat=$(2)
-LANG=C LC_ALL= $$(OBJCOPY_$(1)) --only-section .illegal_globals $$(@) $$(objcbfs)/$(1)_null.offenders >/dev/null 2>&1
if [ -z "$$$$($$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders 2>&1 | grep 'no symbols')" ];then \
echo "Forbidden global variables in $(1):"; \
@@ -212,11 +212,11 @@
postcar-y += postcar.c
postcar-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
-LDFLAGS_postcar += -Map $(objcbfs)/postcar.map
+LDFLAGS_postcar += -Wl,-Map,$(objcbfs)/postcar.map
$(objcbfs)/postcar.debug: $$(postcar-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_postcar) $(LDFLAGS_postcar) -o $@ -L$(obj) $(COMPILER_RT_FLAGS_postcar) --whole-archive --start-group $(filter-out %.ld,$^) --no-whole-archive $(COMPILER_RT_postcar) --end-group -T $(call src-to-obj,postcar,src/arch/x86/memlayout.ld)
+ $(LD_postcar) $(LDFLAGS_postcar) -o $@ -L$(obj) $(COMPILER_RT_FLAGS_postcar) -Wl,--whole-archive,--start-group $(filter-out %.ld,$^) -Wl,--no-whole-archive $(COMPILER_RT_postcar) -Wl,--end-group -T $(call src-to-obj,postcar,src/arch/x86/memlayout.ld)
$(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod
cp $< $@
@@ -309,18 +309,20 @@
endif
-$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(call src-to-obj,ramstage,src/arch/x86/memlayout.ld)
- @printf " CC $(subst $(obj)/,,$(@))\n"
- $(LD_ramstage) $(CPPFLAGS) $(LDFLAGS_ramstage) -o $@ -L$(obj) $< -T $(call src-to-obj,ramstage,src/arch/x86/memlayout.ld)
-
-$(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs)
- @printf " CC $(subst $(obj)/,,$(@))\n"
ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
- $(LD_ramstage) -m elf_i386 -r -o $@ $(COMPILER_RT_FLAGS_ramstage) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) --no-whole-archive $(COMPILER_RT_ramstage) --end-group
+LDFLAGS_ramstage += -Wl,-m,elf_i386
else
- $(LD_ramstage) -m elf_x86_64 -r -o $@ $(COMPILER_RT_FLAGS_ramstage) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) --no-whole-archive $(COMPILER_RT_ramstage) --end-group
+LDFLAGS_ramstage += -Wl,-m,elf_x86_64
endif
+$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.a $(call src-to-obj,ramstage,src/arch/x86/memlayout.ld)
+ @printf " CC $(subst $(obj)/,,$(@))\n"
+ $(LD_ramstage) $(CPPFLAGS) $(LDFLAGS_ramstage) $(COMPILER_RT_FLAGS_ramstage) -o $@ -L$(obj) -Wl,--whole-archive,--start-group $< -Wl,--no-whole-archive $(COMPILER_RT_ramstage) -Wl,--end-group -T $(call src-to-obj,ramstage,src/arch/x86/memlayout.ld)
+
+$(objgenerated)/ramstage.a: $$(ramstage-objs) $$(ramstage-libs)
+ @printf " AR $(subst $(obj)/,,$(@))\n"
+ $(AR_ramstage) rcT $@ $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs)
+
endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64
smm-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
diff --git a/src/cpu/x86/smm/Makefile.inc b/src/cpu/x86/smm/Makefile.inc
index 11a4e67..f582a31 100644
--- a/src/cpu/x86/smm/Makefile.inc
+++ b/src/cpu/x86/smm/Makefile.inc
@@ -25,8 +25,8 @@
smm-generic-ccopts += -D__SMM__
smm-c-deps:=$$(OPTION_TABLE_H)
-$(obj)/smm/smm.o: $$(smm-objs) $(COMPILER_RT_smm)
- $(LD_smm) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smm) --whole-archive --start-group $(smm-objs) --no-whole-archive $(COMPILER_RT_smm) --end-group
+$(obj)/smm/smm.a: $$(smm-objs)
+ $(AR_smm) rcT $@ $^
# change to the target path because objcopy will use the path name in its
# ELF symbol names.
@@ -53,7 +53,7 @@
# SMM Stub Module. The stub is used as a trampoline for relocation and normal
# SMM handling.
$(obj)/smmstub/smmstub.o: $$(smmstub-objs) $(COMPILER_RT_smmstub)
- $(LD_smmstub) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smmstub) --whole-archive --start-group $(smmstub-objs) --no-whole-archive $(COMPILER_RT_smmstub) --end-group
+ $(LD_smmstub) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smmstub) -Wl,--whole-archive,--start-group $(smmstub-objs) -Wl,--no-whole-archive $(COMPILER_RT_smmstub) -Wl,--end-group
# Link the SMM stub module with a 0-byte heap.
ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
@@ -72,9 +72,9 @@
# C-based SMM handler.
ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
-$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o, $(CONFIG_SMM_MODULE_HEAP_SIZE),x86_32))
+$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.a, $(CONFIG_SMM_MODULE_HEAP_SIZE),x86_32))
else
-$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o, $(CONFIG_SMM_MODULE_HEAP_SIZE),x86_64))
+$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.a, $(CONFIG_SMM_MODULE_HEAP_SIZE),x86_64))
endif
$(obj)/smm/smm: $(obj)/smm/smm.elf.rmod
@@ -82,8 +82,8 @@
else # CONFIG_SMM_TSEG
-$(obj)/smm/smm: $(obj)/smm/smm.o $(src)/cpu/x86/smm/smm.ld
- $(LD_smm) $(LDFLAGS_smm) -o $(obj)/smm/smm.elf -T $(src)/cpu/x86/smm/smm.ld $(obj)/smm/smm.o
+$(obj)/smm/smm: $(obj)/smm/smm.a $(src)/cpu/x86/smm/smm.ld
+ $(LD_smm) $(LDFLAGS_smm) -o $(obj)/smm/smm.elf -T $(src)/cpu/x86/smm/smm.ld -Wl,--whole-archive,--start-group $(obj)/smm/smm.a -Wl,--no-whole-archive $(COMPILER_RT_smm) --end-group
$(NM_smm) -n $(obj)/smm/smm.elf | sort > $(obj)/smm/smm.map
$(OBJCOPY_smm) -O binary $(obj)/smm/smm.elf $@
diff --git a/src/include/assert.h b/src/include/assert.h
index e0db0bc..6901953 100644
--- a/src/include/assert.h
+++ b/src/include/assert.h
@@ -61,7 +61,8 @@
dead_code_assertion_failed_at_line_##line(); \
} while (0)
#define _dead_code(line) __dead_code(line)
-#define dead_code() _dead_code(__LINE__)
+//#define dead_code() _dead_code(__LINE__)
+#define dead_code()
/* This can be used in the context of an expression of type 'type'. */
#define dead_code_t(type) ({ \
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 2333f64..ac6d624 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -291,7 +291,7 @@
# rmdoule is named $(1).rmod
define rmodule_link
$(strip $(1)): $(strip $(2)) $$(COMPILER_RT_rmodules_$(4)) $(call src-to-obj,rmodules_$(4),src/lib/rmodule.ld) | $$(RMODTOOL)
- $$(LD_rmodules_$(4)) $$(LDFLAGS_rmodules_$(4)) $(RMODULE_LDFLAGS) -T $(call src-to-obj,rmodules_$(4),src/lib/rmodule.ld) --defsym=__heap_size=$(strip $(3)) -o $$@ --whole-archive --start-group $(filter-out %.ld,$(2)) --end-group
+ $$(LD_rmodules_$(4)) $$(LDFLAGS_rmodules_$(4)) $(RMODULE_LDFLAGS) -T $(call src-to-obj,rmodules_$(4),src/lib/rmodule.ld) -Wl,--defsym=__heap_size=$(strip $(3)) -o $$@ -Wl,--whole-archive,--start-group $(filter-out %.ld,$(2)) -Wl,--no-whole-archive $$(COMPILER_RT_rmodules_$(4)) -Wl,--end-group
$$(NM_rmodules_$(4)) -n $$@ > $$(basename $$(a)).map
endef
diff --git a/src/lib/gcc.c b/src/lib/gcc.c
index 5a93f45..66a7788 100644
--- a/src/lib/gcc.c
+++ b/src/lib/gcc.c
@@ -24,6 +24,7 @@
/* TODO: maybe this code should move to arch/x86 as architecture
* specific implementations may vary
*/
+#if 0
#define WRAP_LIBGCC_CALL(type, name) \
asmlinkage type __real_##name(type a, type b); \
type __wrap_##name(type a, type b); \
@@ -33,3 +34,4 @@
WRAP_LIBGCC_CALL(unsigned long long, __udivdi3)
WRAP_LIBGCC_CALL(long long, __moddi3)
WRAP_LIBGCC_CALL(unsigned long long, __umoddi3)
+#endif
diff --git a/toolchain.inc b/toolchain.inc
index 865227b..f52a518 100644
--- a/toolchain.inc
+++ b/toolchain.inc
@@ -117,7 +117,7 @@
$(error Check your .config file for CONFIG_ARCH_$(1)_* settings))
CC_$(1) := $(CC_$(2))
GCC_$(1) := $(GCC_CC_$(2))
-LD_$(1) := $(LD_$(2))
+LD_$(1) := $(CC_$(2))
NM_$(1) := $(NM_$(2))
AR_$(1) := $(AR_$(2))
GNATBIND_$(1) := $(GNATBIND_$(2))
@@ -130,7 +130,7 @@
CPPFLAGS_$(1) = $$(CPPFLAGS_common) $$(CPPFLAGS_$(2)) -D__ARCH_$(2)__
COMPILER_RT_$(1) := $$(COMPILER_RT_$(2))
COMPILER_RT_FLAGS_$(1) := $$(COMPILER_RT_FLAGS_$(2))
-LDFLAGS_$(1) = $$(LDFLAGS_common) $$(LDFLAGS_$(2))
+LDFLAGS_$(1) = $$(CFLAGS_$(1)) $$(LDFLAGS_common) $$(LDFLAGS_$(2))
endef
# define_class: Allows defining any program as dynamic class and compiler tool
diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile
index 3203d71..8515813 100755
--- a/util/xcompile/xcompile
+++ b/util/xcompile/xcompile
@@ -363,7 +363,7 @@
TCLIST="i386 x86_64"
TWIDTH="32"
TABI="elf"
- CC_RT_EXTRA_GCC="--wrap __divdi3 --wrap __udivdi3 --wrap __moddi3 --wrap __umoddi3"
+ #CC_RT_EXTRA_GCC="-Wl,--wrap=__divdi3,--wrap=__udivdi3,--wrap=__moddi3,--wrap=__umoddi3"
}
arch_config_ppc64() {
--
To view, visit https://review.coreboot.org/c/coreboot/+/38989
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I48c31ea8b1b57276125cffdac44c7c16642547ac
Gerrit-Change-Number: 38989
Gerrit-PatchSet: 1
Gerrit-Owner: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-Reviewer: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-MessageType: newchange
9
34

Change in coreboot[master]: nb/amd/agesa: select ROMSTAGE_CACHED_CBMEM
by Arthur Heymans (Code Review) Feb. 20, 2024
by Arthur Heymans (Code Review) Feb. 20, 2024
Feb. 20, 2024
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/37198 )
Change subject: nb/amd/agesa: select ROMSTAGE_CACHED_CBMEM
......................................................................
nb/amd/agesa: select ROMSTAGE_CACHED_CBMEM
AGESA sets up MTRR's to cache the whole dram, so decompressing
postcar stage to cbmem should be fast and is now selected by
default.
Change-Id: I62ffe1bd646e9ddad77be240f030601790f4da4b
Signed-off-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M src/northbridge/amd/agesa/family14/Kconfig
M src/northbridge/amd/agesa/family15tn/Kconfig
M src/northbridge/amd/agesa/family16kb/Kconfig
3 files changed, 3 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/37198/1
diff --git a/src/northbridge/amd/agesa/family14/Kconfig b/src/northbridge/amd/agesa/family14/Kconfig
index 173714f..cfafb23 100644
--- a/src/northbridge/amd/agesa/family14/Kconfig
+++ b/src/northbridge/amd/agesa/family14/Kconfig
@@ -14,6 +14,7 @@
##
config NORTHBRIDGE_AMD_AGESA_FAMILY14
bool
+ select ROMSTAGE_CACHED_CBMEM
if NORTHBRIDGE_AMD_AGESA_FAMILY14
diff --git a/src/northbridge/amd/agesa/family15tn/Kconfig b/src/northbridge/amd/agesa/family15tn/Kconfig
index a0841eb..e6a469f 100644
--- a/src/northbridge/amd/agesa/family15tn/Kconfig
+++ b/src/northbridge/amd/agesa/family15tn/Kconfig
@@ -14,6 +14,7 @@
##
config NORTHBRIDGE_AMD_AGESA_FAMILY15_TN
bool
+ select ROMSTAGE_CACHED_CBMEM
if NORTHBRIDGE_AMD_AGESA_FAMILY15_TN
diff --git a/src/northbridge/amd/agesa/family16kb/Kconfig b/src/northbridge/amd/agesa/family16kb/Kconfig
index 2be2fd3..e34ef60 100644
--- a/src/northbridge/amd/agesa/family16kb/Kconfig
+++ b/src/northbridge/amd/agesa/family16kb/Kconfig
@@ -15,6 +15,7 @@
##
config NORTHBRIDGE_AMD_AGESA_FAMILY16_KB
bool
+ select ROMSTAGE_CACHED_CBMEM
if NORTHBRIDGE_AMD_AGESA_FAMILY16_KB
--
To view, visit https://review.coreboot.org/c/coreboot/+/37198
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I62ffe1bd646e9ddad77be240f030601790f4da4b
Gerrit-Change-Number: 37198
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-MessageType: newchange
6
28

Change in coreboot[master]: spi/winbond: Pull out winbond_region_to_bpbits function
by Daniel Gröber (dxld) (Code Review) Oct. 5, 2023
by Daniel Gröber (dxld) (Code Review) Oct. 5, 2023
Oct. 5, 2023
Hello Daniel Gröber,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/42115
to review the following change.
Change subject: spi/winbond: Pull out winbond_region_to_bpbits function
......................................................................
spi/winbond: Pull out winbond_region_to_bpbits function
Split region>bpbits conversion related logic out from
winbond_set_write_protection into a new function:
winbond_region_to_bpbits.
Change-Id: I2c7b08cb56772aa620e690077bbbb1fde3d7aae7
Signed-off-by: Daniel Gröber <dxld(a)darkboxed.org>
---
M src/drivers/spi/winbond.c
1 file changed, 94 insertions(+), 59 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/15/42115/1
diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c
index 77191e4..51d43a8 100644
--- a/src/drivers/spi/winbond.c
+++ b/src/drivers/spi/winbond.c
@@ -211,6 +211,13 @@
static int winbond_get_bpbits(const struct spi_flash *flash,
struct spi_flash_bpbits *bpbits);
+static int winbond_region_to_bpbits(
+ const struct spi_flash *flash,
+ const struct spi_flash_part_id *params,
+ const struct region *region,
+ const enum spi_flash_status_reg_lockdown mode,
+ struct spi_flash_bpbits *bits);
+
/*
* Convert BPx, TB and CMP to a region.
* SEC (if available) must be zero.
@@ -449,19 +456,77 @@
{
const struct spi_flash_part_id *params;
struct status_regs mask, val;
- struct region wp_region;
- u8 cmp, bp, tb;
+ struct spi_flash_bpbits bpbits;
int ret;
- /* Need to touch TOP or BOTTOM */
- if (region_offset(region) != 0 && region_end(region) != flash->size)
- return -1;
-
params = flash->part;
if (!params)
return -1;
+ ret = winbond_get_bpbits(flash, &bpbits);
+ if (!ret)
+ return ret;
+
+ ret = winbond_region_to_bpbits(flash, params, region, mode, &bpbits);
+ if (!ret)
+ return ret;
+
+ /* Write block protection bits */
+
+ if (params->bp_bits == 3) {
+ val.reg1 = (union status_reg1) {
+ .bp3 = { .bp = bpbits.bp, .tb = bpbits.tb, .sec = 0 }
+ };
+ mask.reg1 = (union status_reg1) {
+ .bp3 = { .bp = ~0, .tb = 1, .sec = 1 }
+ };
+ } else {
+ val.reg1 = (union status_reg1) {
+ .bp4 = { .bp = bpbits.bp, .tb = bpbits.tb }
+ };
+ mask.reg1 = (union status_reg1) {
+ .bp4 = { .bp = ~0, .tb = 1 }
+ };
+ }
+
+ val.reg2 = (union status_reg2) { .cmp = bpbits.cmp };
+ mask.reg2 = (union status_reg2) { .cmp = 1 };
+
+ if (params->bp_bits == 3) {
+ val.reg1.bp3.srp0 = bpbits.winbond.srp0;
+ mask.reg1.bp3.srp0 = 1;
+ } else {
+ val.reg1.bp4.srp0 = bpbits.winbond.srp0;
+ mask.reg1.bp4.srp0 = 1;
+ }
+
+ val.reg2.srp1 = bpbits.winbond.srp1;
+ mask.reg2.srp1 = 1;
+
+ ret = winbond_flash_cmd_status(flash, mask.u, val.u, true);
+ if (ret)
+ return ret;
+
+ printk(BIOS_DEBUG, "WINBOND: write-protection set to range "
+ "0x%08zx-0x%08zx\n", region_offset(region), region_end(region));
+
+ return ret;
+}
+
+static int winbond_region_to_bpbits(
+ const struct spi_flash *flash,
+ const struct spi_flash_part_id *params,
+ const struct region *region,
+ const enum spi_flash_status_reg_lockdown mode,
+ struct spi_flash_bpbits *bits)
+{
+ struct region wp_region;
+
+ /* Need to touch TOP or BOTTOM */
+ if (region_offset(region) != 0 && region_end(region) != flash->size)
+ return -1;
+
if (params->bp_bits != 3 && params->bp_bits != 4) {
/* FIXME: not implemented */
return -1;
@@ -470,91 +535,61 @@
wp_region = *region;
if (region_offset(&wp_region) == 0)
- tb = 1;
+ bits->tb = 1;
else
- tb = 0;
+ bits->tb = 0;
if (region_sz(&wp_region) > flash->size / 2) {
- cmp = 1;
- wp_region.offset = tb ? 0 : region_sz(&wp_region);
+ bits->cmp = 1;
+ wp_region.offset = bits->tb ? 0 : region_sz(&wp_region);
wp_region.size = flash->size - region_sz(&wp_region);
- tb = !tb;
+ bits->tb = !bits->tb;
} else {
- cmp = 0;
+ bits->cmp = 0;
}
if (region_sz(&wp_region) == 0) {
- bp = 0;
+ bits->bp = 0;
} else if (IS_POWER_OF_2(region_sz(&wp_region)) &&
(region_sz(&wp_region) >=
(1 << params->protection_granularity_shift))) {
- bp = log2(region_sz(&wp_region)) -
+ bits->bp = log2(region_sz(&wp_region)) -
params->protection_granularity_shift + 1;
} else {
printk(BIOS_ERR, "WINBOND: ERROR: unsupported region size\n");
return -1;
}
- /* Write block protection bits */
-
- if (params->bp_bits == 3) {
- val.reg1 = (union status_reg1) {
- .bp3 = { .bp = bp, .tb = tb, .sec = 0 }
- };
- mask.reg1 = (union status_reg1) {
- .bp3 = { .bp = ~0, .tb = 1, .sec = 1 }
- };
- } else {
- val.reg1 = (union status_reg1) {
- .bp4 = { .bp = bp, .tb = tb }
- };
- mask.reg1 = (union status_reg1) {
- .bp4 = { .bp = ~0, .tb = 1 }
- };
- }
-
- val.reg2 = (union status_reg2) { .cmp = cmp };
- mask.reg2 = (union status_reg2) { .cmp = 1 };
-
if (mode != SPI_WRITE_PROTECTION_PRESERVE) {
- u8 srp;
switch (mode) {
case SPI_WRITE_PROTECTION_NONE:
- srp = 0;
+ bits->winbond.srp1 = 0;
+ bits->winbond.srp0 = 0;
break;
case SPI_WRITE_PROTECTION_PIN:
- srp = 1;
+ bits->winbond.srp1 = 0;
+ bits->winbond.srp0 = 1;
break;
case SPI_WRITE_PROTECTION_REBOOT:
- srp = 2;
+ bits->winbond.srp1 = 1;
+ bits->winbond.srp0 = 0;
break;
case SPI_WRITE_PROTECTION_PERMANENT:
- srp = 3;
+ if (params->bp_bits == 3) {
+ bits->winbond.srp1 = 1;
+ bits->winbond.srp0 = 1;
+ } else {
+ /* FIXME: special permanent protect write
+ * sequence not implemented. */
+ return -1;
+ }
break;
default:
return -1;
}
-
- if (params->bp_bits == 3) {
- val.reg1.bp3.srp0 = !!(srp & 1);
- mask.reg1.bp3.srp0 = 1;
- } else {
- val.reg1.bp4.srp0 = !!(srp & 1);
- mask.reg1.bp4.srp0 = 1;
- }
-
- val.reg2.srp1 = !!(srp & 2);
- mask.reg2.srp1 = 1;
}
- ret = winbond_flash_cmd_status(flash, mask.u, val.u, true);
- if (ret)
- return ret;
-
- printk(BIOS_DEBUG, "WINBOND: write-protection set to range "
- "0x%08zx-0x%08zx\n", region_offset(region), region_end(region));
-
- return ret;
+ return 0;
}
static const struct spi_flash_protection_ops spi_flash_protection_ops = {
--
To view, visit https://review.coreboot.org/c/coreboot/+/42115
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I2c7b08cb56772aa620e690077bbbb1fde3d7aae7
Gerrit-Change-Number: 42115
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Gröber (dxld)
Gerrit-Reviewer: Daniel Gröber <dxld(a)darkboxed.org>
Gerrit-MessageType: newchange
3
4

Change in coreboot[master]: spi/winbond: Use spi_flash_bpbits in winbond_bpbits_to_region
by Daniel Gröber (dxld) (Code Review) Oct. 5, 2023
by Daniel Gröber (dxld) (Code Review) Oct. 5, 2023
Oct. 5, 2023
Hello Daniel Gröber,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/42113
to review the following change.
Change subject: spi/winbond: Use spi_flash_bpbits in winbond_bpbits_to_region
......................................................................
spi/winbond: Use spi_flash_bpbits in winbond_bpbits_to_region
Change-Id: I2a1a77fb73047df733498c0fa8b8de1153c3b09e
Signed-off-by: Daniel Gröber <dxld(a)darkboxed.org>
---
M src/drivers/spi/winbond.c
1 file changed, 30 insertions(+), 17 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/13/42113/1
diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c
index e4151de..ccc7ae9 100644
--- a/src/drivers/spi/winbond.c
+++ b/src/drivers/spi/winbond.c
@@ -213,16 +213,15 @@
* SEC (if available) must be zero.
*/
static void winbond_bpbits_to_region(const size_t granularity,
- const u8 bp,
- bool tb,
- const bool cmp,
+ const struct spi_flash_bpbits *bits,
const size_t flash_size,
struct region *out)
{
size_t protected_size =
- MIN(bp ? granularity << (bp - 1) : 0, flash_size);
+ MIN(bits->bp ? granularity << (bits->bp - 1) : 0, flash_size);
- if (cmp) {
+ int tb = bits->tb;
+ if (bits->cmp) {
protected_size = flash_size - protected_size;
tb = !tb;
}
@@ -246,8 +245,7 @@
{
const struct spi_flash_part_id *params;
struct region wp_region;
- union status_reg2 reg2;
- u8 bp, tb;
+ struct spi_flash_bpbits bpbits;
int ret;
params = flash->part;
@@ -258,34 +256,49 @@
const size_t granularity = (1 << params->protection_granularity_shift);
union status_reg1 reg1 = { .u = 0 };
+ union status_reg2 reg2 = { .u = 0 };
ret = spi_flash_cmd(&flash->spi, flash->status_cmd, ®1.u,
sizeof(reg1.u));
if (ret)
return ret;
+ ret = spi_flash_cmd(&flash->spi, CMD_W25_RDSR2, ®2.u,
+ sizeof(reg2.u));
+ if (ret)
+ return ret;
+
if (params->bp_bits == 3) {
if (reg1.bp3.sec) {
// FIXME: not supported
return -1;
}
- bp = reg1.bp3.bp;
- tb = reg1.bp3.tb;
+ bpbits = (struct spi_flash_bpbits){
+ .bp = reg1.bp3.bp,
+ .cmp = reg2.cmp,
+ .tb = reg1.bp3.tb,
+ .winbond = {
+ .srp0 = reg1.bp3.srp0,
+ .srp1 = reg2.srp1,
+ },
+ };
} else if (params->bp_bits == 4) {
- bp = reg1.bp4.bp;
- tb = reg1.bp4.tb;
+ bpbits = (struct spi_flash_bpbits){
+ .bp = reg1.bp4.bp,
+ .cmp = reg2.cmp,
+ .tb = reg1.bp4.tb,
+ .winbond = {
+ .srp = reg1.bp4.srp0,
+ .srl = reg2.srp1,
+ },
+ };
} else {
// FIXME: not supported
return -1;
}
- ret = spi_flash_cmd(&flash->spi, CMD_W25_RDSR2, ®2.u,
- sizeof(reg2.u));
- if (ret)
- return ret;
-
- winbond_bpbits_to_region(granularity, bp, tb, reg2.cmp, flash->size,
+ winbond_bpbits_to_region(granularity, &bpbits, flash->size,
&wp_region);
if (!region_sz(&wp_region)) {
--
To view, visit https://review.coreboot.org/c/coreboot/+/42113
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I2a1a77fb73047df733498c0fa8b8de1153c3b09e
Gerrit-Change-Number: 42113
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Gröber (dxld)
Gerrit-Reviewer: Daniel Gröber <dxld(a)darkboxed.org>
Gerrit-MessageType: newchange
5
4

Change in coreboot[master]: spi: Add struct spi_flash_bpbits, a common rep. for block protection
by Daniel Gröber (dxld) (Code Review) Oct. 5, 2023
by Daniel Gröber (dxld) (Code Review) Oct. 5, 2023
Oct. 5, 2023
Hello Daniel Gröber,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/42112
to review the following change.
Change subject: spi: Add struct spi_flash_bpbits, a common rep. for block protection
......................................................................
spi: Add struct spi_flash_bpbits, a common rep. for block protection
Change-Id: I02828b1f764aea29374e794001e74cdc86a94c92
Signed-off-by: Daniel Gröber <dxld(a)darkboxed.org>
---
M src/include/spi_flash.h
1 file changed, 33 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/12/42112/1
diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h
index 35b02db..7dce216 100644
--- a/src/include/spi_flash.h
+++ b/src/include/spi_flash.h
@@ -49,6 +49,39 @@
int (*status)(const struct spi_flash *flash, u8 *reg);
};
+struct spi_flash_bpbits {
+ unsigned int bp; /*< block protection select bits */
+ bool cmp; /*< complement protect */
+ bool tb; /*< top=0 / bottom=1 select */
+ union {
+ struct {
+ union { bool srp1, srl; };
+ union { bool srp0, srp; };
+ /*
+ * For W25Q*{,F}* parts:
+ * srp1 srp0
+ * 0 0 | writable if WEL==1
+ * 0 1 | writable if WEL==1 && #WP==Vcc
+ * 1 0 | not writable until next power-down
+ * 1 1 | not writable, permanently
+ *
+ * checked datasheets: W25Q128FV, (W25Q80, W25Q16,
+ * W25Q32)
+ *
+ * For W25Q*{J,D}* parts:
+ *
+ * srl srp
+ * 0 0 | writable if WEL==1
+ * 0 1 | writable if WEL==1 && #WP==Vcc
+ * 1 x | not writable until next power-down
+ *
+ * checked datasheets: W25Q132JW, W25Q128JW, W25Q256JV.
+ * W25Q16DW
+ */
+ } winbond;
+ };
+};
+
/* Current code assumes all callbacks are supplied in this object. */
struct spi_flash_protection_ops {
/*
--
To view, visit https://review.coreboot.org/c/coreboot/+/42112
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I02828b1f764aea29374e794001e74cdc86a94c92
Gerrit-Change-Number: 42112
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Gröber (dxld)
Gerrit-Reviewer: Daniel Gröber <dxld(a)darkboxed.org>
Gerrit-MessageType: newchange
4
8

Change in coreboot[master]: spi/winbond: Add a test for block protection status bits
by Daniel Gröber (dxld) (Code Review) Sept. 29, 2023
by Daniel Gröber (dxld) (Code Review) Sept. 29, 2023
Sept. 29, 2023
Hello Daniel Gröber,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/42117
to review the following change.
Change subject: spi/winbond: Add a test for block protection status bits
......................................................................
spi/winbond: Add a test for block protection status bits
With refactoring out of the way we can add a test to make sure the
region<>bpbits mapping is correct. Indeed we found that a number of
configurations are incorrect.
The datasheets say that min/max bp values should protect either all or
none of the flash depending on the cmp and tb bits. However we currently
always return no protection for these values.
The test merely documents the current behavour, a fix will come in a
later commit.
Change-Id: Ieb0632221203166288f9608c8492c1d4bd77dd36
Signed-off-by: Daniel Gröber <dxld(a)darkboxed.org>
---
M src/drivers/spi/spi_flash.c
M src/drivers/spi/spi_flash_internal.h
M src/drivers/spi/spi_winbond.h
M src/drivers/spi/winbond.c
A tests/drivers/Makefile.inc
A tests/drivers/winbond-spi-test.c
6 files changed, 344 insertions(+), 13 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/17/42117/1
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index a389bc4..33416b5 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -337,7 +337,7 @@
};
#define IDCODE_LEN 5
-static int fill_spi_flash(const struct spi_slave *spi, struct spi_flash *flash,
+int fill_spi_flash(const struct spi_slave *spi, struct spi_flash *flash,
const struct spi_flash_vendor_info *vi,
const struct spi_flash_part_id *part)
{
diff --git a/src/drivers/spi/spi_flash_internal.h b/src/drivers/spi/spi_flash_internal.h
index b4d39b3..1ed0ab3 100644
--- a/src/drivers/spi/spi_flash_internal.h
+++ b/src/drivers/spi/spi_flash_internal.h
@@ -24,6 +24,13 @@
/* Common status */
#define STATUS_WIP 0x01
+struct spi_flash_vendor_info;
+struct spi_flash_part_id;
+
+int fill_spi_flash(const struct spi_slave *spi, struct spi_flash *flash,
+ const struct spi_flash_vendor_info *vi,
+ const struct spi_flash_part_id *part);
+
/* Send a single-byte command to the device and read the response */
int spi_flash_cmd(const struct spi_slave *spi, u8 cmd, void *response, size_t len);
diff --git a/src/drivers/spi/spi_winbond.h b/src/drivers/spi/spi_winbond.h
index bdf6694..ff799ff 100644
--- a/src/drivers/spi/spi_winbond.h
+++ b/src/drivers/spi/spi_winbond.h
@@ -21,3 +21,16 @@
/* tw: Maximum time to write a flash cell in milliseconds */
#define WINBOND_FLASH_TIMEOUT 30
+
+int winbond_region_to_bpbits(
+ const struct spi_flash *flash,
+ const struct spi_flash_part_id *params,
+ const struct region *region,
+ const enum spi_flash_status_reg_lockdown mode,
+ struct spi_flash_bpbits *bits);
+
+void winbond_bpbits_to_region(
+ const size_t granularity,
+ const struct spi_flash_bpbits *bits,
+ const size_t flash_size,
+ struct region *out);
diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c
index f68d9d9..d7a750b 100644
--- a/src/drivers/spi/winbond.c
+++ b/src/drivers/spi/winbond.c
@@ -211,21 +211,14 @@
static int winbond_get_bpbits(const struct spi_flash *flash,
struct spi_flash_bpbits *bpbits);
-static int winbond_region_to_bpbits(
- const struct spi_flash *flash,
- const struct spi_flash_part_id *params,
- const struct region *region,
- const enum spi_flash_status_reg_lockdown mode,
- struct spi_flash_bpbits *bits);
-
/*
* Convert BPx, TB and CMP to a region.
* SEC (if available) must be zero.
*/
-static void winbond_bpbits_to_region(const size_t granularity,
- const struct spi_flash_bpbits *bits,
- const size_t flash_size,
- struct region *out)
+void winbond_bpbits_to_region(const size_t granularity,
+ const struct spi_flash_bpbits *bits,
+ const size_t flash_size,
+ struct region *out)
{
size_t protected_size =
MIN(bits->bp ? granularity << (bits->bp - 1) : 0, flash_size);
@@ -514,7 +507,7 @@
return ret;
}
-static int winbond_region_to_bpbits(
+int winbond_region_to_bpbits(
const struct spi_flash *flash,
const struct spi_flash_part_id *params,
const struct region *region,
diff --git a/tests/drivers/Makefile.inc b/tests/drivers/Makefile.inc
new file mode 100644
index 0000000..6e5dff3
--- /dev/null
+++ b/tests/drivers/Makefile.inc
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+tests-y += winbond-spi-test
+
+winbond-spi-test-srcs += tests/drivers/winbond-spi-test.c
+winbond-spi-test-srcs += src/drivers/spi/winbond.c
+winbond-spi-test-srcs += src/drivers/spi/spi_flash.c
+winbond-spi-test-srcs += src/commonlib/region.c
+winbond-spi-test-srcs += src/commonlib/mem_pool.c
diff --git a/tests/drivers/winbond-spi-test.c b/tests/drivers/winbond-spi-test.c
new file mode 100644
index 0000000..da7177b
--- /dev/null
+++ b/tests/drivers/winbond-spi-test.c
@@ -0,0 +1,309 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+#include <string.h>
+
+#include <stdio.h> /* debug */
+
+#include <commonlib/helpers.h>
+#include <spi_flash.h>
+#include <spi-generic.h>
+#include "../drivers/spi/spi_flash_internal.h"
+#include "../drivers/spi/spi_winbond.h"
+
+int fill_spi_flash(const struct spi_slave *spi, struct spi_flash *flash,
+ const struct spi_flash_vendor_info *vi,
+ const struct spi_flash_part_id *part);
+
+struct block_region {
+ /* these are in units of 64k-byte blocks */
+ size_t offset;
+ size_t size;
+};
+
+struct bp_table {
+ uint16_t id;
+ size_t size;
+ struct block_region wp_blocks[2][2][1<<4];
+} bp_table[] = {
+ {
+ /* W25Q256J */
+ .id = 0x7019,
+ .wp_blocks = {
+ /* [cmp][tb][bp] */
+ /* off size */
+
+ /* cmp=0, tb=x, bp=0b0000: NONE */
+ [0][0][0] = { 0, 0 },
+ [0][1][0] = { 0, 0 },
+
+ /* cmp=1, tb=x, bp=0b0000: FIXME: ALL */
+ [1][0][0] = { 0, 0 },
+ [1][1][0] = { 0, 0 },
+
+ /* cmp=0, tb=x, bp=0b110x|0b1x1x: FIXME: ALL */
+ [0][0 ... 1][10 ... 15] = { 0, 0 },
+
+ /* cmp=1, tb=x, bp=0b110x|0b1x1x: NONE */
+ [1][0 ... 1][10 ... 15] = { 0, 0 },
+
+ [0][0][1] = { 511, 1 },
+ [0][0][2] = { 510, 2 },
+ [0][0][3] = { 508, 4 },
+ [0][0][4] = { 504, 8 },
+ [0][0][5] = { 496, 16 },
+ [0][0][6] = { 480, 32 },
+ [0][0][7] = { 448, 64 },
+ [0][0][8] = { 384, 128 },
+ [0][0][9] = { 256, 256 },
+
+ [0][1][1] = { 0, 1 },
+ [0][1][2] = { 0, 2 },
+ [0][1][3] = { 0, 4 },
+ [0][1][4] = { 0, 8 },
+ [0][1][5] = { 0, 16 },
+ [0][1][6] = { 0, 32 },
+ [0][1][7] = { 0, 64 },
+ [0][1][8] = { 0, 128 },
+ [0][1][9] = { 0, 256 },
+
+ [1][0][1] = { 0, 512-1 },
+ [1][0][2] = { 0, 512-2 },
+ [1][0][3] = { 0, 512-4 },
+ [1][0][4] = { 0, 512-8 },
+ [1][0][5] = { 0, 512-16 },
+ [1][0][6] = { 0, 512-32 },
+ [1][0][7] = { 0, 512-64 },
+ [1][0][8] = { 0, 512-128 },
+ [1][0][9] = { 0, 512-256 },
+
+ [1][1][1] = { 1, 512-1 },
+ [1][1][2] = { 2, 512-2 },
+ [1][1][3] = { 4, 512-4 },
+ [1][1][4] = { 8, 512-8 },
+ [1][1][5] = { 16, 512-16 },
+ [1][1][6] = { 32, 512-32 },
+ [1][1][7] = { 64, 512-64 },
+ [1][1][8] = { 128, 512-128 },
+ [1][1][9] = { 256, 512-256 },
+ }
+ },
+
+ {
+ /* W25Q128FW */
+ .id = 0x6018,
+ .wp_blocks = {
+ /* [cmp][tb][bp] */
+ /* off size */
+ [0][0][0] = { 0, 0 },
+
+ /* cmp=0, tb=x, bp=0b000: NONE */
+ [0][0][0] = { 0, 0 },
+ [0][1][0] = { 0, 0 },
+
+ /* cmp=0, tb=x, bp=0b111: FIXME: ALL */
+ [0][0][7] = { 0, 0 },
+ [0][1][7] = { 0, 0 },
+
+ [0][0][1] = { 252, 4 },
+ [0][0][2] = { 248, 8 },
+ [0][0][3] = { 240, 16 },
+ [0][0][4] = { 224, 32 },
+ [0][0][5] = { 192, 64 },
+ [0][0][6] = { 128, 128 },
+
+ [0][1][1] = { 0, 4 },
+ [0][1][2] = { 0, 8 },
+ [0][1][3] = { 0, 16 },
+ [0][1][4] = { 0, 32 },
+ [0][1][5] = { 0, 64 },
+ [0][1][6] = { 0, 128 },
+
+ /* cmp=1, tb=x, bp=0b000: FIXME: ALL */
+ [1][0][0] = { 0, 0 },
+ [1][1][0] = { 0, 0 },
+
+ /* cmp=1, tb=x, bp=0b111: NONE */
+ [1][0][7] = { 0, 0 },
+ [1][1][7] = { 0, 0 },
+
+ [1][0][1] = { 0, 256-4 },
+ [1][0][2] = { 0, 256-8 },
+ [1][0][3] = { 0, 256-16 },
+ [1][0][4] = { 0, 256-32 },
+ [1][0][5] = { 0, 256-64 },
+ [1][0][6] = { 0, 256-128 },
+
+ [1][1][1] = { 4, 256-4 },
+ [1][1][2] = { 8, 256-8 },
+ [1][1][3] = { 16, 256-16 },
+ [1][1][4] = { 32, 256-32 },
+ [1][1][5] = { 64, 256-64 },
+ [1][1][6] = { 128, 256-128 },
+ }
+ }
+};
+
+static void test_one_config(
+ void **state,
+ struct spi_flash flash,
+ const struct spi_flash_part_id *part,
+ const struct bp_table *table,
+ const struct spi_flash_bpbits *bpbits)
+{
+ const size_t granularity =
+ 1<<part->protection_granularity_shift;
+
+ struct region expected, out = {-1, -1};
+ struct region roundtripped = {-1, -1};
+
+ winbond_bpbits_to_region(granularity, bpbits,
+ flash.size, &out);
+
+ enum spi_flash_status_reg_lockdown mode =
+ SPI_WRITE_PROTECTION_PIN;
+ struct spi_flash_bpbits bpbits1;
+ winbond_region_to_bpbits(&flash, part, &out, mode,
+ &bpbits1);
+
+ winbond_bpbits_to_region(granularity, &bpbits1,
+ flash.size, &roundtripped);
+
+ const struct block_region *wp_blocks =
+ &table->wp_blocks[bpbits->cmp][bpbits->tb][bpbits->bp];
+ const size_t block_size = 1<<16;
+
+ expected.offset = wp_blocks->offset * block_size;
+ expected.size = wp_blocks->size * block_size;
+
+#if 0
+ /* debugging */
+ print_message("\nfor part 0x%04x cmp=%d tb=%d bp=%d:\n",
+ part->id[0], (int)bpbits->cmp, (int)bpbits->tb,
+ (int)bpbits->bp);
+ print_message("should: 0x%08zx-0x%08zx\n",
+ region_offset(&expected),
+ region_end(&expected));
+ print_message("is: 0x%08zx-0x%08zx\n",
+ region_offset(&out),
+ region_end(&out));
+ print_message("rt'ed: 0x%08zx-0x%08zx\n",
+ region_offset(&roundtripped),
+ region_end(&roundtripped));
+ print_message("bp1: %d\n", bpbits1.bp);
+#endif
+
+ assert_true(expected.size == out.size);
+ assert_true(expected.offset == out.offset);
+
+ assert_true(expected.size == roundtripped.size);
+ assert_true(expected.offset == roundtripped.offset);
+}
+
+static void winbond_region_bpbits_roundtrip_test(void **state)
+{
+ int n_cfgs_tested = 0;
+
+ const struct spi_flash_vendor_info *vi = &spi_flash_winbond_vi;
+
+ for (size_t i = 0; i < vi->nr_part_ids; i++) {
+ const struct spi_flash_part_id *part = &vi->ids[i];
+
+ if (!part->protection_granularity_shift)
+ continue;
+
+ /* FIXME: Add tables for the other parts supporting block
+ * protection */
+ if (part->id[0] != 0x7019 && part->id[0] != 0x6018)
+ continue;
+
+ struct spi_slave spi;
+ struct spi_flash flash;
+ int ret = fill_spi_flash(&spi, &flash, vi, part);
+ assert_int_equal(ret, 0);
+
+ const struct bp_table *table = NULL;
+ for (uint16_t j = 0; j < ARRAY_SIZE(bp_table); j++) {
+ if (bp_table[j].id == part->id[0]) {
+ table = &bp_table[j];
+ break;
+ }
+ }
+
+ assert_non_null(table);
+
+ /* FIXME: Max values below are clamped to 6 and 9
+ * respectively because the implementation currently thinks
+ * everything above those is fully protected when the
+ * datasheets say the protection range is empty in those
+ * cases. */
+ u8 bp_max;
+ if (part->bp_bits == 3)
+ bp_max = 6;
+ else if (part->bp_bits == 4)
+ bp_max = 9;
+ else
+ fail_msg("Unrecognized bp_bits");
+
+ for (u8 tbcmp = 0; tbcmp < 4; tbcmp++) {
+ /* FIXME: bp=0 isn't tested because the
+ * implementation is currently wrong */
+ for (u8 bp = 1; bp <= bp_max; bp++) {
+ struct spi_flash_bpbits bpbits = {
+ .cmp = tbcmp & (1<<1),
+ .tb = tbcmp & (1<<0),
+ .bp = bp,
+ };
+
+ test_one_config(
+ state, flash, part, table, &bpbits);
+
+ n_cfgs_tested++;
+ }
+ }
+ }
+
+ assert_true(n_cfgs_tested == 60);
+}
+
+ /* Mocks */
+int do_printk(int msg_level, const char *fmt, ...)
+{
+ return -1;
+}
+int spi_claim_bus(const struct spi_slave *slave)
+{
+ return -1;
+}
+int spi_xfer_vector(const struct spi_slave *slave,
+ struct spi_op vectors[], size_t count)
+{
+ return -1;
+}
+void spi_release_bus(const struct spi_slave *slave)
+{
+}
+unsigned int spi_crop_chunk(const struct spi_slave *slave, unsigned int cmd_len,
+ unsigned int buf_len)
+{
+ return 0;
+}
+struct mono_time;
+void timer_monotonic_get(struct mono_time *mt)
+{
+}
+
+const struct spi_flash_ops_descriptor spi_flash_pp_0x20_sector_desc;
+
+int main(void)
+{
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(winbond_region_bpbits_roundtrip_test),
+ };
+
+ return cmocka_run_group_tests(tests, NULL, NULL);
+}
--
To view, visit https://review.coreboot.org/c/coreboot/+/42117
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ieb0632221203166288f9608c8492c1d4bd77dd36
Gerrit-Change-Number: 42117
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Gröber (dxld)
Gerrit-Reviewer: Daniel Gröber <dxld(a)darkboxed.org>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-MessageType: newchange
3
7

Change in coreboot[master]: boot_device: Add boot_device_lockdown
by Patrick Rudolph (Code Review) Sept. 28, 2023
by Patrick Rudolph (Code Review) Sept. 28, 2023
Sept. 28, 2023
Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/39925 )
Change subject: boot_device: Add boot_device_lockdown
......................................................................
boot_device: Add boot_device_lockdown
Add a new method to lock the SPI protected range registers.
This allows to lock the SPI controller early, which can be used to
write-protect the WP_RO region in bootblock before handing of control
to the later stages not protected by WP_RO.
In conjunction with VBOOT and BOOTMEDIA_LOCK_CONTROLLER_RO_VBOOT_RO this
enables a secure boot mechanism on non CHROMEOS enabled devices.
Change-Id: I9d3a80a2e278c77212e1fba5236ea639ea018837
Signed-off-by: Patrick Rudolph <patrick.rudolph(a)9elements.com>
---
M src/drivers/spi/boot_device_rw_nommap.c
M src/drivers/spi/spi_flash.c
M src/include/boot_device.h
M src/include/spi-generic.h
M src/include/spi_flash.h
M src/lib/boot_device.c
M src/security/lockdown/lockdown.c
M src/soc/intel/common/block/fast_spi/fast_spi_flash.c
M src/soc/intel/common/pch/lockdown/lockdown.c
M src/southbridge/intel/bd82x6x/lpc.c
M src/southbridge/intel/common/finalize.c
M src/southbridge/intel/common/spi.c
M src/southbridge/intel/ibexpeak/lpc.c
M src/southbridge/intel/lynxpoint/lpc.c
14 files changed, 82 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/25/39925/1
diff --git a/src/drivers/spi/boot_device_rw_nommap.c b/src/drivers/spi/boot_device_rw_nommap.c
index 5de9a71..be90318 100644
--- a/src/drivers/spi/boot_device_rw_nommap.c
+++ b/src/drivers/spi/boot_device_rw_nommap.c
@@ -133,3 +133,12 @@
return spi_flash_ctrlr_protect_region(boot_dev,
region_device_region(rd), ctrlr_pr);
}
+
+int boot_device_lockdown(void)
+{
+ const struct spi_flash *boot_dev = boot_device_spi_flash();
+ if (boot_dev == NULL)
+ return -1;
+
+ return spi_flash_ctrlr_lockdown(boot_dev);
+}
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index 5149829..6fdda2c 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -707,6 +707,17 @@
return -1;
}
+int spi_flash_ctrlr_lockdown(const struct spi_flash *flash)
+{
+ if (!flash || !flash->spi.ctrlr)
+ return -1;
+
+ if (flash->spi.ctrlr->lockdown)
+ return flash->spi.ctrlr->lockdown(flash);
+
+ return -1;
+}
+
int spi_flash_vector_helper(const struct spi_slave *slave,
struct spi_op vectors[], size_t count,
int (*func)(const struct spi_slave *slave, const void *dout,
diff --git a/src/include/boot_device.h b/src/include/boot_device.h
index a31fdff..d813f16 100644
--- a/src/include/boot_device.h
+++ b/src/include/boot_device.h
@@ -68,6 +68,11 @@
const enum bootdev_prot_type type);
/*
+ * Lock the controller after all WP regions have been set.
+ */
+int boot_device_lockdown(void);
+
+/*
* Initialize the boot device. This may be called multiple times within
* a stage so boot device implementations should account for this behavior.
**/
diff --git a/src/include/spi-generic.h b/src/include/spi-generic.h
index 3022886..7c2a9d8 100644
--- a/src/include/spi-generic.h
+++ b/src/include/spi-generic.h
@@ -156,6 +156,8 @@
* flash_probe: Specialized probe function provided by SPI flash
* controllers.
* flash_protect: Protect a region of flash using the SPI flash controller.
+ * lockdown: Enable protected regions. flash_protect will return an error after
+ * calling this function.
*/
struct spi_ctrlr {
int (*claim_bus)(const struct spi_slave *slave);
@@ -174,6 +176,7 @@
int (*flash_protect)(const struct spi_flash *flash,
const struct region *region,
const enum ctrlr_prot_type type);
+ int (*lockdown)(const struct spi_flash *flash);
};
/*-----------------------------------------------------------------------
diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h
index c74ceae..9c1a5f7 100644
--- a/src/include/spi_flash.h
+++ b/src/include/spi_flash.h
@@ -227,6 +227,12 @@
const enum ctrlr_prot_type type);
/*
+ * Lock down the SPI controller.
+ * Modifying protected protected regions will become impossible.
+ */
+int spi_flash_ctrlr_lockdown(const struct spi_flash *flash);
+
+/*
* This function is provided to support spi flash command-response transactions.
* Only 2 vectors are supported and the 'func' is called with appropriate
* write and read buffers together. This can be used for chipsets that
diff --git a/src/lib/boot_device.c b/src/lib/boot_device.c
index dfb4066..81b1825 100644
--- a/src/lib/boot_device.c
+++ b/src/lib/boot_device.c
@@ -26,6 +26,12 @@
return -1;
}
+int __weak boot_device_lockdown(void)
+{
+ /* return a failure, make aware lockdown is not implemented */
+ return -1;
+}
+
static int boot_device_subregion(const struct region *sub,
struct region_device *subrd,
const struct region_device *parent)
diff --git a/src/security/lockdown/lockdown.c b/src/security/lockdown/lockdown.c
index 3bbf75f..0396ee7 100644
--- a/src/security/lockdown/lockdown.c
+++ b/src/security/lockdown/lockdown.c
@@ -46,6 +46,11 @@
printk(BIOS_INFO, "BM-LOCKDOWN: Enabled bootmedia protection\n");
else
printk(BIOS_ERR, "BM-LOCKDOWN: Failed to enable bootmedia protection\n");
+
+ if (CONFIG(BOOTMEDIA_LOCK_CONTROLLER_RO_VBOOT_RO)) {
+ printk(BIOS_INFO, "BM-LOCKDOWN: Locking down controller\n");
+ boot_device_lockdown();
+ }
}
#if ENV_RAMSTAGE
diff --git a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c
index a8afd48..4428740 100644
--- a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c
+++ b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c
@@ -422,9 +422,16 @@
return 0;
}
+static int fast_spi_flash_lockdown(const struct spi_flash *flash)
+{
+ fast_spi_pr_dlock();
+ return 0;
+}
+
const struct spi_ctrlr fast_spi_flash_ctrlr = {
.setup = fast_spi_flash_ctrlr_setup,
.max_xfer_size = SPI_CTRLR_DEFAULT_MAX_XFER_SIZE,
.flash_probe = fast_spi_flash_probe,
.flash_protect = fast_spi_flash_protect,
+ .lockdown = fast_spi_flash_lockdown,
};
diff --git a/src/soc/intel/common/pch/lockdown/lockdown.c b/src/soc/intel/common/pch/lockdown/lockdown.c
index 036cccc..de45643 100644
--- a/src/soc/intel/common/pch/lockdown/lockdown.c
+++ b/src/soc/intel/common/pch/lockdown/lockdown.c
@@ -20,6 +20,7 @@
#include <soc/pci_devs.h>
#include <soc/pcr_ids.h>
#include <soc/soc_chip.h>
+#include <boot_device.h>
#define PCR_DMI_GCS 0x274C
#define PCR_DMI_GCS_BILD (1 << 0)
@@ -63,7 +64,7 @@
fast_spi_set_opcode_menu();
/* Discrete Lock Flash PR registers */
- fast_spi_pr_dlock();
+ boot_device_lockdown();
/* Lock FAST_SPIBAR */
fast_spi_lock_bar();
diff --git a/src/southbridge/intel/bd82x6x/lpc.c b/src/southbridge/intel/bd82x6x/lpc.c
index 46ab5fc..ae0b70f 100644
--- a/src/southbridge/intel/bd82x6x/lpc.c
+++ b/src/southbridge/intel/bd82x6x/lpc.c
@@ -38,6 +38,7 @@
#include <southbridge/intel/common/pmutil.h>
#include <southbridge/intel/common/rtc.h>
#include <southbridge/intel/common/spi.h>
+#include <boot_device.h>
#define NMI_OFF 0
@@ -849,12 +850,14 @@
{
spi_finalize_ops();
+ /* Lock SPIBAR */
+ if (CONFIG(INTEL_CHIPSET_LOCKDOWN) || acpi_is_wakeup_s3())
+ boot_device_lockdown();
+
/* Call SMM finalize() handlers before resume */
if (CONFIG(HAVE_SMI_HANDLER)) {
- if (CONFIG(INTEL_CHIPSET_LOCKDOWN) ||
- acpi_is_wakeup_s3()) {
+ if (CONFIG(INTEL_CHIPSET_LOCKDOWN) || acpi_is_wakeup_s3())
outb(APM_CNT_FINALIZE, APM_CNT);
- }
}
}
diff --git a/src/southbridge/intel/common/finalize.c b/src/southbridge/intel/common/finalize.c
index 2d4d4a3..e5aa983 100644
--- a/src/southbridge/intel/common/finalize.c
+++ b/src/southbridge/intel/common/finalize.c
@@ -27,9 +27,6 @@
{
const pci_devfn_t lpc_dev = PCI_DEV(0, 0x1f, 0);
- /* Lock SPIBAR */
- RCBA32_OR(0x3804, (1 << 15));
-
if (CONFIG(SPI_FLASH_SMM))
/* Re-init SPI driver to handle locked BAR */
spi_init();
diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c
index 5e967af..ffa283b 100644
--- a/src/southbridge/intel/common/spi.c
+++ b/src/southbridge/intel/common/spi.c
@@ -1110,6 +1110,16 @@
writew_(optype, cntlr.optype);
}
+static int spi_flash_lockdown(const struct spi_flash *flash)
+{
+ if (CONFIG(SOUTHBRIDGE_INTEL_I82801GX)) {
+ writew_(readw_(&cntlr.ich7_spi->spis) | HSFS_FLOCKDN, &cntlr.ich7_spi->spis);
+ } else {
+ writew_(readw_(&cntlr.ich9_spi->spis) | HSFS_FLOCKDN, &cntlr.ich9_spi->spis);
+ }
+ return 0;
+}
+
__weak void intel_southbridge_override_spi(struct intel_swseq_spi_config *spi_config)
{
}
@@ -1119,7 +1129,7 @@
.max_xfer_size = member_size(struct ich9_spi_regs, fdata),
.flash_probe = spi_flash_programmer_probe,
.flash_protect = spi_flash_protect,
-};
+ .lockdown = spi_flash_lockdown,
const struct spi_ctrlr_buses spi_ctrlr_bus_map[] = {
{
diff --git a/src/southbridge/intel/ibexpeak/lpc.c b/src/southbridge/intel/ibexpeak/lpc.c
index 0062e09..c1e7904 100644
--- a/src/southbridge/intel/ibexpeak/lpc.c
+++ b/src/southbridge/intel/ibexpeak/lpc.c
@@ -38,6 +38,7 @@
#include <southbridge/intel/common/pciehp.h>
#include <southbridge/intel/common/acpi_pirq_gen.h>
#include <southbridge/intel/common/spi.h>
+#include <boot_device.h>
#define NMI_OFF 0
@@ -748,12 +749,14 @@
{
spi_finalize_ops();
+ /* Lock SPIBAR */
+ if (CONFIG(INTEL_CHIPSET_LOCKDOWN) || acpi_is_wakeup_s3())
+ boot_device_lockdown();
+
/* Call SMM finalize() handlers before resume */
if (CONFIG(HAVE_SMI_HANDLER)) {
- if (CONFIG(INTEL_CHIPSET_LOCKDOWN) ||
- acpi_is_wakeup_s3()) {
+ if (CONFIG(INTEL_CHIPSET_LOCKDOWN) || acpi_is_wakeup_s3())
outb(APM_CNT_FINALIZE, APM_CNT);
- }
}
}
diff --git a/src/southbridge/intel/lynxpoint/lpc.c b/src/southbridge/intel/lynxpoint/lpc.c
index 745c231..e4ab43d 100644
--- a/src/southbridge/intel/lynxpoint/lpc.c
+++ b/src/southbridge/intel/lynxpoint/lpc.c
@@ -35,6 +35,7 @@
#include <southbridge/intel/common/acpi_pirq_gen.h>
#include <southbridge/intel/common/rtc.h>
#include <southbridge/intel/common/spi.h>
+#include <boot_device.h>
#define NMI_OFF 0
@@ -951,6 +952,10 @@
{
spi_finalize_ops();
+ /* Lock SPIBAR */
+ if (CONFIG(INTEL_CHIPSET_LOCKDOWN) || acpi_is_wakeup_s3())
+ boot_device_lockdown();
+
if (acpi_is_wakeup_s3() || CONFIG(INTEL_CHIPSET_LOCKDOWN))
outb(APM_CNT_FINALIZE, APM_CNT);
}
--
To view, visit https://review.coreboot.org/c/coreboot/+/39925
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I9d3a80a2e278c77212e1fba5236ea639ea018837
Gerrit-Change-Number: 39925
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-MessageType: newchange
5
9

Change in coreboot[master]: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at buil...
by Hung-Te Lin (Code Review) Sept. 27, 2023
by Hung-Te Lin (Code Review) Sept. 27, 2023
Sept. 27, 2023
Hung-Te Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time
......................................................................
util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time
Some FMAP sections (for example MRC_VAR_CACHE, RW_DDR_TRAINING, ...) are
accessed directly by raw block I/O and must be aligned at SPI flash
erase block size (see spi_flash.c#spi_flash_erase_cmd, error "SF: Erase
offset/length not multiple of erase size").
If we don't add explicit offset to these sections in FMD files, changing
size of other sections may unexpectedly causing them to be unaligned.
This patch adds a new flag "ALIGNED" so we can declare a FMAP section as
RW_DDR_TRAINING(ALIGNED) 8k
to ensure an 8k section that its offset and size will be both aligned
at 4k.
Note: in current implementation the alignment is fixed at 4k, which is
supported on almost all SPI chipsets today.
TEST=Change bootblock from default.fmd to BOOTBLOCK(ALIGNED) 127k and build,
seeing error message:
"E: Section 'BOOTBLOCK'@0[0x1fc00] must be aligned to 0x1000"
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9
Signed-off-by: Hung-Te Lin <hungte(a)chromium.org>
---
M util/cbfstool/fmap_from_fmd.c
M util/cbfstool/fmd.h
M util/cbfstool/fmd_parser.c_shipped
M util/cbfstool/fmd_parser.h_shipped
M util/cbfstool/fmd_parser.y
M util/cbfstool/fmd_scanner.c_shipped
M util/cbfstool/fmd_scanner.h_shipped
M util/cbfstool/fmd_scanner.l
8 files changed, 629 insertions(+), 440 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/1
diff --git a/util/cbfstool/fmap_from_fmd.c b/util/cbfstool/fmap_from_fmd.c
index 374667a..f822f7b 100644
--- a/util/cbfstool/fmap_from_fmd.c
+++ b/util/cbfstool/fmap_from_fmd.c
@@ -35,6 +35,18 @@
if (section->flags.f.preserve)
flags |= FMAP_AREA_PRESERVE;
+ if (section->flags.f.aligned) {
+ /* Currently the alignment is fixed at 4K. */
+ const int alignment = 0x1000;
+ if (absolute_watermark % alignment ||
+ section->size % alignment) {
+ ERROR("Section '%s'@%#x[%#x] must be aligned to %#x\n",
+ section->name,absolute_watermark, section->size,
+ alignment);
+ return false;
+ }
+ }
+
if (fmap_append_area(flashmap, absolute_watermark, section->size,
(uint8_t *)section->name, flags) < 0) {
ERROR("Failed to insert section '%s' into FMAP\n",
diff --git a/util/cbfstool/fmd.h b/util/cbfstool/fmd.h
index 90e6d6e..1eb3a22 100644
--- a/util/cbfstool/fmd.h
+++ b/util/cbfstool/fmd.h
@@ -33,6 +33,7 @@
struct {
int cbfs: 1; /* The section contains a CBFS area. */
int preserve: 1; /* Preserve the section before update. */
+ int aligned:1; /* The section must be aligned for block I/O. */
} f;
int v;
};
diff --git a/util/cbfstool/fmd_parser.c_shipped b/util/cbfstool/fmd_parser.c_shipped
index 2597fc6..7a5f34c 100644
--- a/util/cbfstool/fmd_parser.c_shipped
+++ b/util/cbfstool/fmd_parser.c_shipped
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
+/* A Bison parser, made by GNU Bison 3.4.1. */
/* Bison implementation for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
+ Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -40,11 +41,14 @@
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
+/* Undocumented macros, especially those whose name start with YY_,
+ are private implementation details. Do not rely on them. */
+
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "3.0.4"
+#define YYBISON_VERSION "3.4.1"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -61,8 +65,8 @@
-/* Copy the first part of user declarations. */
-#line 16 "fmd_parser.y" /* yacc.c:339 */
+/* First part of user prologue. */
+#line 16 "fmd_parser.y"
#include "fmd_scanner.h"
#include "common.h"
@@ -71,13 +75,17 @@
struct flashmap_descriptor *res = NULL;
-#line 75 "y.tab.c" /* yacc.c:339 */
+#line 79 "fmd_parser.tab.c"
# ifndef YY_NULLPTR
-# if defined __cplusplus && 201103L <= __cplusplus
-# define YY_NULLPTR nullptr
+# if defined __cplusplus
+# if 201103L <= __cplusplus
+# define YY_NULLPTR nullptr
+# else
+# define YY_NULLPTR 0
+# endif
# else
-# define YY_NULLPTR 0
+# define YY_NULLPTR ((void*)0)
# endif
# endif
@@ -89,10 +97,10 @@
# define YYERROR_VERBOSE 0
#endif
-/* In a future release of Bison, this section will be replaced
- by #include "y.tab.h". */
-#ifndef YY_YY_Y_TAB_H_INCLUDED
-# define YY_YY_Y_TAB_H_INCLUDED
+/* Use api.header.include to #include this header
+ instead of duplicating it here. */
+#ifndef YY_YY_FMD_PARSER_TAB_H_INCLUDED
+# define YY_YY_FMD_PARSER_TAB_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
@@ -101,7 +109,7 @@
extern int yydebug;
#endif
/* "%code requires" blocks. */
-#line 34 "fmd_parser.y" /* yacc.c:355 */
+#line 34 "fmd_parser.y"
#include "fmd.h"
#include "option.h"
@@ -126,7 +134,7 @@
struct unsigned_option size, struct descriptor_list children);
void yyerror(const char *s);
-#line 130 "y.tab.c" /* yacc.c:355 */
+#line 138 "fmd_parser.tab.c"
/* Token type. */
#ifndef YYTOKENTYPE
@@ -137,22 +145,16 @@
OCTAL = 259,
STRING = 260,
FLAG_CBFS = 261,
- FLAG_PRESERVE = 262
+ FLAG_PRESERVE = 262,
+ FLAG_ALIGNED = 263
};
#endif
-/* Tokens. */
-#define INTEGER 258
-#define OCTAL 259
-#define STRING 260
-#define FLAG_CBFS 261
-#define FLAG_PRESERVE 262
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-
union YYSTYPE
{
-#line 25 "fmd_parser.y" /* yacc.c:355 */
+#line 25 "fmd_parser.y"
unsigned intval;
char *strval;
@@ -161,9 +163,9 @@
union flashmap_flags flags;
struct descriptor_list region_listhdr;
-#line 165 "y.tab.c" /* yacc.c:355 */
-};
+#line 167 "fmd_parser.tab.c"
+};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
@@ -174,11 +176,9 @@
int yyparse (void);
-#endif /* !YY_YY_Y_TAB_H_INCLUDED */
+#endif /* !YY_YY_FMD_PARSER_TAB_H_INCLUDED */
-/* Copy the second part of user declarations. */
-#line 182 "y.tab.c" /* yacc.c:358 */
#ifdef short
# undef short
@@ -199,13 +199,13 @@
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
-typedef unsigned short int yytype_uint16;
+typedef unsigned short yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
-typedef short int yytype_int16;
+typedef short yytype_int16;
#endif
#ifndef YYSIZE_T
@@ -217,7 +217,7 @@
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
-# define YYSIZE_T unsigned int
+# define YYSIZE_T unsigned
# endif
#endif
@@ -253,15 +253,6 @@
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
-#if !defined _Noreturn \
- && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
-# if defined _MSC_VER && 1200 <= _MSC_VER
-# define _Noreturn __declspec (noreturn)
-# else
-# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
-# endif
-#endif
-
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
@@ -269,7 +260,7 @@
# define YYUSE(E) /* empty */
#endif
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
@@ -289,6 +280,8 @@
#endif
+#define YY_ASSERT(E) ((void) (0 && (E)))
+
#if ! defined yyoverflow || YYERROR_VERBOSE
/* The parser invokes alloca or malloc; define the necessary symbols. */
@@ -420,42 +413,42 @@
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 4
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 23
+#define YYLAST 24
/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 13
+#define YYNTOKENS 14
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 14
/* YYNRULES -- Number of rules. */
-#define YYNRULES 21
+#define YYNRULES 22
/* YYNSTATES -- Number of states. */
-#define YYNSTATES 31
+#define YYNSTATES 32
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
- by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
-#define YYMAXUTOK 262
+#define YYMAXUTOK 263
+/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
+ as returned by yylex, with out-of-bounds checking. */
#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+ ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
- as returned by yylex, without out-of-bounds checking. */
+ as returned by yylex. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 8, 9, 2, 2, 2, 2, 2, 2, 2, 2,
+ 9, 10, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 10, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 11, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 11, 2, 12, 2, 2, 2, 2,
+ 2, 2, 2, 12, 2, 13, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -469,16 +462,16 @@
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7
+ 5, 6, 7, 8
};
#if YYDEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
- 0, 80, 80, 86, 100, 107, 108, 109, 109, 110,
- 111, 112, 113, 114, 115, 116, 117, 119, 123, 124,
- 125, 136
+ 0, 81, 81, 87, 101, 108, 109, 110, 110, 111,
+ 112, 113, 114, 115, 116, 117, 118, 119, 121, 125,
+ 126, 127, 138
};
#endif
@@ -488,8 +481,8 @@
static const char *const yytname[] =
{
"$end", "error", "$undefined", "INTEGER", "OCTAL", "STRING",
- "FLAG_CBFS", "FLAG_PRESERVE", "'('", "')'", "'@'", "'{'", "'}'",
- "$accept", "flash_chip", "flash_region", "region_name",
+ "FLAG_CBFS", "FLAG_PRESERVE", "FLAG_ALIGNED", "'('", "')'", "'@'", "'{'",
+ "'}'", "$accept", "flash_chip", "flash_region", "region_name",
"region_flags_opt", "region_flags", "region_flag", "region_offset_opt",
"region_offset", "region_size_opt", "region_size", "region_list_opt",
"region_list", "region_list_entries", YY_NULLPTR
@@ -501,15 +494,15 @@
(internal) symbol number NUM (which must be that of a token). */
static const yytype_uint16 yytoknum[] =
{
- 0, 256, 257, 258, 259, 260, 261, 262, 40, 41,
- 64, 123, 125
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 40,
+ 41, 64, 123, 125
};
# endif
-#define YYPACT_NINF -12
+#define YYPACT_NINF -13
#define yypact_value_is_default(Yystate) \
- (!!((Yystate) == (-12)))
+ (!!((Yystate) == (-13)))
#define YYTABLE_NINF -1
@@ -520,10 +513,10 @@
STATE-NUM. */
static const yytype_int8 yypact[] =
{
- -1, -12, 1, -2, -12, 2, 3, -12, -12, -12,
- 0, -1, -12, -12, 4, -5, -4, -2, -12, -12,
- -12, -12, 5, -4, 3, -12, -12, 0, -12, -12,
- -12
+ 0, -13, 1, -2, -13, 3, 4, -13, -13, -13,
+ -1, 0, -13, -13, 5, -5, -4, -2, -13, -13,
+ -13, -13, -13, 2, -4, 4, -13, -13, -1, -13,
+ -13, -13
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -531,24 +524,24 @@
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
- 0, 4, 0, 11, 1, 0, 0, 12, 13, 16,
- 0, 0, 2, 20, 5, 0, 0, 11, 19, 21,
- 9, 10, 0, 7, 14, 6, 8, 17, 15, 3,
- 18
+ 0, 4, 0, 12, 1, 0, 0, 13, 14, 17,
+ 0, 0, 2, 21, 5, 0, 0, 12, 20, 22,
+ 9, 10, 11, 0, 7, 15, 6, 8, 18, 16,
+ 3, 19
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
- -12, -12, -6, 10, -12, -10, -12, 6, -12, -12,
- -9, -12, -11, -12
+ -13, -13, 6, 10, -13, -11, -13, 7, -13, -13,
+ -10, -13, -12, -13
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
- -1, 2, 13, 14, 17, 22, 23, 6, 7, 27,
- 10, 29, 12, 15
+ -1, 2, 13, 14, 17, 23, 24, 6, 7, 28,
+ 10, 30, 12, 15
};
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
@@ -556,42 +549,42 @@
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_uint8 yytable[] =
{
- 1, 4, 20, 21, 1, 8, 9, 18, 5, 19,
- 3, 11, 16, 26, 25, 28, 30, 0, 0, 0,
- 0, 0, 0, 24
+ 1, 4, 20, 21, 22, 1, 8, 9, 18, 5,
+ 3, 11, 26, 27, 16, 29, 31, 0, 0, 0,
+ 0, 19, 0, 0, 25
};
static const yytype_int8 yycheck[] =
{
- 5, 0, 6, 7, 5, 3, 3, 12, 10, 15,
- 0, 11, 8, 23, 9, 24, 27, -1, -1, -1,
- -1, -1, -1, 17
+ 5, 0, 6, 7, 8, 5, 3, 3, 13, 11,
+ 0, 12, 10, 24, 9, 25, 28, -1, -1, -1,
+ -1, 15, -1, -1, 17
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
- 0, 5, 14, 16, 0, 10, 20, 21, 3, 3,
- 23, 11, 25, 15, 16, 26, 8, 17, 12, 15,
- 6, 7, 18, 19, 20, 9, 18, 22, 23, 24,
- 25
+ 0, 5, 15, 17, 0, 11, 21, 22, 3, 3,
+ 24, 12, 26, 16, 17, 27, 9, 18, 13, 16,
+ 6, 7, 8, 19, 20, 21, 10, 19, 23, 24,
+ 25, 26
};
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
- 0, 13, 14, 15, 16, 17, 17, 18, 18, 19,
- 19, 20, 20, 21, 22, 22, 23, 24, 24, 25,
- 26, 26
+ 0, 14, 15, 16, 17, 18, 18, 19, 19, 20,
+ 20, 20, 21, 21, 22, 23, 23, 24, 25, 25,
+ 26, 27, 27
};
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 4, 5, 1, 0, 3, 1, 2, 1,
- 1, 0, 1, 2, 0, 1, 1, 0, 1, 3,
- 1, 2
+ 1, 1, 0, 1, 2, 0, 1, 1, 0, 1,
+ 3, 1, 2
};
@@ -607,22 +600,22 @@
#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (yylen); \
- yystate = *yyssp; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (0)
+#define YYBACKUP(Token, Value) \
+ do \
+ if (yychar == YYEMPTY) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (yylen); \
+ yystate = *yyssp; \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+ while (0)
/* Error token number */
#define YYTERROR 1
@@ -662,37 +655,37 @@
} while (0)
-/*----------------------------------------.
-| Print this symbol's value on YYOUTPUT. |
-`----------------------------------------*/
+/*-----------------------------------.
+| Print this symbol's value on YYO. |
+`-----------------------------------*/
static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep)
{
- FILE *yyo = yyoutput;
- YYUSE (yyo);
+ FILE *yyoutput = yyo;
+ YYUSE (yyoutput);
if (!yyvaluep)
return;
# ifdef YYPRINT
if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+ YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
# endif
YYUSE (yytype);
}
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
+/*---------------------------.
+| Print this symbol on YYO. |
+`---------------------------*/
static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep)
{
- YYFPRINTF (yyoutput, "%s %s (",
+ YYFPRINTF (yyo, "%s %s (",
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
- yy_symbol_value_print (yyoutput, yytype, yyvaluep);
- YYFPRINTF (yyoutput, ")");
+ yy_symbol_value_print (yyo, yytype, yyvaluep);
+ YYFPRINTF (yyo, ")");
}
/*------------------------------------------------------------------.
@@ -726,7 +719,7 @@
static void
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
{
- unsigned long int yylno = yyrline[yyrule];
+ unsigned long yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
@@ -737,7 +730,7 @@
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
yystos[yyssp[yyi + 1 - yynrhs]],
- &(yyvsp[(yyi + 1) - (yynrhs)])
+ &yyvsp[(yyi + 1) - (yynrhs)]
);
YYFPRINTF (stderr, "\n");
}
@@ -841,7 +834,10 @@
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
- /* Fall through. */
+ else
+ goto append;
+
+ append:
default:
if (yyres)
yyres[yyn] = *yyp;
@@ -859,7 +855,7 @@
if (! yyres)
return yystrlen (yystr);
- return yystpcpy (yyres, yystr) - yyres;
+ return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
}
# endif
@@ -937,10 +933,10 @@
yyarg[yycount++] = yytname[yyx];
{
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
- if (! (yysize <= yysize1
- && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+ yysize = yysize1;
+ else
return 2;
- yysize = yysize1;
}
}
}
@@ -952,6 +948,7 @@
case N: \
yyformat = S; \
break
+ default: /* Avoid compiler warnings. */
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
@@ -963,9 +960,10 @@
{
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
- if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+ yysize = yysize1;
+ else
return 2;
- yysize = yysize1;
}
if (*yymsg_alloc < yysize)
@@ -1091,23 +1089,33 @@
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
+
/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
+| yynewstate -- push a new state, which is found in yystate. |
`------------------------------------------------------------*/
- yynewstate:
+yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
- yysetstate:
- *yyssp = yystate;
+
+/*--------------------------------------------------------------------.
+| yynewstate -- set current state (the top of the stack) to yystate. |
+`--------------------------------------------------------------------*/
+yysetstate:
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+ YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
+ *yyssp = (yytype_int16) yystate;
if (yyss + yystacksize - 1 <= yyssp)
+#if !defined yyoverflow && !defined YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+#else
{
/* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
+ YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
-#ifdef yyoverflow
+# if defined yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
@@ -1123,14 +1131,10 @@
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
-
yyss = yyss1;
yyvs = yyvs1;
}
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
+# else /* defined YYSTACK_RELOCATE */
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
@@ -1146,35 +1150,33 @@
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
-# undef YYSTACK_RELOCATE
+# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
-#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
+ (unsigned long) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
if (yystate == YYFINAL)
YYACCEPT;
goto yybackup;
+
/*-----------.
| yybackup. |
`-----------*/
yybackup:
-
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
@@ -1232,7 +1234,6 @@
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
-
goto yynewstate;
@@ -1247,7 +1248,7 @@
/*-----------------------------.
-| yyreduce -- Do a reduction. |
+| yyreduce -- do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
@@ -1267,18 +1268,18 @@
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
- case 2:
-#line 81 "fmd_parser.y" /* yacc.c:1646 */
+ case 2:
+#line 82 "fmd_parser.y"
{
union flashmap_flags flags = { .v=0 };
if (!(res = parse_descriptor((yyvsp[-3].strval), flags, (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr))))
YYABORT;
}
-#line 1278 "y.tab.c" /* yacc.c:1646 */
+#line 1279 "fmd_parser.tab.c"
break;
case 3:
-#line 88 "fmd_parser.y" /* yacc.c:1646 */
+#line 89 "fmd_parser.y"
{
struct flashmap_descriptor *node = parse_descriptor((yyvsp[-4].strval), (yyvsp[-3].flags), (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr));
if (!node)
@@ -1291,91 +1292,97 @@
(yyval.region_ptr) = node;
}
-#line 1295 "y.tab.c" /* yacc.c:1646 */
+#line 1296 "fmd_parser.tab.c"
break;
case 4:
-#line 101 "fmd_parser.y" /* yacc.c:1646 */
+#line 102 "fmd_parser.y"
{
if (!(yyvsp[0].strval)) {
perror("E: While allocating section name");
YYABORT;
}
}
-#line 1306 "y.tab.c" /* yacc.c:1646 */
+#line 1307 "fmd_parser.tab.c"
break;
case 5:
-#line 107 "fmd_parser.y" /* yacc.c:1646 */
+#line 108 "fmd_parser.y"
{ (yyval.flags) = (union flashmap_flags){ .v=0 }; }
-#line 1312 "y.tab.c" /* yacc.c:1646 */
+#line 1313 "fmd_parser.tab.c"
break;
case 6:
-#line 108 "fmd_parser.y" /* yacc.c:1646 */
+#line 109 "fmd_parser.y"
{ (yyval.flags) = (yyvsp[-1].flags); }
-#line 1318 "y.tab.c" /* yacc.c:1646 */
+#line 1319 "fmd_parser.tab.c"
break;
case 8:
-#line 109 "fmd_parser.y" /* yacc.c:1646 */
+#line 110 "fmd_parser.y"
{ (yyval.flags).v = (yyvsp[-1].flags).v | (yyvsp[0].flags).v; }
-#line 1324 "y.tab.c" /* yacc.c:1646 */
+#line 1325 "fmd_parser.tab.c"
break;
case 9:
-#line 110 "fmd_parser.y" /* yacc.c:1646 */
+#line 111 "fmd_parser.y"
{ (yyval.flags).v = 0; (yyval.flags).f.cbfs = 1; }
-#line 1330 "y.tab.c" /* yacc.c:1646 */
+#line 1331 "fmd_parser.tab.c"
break;
case 10:
-#line 111 "fmd_parser.y" /* yacc.c:1646 */
+#line 112 "fmd_parser.y"
{ (yyval.flags).v = 0; (yyval.flags).f.preserve = 1; }
-#line 1336 "y.tab.c" /* yacc.c:1646 */
+#line 1337 "fmd_parser.tab.c"
break;
case 11:
-#line 112 "fmd_parser.y" /* yacc.c:1646 */
- { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
-#line 1342 "y.tab.c" /* yacc.c:1646 */
+#line 113 "fmd_parser.y"
+ { (yyval.flags).v = 0; (yyval.flags).f.aligned = 1; }
+#line 1343 "fmd_parser.tab.c"
break;
- case 13:
-#line 114 "fmd_parser.y" /* yacc.c:1646 */
- { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
-#line 1348 "y.tab.c" /* yacc.c:1646 */
+ case 12:
+#line 114 "fmd_parser.y"
+ { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
+#line 1349 "fmd_parser.tab.c"
break;
case 14:
-#line 115 "fmd_parser.y" /* yacc.c:1646 */
- { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
-#line 1354 "y.tab.c" /* yacc.c:1646 */
+#line 116 "fmd_parser.y"
+ { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
+#line 1355 "fmd_parser.tab.c"
break;
- case 16:
-#line 117 "fmd_parser.y" /* yacc.c:1646 */
- { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
-#line 1360 "y.tab.c" /* yacc.c:1646 */
+ case 15:
+#line 117 "fmd_parser.y"
+ { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
+#line 1361 "fmd_parser.tab.c"
break;
case 17:
-#line 119 "fmd_parser.y" /* yacc.c:1646 */
+#line 119 "fmd_parser.y"
+ { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
+#line 1367 "fmd_parser.tab.c"
+ break;
+
+ case 18:
+#line 121 "fmd_parser.y"
{
(yyval.region_listhdr) = (struct descriptor_list)
{.len = 0, .head = NULL, .tail = NULL};
}
-#line 1369 "y.tab.c" /* yacc.c:1646 */
- break;
-
- case 19:
-#line 124 "fmd_parser.y" /* yacc.c:1646 */
- { (yyval.region_listhdr) = (yyvsp[-1].region_listhdr); }
-#line 1375 "y.tab.c" /* yacc.c:1646 */
+#line 1376 "fmd_parser.tab.c"
break;
case 20:
-#line 126 "fmd_parser.y" /* yacc.c:1646 */
+#line 126 "fmd_parser.y"
+ { (yyval.region_listhdr) = (yyvsp[-1].region_listhdr); }
+#line 1382 "fmd_parser.tab.c"
+ break;
+
+ case 21:
+#line 128 "fmd_parser.y"
{
struct descriptor_node *node = malloc(sizeof(*node));
if (!node) {
@@ -1386,11 +1393,11 @@
node->next = NULL;
(yyval.region_listhdr) = (struct descriptor_list){.len = 1, .head = node, .tail = node};
}
-#line 1390 "y.tab.c" /* yacc.c:1646 */
+#line 1397 "fmd_parser.tab.c"
break;
- case 21:
-#line 137 "fmd_parser.y" /* yacc.c:1646 */
+ case 22:
+#line 139 "fmd_parser.y"
{
struct descriptor_node *node = malloc(sizeof(*node));
if (!node) {
@@ -1404,11 +1411,12 @@
(yyval.region_listhdr) = (struct descriptor_list)
{.len = (yyvsp[-1].region_listhdr).len + 1, .head = (yyvsp[-1].region_listhdr).head, .tail = node};
}
-#line 1408 "y.tab.c" /* yacc.c:1646 */
+#line 1415 "fmd_parser.tab.c"
break;
-#line 1412 "y.tab.c" /* yacc.c:1646 */
+#line 1419 "fmd_parser.tab.c"
+
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -1433,14 +1441,13 @@
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
+ {
+ const int yylhs = yyr1[yyn] - YYNTOKENS;
+ const int yyi = yypgoto[yylhs] + *yyssp;
+ yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
+ ? yytable[yyi]
+ : yydefgoto[yylhs]);
+ }
goto yynewstate;
@@ -1523,12 +1530,10 @@
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
+ /* Pacify compilers when the user code never invokes YYERROR and the
+ label yyerrorlab therefore never appears in user code. */
+ if (0)
+ YYERROR;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
@@ -1590,6 +1595,7 @@
yyresult = 0;
goto yyreturn;
+
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
@@ -1597,6 +1603,7 @@
yyresult = 1;
goto yyreturn;
+
#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
@@ -1607,6 +1614,10 @@
/* Fall through. */
#endif
+
+/*-----------------------------------------------------.
+| yyreturn -- parsing is finished, return the result. |
+`-----------------------------------------------------*/
yyreturn:
if (yychar != YYEMPTY)
{
@@ -1636,7 +1647,7 @@
#endif
return yyresult;
}
-#line 151 "fmd_parser.y" /* yacc.c:1906 */
+#line 153 "fmd_parser.y"
struct flashmap_descriptor *parse_descriptor(
diff --git a/util/cbfstool/fmd_parser.h_shipped b/util/cbfstool/fmd_parser.h_shipped
index 07c0259..afe77af 100644
--- a/util/cbfstool/fmd_parser.h_shipped
+++ b/util/cbfstool/fmd_parser.h_shipped
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
+/* A Bison parser, made by GNU Bison 3.4.1. */
/* Bison interface for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
+ Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,8 +31,11 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
-#ifndef YY_YY_Y_TAB_H_INCLUDED
-# define YY_YY_Y_TAB_H_INCLUDED
+/* Undocumented macros, especially those whose name start with YY_,
+ are private implementation details. Do not rely on them. */
+
+#ifndef YY_YY_FMD_PARSER_TAB_H_INCLUDED
+# define YY_YY_FMD_PARSER_TAB_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
@@ -40,7 +44,7 @@
extern int yydebug;
#endif
/* "%code requires" blocks. */
-#line 34 "fmd_parser.y" /* yacc.c:1909 */
+#line 34 "fmd_parser.y"
#include "fmd.h"
#include "option.h"
@@ -65,7 +69,7 @@
struct unsigned_option size, struct descriptor_list children);
void yyerror(const char *s);
-#line 69 "y.tab.h" /* yacc.c:1909 */
+#line 73 "fmd_parser.tab.h"
/* Token type. */
#ifndef YYTOKENTYPE
@@ -76,22 +80,16 @@
OCTAL = 259,
STRING = 260,
FLAG_CBFS = 261,
- FLAG_PRESERVE = 262
+ FLAG_PRESERVE = 262,
+ FLAG_ALIGNED = 263
};
#endif
-/* Tokens. */
-#define INTEGER 258
-#define OCTAL 259
-#define STRING 260
-#define FLAG_CBFS 261
-#define FLAG_PRESERVE 262
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-
union YYSTYPE
{
-#line 25 "fmd_parser.y" /* yacc.c:1909 */
+#line 25 "fmd_parser.y"
unsigned intval;
char *strval;
@@ -100,9 +98,9 @@
union flashmap_flags flags;
struct descriptor_list region_listhdr;
-#line 104 "y.tab.h" /* yacc.c:1909 */
-};
+#line 102 "fmd_parser.tab.h"
+};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
@@ -113,4 +111,4 @@
int yyparse (void);
-#endif /* !YY_YY_Y_TAB_H_INCLUDED */
+#endif /* !YY_YY_FMD_PARSER_TAB_H_INCLUDED */
diff --git a/util/cbfstool/fmd_parser.y b/util/cbfstool/fmd_parser.y
index 3ba710c..2f59399 100644
--- a/util/cbfstool/fmd_parser.y
+++ b/util/cbfstool/fmd_parser.y
@@ -61,6 +61,7 @@
%token <strval> STRING
%token FLAG_CBFS
%token FLAG_PRESERVE
+%token FLAG_ALIGNED
%type <region_ptr> flash_region
%type <strval> region_name
@@ -109,6 +110,7 @@
region_flags: region_flag | region_flag region_flags { $$.v = $1.v | $2.v; };
region_flag: FLAG_CBFS { $$.v = 0; $$.f.cbfs = 1; };
region_flag: FLAG_PRESERVE { $$.v = 0; $$.f.preserve = 1; };
+region_flag: FLAG_ALIGNED { $$.v = 0; $$.f.aligned = 1; };
region_offset_opt: { $$ = (struct unsigned_option){false, 0}; }
| region_offset;
region_offset: '@' INTEGER { $$ = (struct unsigned_option){true, $2}; };
diff --git a/util/cbfstool/fmd_scanner.c_shipped b/util/cbfstool/fmd_scanner.c_shipped
index 71d541d..e0d6418 100644
--- a/util/cbfstool/fmd_scanner.c_shipped
+++ b/util/cbfstool/fmd_scanner.c_shipped
@@ -8,7 +8,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
+#define YY_FLEX_SUBMINOR_VERSION 4
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -83,10 +83,16 @@
#define UINT32_MAX (4294967295U)
#endif
+#ifndef SIZE_MAX
+#define SIZE_MAX (~(size_t)0)
+#endif
+
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */
+
/* TODO: this is always defined, so inline it */
#define yyconst const
@@ -99,32 +105,26 @@
/* Returned upon end-of-file. */
#define YY_NULL 0
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
+/* Promotes a possibly negative, possibly signed char to an
+ * integer in range [0..255] for use as an array index.
*/
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
*/
#define BEGIN (yy_start) = 1 + 2 *
-
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START (((yy_start) - 1) / 2)
#define YYSTATE YY_START
-
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart(yyin )
-
+#define YY_NEW_FILE yyrestart( yyin )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
@@ -161,7 +161,7 @@
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
-
+
#define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
@@ -178,7 +178,6 @@
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
-
#define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_STRUCT_YY_BUFFER_STATE
@@ -260,7 +259,6 @@
#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
? (yy_buffer_stack)[(yy_buffer_stack_top)] \
: NULL)
-
/* Same as previous macro, but useful when we know that the buffer stack is not
* NULL or when we need an lvalue. For internal use only.
*/
@@ -281,65 +279,59 @@
*/
static int yy_did_buffer_switch_on_eof;
-void yyrestart (FILE *input_file );
-void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
-void yy_delete_buffer (YY_BUFFER_STATE b );
-void yy_flush_buffer (YY_BUFFER_STATE b );
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
-void yypop_buffer_state (void );
+void yyrestart ( FILE *input_file );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size );
+void yy_delete_buffer ( YY_BUFFER_STATE b );
+void yy_flush_buffer ( YY_BUFFER_STATE b );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer );
+void yypop_buffer_state ( void );
-static void yyensure_buffer_stack (void );
-static void yy_load_buffer_state (void );
-static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
+static void yyensure_buffer_stack ( void );
+static void yy_load_buffer_state ( void );
+static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file );
+#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER )
-#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
-YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
-
-void *yyalloc (yy_size_t );
-void *yyrealloc (void *,yy_size_t );
-void yyfree (void * );
+void *yyalloc ( yy_size_t );
+void *yyrealloc ( void *, yy_size_t );
+void yyfree ( void * );
#define yy_new_buffer yy_create_buffer
-
#define yy_set_interactive(is_interactive) \
{ \
if ( ! YY_CURRENT_BUFFER ){ \
yyensure_buffer_stack (); \
YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ); \
+ yy_create_buffer( yyin, YY_BUF_SIZE ); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
-
#define yy_set_bol(at_bol) \
{ \
if ( ! YY_CURRENT_BUFFER ){\
yyensure_buffer_stack (); \
YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ); \
+ yy_create_buffer( yyin, YY_BUF_SIZE ); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
-
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
/* Begin user sect3 */
#define yywrap() (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
-
-typedef unsigned char YY_CHAR;
+typedef flex_uint8_t YY_CHAR;
FILE *yyin = NULL, *yyout = NULL;
typedef int yy_state_type;
extern int yylineno;
-
int yylineno = 1;
extern char *yytext;
@@ -348,10 +340,10 @@
#endif
#define yytext_ptr yytext
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
-static int yy_get_next_buffer (void );
-static void yynoreturn yy_fatal_error (yyconst char* msg );
+static yy_state_type yy_get_previous_state ( void );
+static yy_state_type yy_try_NUL_trans ( yy_state_type current_state );
+static int yy_get_next_buffer ( void );
+static void yynoreturn yy_fatal_error ( const char* msg );
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
@@ -362,9 +354,8 @@
(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;
-
-#define YY_NUM_RULES 13
-#define YY_END_OF_BUFFER 14
+#define YY_NUM_RULES 14
+#define YY_END_OF_BUFFER 15
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -372,15 +363,16 @@
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[40] =
+static const flex_int16_t yy_accept[47] =
{ 0,
- 11, 11, 11, 11, 14, 11, 1, 1, 12, 3,
- 12, 7, 8, 4, 11, 11, 11, 1, 0, 2,
- 9, 7, 11, 8, 8, 11, 11, 9, 10, 11,
- 11, 10, 5, 11, 11, 11, 11, 6, 0
+ 12, 12, 12, 12, 15, 12, 1, 1, 13, 3,
+ 13, 8, 9, 4, 12, 12, 12, 12, 1, 0,
+ 2, 10, 8, 12, 9, 9, 12, 12, 12, 10,
+ 11, 12, 12, 12, 11, 12, 5, 12, 12, 12,
+ 12, 12, 7, 12, 6, 0
} ;
-static yyconst YY_CHAR yy_ec[256] =
+static const YY_CHAR yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
@@ -388,13 +380,13 @@
1, 2, 1, 1, 4, 1, 1, 1, 1, 5,
6, 1, 1, 1, 1, 1, 1, 7, 8, 8,
8, 8, 8, 8, 8, 8, 8, 1, 1, 1,
- 1, 1, 1, 9, 10, 11, 12, 10, 13, 14,
- 15, 1, 1, 1, 15, 1, 15, 1, 1, 16,
- 1, 17, 18, 1, 1, 19, 1, 20, 1, 1,
- 1, 1, 1, 1, 1, 1, 10, 10, 10, 10,
+ 1, 1, 1, 9, 10, 11, 12, 13, 14, 15,
+ 16, 1, 17, 1, 18, 19, 18, 20, 1, 21,
+ 1, 22, 23, 1, 1, 24, 1, 25, 1, 1,
+ 1, 1, 1, 1, 1, 1, 26, 26, 26, 26,
- 10, 10, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 20,
+ 26, 26, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 25,
1, 1, 9, 1, 9, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -412,54 +404,67 @@
1, 1, 1, 1, 1
} ;
-static yyconst YY_CHAR yy_meta[21] =
+static const YY_CHAR yy_meta[27] =
{ 0,
1, 2, 2, 2, 2, 2, 1, 1, 2, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1
} ;
-static yyconst flex_uint16_t yy_base[43] =
+static const flex_int16_t yy_base[50] =
{ 0,
- 0, 8, 12, 13, 63, 0, 18, 20, 59, 64,
- 64, 23, 19, 64, 50, 43, 0, 30, 56, 64,
- 20, 0, 37, 0, 0, 44, 44, 0, 41, 28,
- 24, 0, 0, 28, 22, 18, 23, 0, 64, 51,
- 0, 53
+ 0, 8, 12, 28, 57, 0, 17, 23, 53, 105,
+ 105, 43, 62, 105, 36, 43, 31, 0, 25, 49,
+ 105, 5, 0, 74, 0, 0, 31, 32, 32, 0,
+ 13, 29, 21, 20, 0, 22, 0, 27, 25, 15,
+ 23, 11, 0, 18, 0, 105, 100, 0, 102
} ;
-static yyconst flex_int16_t yy_def[43] =
+static const flex_int16_t yy_def[50] =
{ 0,
- 40, 40, 2, 2, 39, 41, 39, 39, 42, 39,
- 39, 41, 41, 39, 41, 41, 41, 39, 42, 39,
- 12, 41, 41, 13, 41, 41, 41, 41, 23, 41,
- 41, 41, 41, 41, 41, 41, 41, 41, 0, 39,
- 39, 39
+ 47, 47, 2, 2, 46, 48, 46, 46, 49, 46,
+ 46, 48, 48, 46, 48, 48, 48, 48, 46, 49,
+ 46, 12, 48, 48, 13, 48, 48, 48, 48, 48,
+ 24, 48, 48, 48, 48, 48, 48, 48, 48, 48,
+ 48, 48, 48, 48, 48, 0, 46, 46, 46
} ;
-static yyconst flex_uint16_t yy_nxt[85] =
+static const flex_int16_t yy_nxt[132] =
{ 0,
- 17, 7, 8, 9, 10, 11, 12, 13, 11, 7,
- 8, 9, 10, 11, 12, 13, 11, 14, 14, 18,
- 18, 18, 18, 15, 15, 24, 24, 16, 16, 21,
- 21, 18, 18, 25, 28, 38, 37, 22, 36, 17,
- 35, 34, 23, 29, 29, 33, 29, 29, 29, 29,
- 29, 6, 6, 19, 19, 32, 31, 30, 20, 27,
- 26, 20, 39, 5, 39, 39, 39, 39, 39, 39,
- 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
- 39, 39, 39, 39
+ 18, 7, 8, 9, 10, 11, 12, 13, 11, 7,
+ 8, 9, 10, 11, 12, 13, 11, 14, 19, 19,
+ 30, 15, 30, 16, 19, 19, 19, 19, 35, 18,
+ 35, 45, 17, 14, 44, 43, 42, 15, 41, 16,
+ 40, 39, 38, 37, 36, 34, 33, 32, 17, 22,
+ 22, 21, 29, 28, 27, 21, 46, 46, 23, 46,
+ 23, 46, 46, 46, 46, 46, 46, 24, 25, 25,
+ 46, 46, 46, 46, 46, 46, 46, 26, 46, 26,
+ 31, 31, 46, 31, 31, 31, 31, 31, 31, 46,
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 31,
+
+ 6, 6, 20, 20, 5, 46, 46, 46, 46, 46,
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
+ 46
} ;
-static yyconst flex_int16_t yy_chk[85] =
+static const flex_int16_t yy_chk[132] =
{ 0,
- 41, 1, 1, 1, 1, 1, 1, 1, 1, 2,
- 2, 2, 2, 2, 2, 2, 2, 3, 4, 7,
- 7, 8, 8, 3, 4, 13, 13, 3, 4, 12,
- 12, 18, 18, 13, 21, 37, 36, 12, 35, 21,
- 34, 31, 12, 23, 23, 30, 23, 23, 23, 23,
- 23, 40, 40, 42, 42, 29, 27, 26, 19, 16,
- 15, 9, 5, 39, 39, 39, 39, 39, 39, 39,
- 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
- 39, 39, 39, 39
+ 48, 1, 1, 1, 1, 1, 1, 1, 1, 2,
+ 2, 2, 2, 2, 2, 2, 2, 3, 7, 7,
+ 22, 3, 22, 3, 8, 8, 19, 19, 31, 22,
+ 31, 44, 3, 4, 42, 41, 40, 4, 39, 4,
+ 38, 36, 34, 33, 32, 29, 28, 27, 4, 12,
+ 12, 20, 17, 16, 15, 9, 5, 0, 12, 0,
+ 12, 0, 0, 0, 0, 0, 0, 12, 13, 13,
+ 0, 0, 0, 0, 0, 0, 0, 13, 0, 13,
+ 24, 24, 0, 24, 24, 24, 24, 24, 24, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 24,
+
+ 47, 47, 49, 49, 46, 46, 46, 46, 46, 46,
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
+ 46
} ;
static yy_state_type yy_last_accepting_state;
@@ -499,8 +504,9 @@
int parse_integer(char *src, int base);
int copy_string(const char *src);
+#line 508 "<stdout>"
-#line 504 "<stdout>"
+#line 510 "<stdout>"
#define INITIAL 0
#define FLAGS 1
@@ -517,36 +523,36 @@
#define YY_EXTRA_TYPE void *
#endif
-static int yy_init_globals (void );
+static int yy_init_globals ( void );
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
-int yylex_destroy (void );
+int yylex_destroy ( void );
-int yyget_debug (void );
+int yyget_debug ( void );
-void yyset_debug (int debug_flag );
+void yyset_debug ( int debug_flag );
-YY_EXTRA_TYPE yyget_extra (void );
+YY_EXTRA_TYPE yyget_extra ( void );
-void yyset_extra (YY_EXTRA_TYPE user_defined );
+void yyset_extra ( YY_EXTRA_TYPE user_defined );
-FILE *yyget_in (void );
+FILE *yyget_in ( void );
-void yyset_in (FILE * _in_str );
+void yyset_in ( FILE * _in_str );
-FILE *yyget_out (void );
+FILE *yyget_out ( void );
-void yyset_out (FILE * _out_str );
+void yyset_out ( FILE * _out_str );
- int yyget_leng (void );
+ int yyget_leng ( void );
-char *yyget_text (void );
+char *yyget_text ( void );
-int yyget_lineno (void );
+int yyget_lineno ( void );
-void yyset_lineno (int _line_number );
+void yyset_lineno ( int _line_number );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -554,32 +560,31 @@
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int yywrap (void );
+extern "C" int yywrap ( void );
#else
-extern int yywrap (void );
+extern int yywrap ( void );
#endif
#endif
#ifndef YY_NO_UNPUT
- static void yyunput (int c,char *buf_ptr );
+ static void yyunput ( int c, char *buf_ptr );
#endif
#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
+static void yy_flex_strncpy ( char *, const char *, int );
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
+static int yy_flex_strlen ( const char * );
#endif
#ifndef YY_NO_INPUT
-
#ifdef __cplusplus
-static int yyinput (void );
+static int yyinput ( void );
#else
-static int input (void );
+static int input ( void );
#endif
#endif
@@ -610,7 +615,7 @@
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
- size_t n; \
+ int n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@@ -623,7 +628,7 @@
else \
{ \
errno=0; \
- while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
@@ -712,16 +717,16 @@
if ( ! YY_CURRENT_BUFFER ) {
yyensure_buffer_stack ();
YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE );
+ yy_create_buffer( yyin, YY_BUF_SIZE );
}
- yy_load_buffer_state( );
+ yy_load_buffer_state( );
}
{
#line 31 "fmd_scanner.l"
-#line 725 "<stdout>"
+#line 730 "<stdout>"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
@@ -748,13 +753,13 @@
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 40 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ if ( yy_current_state >= 47 )
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
- while ( yy_base[yy_current_state] != 64 );
+ while ( yy_base[yy_current_state] != 105 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -813,38 +818,43 @@
return FLAG_PRESERVE;
YY_BREAK
case 7:
-#line 39 "fmd_scanner.l"
-case 8:
YY_RULE_SETUP
-#line 39 "fmd_scanner.l"
-return parse_integer(yytext, 10);
+#line 38 "fmd_scanner.l"
+return FLAG_ALIGNED;
YY_BREAK
+case 8:
+#line 40 "fmd_scanner.l"
case 9:
YY_RULE_SETUP
#line 40 "fmd_scanner.l"
-return OCTAL;
+return parse_integer(yytext, 10);
YY_BREAK
case 10:
YY_RULE_SETUP
#line 41 "fmd_scanner.l"
-return parse_integer(yytext + 2, 16);
+return OCTAL;
YY_BREAK
case 11:
YY_RULE_SETUP
#line 42 "fmd_scanner.l"
-return copy_string(yytext);
+return parse_integer(yytext + 2, 16);
YY_BREAK
case 12:
YY_RULE_SETUP
#line 43 "fmd_scanner.l"
-return *yytext;
+return copy_string(yytext);
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 45 "fmd_scanner.l"
+#line 44 "fmd_scanner.l"
+return *yytext;
+ YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 46 "fmd_scanner.l"
ECHO;
YY_BREAK
-#line 848 "<stdout>"
+#line 858 "<stdout>"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(FLAGS):
yyterminate();
@@ -923,7 +933,7 @@
{
(yy_did_buffer_switch_on_eof) = 0;
- if ( yywrap( ) )
+ if ( yywrap( ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
@@ -1055,7 +1065,8 @@
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
- yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
+ yyrealloc( (void *) b->yy_ch_buf,
+ (yy_size_t) (b->yy_buf_size + 2) );
}
else
/* Can't grow it, we don't own it. */
@@ -1087,7 +1098,7 @@
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
- yyrestart(yyin );
+ yyrestart( yyin );
}
else
@@ -1104,9 +1115,12 @@
if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
+ (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ /* "- 2" to take care of EOB's */
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
}
(yy_n_chars) += number_to_move;
@@ -1138,10 +1152,10 @@
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 40 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ if ( yy_current_state >= 47 )
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
}
return yy_current_state;
@@ -1166,11 +1180,11 @@
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 40 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ if ( yy_current_state >= 47 )
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
- yy_is_jam = (yy_current_state == 39);
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
+ yy_is_jam = (yy_current_state == 46);
return yy_is_jam ? 0 : yy_current_state;
}
@@ -1240,7 +1254,7 @@
else
{ /* need more input */
- int offset = (yy_c_buf_p) - (yytext_ptr);
+ int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) )
@@ -1257,13 +1271,13 @@
*/
/* Reset buffer status. */
- yyrestart(yyin );
+ yyrestart( yyin );
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
- if ( yywrap( ) )
+ if ( yywrap( ) )
return 0;
if ( ! (yy_did_buffer_switch_on_eof) )
@@ -1301,11 +1315,11 @@
if ( ! YY_CURRENT_BUFFER ){
yyensure_buffer_stack ();
YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE );
+ yy_create_buffer( yyin, YY_BUF_SIZE );
}
- yy_init_buffer(YY_CURRENT_BUFFER,input_file );
- yy_load_buffer_state( );
+ yy_init_buffer( YY_CURRENT_BUFFER, input_file );
+ yy_load_buffer_state( );
}
/** Switch to a different input buffer.
@@ -1333,7 +1347,7 @@
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- yy_load_buffer_state( );
+ yy_load_buffer_state( );
/* We don't actually know whether we did this switch during
* EOF (yywrap()) processing, but the only time this flag
@@ -1361,22 +1375,22 @@
{
YY_BUFFER_STATE b;
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
- b->yy_buf_size = (yy_size_t)size;
+ b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
- b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
+ b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
- yy_init_buffer(b,file );
+ yy_init_buffer( b, file );
return b;
}
@@ -1395,9 +1409,9 @@
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
- yyfree((void *) b->yy_ch_buf );
+ yyfree( (void *) b->yy_ch_buf );
- yyfree((void *) b );
+ yyfree( (void *) b );
}
/* Initializes or reinitializes a buffer.
@@ -1409,7 +1423,7 @@
{
int oerrno = errno;
- yy_flush_buffer(b );
+ yy_flush_buffer( b );
b->yy_input_file = file;
b->yy_fill_buffer = 1;
@@ -1452,7 +1466,7 @@
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
- yy_load_buffer_state( );
+ yy_load_buffer_state( );
}
/** Pushes the new state onto the stack. The new state becomes
@@ -1483,7 +1497,7 @@
YY_CURRENT_BUFFER_LVALUE = new_buffer;
/* copied from yy_switch_to_buffer. */
- yy_load_buffer_state( );
+ yy_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
}
@@ -1502,7 +1516,7 @@
--(yy_buffer_stack_top);
if (YY_CURRENT_BUFFER) {
- yy_load_buffer_state( );
+ yy_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
}
}
@@ -1512,7 +1526,7 @@
*/
static void yyensure_buffer_stack (void)
{
- int num_to_alloc;
+ yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
@@ -1569,11 +1583,11 @@
/* They forgot to leave room for the EOB's. */
return NULL;
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = NULL;
@@ -1583,7 +1597,7 @@
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
- yy_switch_to_buffer(b );
+ yy_switch_to_buffer( b );
return b;
}
@@ -1596,10 +1610,10 @@
* @note If you want to scan bytes that may contain NUL values, then use
* yy_scan_bytes() instead.
*/
-YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
+YY_BUFFER_STATE yy_scan_string (const char * yystr )
{
- return yy_scan_bytes(yystr,(int) strlen(yystr) );
+ return yy_scan_bytes( yystr, (int) strlen(yystr) );
}
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
@@ -1609,7 +1623,7 @@
*
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
+YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
@@ -1618,7 +1632,7 @@
/* Get memory for full buffer, including space for trailing EOB's. */
n = (yy_size_t) (_yybytes_len + 2);
- buf = (char *) yyalloc(n );
+ buf = (char *) yyalloc( n );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
@@ -1627,7 +1641,7 @@
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
- b = yy_scan_buffer(buf,n );
+ b = yy_scan_buffer( buf, n );
if ( ! b )
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
@@ -1643,9 +1657,9 @@
#define YY_EXIT_FAILURE 2
#endif
-static void yynoreturn yy_fatal_error (yyconst char* msg )
+static void yynoreturn yy_fatal_error (const char* msg )
{
- (void) fprintf( stderr, "%s\n", msg );
+ fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
@@ -1673,7 +1687,7 @@
*/
int yyget_lineno (void)
{
-
+
return yylineno;
}
@@ -1780,7 +1794,7 @@
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
- yy_delete_buffer(YY_CURRENT_BUFFER );
+ yy_delete_buffer( YY_CURRENT_BUFFER );
YY_CURRENT_BUFFER_LVALUE = NULL;
yypop_buffer_state();
}
@@ -1801,7 +1815,7 @@
*/
#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+static void yy_flex_strncpy (char* s1, const char * s2, int n )
{
int i;
@@ -1811,7 +1825,7 @@
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
+static int yy_flex_strlen (const char * s )
{
int n;
for ( n = 0; s[n]; ++n )
@@ -1846,8 +1860,7 @@
#define YYTABLES_NAME "yytables"
-#line 45 "fmd_scanner.l"
-
+#line 46 "fmd_scanner.l"
int parse_integer(char *src, int base)
diff --git a/util/cbfstool/fmd_scanner.h_shipped b/util/cbfstool/fmd_scanner.h_shipped
index 2a8b291..92d2c72 100644
--- a/util/cbfstool/fmd_scanner.h_shipped
+++ b/util/cbfstool/fmd_scanner.h_shipped
@@ -11,7 +11,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
+#define YY_FLEX_SUBMINOR_VERSION 4
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -86,10 +86,16 @@
#define UINT32_MAX (4294967295U)
#endif
+#ifndef SIZE_MAX
+#define SIZE_MAX (~(size_t)0)
+#endif
+
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */
+
/* TODO: this is always defined, so inline it */
#define yyconst const
@@ -177,21 +183,21 @@
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-void yyrestart (FILE *input_file );
-void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
-void yy_delete_buffer (YY_BUFFER_STATE b );
-void yy_flush_buffer (YY_BUFFER_STATE b );
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
-void yypop_buffer_state (void );
+void yyrestart ( FILE *input_file );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size );
+void yy_delete_buffer ( YY_BUFFER_STATE b );
+void yy_flush_buffer ( YY_BUFFER_STATE b );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer );
+void yypop_buffer_state ( void );
-YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
-void *yyalloc (yy_size_t );
-void *yyrealloc (void *,yy_size_t );
-void yyfree (void * );
+void *yyalloc ( yy_size_t );
+void *yyrealloc ( void *, yy_size_t );
+void yyfree ( void * );
/* Begin user sect3 */
@@ -227,31 +233,31 @@
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
-int yylex_destroy (void );
+int yylex_destroy ( void );
-int yyget_debug (void );
+int yyget_debug ( void );
-void yyset_debug (int debug_flag );
+void yyset_debug ( int debug_flag );
-YY_EXTRA_TYPE yyget_extra (void );
+YY_EXTRA_TYPE yyget_extra ( void );
-void yyset_extra (YY_EXTRA_TYPE user_defined );
+void yyset_extra ( YY_EXTRA_TYPE user_defined );
-FILE *yyget_in (void );
+FILE *yyget_in ( void );
-void yyset_in (FILE * _in_str );
+void yyset_in ( FILE * _in_str );
-FILE *yyget_out (void );
+FILE *yyget_out ( void );
-void yyset_out (FILE * _out_str );
+void yyset_out ( FILE * _out_str );
- int yyget_leng (void );
+ int yyget_leng ( void );
-char *yyget_text (void );
+char *yyget_text ( void );
-int yyget_lineno (void );
+int yyget_lineno ( void );
-void yyset_lineno (int _line_number );
+void yyset_lineno ( int _line_number );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -259,18 +265,18 @@
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int yywrap (void );
+extern "C" int yywrap ( void );
#else
-extern int yywrap (void );
+extern int yywrap ( void );
#endif
#endif
#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
+static void yy_flex_strncpy ( char *, const char *, int );
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
+static int yy_flex_strlen ( const char * );
#endif
#ifndef YY_NO_INPUT
@@ -317,9 +323,154 @@
#undef YY_DECL
#endif
-#line 45 "fmd_scanner.l"
+#ifndef yy_create_buffer_ALREADY_DEFINED
+#undef yy_create_buffer
+#endif
+#ifndef yy_delete_buffer_ALREADY_DEFINED
+#undef yy_delete_buffer
+#endif
+#ifndef yy_scan_buffer_ALREADY_DEFINED
+#undef yy_scan_buffer
+#endif
+#ifndef yy_scan_string_ALREADY_DEFINED
+#undef yy_scan_string
+#endif
+#ifndef yy_scan_bytes_ALREADY_DEFINED
+#undef yy_scan_bytes
+#endif
+#ifndef yy_init_buffer_ALREADY_DEFINED
+#undef yy_init_buffer
+#endif
+#ifndef yy_flush_buffer_ALREADY_DEFINED
+#undef yy_flush_buffer
+#endif
+#ifndef yy_load_buffer_state_ALREADY_DEFINED
+#undef yy_load_buffer_state
+#endif
+#ifndef yy_switch_to_buffer_ALREADY_DEFINED
+#undef yy_switch_to_buffer
+#endif
+#ifndef yypush_buffer_state_ALREADY_DEFINED
+#undef yypush_buffer_state
+#endif
+#ifndef yypop_buffer_state_ALREADY_DEFINED
+#undef yypop_buffer_state
+#endif
+#ifndef yyensure_buffer_stack_ALREADY_DEFINED
+#undef yyensure_buffer_stack
+#endif
+#ifndef yylex_ALREADY_DEFINED
+#undef yylex
+#endif
+#ifndef yyrestart_ALREADY_DEFINED
+#undef yyrestart
+#endif
+#ifndef yylex_init_ALREADY_DEFINED
+#undef yylex_init
+#endif
+#ifndef yylex_init_extra_ALREADY_DEFINED
+#undef yylex_init_extra
+#endif
+#ifndef yylex_destroy_ALREADY_DEFINED
+#undef yylex_destroy
+#endif
+#ifndef yyget_debug_ALREADY_DEFINED
+#undef yyget_debug
+#endif
+#ifndef yyset_debug_ALREADY_DEFINED
+#undef yyset_debug
+#endif
+#ifndef yyget_extra_ALREADY_DEFINED
+#undef yyget_extra
+#endif
+#ifndef yyset_extra_ALREADY_DEFINED
+#undef yyset_extra
+#endif
+#ifndef yyget_in_ALREADY_DEFINED
+#undef yyget_in
+#endif
+#ifndef yyset_in_ALREADY_DEFINED
+#undef yyset_in
+#endif
+#ifndef yyget_out_ALREADY_DEFINED
+#undef yyget_out
+#endif
+#ifndef yyset_out_ALREADY_DEFINED
+#undef yyset_out
+#endif
+#ifndef yyget_leng_ALREADY_DEFINED
+#undef yyget_leng
+#endif
+#ifndef yyget_text_ALREADY_DEFINED
+#undef yyget_text
+#endif
+#ifndef yyget_lineno_ALREADY_DEFINED
+#undef yyget_lineno
+#endif
+#ifndef yyset_lineno_ALREADY_DEFINED
+#undef yyset_lineno
+#endif
+#ifndef yyget_column_ALREADY_DEFINED
+#undef yyget_column
+#endif
+#ifndef yyset_column_ALREADY_DEFINED
+#undef yyset_column
+#endif
+#ifndef yywrap_ALREADY_DEFINED
+#undef yywrap
+#endif
+#ifndef yyget_lval_ALREADY_DEFINED
+#undef yyget_lval
+#endif
+#ifndef yyset_lval_ALREADY_DEFINED
+#undef yyset_lval
+#endif
+#ifndef yyget_lloc_ALREADY_DEFINED
+#undef yyget_lloc
+#endif
+#ifndef yyset_lloc_ALREADY_DEFINED
+#undef yyset_lloc
+#endif
+#ifndef yyalloc_ALREADY_DEFINED
+#undef yyalloc
+#endif
+#ifndef yyrealloc_ALREADY_DEFINED
+#undef yyrealloc
+#endif
+#ifndef yyfree_ALREADY_DEFINED
+#undef yyfree
+#endif
+#ifndef yytext_ALREADY_DEFINED
+#undef yytext
+#endif
+#ifndef yyleng_ALREADY_DEFINED
+#undef yyleng
+#endif
+#ifndef yyin_ALREADY_DEFINED
+#undef yyin
+#endif
+#ifndef yyout_ALREADY_DEFINED
+#undef yyout
+#endif
+#ifndef yy_flex_debug_ALREADY_DEFINED
+#undef yy_flex_debug
+#endif
+#ifndef yylineno_ALREADY_DEFINED
+#undef yylineno
+#endif
+#ifndef yytables_fload_ALREADY_DEFINED
+#undef yytables_fload
+#endif
+#ifndef yytables_destroy_ALREADY_DEFINED
+#undef yytables_destroy
+#endif
+#ifndef yyTABLES_NAME_ALREADY_DEFINED
+#undef yyTABLES_NAME
+#endif
+
+#line 46 "fmd_scanner.l"
-#line 324 "fmd_scanner.h_shipped"
+#line 475 "fmd_scanner.h_shipped"
#undef yyIN_HEADER
#endif /* yyHEADER_H */
diff --git a/util/cbfstool/fmd_scanner.l b/util/cbfstool/fmd_scanner.l
index be9a5de..50adbf4 100644
--- a/util/cbfstool/fmd_scanner.l
+++ b/util/cbfstool/fmd_scanner.l
@@ -35,6 +35,7 @@
<FLAGS>\) BEGIN(INITIAL); return *yytext;
<FLAGS>CBFS return FLAG_CBFS;
<FLAGS>PRESERVE return FLAG_PRESERVE;
+<FLAGS>ALIGNED return FLAG_ALIGNED;
0{MULTIPLIER}? |
[1-9][0-9]*{MULTIPLIER}? return parse_integer(yytext, 10);
0[0-9]+{MULTIPLIER}? return OCTAL;
--
To view, visit https://review.coreboot.org/c/coreboot/+/37262
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9
Gerrit-Change-Number: 37262
Gerrit-PatchSet: 1
Gerrit-Owner: Hung-Te Lin <hungte(a)chromium.org>
Gerrit-MessageType: newchange
8
63