Zheng Bao ([email protected]) just uploaded a new patch set to gerrit, which 
you can find at http://review.coreboot.org/1417

-gerrit

commit fd5a9cdb5e6d4d08f44f36a402e0f258e00ff56e
Author: zbao <[email protected]>
Date:   Wed Aug 15 19:59:35 2012 +0800

    AMD Hudson: Move the combining firmware from Python to Makefile
    
    Maybe sooner or later python is not a default tools to build coreboot.
    Most of the work is done by awk now. GNU extension of gawk is not used, 
isn't?
    cat, awk, test, mv are the external tools.
    If XHCI or IMC firmware is not available and not defined, this script can 
skip
    integrating them.
    
    Change-Id: I9944b22b0b755672a46d472c355d138abafd6393
    Signed-off-by: Zheng Bao <[email protected]>
    Signed-off-by: zbao <[email protected]>
---
 src/southbridge/amd/agesa/hudson/Makefile.inc  | 67 +++++++++++++++++++++++++-
 src/southbridge/amd/agesa/hudson/hudson_fwm.py | 64 ------------------------
 2 files changed, 65 insertions(+), 66 deletions(-)

diff --git a/src/southbridge/amd/agesa/hudson/Makefile.inc 
b/src/southbridge/amd/agesa/hudson/Makefile.inc
index 19ffae1..f51cd8b 100644
--- a/src/southbridge/amd/agesa/hudson/Makefile.inc
+++ b/src/southbridge/amd/agesa/hudson/Makefile.inc
@@ -14,8 +14,71 @@ romstage-y += early_setup.c
 
 ramstage-$(CONFIG_HAVE_ACPI_RESUME) += spi.c
 
-$(obj)/hudson.bin:
-       python $(src)/southbridge/amd/agesa/hudson/hudson_fwm.py 
$(CONFIG_HUDSON_FWM_POSITION) $@ $(CONFIG_HUDSON_XHCI_FWM_FILE) 
$(CONFIG_HUDSON_IMC_FWM_FILE) ""
+# ROMSIG At ROMBASE + 0x20000:
+# +-----------+---------------+----------------+------------+
+# |0x55AA55AA |EC ROM Address |GEC ROM Address |USB3 ROM    |
+# +-----------+---------------+----------------+------------+
+# In our coreboot implementation, we concatenate the ROM images
+# next to the ROMSIG. EC ROM should be 64K aligned.
+# Final hudson.bin:
+# +-----------+---------------+----------------+------------+
+# |0x55AA55AA |EC ROM Address |GEC ROM Address |USB3 ROM    |
+# +-----------+---------------+----------------+------------+
+# |                   USB3 ROM                              |
+# +---------------------------------------------------------+
+# |                   GEC ROM                               |
+# +---------------------------------------------------------+
+# |                   EC ROM                                |
+# +---------------------------------------------------------+
+#
+$(obj)/hudson.bin: $(top)/$(strip $(patsubst "%", %, 
$(CONFIG_HUDSON_XHCI_FWM_FILE))) \
+                       $(top)/$(strip $(patsubst "%", %, 
$(CONFIG_HUDSON_IMC_FWM_FILE)))
+       echo "    Hudson FW  $@"
+       ( \
+       echo $(CONFIG_HUDSON_FWM_POSITION) | LC_ALL=C awk ' \
+       function cbstrtonum(str,    n,ret,i,c,k) \
+       { \
+               str = substr(str, 3); \
+               n = length(str); \
+               ret = 0; \
+               for (i = 1; i <= n; i++) { \
+                       c = substr(str, i, 1); \
+                       c = tolower(c); \
+                       k = index("123456789abcdef", c); \
+                       ret = ret * 16 + k; \
+               } \
+               return ret; \
+       } \
+       { \
+               printf ("%d ", cbstrtonum($$1)); \
+       } ' ; \
+       for fwm in "$(CONFIG_HUDSON_IMC_FWM_FILE)" 
"$(CONFIG_HUDSON_GEC_FWM_FILE)" "$(CONFIG_HUDSON_XHCI_FWM_FILE)" ; do \
+               if [ -z $$fwm ]; then \
+                       awk 'BEGIN {printf ("0 ");}'; \
+               else \
+                       [ -r $$fwm ] || { echo "$$fwm not found"; exit 1; };  \
+                       ls -l $$fwm | awk '{printf("%d ", $$5);}'; \
+               fi \
+       done ) | \
+       LC_ALL=C awk ' \
+       function print_raw_dword(number) \
+       { \
+               printf ("%c%c%c%c", number % 0x100, number/0x100 % 0x100, 
number/0x10000 % 0x100, number/0x1000000); \
+       } \
+       {       # $$1=ROMSIG address, $$2=EC_ROM_size, $$3=GEC_ROM_size, 
$$4=USB3_ROM_size \
+               print_raw_dword(0x55AA55AA); \
+               imc_offset = $$1 + 16 + $$3 + 65535; \
+               imc_offset = imc_offset - (imc_offset) % 65536; #align 64K \
+               if ($$2) print_raw_dword(imc_offset);     else 
print_raw_dword(0); \
+               if ($$3) print_raw_dword($$1 + 16 + $$3); else 
print_raw_dword(0); \
+               if ($$4) print_raw_dword($$1 + 16);       else 
print_raw_dword(0); \
+       } ' >  [email protected]
+       [ -z $(CONFIG_HUDSON_XHCI_FWM_FILE) ] || cat 
$(CONFIG_HUDSON_XHCI_FWM_FILE) >> [email protected]
+       [ -z $(CONFIG_HUDSON_GEC_FWM_FILE) ] || cat 
$(CONFIG_HUDSON_GEC_FWM_FILE) >> [email protected]
+       [ -z $(CONFIG_HUDSON_IMC_FWM_FILE) ] || \
+       { ls -l [email protected] | awk '{ print $$5 }' | LC_ALL=C awk '{for (i=$$1; 
i<($$1+65535) - ($$1+65535)%65536; i++) {printf "%c", 255}}' >> [email protected] ; \
+       cat $(CONFIG_HUDSON_IMC_FWM_FILE) >> [email protected]; }
+       mv -f [email protected] $@
 
 ifeq ($(CONFIG_HUDSON_FWM), y)
 cbfs-files-y += hudson/fwm
