From: Laurent Vivier <Laurent.Vivier@bull.net>
To: qemu-devel@nongnu.org
Cc: Laurent.Vivier@bull.net
Subject: [Qemu-devel] [PATCH 5/7] Add parallel flash support by -disk
Date: Wed, 31 Oct 2007 16:51:57 +0100 [thread overview]
Message-ID: <1193845917894@bull.net> (raw)
In-Reply-To: <1193845916426@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=pflash"
--
vl.c | 59 +++++++++++++++++++++++++++++++++--------------------------
vl.h | 2 +-
2 files changed, 34 insertions(+), 27 deletions(-)
Index: qemu/vl.c
===================================================================
--- 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 @@
}
#define FD_ALIAS ",index=%d,if=floppy"
+#define PFLASH_ALIAS ",if=pflash"
#define HD_ALIAS ",index=%d,media=disk"
#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 = IF_SCSI;
else if (!strcmp(buf, "floppy"))
interface = IF_FLOPPY;
+ else if (!strcmp(buf, "pflash"))
+ interface = IF_PFLASH;
else {
fprintf(stderr, "unsupported bus type '%s'\n", buf);
return -1;
@@ -4993,6 +4996,29 @@
}
}
break;
+ case IF_PFLASH:
+ if (disk_index == -1) {
+ disk_index = 0;
+ while (pflash_table[disk_index] && disk_index < MAX_PFLASH)
+ disk_index++;
+ }
+ if (disk_index >= 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] = 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 = first_machine;
cpu_model = NULL;
initrd_filename = NULL;
- for(i = 0; i < MAX_PFLASH; i++)
- pflash_filename[i] = NULL;
- pflash_index = 0;
sd_filename = NULL;
mtd_filename = NULL;
ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
@@ -8097,11 +8119,13 @@
sd_filename = optarg;
break;
case QEMU_OPTION_pflash:
- if (pflash_index >= MAX_PFLASH) {
- fprintf(stderr, "qemu: too many parallel flash images\n");
+ if (nb_disks >= MAX_DISKS) {
+ fprintf(stderr, "qemu: too many disks\n");
exit(1);
}
- pflash_filename[pflash_index++] = optarg;
+ snprintf(disks[nb_disks], sizeof(disks[0]),
+ "%s" PFLASH_ALIAS, optarg);
+ nb_disks++;
break;
case QEMU_OPTION_snapshot:
snapshot = 1;
@@ -8639,23 +8663,6 @@
if (disk_init(disks[i], snapshot, machine) == -1)
exit(1);
- /* Open the virtual parallel flash block devices */
- for(i = 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] = 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 = bdrv_new ("sd");
/* FIXME: This isn't really a floppy, but it's a reasonable
approximation. */
Index: qemu/vl.h
===================================================================
--- 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)
-#define MAX_DISKS (MAX_IDE_DISKS + MAX_SCSI_DISKS + MAX_FD)
+#define MAX_DISKS (MAX_IDE_DISKS + MAX_SCSI_DISKS + MAX_FD + MAX_PFLASH)
extern BlockDriverState *bs_table[MAX_IDE_DISKS + 1];
extern BlockDriverState *sd_table[MAX_SCSI_DISKS + 1];
next prev parent reply other threads:[~2007-10-31 15:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-31 15:51 [Qemu-devel] [PATCH 0/7] Add -disk interface Laurent Vivier
2007-10-31 15:51 ` [Qemu-devel] [PATCH 1/7] Add arg -disk to define new disk with more features Laurent Vivier
2007-10-31 15:51 ` [Qemu-devel] [PATCH 2/7] Add scsi support for the target PC Laurent Vivier
2007-10-31 15:51 ` [Qemu-devel] [PATCH 3/7] Add floppy support by -disk Laurent Vivier
2007-10-31 15:51 ` [Qemu-devel] [PATCH 4/7] remove fd_filename from the machine init interface Laurent Vivier
2007-10-31 15:51 ` Laurent Vivier [this message]
2007-10-31 15:51 ` [Qemu-devel] [PATCH 6/7] Add flash support by -disk Laurent Vivier
2007-10-31 15:51 ` [Qemu-devel] [PATCH 7/7] Add SecureDigital " Laurent Vivier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1193845917894@bull.net \
--to=laurent.vivier@bull.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).