From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1InFrp-000403-7q for qemu-devel@nongnu.org; Wed, 31 Oct 2007 11:52:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1InFro-0003zf-Dk for qemu-devel@nongnu.org; Wed, 31 Oct 2007 11:52:28 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1InFro-0003zU-9S for qemu-devel@nongnu.org; Wed, 31 Oct 2007 11:52:28 -0400 Received: from ecfrec.frec.bull.fr ([129.183.4.8]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1InFrm-00045j-Lp for qemu-devel@nongnu.org; Wed, 31 Oct 2007 11:52:27 -0400 Received: from localhost (localhost [127.0.0.1]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id 85C9819D94F for ; Wed, 31 Oct 2007 16:52:19 +0100 (CET) Received: from ecfrec.frec.bull.fr ([127.0.0.1]) by localhost (ecfrec.frec.bull.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 25561-02 for ; Wed, 31 Oct 2007 16:52:16 +0100 (CET) Received: from ecn002.frec.bull.fr (ecn002.frec.bull.fr [129.183.4.6]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id 99E5819D90E for ; Wed, 31 Oct 2007 16:52:14 +0100 (CET) In-Reply-To: <1193845916426@bull.net> Date: Wed, 31 Oct 2007 16:51:57 +0100 Message-Id: <1193845917894@bull.net> Mime-Version: 1.0 From: Laurent Vivier Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Subject: [Qemu-devel] [PATCH 5/7] Add parallel flash support by -disk Reply-To: Laurent Vivier , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Laurent.Vivier@bull.net This patch allows to define a parallel flash using -disk syntax. It adds an interface type "pflash". "-pflash file" is an alias for "-disk file,if=3Dpflash" -- vl.c | 59 +++++++++++++++++++++++++++++++++-------------------------- vl.h | 2 +- 2 files changed, 34 insertions(+), 27 deletions(-) Index: qemu/vl.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- qemu.orig/vl.c 2007-10-31 14:49:59.000000000 +0100 +++ qemu/vl.c 2007-10-31 15:01:05.000000000 +0100 @@ -4712,6 +4712,7 @@ } =20 #define FD_ALIAS ",index=3D%d,if=3Dfloppy" +#define PFLASH_ALIAS ",if=3Dpflash" #define HD_ALIAS ",index=3D%d,media=3Ddisk" =20 #ifdef TARGET_PPC @@ -4723,7 +4724,7 @@ static int disk_init(const char *str, int snapshot, QEMUMachine *machine) { char buf[16]; - enum { IF_IDE, IF_SCSI, IF_FLOPPY } interface; + enum { IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH } interface; enum { MEDIA_DISK, MEDIA_CDROM } media; int bus_id, unit_id; int cyls, heads, secs, translation; @@ -4814,6 +4815,8 @@ interface =3D IF_SCSI; else if (!strcmp(buf, "floppy")) interface =3D IF_FLOPPY; + else if (!strcmp(buf, "pflash")) + interface =3D IF_PFLASH; else { fprintf(stderr, "unsupported bus type '%s'\n", buf); return -1; @@ -4993,6 +4996,29 @@ } } break; + case IF_PFLASH: + if (disk_index =3D=3D -1) { + disk_index =3D 0; + while (pflash_table[disk_index] && disk_index < MAX_PFLASH) + disk_index++; + } + if (disk_index >=3D MAX_PFLASH) { + fprintf(stderr, "qemu: too many parallel flash images\n"); + return -1; + } + + if (!pflash_table[disk_index]) { + snprintf(buf, sizeof(buf), "fl%c", disk_index + 'a'); + pflash_table[disk_index] =3D bdrv_new(buf); + + if (file[0] && bdrv_open(pflash_table[disk_index], file, + snapshot ? BDRV_O_SNAPSHOT : 0) < 0) { + fprintf(stderr, "qemu: could not open flash image '%s'\n", + file); + return -1; + } + } + break; } return 0; } @@ -7872,10 +7898,9 @@ int use_gdbstub; const char *gdbstub_port; #endif - int i, pflash_index; + int i; int snapshot, linux_boot; const char *initrd_filename; - const char *pflash_filename[MAX_PFLASH]; const char *sd_filename; const char *mtd_filename; const char *kernel_filename, *kernel_cmdline; @@ -7938,9 +7963,6 @@ machine =3D first_machine; cpu_model =3D NULL; initrd_filename =3D NULL; - for(i =3D 0; i < MAX_PFLASH; i++) - pflash_filename[i] =3D NULL; - pflash_index =3D 0; sd_filename =3D NULL; mtd_filename =3D NULL; ram_size =3D DEFAULT_RAM_SIZE * 1024 * 1024; @@ -8097,11 +8119,13 @@ sd_filename =3D optarg; break; case QEMU_OPTION_pflash: - if (pflash_index >=3D MAX_PFLASH) { - fprintf(stderr, "qemu: too many parallel flash images\= n"); + if (nb_disks >=3D MAX_DISKS) { + fprintf(stderr, "qemu: too many disks\n"); exit(1); } - pflash_filename[pflash_index++] =3D optarg; + snprintf(disks[nb_disks], sizeof(disks[0]), + "%s" PFLASH_ALIAS, optarg); + nb_disks++; break; case QEMU_OPTION_snapshot: snapshot =3D 1; @@ -8639,23 +8663,6 @@ if (disk_init(disks[i], snapshot, machine) =3D=3D -1) exit(1); =20 - /* Open the virtual parallel flash block devices */ - for(i =3D 0; i < MAX_PFLASH; i++) { - if (pflash_filename[i]) { - if (!pflash_table[i]) { - char buf[64]; - snprintf(buf, sizeof(buf), "fl%c", i + 'a'); - pflash_table[i] =3D bdrv_new(buf); - } - if (bdrv_open(pflash_table[i], pflash_filename[i], - snapshot ? BDRV_O_SNAPSHOT : 0) < 0) { - fprintf(stderr, "qemu: could not open flash image '%s'\n", - pflash_filename[i]); - exit(1); - } - } - } - sd_bdrv =3D bdrv_new ("sd"); /* FIXME: This isn't really a floppy, but it's a reasonable approximation. */ Index: qemu/vl.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- qemu.orig/vl.h 2007-10-31 14:51:08.000000000 +0100 +++ qemu/vl.h 2007-10-31 15:01:05.000000000 +0100 @@ -994,7 +994,7 @@ #define MAX_IDE_DEVS 2 #define MAX_IDE_DISKS (MAX_IDE_BUS * MAX_IDE_DEVS) =20 -#define MAX_DISKS (MAX_IDE_DISKS + MAX_SCSI_DISKS + MAX_FD) +#define MAX_DISKS (MAX_IDE_DISKS + MAX_SCSI_DISKS + MAX_FD + MAX_PFLASH) =20 extern BlockDriverState *bs_table[MAX_IDE_DISKS + 1]; extern BlockDriverState *sd_table[MAX_SCSI_DISKS + 1];