diff --git a/src/southbridge/amd/agesa/hudson/hudson_fwm.py 
b/src/southbridge/amd/agesa/hudson/hudson_fwm.py
deleted file mode 100644
index ad60b3b..0000000
--- a/src/southbridge/amd/agesa/hudson/hudson_fwm.py
+++ /dev/null
@@ -1,64 +0,0 @@
-import sys, os, re
-import struct
-from Queue import Queue
-
-def main(start_addr, file_name, xhci_name, imc_name, gec_name):
-       fwm_sig         = 0x55AA55AA # Hudson-2/3/4 firmware signature
-       fwm_header_len  = 0x10       # 55AA55AA, imc_off, gec_off, xhci_off
-
-       if not os.path.exists(xhci_name):
-               print "XHCI firmware %s does not exist\n" % xhci_name
-               sys.exit(1)
-       if not os.path.exists(imc_name):
-               print "IMC firmware %s does not exist\n" % imc_name
-               sys.exit(1)
-
-       f = open(file_name, "w")
-       print "write to file " + file_name
-
-       imc_offset      = 0x10000 # 64K Bytes offset, hardcoded
-       imc_addr        = start_addr + imc_offset; #startaddr + 0x10000
-       gec_offset      = 0 #TODO
-       gec_addr        = 0 #TODO
-       xhci_addr       = start_addr + fwm_header_len #ROMSIG take 0x10 bytes
-
-       format="I" # one unsigned integer
-       data=struct.pack(format, fwm_sig)
-       f.write(data)
-       data=struct.pack(format, imc_addr)
-       f.write(data)
-       data=struct.pack(format, gec_addr)
-       f.write(data)
-       data=struct.pack(format, xhci_addr)
-       f.write(data)
-
-       fwm_content = open(xhci_name).read()
-       f.write(fwm_content)
-
-       imc_content = open(imc_name).read()
-       f.seek(0)
-       f.seek(imc_offset)
-       f.write(imc_content)
-#      if os.path.exists(gec_name):
-#              gec_conent = open(gec_name).read()
-#              f.seek(0)
-#              f.seek(gec_offset)
-#              f.write(gec_content)
-
-       f.close()
-       print "done\n"
-
-
-if __name__ == '__main__':
-       if (len(sys.argv) < 6):
-               print "\nUsage: %s <rom_addr> <rom_file> <xhci_rom> <imc_rom> 
<gec_rom>\n" % sys.argv[0]
-               print "Example: %s 0xFFF20000 hudson.bin xhci.bin imc.bin 
gec.bin\n" % sys.argv[0]
-               sys.exit(1)
-       rom_addr = int(sys.argv[1], 16)
-       rom_file = sys.argv[2]
-       xhci_file = sys.argv[3]
-       imc_file = sys.argv[4]
-       gec_file = sys.argv[5]
-       print "%x %s %s %s %s" % (rom_addr, rom_file, xhci_file, imc_file, 
gec_file)
-
-       main(rom_addr, rom_file, xhci_file, imc_file, gec_file)

-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to