[coreboot] Patch set updated for coreboot: b68b853 AMD hudson & SB800 - Fix issues with mawk

Martin Roth (martin.roth@se-eng.com) gerrit at coreboot.org
Tue Mar 12 02:45:02 CET 2013


Martin Roth (martin.roth at se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2628

-gerrit

commit b68b8539d852a47fa8465ffcc1631ea4557724da
Author: Martin Roth <martin.roth at se-eng.com>
Date:   Mon Mar 11 13:17:27 2013 -0600

    AMD hudson & SB800 - Fix issues with mawk
    
    When calculating the offsets of the various binary blobs within the
    coreboot.rom file, we noticed that using mawk as the awk tool instead
    of using gawk led to build issues.  This was finally traced to the
    maximum value of the unsigned long variables within mawk - 0x7fff_ffff.
    Because we were doing calculations on values up in the 0xfffcxxxx
    range, these numbers would either be turned into floating point values
    and printed using scientific notation, or truncated at 0x7fff_ffff.
    
    I see two solutions to this issue - we can either check for mawk and
    warn the user that it's not supported in a fashion similar to what
    is already being done for the solaris awk and suggest that everyone
    use gawk instead, or we can work around the issue.  I tried to work
    around it by getting rid of the top 0xF000_0000 when doing the
    calculations in awk, then adding it back when the final values are
    loaded into the final variables for the make.
    
    The downside to this approach is that we could run into this error
    again in the future for anyone who uses mawk.
    
    Change-Id: I7b6b821c8ab13ad11f72e674ac726a98e8678710
    Signed-off-by: Martin Roth <martin.roth at se-eng.com>
---
 src/southbridge/amd/agesa/hudson/Makefile.inc | 21 +++++++++++++++------
 src/southbridge/amd/cimx/sb800/Makefile.inc   |  9 +++++++--
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/southbridge/amd/agesa/hudson/Makefile.inc b/src/southbridge/amd/agesa/hudson/Makefile.inc
index 18a0ffb..ce0675d 100644
--- a/src/southbridge/amd/agesa/hudson/Makefile.inc
+++ b/src/southbridge/amd/agesa/hudson/Makefile.inc
@@ -22,10 +22,17 @@ ramstage-$(CONFIG_HAVE_ACPI_RESUME) += spi.c
 # EC ROM should be 64K aligned.
 HUDSON_FWM_POSITION=$(shell printf %u $(CONFIG_HUDSON_FWM_POSITION))
 
+# MAWK's limit for unsigned long is 0x7FFF_FFFF.  To work around this, remove
+# the top 0xF000_0000 (4026531840) from the calculation and add it back later
+# in the print statements when assigning the positions.
+HUDSON_FWM_POS__TRUNC=$(shell echo $(HUDSON_FWM_POSITION) \
+		| awk '{print  $$1 - 4026531840}')
+
 #assume the cbfs header is less than 128 bytes.
 ROMSIG_SIZE=16
 ifeq ($(CONFIG_HUDSON_XHCI_FWM), y)
-HUDSON_XHCI_POSITION=$(shell echo $(HUDSON_FWM_POSITION) $(ROMSIG_SIZE) 128 | awk '{print $$1 + $$2 + $$3}')
+HUDSON_XHCI_POSITION=$(shell echo $(HUDSON_FWM_POS__TRUNC) $(ROMSIG_SIZE) 128 \
+		| awk '{printf("0xF%X", $$1 + $$2 + $$3)}')
 XHCI_FWM_SIZE=$(word 5,$(shell ls -l $(CONFIG_HUDSON_XHCI_FWM_FILE)))
 else
 HUDSON_XHCI_POSITION=0
@@ -33,8 +40,9 @@ XHCI_FWM_SIZE=0
 endif
 
 ifeq ($(CONFIG_HUDSON_GEC_FWM), y)
-HUDSON_GEC_POSITION=$(shell echo $(HUDSON_FWM_POSITION) $(ROMSIG_SIZE) 128 \
-		$(XHCI_FWM_SIZE) 128 | awk '{print $$1 + $$2 + $$3 + $$4 + $$5}')
+HUDSON_GEC_POSITION=$(shell echo $(HUDSON_FWM_POS__TRUNC) $(ROMSIG_SIZE) 128 \
+		$(XHCI_FWM_SIZE) 128 | \
+		awk '{printf("0xF%X", $$1 + $$2 + $$3 + $$4 + $$5)}')
 GEC_FWM_SIZE=$(word 5,$(shell ls -l $(CONFIG_HUDSON_GEC_FWM_FILE)))
 else
 HUDSON_GEC_POSITION=0
@@ -42,10 +50,11 @@ GEC_FWM_SIZE=0
 endif
 
 ifeq ($(CONFIG_HUDSON_IMC_FWM), y)
-HUDSON_IMC_POSITION_UNALIGN=$(shell echo $(HUDSON_FWM_POSITION) $(ROMSIG_SIZE) 128 \
-		$(XHCI_FWM_SIZE) 128 \
+HUDSON_IMC_POSITION_UNALIGN=$(shell echo $(HUDSON_FWM_POS__TRUNC) \
+		$(ROMSIG_SIZE) 128 $(XHCI_FWM_SIZE) 128 \
 		$(GEC_FWM_SIZE) 128 65535 | awk '{print $$1 + $$2 + $$3 + $$4 + $$5 + $$6 + $$7 + $$8}')
-HUDSON_IMC_POSITION=$(shell echo $(HUDSON_IMC_POSITION_UNALIGN) | awk '{print $$1 - $$1 % 65536}')
+HUDSON_IMC_POSITION=$(shell echo $(HUDSON_IMC_POSITION_UNALIGN) \
+		| awk '{printf("0xF%X", $$1 - $$1 % 65536)}')
 else
 HUDSON_IMC_POSITION=0
 endif
diff --git a/src/southbridge/amd/cimx/sb800/Makefile.inc b/src/southbridge/amd/cimx/sb800/Makefile.inc
index 4041b22..05937e7 100644
--- a/src/southbridge/amd/cimx/sb800/Makefile.inc
+++ b/src/southbridge/amd/cimx/sb800/Makefile.inc
@@ -70,8 +70,13 @@ SB800_FWM_POSITION=$(shell printf %u $(CONFIG_SB800_FWM_POSITION))
 #assume the cbfs header is less than 128 bytes.
 ROMSIG_SIZE=16
 
-SB800_IMC_POSITION_UNALIGN=$(shell echo $(SB800_FWM_POSITION) $(ROMSIG_SIZE) 128 65535 | awk '{print $$1 + $$2 + $$3 + $$4}')
-SB800_IMC_POSITION=$(shell echo $(SB800_IMC_POSITION_UNALIGN) | awk '{print $$1 - $$1 % 65536}')
+# MAWK's limit for unsigned long is 0x7FFF_FFFF.  To work around this, remove
+# the top 0xF000_0000 (4026531840) from the calculation and add it back in the
+# printf later.
+SB800_IMC_POSITION_UNALIGN=$(shell echo $(SB800_FWM_POSITION) $(ROMSIG_SIZE) \
+		128 65535 | awk '{print $$1 - 4026531840 + $$2 + $$3 + $$4}')
+SB800_IMC_POSITION=$(shell echo $(SB800_IMC_POSITION_UNALIGN) \
+		| awk '{printf ("0xF%X", $$1 - $$1 % 65536)}')
 
 $(obj)/coreboot_SB800_romsig.bin: \
 			$(call strip_quotes, $(CONFIG_SB800_IMC_FWM_FILE)) \



More information about the coreboot mailing list