Nico Huber has submitted this change. ( https://review.coreboot.org/c/coreboot/+/51325 )
Change subject: soc/intel/fast_spi/Makefile: Rewrite 16mib check for legibility ......................................................................
soc/intel/fast_spi/Makefile: Rewrite 16mib check for legibility
Perform some cosmetical changes:
* Override the first prerequisite so we can use `$<`. * Add/remove whitspace to align things (recipe needs to be indented by a single tab only). * We can use shell variables inside double quotes. To make the end of the variable name clear, use braces, e.g. "${x}". NB. Most of the double quotes are unnecessary. They only change the way the script would be failing in case of spurious whitespace. * Break some lines doing multiple things at once. * To reduce remaining clutter, put reading numbers into a shell function.
And functional changes:
* No need to spawn `cat`, the shell can redirect input as well as output (using `<`). * To read a number from the `fmap_config.h`, we spawned 4 processes where a single one can achieve the same. With one exception: GNU awk refuses to parse hex numbers by default. Luckily, it turned out that we don't need intermediate decimal numbers: Shells can do arithmetic with hex values as well.
Change-Id: Ia7bfba0d7864fc091ee6003e09b705fd7254e99b Signed-off-by: Nico Huber nico.h@gmx.de Reviewed-on: https://review.coreboot.org/c/coreboot/+/51325 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Angel Pons th3fanbus@gmail.com Reviewed-by: Furquan Shaikh furquan@google.com --- M src/soc/intel/common/block/fast_spi/Makefile.inc 1 file changed, 19 insertions(+), 10 deletions(-)
Approvals: build bot (Jenkins): Verified Furquan Shaikh: Looks good to me, approved Angel Pons: Looks good to me, but someone else must approve
diff --git a/src/soc/intel/common/block/fast_spi/Makefile.inc b/src/soc/intel/common/block/fast_spi/Makefile.inc index 75596de..eeaae51 100644 --- a/src/soc/intel/common/block/fast_spi/Makefile.inc +++ b/src/soc/intel/common/block/fast_spi/Makefile.inc @@ -35,16 +35,25 @@ # Check to ensure that no sections in the FMAP cross 16MiB boundary if # the platform supports split decode windows for BIOS region greater # than 16MiB. -$(call add_intermediate, check-fmap-16mib-crossing, $(obj)/fmap_config.h) - flash_offset=$$(printf "%d" $$(cat $(obj)/fmap_config.h | grep "FMAP_SECTION_FLASH_START" | awk '{print $$NF}')); \ - for x in $$(cat $(obj)/fmap_config.h | grep "FMAP_TERMINAL_SECTIONS" | cut -d" -f2); do \ - start=$$(printf "%d" $$(cat $(obj)/fmap_config.h | grep "FMAP_SECTION_"$$x"_START" | awk '{print $$NF}')); \ - size=$$(printf "%d" $$(cat $(obj)/fmap_config.h | grep "FMAP_SECTION_"$$x"_SIZE" | awk '{print $$NF}')); \ - start=$$((start-flash_offset)); \ - end=$$((start+size-1)); \ - if [ $$start -lt 16777216 ] && [ $$end -ge 16777216 ]; then echo "ERROR:" $$x "crosses 16MiB boundary"; fail=1; break; fi; \ - done; \ - exit $$fail + +$(call add_intermediate, check-fmap-16mib-crossing) +check-fmap-16mib-crossing: $(obj)/fmap_config.h + fmap_get() { awk "/$$1/ { print $$NF }" < $<; }; \ + \ + flash_offset=$$(fmap_get FMAP_SECTION_FLASH_START); \ + for x in $$(grep "FMAP_TERMINAL_SECTIONS" < $< | cut -d" -f2); \ + do \ + start=$$(fmap_get "FMAP_SECTION_$${x}_START"); \ + size=$$(fmap_get "FMAP_SECTION_$${x}_SIZE"); \ + start=$$((start-flash_offset)); \ + end=$$((start+size-1)); \ + if [ $$start -lt 16777216 ] && [ $$end -ge 16777216 ]; then \ + echo "ERROR: $$x crosses 16MiB boundary"; \ + fail=1; \ + break; \ + fi; \ + done; \ + exit $$fail
CBFSTOOL_ADD_CMD_OPTIONS += --ext-win-base $(CONFIG_EXT_BIOS_WIN_BASE) --ext-win-size $(CONFIG_EXT_BIOS_WIN_SIZE)