Add -drive parameter, by Laurent Vivier.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3759 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/hw/mainstone.c b/hw/mainstone.c
index 13f72b3..3540152 100644
--- a/hw/mainstone.c
+++ b/hw/mainstone.c
@@ -29,6 +29,7 @@
uint32_t mainstone_rom = 0x00800000;
struct pxa2xx_state_s *cpu;
qemu_irq *mst_irq;
+ int index;
if (!cpu_model)
cpu_model = "pxa270-c5";
@@ -47,18 +48,32 @@
/* Setup initial (reset) machine state */
cpu->env->regs[15] = PXA2XX_SDRAM_BASE;
- /* There are two 32MiB flash devices on the board */
- if (!pflash_register(MST_FLASH_0, mainstone_ram + PXA2XX_INTERNAL_SIZE,
- pflash_table[0], 256 * 1024, 128, 4, 0, 0, 0, 0)) {
- fprintf(stderr, "qemu: Error register flash memory.\n");
- exit(1);
- }
+ /* There are two 32MiB flash devices on the board */
+ index = drive_get_index(IF_PFLASH, 0, 0);
+ if (index == -1) {
+ fprintf(stderr, "Two flash images must be given with the "
+ "'pflash' parameter\n");
+ exit(1);
+ }
+ if (!pflash_register(MST_FLASH_0, mainstone_ram + PXA2XX_INTERNAL_SIZE,
+ drives_table[index].bdrv,
+ 256 * 1024, 128, 4, 0, 0, 0, 0)) {
+ fprintf(stderr, "qemu: Error registering flash memory.\n");
+ exit(1);
+ }
- if (!pflash_register(MST_FLASH_1, mainstone_ram + PXA2XX_INTERNAL_SIZE,
- pflash_table[1], 256 * 1024, 128, 4, 0, 0, 0, 0)) {
- fprintf(stderr, "qemu: Error register flash memory.\n");
- exit(1);
- }
+ index = drive_get_index(IF_PFLASH, 0, 1);
+ if (index == -1) {
+ fprintf(stderr, "Two flash images must be given with the "
+ "'pflash' parameter\n");
+ exit(1);
+ }
+ if (!pflash_register(MST_FLASH_1, mainstone_ram + PXA2XX_INTERNAL_SIZE,
+ drives_table[index].bdrv,
+ 256 * 1024, 128, 4, 0, 0, 0, 0)) {
+ fprintf(stderr, "qemu: Error registering flash memory.\n");
+ exit(1);
+ }
mst_irq = mst_irq_init(cpu, MST_FPGA_PHYS, PXA2XX_PIC_GPIO_0);
smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]);