From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MR2tA-0002IP-KP for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MR2tA-0002Hq-0b for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:08 -0400 Received: from [199.232.76.173] (port=56663 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MR2t9-0002Hh-No for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:07 -0400 Received: from ey-out-1920.google.com ([74.125.78.147]:26647) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MR2t9-00033e-2X for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:07 -0400 Received: by ey-out-1920.google.com with SMTP id 5so714730eyb.4 for ; Wed, 15 Jul 2009 04:43:05 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <200907101914.n6AJDphA012182@d03av02.boulder.ibm.com> References: <200907101914.n6AJDphA012182@d03av02.boulder.ibm.com> Date: Wed, 15 Jul 2009 13:43:04 +0200 Message-ID: <5b31733c0907150443u58508750nb8dc860c4478ca27@mail.gmail.com> From: Filip Navara Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [Qemu-commits] [COMMIT 89e671e] Replace signrom with shell script v3 List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel On Fri, Jul 10, 2009 at 9:16 PM, Anthony Liguori wrote= : > From: Alexander Graf > > In order to not execute code we just compiled, let's replace signrom > with a shell script that does the same thing while staying compatible > to pretty much every system available. > > This should make cross-compilation for windows easier. > > aliguori: fix build when objdir !=3D srcdir > > Signed-off-by: Alexander Graf > Signed-off-by: Anthony Liguori > > diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile > index c4a6f42..7f987d8 100644 > --- a/pc-bios/optionrom/Makefile > +++ b/pc-bios/optionrom/Makefile > @@ -37,12 +37,9 @@ build-all: multiboot.bin > =A0%.img: %.o > =A0 =A0 =A0 =A0$(LD) --oformat binary -Ttext 0 -o $@ $< > > -%.bin: %.img signrom > - =A0 =A0 =A0 ./signrom $< $@ > +%.bin: %.img > + =A0 =A0 =A0 $(SRC_PATH)/pc-bios/optionrom/signrom.sh $< $@ > =A0 =A0 =A0 =A0cp $@ $(SRC_PATH)/pc-bios/ > > -signrom: signrom.c > - =A0 =A0 =A0 $(CC) -o $@ -g -Wall $^ > - > =A0clean: > - =A0 =A0 =A0 $(RM) *.o *.img *.bin signrom *~ > + =A0 =A0 =A0 $(RM) *.o *.img *.bin *~ > diff --git a/pc-bios/optionrom/signrom.c b/pc-bios/optionrom/signrom.c > deleted file mode 100644 > index fe8d677..0000000 > --- a/pc-bios/optionrom/signrom.c > +++ /dev/null > @@ -1,79 +0,0 @@ > -/* > - * Extended Boot Option ROM > - * > - * 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 > - * the Free Software Foundation; either version 2 of the License, or > - * (at your option) any later version. > - * > - * This program is distributed in the hope that it will be useful, > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > - * GNU General Public License for more details. > - * > - * You should have received a copy of the GNU General Public License > - * along with this program; if not, write to the Free Software > - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, U= SA. > - * > - * Copyright IBM Corporation, 2007 > - * =A0 Authors: Anthony Liguori > - */ > - > -#include > -#include > -#include > - > -int main(int argc, char **argv) > -{ > - =A0 =A0 =A0 FILE *fin, *fout; > - =A0 =A0 =A0 char buffer[512], oldbuffer[512]; > - =A0 =A0 =A0 int i, size, lag =3D 0; > - =A0 =A0 =A0 uint8_t sum =3D 0; > - > - =A0 =A0 =A0 if (argc !=3D 3) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 printf("Usage: %s ROM OUTPUT\n", argv[0]); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 1; > - =A0 =A0 =A0 } > - > - =A0 =A0 =A0 fin =3D fopen(argv[1], "rb"); > - =A0 =A0 =A0 fout =3D fopen(argv[2], "wb"); > - > - =A0 =A0 =A0 if (fin =3D=3D NULL || fout =3D=3D NULL) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 fprintf(stderr, "Could not open input/outpu= t files\n"); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 1; > - =A0 =A0 =A0 } > - > - =A0 =A0 =A0 do { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 size =3D fread(buffer, 512, 1, fin); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (size =3D=3D 1) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 for (i =3D 0; i < 512; i++) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sum +=3D bu= ffer[i]; > - > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (lag) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (fwrite(= oldbuffer, 512, 1, fout) !=3D 1) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 fprintf(stderr, "Write failed\n"); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 return 1; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 lag =3D 1; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 memcpy(oldbuffer, buffer, 5= 12); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > - =A0 =A0 =A0 } while (size =3D=3D 1); > - > - =A0 =A0 =A0 if (size !=3D 0) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 fprintf(stderr, "Failed to read from input = file\n"); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 1; > - =A0 =A0 =A0 } > - > - =A0 =A0 =A0 oldbuffer[511] =3D -sum; > - > - =A0 =A0 =A0 if (fwrite(oldbuffer, 512, 1, fout) !=3D 1) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 fprintf(stderr, "Failed to write to output = file\n"); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 1; > - =A0 =A0 =A0 } > - > - =A0 =A0 =A0 fclose(fin); > - =A0 =A0 =A0 fclose(fout); > - > - =A0 =A0 =A0 return 0; > -} > diff --git a/pc-bios/optionrom/signrom.sh b/pc-bios/optionrom/signrom.sh > new file mode 100755 > index 0000000..4273d1f > --- /dev/null > +++ b/pc-bios/optionrom/signrom.sh > @@ -0,0 +1,45 @@ > +#!/bin/sh > + > +# Option ROM Signing utility > +# > +# 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 > +# the Free Software Foundation; either version 2 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program; if not, write to the Free Software > +# Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US= A. > +# > +# Copyright Novell Inc, 2009 > +# =A0 Authors: Alexander Graf > +# > +# Syntax: signrom.sh > + > +# did we get proper arguments? > +test "$1" -a "$2" || exit 1 > + > +sum=3D0 > + > +# find out the file size > +x=3D`dd if=3D"$1" bs=3D1 count=3D1 skip=3D2 2>/dev/null | od -t u1 -A n` > +#size=3D`expr $x \* 512 - 1` > +size=3D$(( $x * 512 - 1 )) This doesn't work on MSYS, "expr" would work, but "dd" is not present at all on MSYS... > + > +# now get the checksum > +for i in `od -A n -t u1 -v "$1"`; do > + =A0 =A0# add each byte's value to sum > + =A0 =A0sum=3D$(( $sum + $i )) > +done > + > +sum=3D$(( $sum % 256 )) > +sum=3D$(( 256 - $sum )) > + > +# and write the output file > +cp "$1" "$2" > +printf "\\$sum" | dd of=3D"$2" bs=3D1 count=3D1 seek=3D$size conv=3Dnotr= unc 2>/dev/null "dd" not present on MSYS again. This makes compilation on Windows even more painful than with the C-based signrom.c. How about moving the ROM signing code into main QEMU as an option for loading option ROM files? That would resolve the problem once and for all. Best regards, Filip Navara