Commit 86f55663bd3926abba1d37e0440503a89ed2900f

Authored by j_mayer
1 parent 35cdaad6

Add -pflash option to register parallel flash bloc devices.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2719 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 35 additions and 1 deletions
... ... @@ -138,6 +138,7 @@ IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS];
138 138 /* Note: bs_table[MAX_DISKS] is a dummy block driver if none available
139 139 to store the VM snapshots */
140 140 BlockDriverState *bs_table[MAX_DISKS + 1], *fd_table[MAX_FD];
  141 +BlockDriverState *pflash_table[MAX_PFLASH];
141 142 BlockDriverState *sd_bdrv;
142 143 /* point to the block driver where the snapshots are managed */
143 144 BlockDriverState *bs_snapshots;
... ... @@ -6366,6 +6367,7 @@ void help(void)
6366 6367 "-hdc/-hdd file use 'file' as IDE hard disk 2/3 image\n"
6367 6368 "-cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master)\n"
6368 6369 "-sd file use 'file' as SecureDigital card image\n"
  6370 + "-pflash file use 'file' as a parallel flash image\n"
6369 6371 "-boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n)\n"
6370 6372 "-snapshot write to temporary files instead of disk image files\n"
6371 6373 #ifdef CONFIG_SDL
... ... @@ -6504,6 +6506,7 @@ enum {
6504 6506 QEMU_OPTION_hdd,
6505 6507 QEMU_OPTION_cdrom,
6506 6508 QEMU_OPTION_sd,
  6509 + QEMU_OPTION_pflash,
6507 6510 QEMU_OPTION_boot,
6508 6511 QEMU_OPTION_snapshot,
6509 6512 #ifdef TARGET_I386
... ... @@ -6583,6 +6586,7 @@ const QEMUOption qemu_options[] = {
6583 6586 { "hdd", HAS_ARG, QEMU_OPTION_hdd },
6584 6587 { "cdrom", HAS_ARG, QEMU_OPTION_cdrom },
6585 6588 { "sd", HAS_ARG, QEMU_OPTION_sd },
  6589 + { "pflash", HAS_ARG, QEMU_OPTION_pflash },
6586 6590 { "boot", HAS_ARG, QEMU_OPTION_boot },
6587 6591 { "snapshot", 0, QEMU_OPTION_snapshot },
6588 6592 #ifdef TARGET_I386
... ... @@ -6867,10 +6871,11 @@ int main(int argc, char **argv)
6867 6871 int use_gdbstub;
6868 6872 const char *gdbstub_port;
6869 6873 #endif
6870   - int i, cdrom_index;
  6874 + int i, cdrom_index, pflash_index;
6871 6875 int snapshot, linux_boot;
6872 6876 const char *initrd_filename;
6873 6877 const char *hd_filename[MAX_DISKS], *fd_filename[MAX_FD];
  6878 + const char *pflash_filename[MAX_PFLASH];
6874 6879 const char *sd_filename;
6875 6880 const char *kernel_filename, *kernel_cmdline;
6876 6881 DisplayState *ds = &display_state;
... ... @@ -6932,6 +6937,9 @@ int main(int argc, char **argv)
6932 6937 fd_filename[i] = NULL;
6933 6938 for(i = 0; i < MAX_DISKS; i++)
6934 6939 hd_filename[i] = NULL;
  6940 + for(i = 0; i < MAX_PFLASH; i++)
  6941 + pflash_filename[i] = NULL;
  6942 + pflash_index = 0;
6935 6943 sd_filename = NULL;
6936 6944 ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
6937 6945 vga_ram_size = VGA_RAM_SIZE;
... ... @@ -7054,6 +7062,13 @@ int main(int argc, char **argv)
7054 7062 case QEMU_OPTION_sd:
7055 7063 sd_filename = optarg;
7056 7064 break;
  7065 + case QEMU_OPTION_pflash:
  7066 + if (pflash_index >= MAX_PFLASH) {
  7067 + fprintf(stderr, "qemu: too many parallel flash images\n");
  7068 + exit(1);
  7069 + }
  7070 + pflash_filename[pflash_index++] = optarg;
  7071 + break;
7057 7072 case QEMU_OPTION_snapshot:
7058 7073 snapshot = 1;
7059 7074 break;
... ... @@ -7563,6 +7578,23 @@ int main(int argc, char **argv)
7563 7578 }
7564 7579 }
7565 7580  
  7581 + /* Open the virtual parallel flash bloc devices */
  7582 + for(i = 0; i < MAX_PFLASH; i++) {
  7583 + if (pflash_filename[i]) {
  7584 + if (!pflash_table[i]) {
  7585 + char buf[64];
  7586 + snprintf(buf, sizeof(buf), "fl%c", i + 'a');
  7587 + pflash_table[i] = bdrv_new(buf);
  7588 + }
  7589 + if (bdrv_open(pflash_table[i], pflash_filename[i],
  7590 + snapshot ? BDRV_O_SNAPSHOT : 0) < 0) {
  7591 + fprintf(stderr, "qemu: could not open flash image '%s'\n",
  7592 + pflash_filename[i]);
  7593 + exit(1);
  7594 + }
  7595 + }
  7596 + }
  7597 +
7566 7598 sd_bdrv = bdrv_new ("sd");
7567 7599 /* FIXME: This isn't really a floppy, but it's a reasonable
7568 7600 approximation. */
... ...
... ... @@ -1459,6 +1459,8 @@ int sh7750_register_io_device(struct SH7750State *s,
1459 1459 int tc58128_init(struct SH7750State *s, char *zone1, char *zone2);
1460 1460  
1461 1461 /* NOR flash devices */
  1462 +#define MAX_PFLASH 4
  1463 +extern BlockDriverState *pflash_table[MAX_PFLASH];
1462 1464 typedef struct pflash_t pflash_t;
1463 1465  
1464 1466 pflash_t *pflash_register (target_ulong base, ram_addr_t off,
... ...