The potential pitfalls for this patch are many, but I think the
reward outweights the risk.

The script will need the usual 0755 treatment.

Jordan

-- 
Jordan Crouse
Systems Software Development Engineer 
Advanced Micro Devices, Inc.
buildrom: Add script to automatically pad ROMs

Many ROMs may need to be padded before use.  This script tries to do 
this somewhat automatically.  If the platform needs the payload to be
padded to a power of 2, then it should set PAYLOAD_DOPAD to '-p'. 
Otherwise, the script behaves as it normally does.

Signed-off-by: Jordan Crouse <[EMAIL PROTECTED]>
Index: buildrom-devel/bin/construct-rom.sh
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ buildrom-devel/bin/construct-rom.sh	2008-09-22 15:45:11.000000000 -0600
@@ -0,0 +1,51 @@
+#!/bin/sh -e
+# Usage: ./construct-rom.sh [-p] components ...
+
+DOPAD=0
+
+if [ "$1" == "-p" ]; then
+	DOPAD=1
+	shift
+fi
+
+COMPONENTS=$*
+
+if [ $DOPAD -eq 1 ]; then
+
+	ROMSIZE=0
+
+	# Get the size of all the components together
+
+	for c in $COMPONENTS; do
+		size=`du -b $c | cut -f1`
+		ROMSIZE=`expr $ROMSIZE + $size`
+	done
+
+	# Pad to a power of 2, starting with 128k
+	RSIZE=131072
+
+	while true; do
+		PAD=0
+
+		if [ $ROMSIZE -gt $RSIZE ]; then
+			RSIZE=`expr $RSIZE "*" 2`
+			continue
+		fi
+
+		if [ $ROMSIZE -lt $RSIZE ]; then
+			PAD=`expr $RSIZE - $ROMSIZE`
+		fi
+
+		break
+	done
+
+	PADFILE=`mktemp`
+	dd if=/dev/zero of=$PADFILE bs=1 count=$PAD > /dev/null 2>&1
+	COMPONENTS="$PADFILE $COMPONENTS"
+fi
+
+cat $COMPONENTS
+
+if [ $DOPAD -eq 1 ]; then
+	rm -rf $PADFILE
+fi
Index: buildrom-devel/config/platforms/dbm690t.conf
===================================================================
--- buildrom-devel.orig/config/platforms/dbm690t.conf	2008-09-22 15:04:25.000000000 -0600
+++ buildrom-devel/config/platforms/dbm690t.conf	2008-09-22 15:45:11.000000000 -0600
@@ -51,6 +51,9 @@
 CBV2_TDIR=dbm690t
 CBV2_TAG=3590
 
+# Tell construct-rom.sh to pad the ROM to a power of 2
+PLATFORM_DOPAD := -p
+
 # FILO configuration
 
 FILO_CONFIG=dbm690t-Config
Index: buildrom-devel/config/platforms/platforms.conf
===================================================================
--- buildrom-devel.orig/config/platforms/platforms.conf	2008-09-22 14:55:00.000000000 -0600
+++ buildrom-devel/config/platforms/platforms.conf	2008-09-22 15:45:11.000000000 -0600
@@ -6,6 +6,11 @@
 STRIP=strip
 AS=as
 
+# Each individual platform needs to decide if they want to pad the
+# ROM or not
+
+PLATFORM_DOPAD :=
+
 ##Include the correct platform configuration
 
 PLATFORM-y=
Index: buildrom-devel/packages/coreboot-v2/coreboot.inc
===================================================================
--- buildrom-devel.orig/packages/coreboot-v2/coreboot.inc	2008-09-22 14:54:02.000000000 -0600
+++ buildrom-devel/packages/coreboot-v2/coreboot.inc	2008-09-22 15:45:11.000000000 -0600
@@ -150,7 +150,7 @@
 
 $(OUTPUT_DIR)/$(TARGET_ROM): $(CBV2_COMPONENTS)
 	@ mkdir -p $(OUTPUT_DIR)
-	@ cat $(CBV2_COMPONENTS) > $@
+	@ $(BIN_DIR)/construct-rom.sh $(PLATFORM_DOPAD) $(CBV2_COMPONENTS) > $@
 
 generic-coreboot: $(OUTPUT_DIR)/$(TARGET_ROM)
 
--
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to