Add "-drive" parameter
cover Add "-drive" parameter
These two patches are update of the patches previously sent.
[PATCH 1/2][UPDATE] remove unused parameters from QEMUMachineInitFunc
[PATCH 2/2][UPDATED] Add arg -drive to define new drive with more features
Laurent
PATCH 1/2 remove unused parameters from QEMUMachineInitFunc
It appears that fd_filename and snapshot are not needed/used by machine init functions (QEMUMachineInitFunc).
This patch removes them.
--- hw/an5206.c | 4 ++-- hw/etraxfs.c | 4 ++-- hw/integratorcp.c | 1 - hw/mcf5208.c | 1 - hw/mips_malta.c | 4 ++-- hw/mips_mipssim.c | 4 ++-- hw/mips_pica61.c | 4 ++-- hw/mips_r4k.c | 4 ++-- hw/palm.c | 1 - hw/pc.c | 20 ++++++++------------ hw/ppc405_boards.c | 2 -- hw/ppc_chrp.c | 1 - hw/ppc_oldworld.c | 1 - hw/ppc_prep.c | 5 ++--- hw/r2d.c | 4 ++-- hw/realview.c | 1 - hw/shix.c | 4 ++-- hw/spitz.c | 4 ---- hw/sun4m.c | 8 ++++---- hw/sun4u.c | 4 ++-- hw/versatilepb.c | 17 ++++++++--------- vl.c | 3 +-- vl.h | 3 +-- 23 files changed, 42 insertions(+), 62 deletions(-)
vl.h +1 -2
@@ -582,8 +582,7 @@ extern uint8_t _translate_keycode(const#ifdef NEED_CPU_H typedef void QEMUMachineInitFunc (int ram_size,int vga_ram_size, -const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model);
hw/an5206.c +2 -2
@@ -27,8 +27,8 @@ void DMA_run (void)/* Board init. */ -static void an5206_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void an5206_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/etraxfs.c +2 -2
@@ -107,8 +107,8 @@ static void dummy_cpu_set_irq(void *opaq }static -void bareetraxfs_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +void bareetraxfs_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/integratorcp.c +0 -1
@@ -466,7 +466,6 @@ static void icp_control_init(uint32_t bastatic void integratorcp_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/mcf5208.c +0 -1
@@ -199,7 +199,6 @@ static void mcf5208_sys_init(qemu_irq *pstatic void mcf5208evb_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/mips_malta.c +2 -2
@@ -746,8 +746,8 @@ static void main_cpu_reset(void *opaque) }static -void mips_malta_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +void mips_malta_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/mips_mipssim.c +2 -2
@@ -100,8 +100,8 @@ static void main_cpu_reset(void *opaque) }static void -mips_mipssim_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +mips_mipssim_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/palm.c +0 -1
@@ -179,7 +179,6 @@ static void palmte_gpio_setup(struct omastatic void palmte_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/ppc405_boards.c +0 -2
@@ -173,7 +173,6 @@ static void ref405ep_fpga_init (uint32_t static void ref405ep_init (int ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, - const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename,
@@ -499,7 +498,6 @@ static void taihu_cpld_init (uint32_t ba static void taihu_405ep_init(int ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, - const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename,
hw/ppc_chrp.c +0 -1
@@ -50,7 +50,6 @@ static CPUReadMemoryFunc *unin_read[] =/* PowerPC Mac99 hardware initialisation */ static void ppc_core99_init (int ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, - const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename,
hw/ppc_oldworld.c +0 -1
@@ -94,7 +94,6 @@ static int vga_osi_call (CPUState *env) static void ppc_heathrow_init (int ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, - const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename,
hw/r2d.c +2 -2
@@ -27,8 +27,8 @@#define SDRAM_BASE 0x0c000000/* Physical location of SDRAM: Area 3 */ #define SDRAM_SIZE 0x04000000 -static void r2d_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState * ds,const char **fd_filename,int snapshot, +static void r2d_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState * ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/shix.c +2 -2
@@ -62,8 +62,8 @@ void vga_screen_dump(const char *filenam/* XXXXX */ } -static void shix_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState * ds,const char **fd_filename,int snapshot, +static void shix_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState * ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/spitz.c +0 -4
@@ -1234,7 +1234,6 @@ static void spitz_common_init(int ram_sistatic void spitz_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
@@ -1244,7 +1243,6 @@ static void spitz_init(int ram_size, intstatic void borzoi_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
@@ -1254,7 +1252,6 @@ static void borzoi_init(int ram_size, instatic void akita_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
@@ -1264,7 +1261,6 @@ static void akita_init(int ram_size, intstatic void terrier_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/sun4u.c +2 -2
@@ -306,8 +306,8 @@ static const int parallel_irq[MAX_PARALLstatic fdctrl_t *floppy_controller;/* Sun4u hardware initialisation */ -static void sun4u_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void sun4u_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/mips_pica61.c +2 -2
@@ -54,8 +54,8 @@ static void main_cpu_reset(void *opaque) }static -void mips_pica61_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +void mips_pica61_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/mips_r4k.c +2 -2
@@ -137,8 +137,8 @@ static void main_cpu_reset(void *opaque) }static -void mips_r4k_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +void mips_r4k_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/pc.c +8 -12
@@ -684,8 +684,8 @@ static void pc_init_ne2k_isa(NICInfo *nd }/* PC hardware initialisation */ -static void pc_init1 (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void pc_init1 (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,int pci_enabled,const char *cpu_model)
@@ -973,30 +973,26 @@ static void pc_init1(int ram_size, int v#endif } -static void pc_init_pci (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename, -int snapshot, +static void pc_init_pci (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) { -pc_init1 (ram_size, vga_ram_size, boot_device, - ds, fd_filename, snapshot, +pc_init1 (ram_size, vga_ram_size, boot_device, ds, kernel_filename, kernel_cmdline, initrd_filename,1 , cpu_model); } -static void pc_init_isa (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename, -int snapshot, +static void pc_init_isa (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) { -pc_init1 (ram_size, vga_ram_size, boot_device, - ds, fd_filename, snapshot, +pc_init1 (ram_size, vga_ram_size, boot_device, ds, kernel_filename, kernel_cmdline, initrd_filename,0 , cpu_model); }
hw/ppc_prep.c +2 -3
@@ -522,9 +522,8 @@ CPUReadMemoryFunc *PPC_prep_io_read[] =/* PowerPC PREP hardware initialisation */ static void ppc_prep_init (int ram_size,int vga_ram_size, -const char *boot_device, -DisplayState *ds,const char **fd_filename, -int snapshot,const char *kernel_filename, +const char *boot_device,DisplayState *ds, +const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model)
hw/realview.c +0 -1
@@ -14,7 +14,6 @@static void realview_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/sun4m.c +4 -4
@@ -603,8 +603,8 @@ static void sun4m_common_init(int RAM_si }/* SPARCstation 5 hardware initialisation */ -static void ss5_init (int RAM_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void ss5_init (int RAM_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
@@ -616,8 +616,8 @@ static void ss5_init(int RAM_size, int v }/* SPARCstation 10 hardware initialisation */ -static void ss10_init (int RAM_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void ss10_init (int RAM_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/versatilepb.c +8 -9
@@ -153,7 +153,6 @@ static qemu_irq *vpb_sic_init(uint32_t bstatic void versatile_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model,int board_id)
@@ -270,24 +269,24 @@ static void versatile_init(int ram_size, initrd_filename, board_id, 0x0); } -static void vpb_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void vpb_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) { -versatile_init (ram_size, vga_ram_size, boot_device, - ds, fd_filename, snapshot, +versatile_init (ram_size, vga_ram_size, + boot_device, ds, kernel_filename, kernel_cmdline, initrd_filename, cpu_model,0x183 ); } -static void vab_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void vab_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) { -versatile_init (ram_size, vga_ram_size, boot_device, - ds, fd_filename, snapshot, +versatile_init (ram_size, vga_ram_size, + boot_device, ds, kernel_filename, kernel_cmdline, initrd_filename, cpu_model,0x25e ); }
vl.c +1 -2
@@ -8511,8 +8511,7 @@ int main(int argc, char **argv) } } - machine->init (ram_size, vga_ram_size, boot_devices, - ds, fd_filename, snapshot, + machine->init (ram_size, vga_ram_size, boot_devices, ds, kernel_filename, kernel_cmdline, initrd_filename, cpu_model);/* init USB devices */
PATCH 2/2 Add arg -drive to define new drive with more features
This patch introduces a new parameter allowing to define drives.
The new parameter is "-drive":
-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,cyls=c,heads=h,secs=s[,trans=t]][snapshot=on|off]
where:
file is the disk image
type is the interface type (ide, scsi, sd, mtd, floppy, pflash) n is the bus number of the given type
m is the unit number on the given bus
d is the type of the media (disk, cdrom)
c,h,s,t are the parameters usually given by -hdachs snapshot allows to enable or not the snapshot for this disk
"-cdrom file" is an alias for "-drive file=file,bus=1,unit=0,media=cdrom" "-hda file" is an alias for "-drive file=file,bus=0,unit=0,media=disk" "-hdb file" is an alias for "-drive file=file,bus=0,unit=1,media=disk" "-hdc file" is an alias for "-drive file=file,bus=1,unit=0,media=disk" "-hdd file" is an alias for "-drive file=file,bus=1,unit=1,media=disk" "-hda file -hdachs a,b,c" is an alias for
"-drive file=file,bus=0,unit=0,cyls=a,heads=b,secs=c"
You can also define a cdrom on the slace of ide0 with:
"-drive file=file,if=ide,bus=0,unit=1,media=cdrom"
You can define an empty cdrom:
"-drive if=ide,bus=0,unit=1,media=cdrom"
"-drive file=file,if=scsi,bus=0,unit=6" allows to connect the disk image file to the scsi bus 0 with the unit id 6.
if there is no SCSI disk, the SCSI interface is not created.
It also defines the default interface type to "scsi" for targets "realview", "SS-5", "SS-10", "versatilepb", "versatileab" to keep old behavior, where "-hda" is a SCSI disk.
"-fda file" is an alias for "-drive file=file,unit=0,if=floppy" "-fdb file" is an alias for "-drive file=file,unit=1,if=floppy" "-pflash file" is an alias for "-drive file=file,if=pflash" "-mtdblock file" is an alias for "-drive file=file,if=mtd" "-sd file" becomes the alias of "-drive file=file,if=sd"
"-drive file=a -drive file=b" will be interpreted like "-hda a -hdb b"
--- hw/esp.c | 10 - hw/integratorcp.c | 8 hw/lsi53c895a.c | 3 hw/mips_malta.c | 15 + hw/mips_pica61.c | 21 +- hw/mips_r4k.c | 17 + hw/nand.c | 2 hw/omap_mmc.c | 2 hw/pc.c | 65 ++++-- hw/ppc405_boards.c | 29 +- hw/ppc_chrp.c | 17 + hw/ppc_oldworld.c | 31 ++- hw/ppc_prep.c | 27 ++ hw/pxa2xx_mmci.c | 3 hw/realview.c | 17 + hw/spitz.c | 9 hw/esp.c | 10 - hw/integratorcp.c | 8 hw/lsi53c895a.c | 3 hw/mips_malta.c | 15 + hw/mips_pica61.c | 21 +- hw/mips_r4k.c | 17 + hw/nand.c | 2 hw/omap_mmc.c | 2 hw/pc.c | 65 ++++-- hw/ppc405_boards.c | 29 +- hw/ppc_chrp.c | 17 + hw/ppc_oldworld.c | 31 ++- hw/ppc_prep.c | 27 ++ hw/pxa2xx_mmci.c | 3 hw/realview.c | 17 + hw/spitz.c | 9 hw/sun4m.c | 26 +- hw/sun4u.c | 24 ++ hw/versatilepb.c | 18 + monitor.c | 11 - vl.c | 527 +++++++++++++++++++++++++++++++++++------------------ vl.h | 32 ++- 22 files changed, 644 insertions(+), 270 deletions(-)
vl.c +356 -171
@@ -149,12 +149,10 @@ char phys_ram_file[1024];void *ioport_opaque[MAX_IOPORTS ];IOPortReadFunc *ioport_read_table[3 ][MAX_IOPORTS ];IOPortWriteFunc *ioport_write_table[3 ][MAX_IOPORTS ]; -/* Note: bs_table[MAX_DISKS] is a dummy block driver if none available +/* Note: drives_table[MAX_DRIVES] is a dummy block driver if none available to store the VM snapshots */ -BlockDriverState *bs_table[MAX_DISKS +1 ], *fd_table[MAX_FD ]; -BlockDriverState *pflash_table[MAX_PFLASH ]; -BlockDriverState *sd_bdrv; -BlockDriverState *mtd_bdrv; +DriveInfo drives_table[MAX_DRIVES +1 ]; +int nb_drives;/* point to the block driver where the snapshots are managed */ BlockDriverState *bs_snapshots;int vga_ram_size;
@@ -218,6 +216,8 @@ int alt_grab = 0;unsigned int nb_prom_envs =0 ;const char *prom_envs[MAX_PROM_ENVS ];#endif +int nb_drives_opt; +char drives_opt[MAX_DRIVES ][1024 ];#define TFR (expr) do { if ((expr) != -1) break; } while (errno == EINTR)
@@ -1734,12 +1734,9 @@ static int mux_proc_byte(CharDriverStatecase 's' : {int i; -for (i =0 ; i <MAX_DISKS ; i++) { -if (bs_table[i]) -bdrv_commit (bs_table[i]); +for (i =0 ; i < nb_drives; i++) { +bdrv_commit (drives_table[i].bdrv); } -if (mtd_bdrv) -bdrv_commit (mtd_bdrv); }break ;case 'b' :
@@ -4692,6 +4689,276 @@ void do_info_network(void) } } +#define HD_ALIAS "file=%s,bus=%d,unit=%d,media=disk" +#ifdef TARGET_PPC +#define CDROM_ALIAS "bus=0,unit=1,media=cdrom" +#else +#define CDROM_ALIAS "bus=1,unit=0,media=cdrom" +#endif +#define FD_ALIAS "unit=%d,if=floppy" +#define PFLASH_ALIAS "file=%s,if=pflash" +#define MTD_ALIAS "file=%s,if=mtd" +#define SD_ALIAS "file=%s,if=sd" + +static int drive_add (const char *fmt, ...) +{ +va_list ap; + +if (nb_drives_opt >=MAX_DRIVES ) { +fprintf (stderr,"qemu: too many drives\n" ); +exit (1 ); + } + +va_start (ap, fmt); +vsnprintf (drives_opt[nb_drives_opt],sizeof (drives_opt[0 ]), fmt, ap); +va_end (ap); + +return nb_drives_opt++; +} + +int drive_get_index (BlockInterfaceType interface,int bus,int unit) +{ +int index; + +/* seek interface, bus and unit */ + +for (index =0 ; index < nb_drives; index++) +if (drives_table[index].interface == interface && + drives_table[index].bus == bus && + drives_table[index].unit == unit) +return index; + +return -1 ; +} + +int drive_get_max_bus (BlockInterfaceType interface) +{ +int max_bus; +int index; + + max_bus =-1 ; +for (index =0 ; index < nb_drives; index++) { +if (drives_table[index].interface == interface && + drives_table[index].bus > max_bus) + max_bus = drives_table[index].bus; + } +return max_bus; +} + +static int drive_init (const char *str,int snapshot,QEMUMachine *machine) +{ +char buf[16 ]; +char file[1024 ]; +BlockInterfaceType interface; +enum {MEDIA_DISK ,MEDIA_CDROM } media; +int bus_id, unit_id; +int cyls, heads, secs, translation; +BlockDriverState *bdrv; +int max_devs; + + file[0 ] =0 ; + cyls = heads = secs =0 ; + bus_id =0 ; + unit_id =-1 ; + translation =BIOS_ATA_TRANSLATION_AUTO ; + +if (!strcmp (machine->name,"realview" ) || + !strcmp (machine->name,"SS-5" ) || + !strcmp (machine->name,"SS-10" ) || + !strcmp (machine->name,"versatilepb" ) || + !strcmp (machine->name,"versatileab" )) { + interface =IF_SCSI ; + max_devs =MAX_SCSI_DEVS ; + }else { + interface =IF_IDE ; + max_devs =MAX_IDE_DEVS ; + } + media =MEDIA_DISK ; + +/* extract parameters */ + +if (get_param_value (buf,sizeof (buf),"bus" , str)) { + bus_id =strtol (buf,NULL ,0 ); +if (bus_id <0 ) { +fprintf (stderr,"qemu: invalid bus id\n" ); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"unit" , str)) { + unit_id =strtol (buf,NULL ,0 ); +if (unit_id <0 ) { +fprintf (stderr,"qemu: invalid unit id\n" ); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"cyls" , str)) { + cyls =strtol (buf,NULL ,0 ); +if (cyls <1 || cyls >16383 ) { +fprintf (stderr,"qemu: invalid physical cyls number\n" ); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"heads" , str)) { + heads =strtol (buf,NULL ,0 ); +if (heads <1 || heads >16 ) { +fprintf (stderr,"qemu: invalid physical heads number\n" ); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"secs" , str)) { + secs =strtol (buf,NULL ,0 ); +if (secs <1 || secs >63 ) { +fprintf (stderr,"qemu: invalid physical secs number\n" ); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"if" , str)) { +if (!strcmp (buf,"ide" )) { + interface =IF_IDE ; + max_devs =MAX_IDE_DEVS ; + }else if (!strcmp (buf,"scsi" )) { + interface =IF_SCSI ; + max_devs =MAX_SCSI_DEVS ; + }else if (!strcmp (buf,"floppy" )) { + interface =IF_FLOPPY ; + max_devs =0 ; + }else if (!strcmp (buf,"pflash" )) { + interface =IF_PFLASH ; + max_devs =0 ; + }else if (!strcmp (buf,"mtd" )) { + interface =IF_MTD ; + max_devs =0 ; + }else if (!strcmp (buf,"sd" )) { + interface =IF_SD ; + max_devs =0 ; + }else { +fprintf (stderr,"unsupported bus type '%s'\n" , buf); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"trans" , str)) { +if (!strcmp (buf,"none" )) + translation =BIOS_ATA_TRANSLATION_NONE ; +else if (!strcmp (buf,"lba" )) + translation =BIOS_ATA_TRANSLATION_LBA ; +else if (!strcmp (buf,"auto" )) + translation =BIOS_ATA_TRANSLATION_AUTO ; +else { +fprintf (stderr,"qemu: invalid translation type\n" ); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"media" , str)) { +if (!strcmp (buf,"disk" )) { + media =MEDIA_DISK ; + }else if (!strcmp (buf,"cdrom" )) { +if (cyls || secs || heads) { +fprintf (stderr,"qemu: invalid physical CHS format\n" ); +return -1 ; + } + media =MEDIA_CDROM ; + }else { +fprintf (stderr,"qemu: invalid media\n" ); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"snapshot" , str)) { +if (!strcmp (buf,"on" )) + snapshot =1 ; +else if (!strcmp (buf,"off" )) + snapshot =0 ; +else { +fprintf (stderr,"qemu: invalid snapshot option\n" ); +return -1 ; + } + } + +get_param_value (file,sizeof (file),"file" , str); + +/* if user doesn't specify a unit_id, +* try to find the first free +*/ + +if (unit_id ==-1 ) { + unit_id =0 ; +while (drive_get_index (interface, bus_id, unit_id) !=-1 ) { + unit_id++; +if (max_devs && unit_id >= max_devs) { + unit_id -= max_devs; + bus_id++; + } + } + } + +/* check unit id */ + +if (max_devs && unit_id >= max_devs) { +fprintf (stderr,"qemu: unit %d too big on bus %d (max is %d)\n" , + unit_id, bus_id, max_devs -1 ); +exit (1 ); + } + +/* +* ignore multiple definitions +*/ + +if (drive_get_index (interface, bus_id, unit_id) !=-1 ) +return 0 ; + +/* init */ + +snprintf (buf,sizeof (buf),"drive%d" , nb_drives); + bdrv =bdrv_new (buf); + drives_table[nb_drives].bdrv = bdrv; + drives_table[nb_drives].interface = interface; + drives_table[nb_drives].bus = bus_id; + drives_table[nb_drives].unit = unit_id; + nb_drives++; + +switch (interface) { +case IF_IDE : +case IF_SCSI : +switch (media) { +case MEDIA_DISK : +if (cyls !=0 ) { +bdrv_set_geometry_hint (bdrv, cyls, heads, secs); +bdrv_set_translation_hint (bdrv, translation); + } +break ; +case MEDIA_CDROM : +bdrv_set_type_hint (bdrv,BDRV_TYPE_CDROM ); +break ; + } +break ; +case IF_SD : +/* FIXME: This isn't really a floppy, but it's a reasonable +approximation. */ +case IF_FLOPPY : +bdrv_set_type_hint (bdrv,BDRV_TYPE_FLOPPY ); +break ; +case IF_PFLASH : +case IF_MTD : +break ; + } +if (!file[0 ]) +return 0 ; +if (bdrv_open (bdrv, file, snapshot ?BDRV_O_SNAPSHOT :0 ) <0 || +qemu_key_check (bdrv, file)) { +fprintf (stderr,"qemu: could not open disk image %s\n" , + file); +return -1 ; + } +return 0 ; +} +/***********************************************************/ /* USB devices */
@@ -5475,8 +5742,8 @@ static BlockDriverState *get_bs_snapshotif (bs_snapshots)return bs_snapshots; -for (i =0 ; i <=MAX_DISKS ; i++) { - bs = bs_table[i]; +for (i =0 ; i <= nb_drives; i++) { + bs = drives_table[i].bdrv;if (bdrv_can_snapshot (bs)) goto ok; }
@@ -5584,8 +5851,8 @@ void do_savevm(const char *name)/* create the snapshots */ -for (i =0 ; i <MAX_DISKS ; i++) { - bs1 = bs_table[i]; +for (i =0 ; i < nb_drives; i++) { + bs1 = drives_table[i].bdrv;if (bdrv_has_snapshot (bs1)) {if (must_delete) { ret =bdrv_snapshot_delete (bs1, old_sn->id_str);
@@ -5627,8 +5894,8 @@ void do_loadvm(const char *name) saved_vm_running = vm_running;vm_stop (0 ); -for (i =0 ; i <=MAX_DISKS ; i++) { - bs1 = bs_table[i]; +for (i =0 ; i <= nb_drives; i++) { + bs1 = drives_table[i].bdrv;if (bdrv_has_snapshot (bs1)) { ret =bdrv_snapshot_goto (bs1, name);if (ret <0 ) {
@@ -5688,8 +5955,8 @@ void do_delvm(const char *name)return ; } -for (i =0 ; i <=MAX_DISKS ; i++) { - bs1 = bs_table[i]; +for (i =0 ; i <= nb_drives; i++) { + bs1 = drives_table[i].bdrv;if (bdrv_has_snapshot (bs1)) { ret =bdrv_snapshot_delete (bs1, name);if (ret <0 ) {
@@ -5717,8 +5984,8 @@ void do_info_snapshots(void)return ; }term_printf ("Snapshot devices:" ); -for (i =0 ; i <=MAX_DISKS ; i++) { - bs1 = bs_table[i]; +for (i =0 ; i <= nb_drives; i++) { + bs1 = drives_table[i].bdrv;if (bdrv_has_snapshot (bs1)) {if (bs == bs1)term_printf (" %s" ,bdrv_get_device_name (bs1));
@@ -6468,15 +6735,14 @@ static void ram_save(QEMUFile *f, void */* find if the memory block is available on a virtual block device */ sector_num =-1 ; -for (j =0 ; j <MAX_DISKS ; j++) { -if (bs_table[j]) { - sector_num =bdrv_hash_find (bs_table[j], - phys_ram_base + i,BDRV_HASH_BLOCK_SIZE ); -if (sector_num >=0 ) -break ; - } +for (j =0 ; j < nb_drives; j++) { + sector_num =bdrv_hash_find (drives_table[j].bdrv, + phys_ram_base + i, +BDRV_HASH_BLOCK_SIZE ); +if (sector_num >=0 ) +break ; } -if (j ==MAX_DISKS ) +if (j == nb_drives) goto normal_compress; buf[0 ] =1 ; buf[1 ] = j;
@@ -6527,11 +6793,12 @@ static int ram_load(QEMUFile *f, void *oram_decompress_buf (s, buf +1 ,9 ); bs_index = buf[1 ]; sector_num =be64_to_cpupu ((const uint64_t *)(buf +2 )); -if (bs_index >=MAX_DISKS || bs_table[bs_index] ==NULL ) { +if (bs_index >= nb_drives) {fprintf (stderr,"Invalid block device index %d\n" , bs_index); goto error; } -if (bdrv_read (bs_table[bs_index], sector_num, phys_ram_base + i, +if (bdrv_read (drives_table[bs_index].bdrv, sector_num, + phys_ram_base + i,BDRV_HASH_BLOCK_SIZE /512 ) <0 ) {fprintf (stderr,"Error while reading sector %d:%" PRId64"\n" , bs_index, sector_num);
@@ -7028,6 +7295,8 @@ static void help(int exitcode)"-hda/-hdb file use 'file' as IDE hard disk 0/1 image\n" "-hdc/-hdd file use 'file' as IDE hard disk 2/3 image\n" "-cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master)\n" +"-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,cyls=c,heads=h,secs=s[,trans=t]][snapshot=on|off]\n" +" use 'file' as a drive image\n" "-mtdblock file use 'file' as on-board Flash memory image\n" "-sd file use 'file' as SecureDigital card image\n" "-pflash file use 'file' as a parallel flash image\n"
@@ -7173,6 +7442,7 @@ enum { QEMU_OPTION_hdb, QEMU_OPTION_hdc, QEMU_OPTION_hdd, + QEMU_OPTION_drive, QEMU_OPTION_cdrom, QEMU_OPTION_mtdblock, QEMU_OPTION_sd,
@@ -7262,6 +7532,7 @@ const QEMUOption qemu_options[] = { { "hdb", HAS_ARG, QEMU_OPTION_hdb }, { "hdc", HAS_ARG, QEMU_OPTION_hdc }, { "hdd", HAS_ARG, QEMU_OPTION_hdd }, + { "drive", HAS_ARG, QEMU_OPTION_drive }, { "cdrom", HAS_ARG, QEMU_OPTION_cdrom }, { "mtdblock", HAS_ARG, QEMU_OPTION_mtdblock }, { "sd", HAS_ARG, QEMU_OPTION_sd },
@@ -7374,16 +7645,9 @@ int qemu_key_check(BlockDriverState *bs,static BlockDriverState *get_bdrv (int index) { -BlockDriverState *bs; - -if (index <4 ) { - bs = bs_table[index]; - }else if (index <6 ) { - bs = fd_table[index -4 ]; - }else { - bs =NULL ; - } -return bs; +if (index > nb_drives) +return NULL ; +return drives_table[index].bdrv; }static void read_passwords (void )
@@ -7583,19 +7847,16 @@ int main(int argc, char **argv)const char *gdbstub_port;#endif uint32_t boot_devices_bitmap =0 ; -int i, cdrom_index, pflash_index; +int i;int snapshot, linux_boot, net_boot;const char *initrd_filename; -const char *hd_filename[MAX_DISKS ], *fd_filename[MAX_FD ]; -const char *pflash_filename[MAX_PFLASH ]; -const char *sd_filename; -const char *mtd_filename;const char *kernel_filename, *kernel_cmdline;const char *boot_devices ="" ;DisplayState *ds = &display_state;int cyls, heads, secs, translation;char net_clients[MAX_NET_CLIENTS ][256 ];int nb_net_clients; +int hda_index;int optind;const char *r, *optarg;CharDriverState *monitor_hd;
@@ -7648,15 +7909,6 @@ int main(int argc, char **argv) machine = first_machine; cpu_model =NULL ; initrd_filename =NULL ; -for (i =0 ; i <MAX_FD ; i++) - fd_filename[i] =NULL ; -for (i =0 ; i <MAX_DISKS ; i++) - hd_filename[i] =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 ; vga_ram_size =VGA_RAM_SIZE ;#ifdef CONFIG_GDBSTUB
@@ -7667,11 +7919,6 @@ int main(int argc, char **argv) nographic =0 ; kernel_filename =NULL ; kernel_cmdline ="" ; -#ifdef TARGET_PPC - cdrom_index =1 ; -#else - cdrom_index =2 ; -#endif cyls = heads = secs =0 ; translation =BIOS_ATA_TRANSLATION_AUTO ;pstrcpy (monitor_device,sizeof (monitor_device),"vc" );
@@ -7689,6 +7936,9 @@ int main(int argc, char **argv) usb_devices_index =0 ; nb_net_clients =0 ; + nb_drives =0 ; + nb_drives_opt =0 ; + hda_index =-1 ; nb_nics =0 ;/* default mac address of the first network interface */
@@ -7699,7 +7949,7 @@ int main(int argc, char **argv)break ; r = argv[optind];if (r[0 ] !='-' ) { - hd_filename[0 ] = argv[optind++]; + hda_index =drive_add (HD_ALIAS , argv[optind++],0 ,0 ); }else {const QEMUOption *popt;
@@ -7759,29 +8009,38 @@ int main(int argc, char **argv) initrd_filename = optarg;break ;case QEMU_OPTION_hda: +if (cyls ==0 ) + hda_index =drive_add (HD_ALIAS , optarg,0 ,0 ); +else + hda_index =drive_add (HD_ALIAS +",cyls=%d,heads=%d,secs=%d%s" , + optarg,0 ,0 , cyls, heads, secs, + translation ==BIOS_ATA_TRANSLATION_LBA ? +",trans=lba" : + translation ==BIOS_ATA_TRANSLATION_NONE ? +",trans=none" :"" ); +break ;case QEMU_OPTION_hdb:case QEMU_OPTION_hdc:case QEMU_OPTION_hdd: {int hd_index; hd_index = popt->index - QEMU_OPTION_hda; - hd_filename[hd_index] = optarg; -if (hd_index == cdrom_index) - cdrom_index =-1 ; +drive_add (HD_ALIAS , optarg, hd_index /MAX_IDE_DEVS , + hd_index %MAX_IDE_DEVS ); }break ; +case QEMU_OPTION_drive: +drive_add ("%s" , optarg); +break ;case QEMU_OPTION_mtdblock: - mtd_filename = optarg; +drive_add (MTD_ALIAS , optarg);break ;case QEMU_OPTION_sd: - sd_filename = optarg; +drive_add (SD_ALIAS , optarg);break ;case QEMU_OPTION_pflash: -if (pflash_index >=MAX_PFLASH ) { -fprintf (stderr,"qemu: too many parallel flash images\n" ); -exit (1 ); - } - pflash_filename[pflash_index++] = optarg; +drive_add (PFLASH_ALIAS , optarg);break ;case QEMU_OPTION_snapshot: snapshot =1 ;
@@ -7820,6 +8079,17 @@ int main(int argc, char **argv)fprintf (stderr,"qemu: invalid physical CHS format\n" );exit (1 ); } +if (hda_index !=-1 ) +snprintf (drives_opt[hda_index] + +strlen (drives_opt[hda_index]), +sizeof (drives_opt[0 ]) - +strlen (drives_opt[hda_index]), +",cyls=%d,heads=%d,secs=%d%s" , + cyls, heads, secs, + translation ==BIOS_ATA_TRANSLATION_LBA ? +",trans=lba" : + translation ==BIOS_ATA_TRANSLATION_NONE ? +",trans=none" :"" ); }break ;case QEMU_OPTION_nographic:
@@ -7838,9 +8108,7 @@ int main(int argc, char **argv) kernel_cmdline = optarg;break ;case QEMU_OPTION_cdrom: -if (cdrom_index >=0 ) { - hd_filename[cdrom_index] = optarg; - } +drive_add ("file=%s," CDROM_ALIAS , optarg);break ;case QEMU_OPTION_boot: boot_devices = optarg;
@@ -7874,10 +8142,9 @@ int main(int argc, char **argv) }break ;case QEMU_OPTION_fda: - fd_filename[0 ] = optarg; -break ;case QEMU_OPTION_fdb: - fd_filename[1 ] = optarg; +drive_add ("file=%s," FD_ALIAS , optarg, + popt->index - QEMU_OPTION_fda);break ;#ifdef TARGET_I386 case QEMU_OPTION_no_fd_bootchk:
@@ -8258,19 +8525,11 @@ int main(int argc, char **argv)/* XXX: this should not be: some embedded targets just have flash */ if (!linux_boot && net_boot ==0 && - hd_filename[0 ] =='\0' && - (cdrom_index >=0 && hd_filename[cdrom_index] =='\0' ) && - fd_filename[0 ] =='\0' ) + nb_drives_opt ==0 )help (1 ); -/* boot to floppy or the default cd if no hard disk defined yet */ if (!boot_devices[0 ]) { -if (hd_filename[0 ] !='\0' ) - boot_devices ="c" ; -else if (fd_filename[0 ] !='\0' ) - boot_devices ="a" ; -else - boot_devices ="d" ; + boot_devices ="cad" ; }setvbuf (stdout,NULL , _IOLBF,0 );
@@ -8347,97 +8606,23 @@ int main(int argc, char **argv)exit (1 ); } -/* we always create the cdrom drive, even if no disk is there */ bdrv_init (); -if (cdrom_index >=0 ) { - bs_table[cdrom_index] =bdrv_new ("cdrom" ); -bdrv_set_type_hint (bs_table[cdrom_index],BDRV_TYPE_CDROM ); - } -/* open the virtual block devices */ -for (i =0 ; i <MAX_DISKS ; i++) { -if (hd_filename[i]) { -if (!bs_table[i]) { -char buf[64 ]; -snprintf (buf,sizeof (buf),"hd%c" , i +'a' ); - bs_table[i] =bdrv_new (buf); - } -if (bdrv_open (bs_table[i], hd_filename[i], snapshot ?BDRV_O_SNAPSHOT :0 ) <0 ) { -fprintf (stderr,"qemu: could not open hard disk image '%s'\n" , - hd_filename[i]); -exit (1 ); - } -if (i ==0 && cyls !=0 ) { -bdrv_set_geometry_hint (bs_table[i], cyls, heads, secs); -bdrv_set_translation_hint (bs_table[i], translation); - } - } - } +/* we always create the cdrom drive, even if no disk is there */ -/* we always create at least one floppy disk */ - fd_table[0 ] =bdrv_new ("fda" ); -bdrv_set_type_hint (fd_table[0 ],BDRV_TYPE_FLOPPY ); - -for (i =0 ; i <MAX_FD ; i++) { -if (fd_filename[i]) { -if (!fd_table[i]) { -char buf[64 ]; -snprintf (buf,sizeof (buf),"fd%c" , i +'a' ); - fd_table[i] =bdrv_new (buf); -bdrv_set_type_hint (fd_table[i],BDRV_TYPE_FLOPPY ); - } -if (fd_filename[i][0 ] !='\0' ) { -if (bdrv_open (fd_table[i], fd_filename[i], - snapshot ?BDRV_O_SNAPSHOT :0 ) <0 ) { -fprintf (stderr,"qemu: could not open floppy disk image '%s'\n" , - fd_filename[i]); -exit (1 ); - } - } - } - } +if (nb_drives_opt <MAX_DRIVES ) +drive_add (CDROM_ALIAS ); -/* 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 ); - } - } - } +/* we always create at least on floppy */ - sd_bdrv =bdrv_new ("sd" ); -/* FIXME: This isn't really a floppy, but it's a reasonable -approximation. */ -bdrv_set_type_hint (sd_bdrv,BDRV_TYPE_FLOPPY ); -if (sd_filename) { -if (bdrv_open (sd_bdrv, sd_filename, - snapshot ?BDRV_O_SNAPSHOT :0 ) <0 ) { -fprintf (stderr,"qemu: could not open SD card image %s\n" , - sd_filename); - }else -qemu_key_check (sd_bdrv, sd_filename); - } +if (nb_drives_opt <MAX_DRIVES ) +drive_add (FD_ALIAS ,0 ); -if (mtd_filename) { - mtd_bdrv =bdrv_new ("mtd" ); -if (bdrv_open (mtd_bdrv, mtd_filename, - snapshot ?BDRV_O_SNAPSHOT :0 ) <0 || -qemu_key_check (mtd_bdrv, mtd_filename)) { -fprintf (stderr,"qemu: could not open Flash image %s\n" , - mtd_filename); -bdrv_delete (mtd_bdrv); - mtd_bdrv =0 ; - } - } +/* open the virtual block devices */ + +for (i =0 ; i < nb_drives_opt; i++) +if (drive_init (drives_opt[i], snapshot, machine) ==-1 ) +exit (1 );register_savevm ("timer" ,0 ,2 , timer_save, timer_load,NULL );register_savevm ("ram" ,0 ,2 , ram_save, ram_load,NULL );
vl.h +24 -8
@@ -785,13 +785,27 @@ void isa_cirrus_vga_init(DisplayState *dvoid pci_vmsvga_init (PCIBus *bus,DisplayState *ds,uint8_t *vga_ram_base,unsigned long vga_ram_offset,int vga_ram_size); -/* ide.c */ -#define MAX_DISKS 4 +typedef enum { +IF_IDE ,IF_SCSI ,IF_FLOPPY ,IF_PFLASH ,IF_MTD ,IF_SD +}BlockInterfaceType ; + +typedef struct DriveInfo { +BlockDriverState *bdrv; +BlockInterfaceType interface; +int bus; +int unit; +}DriveInfo ; + +#define MAX_DRIVES 32 -extern BlockDriverState *bs_table[MAX_DISKS +1 ]; -extern BlockDriverState *sd_bdrv; -extern BlockDriverState *mtd_bdrv; +extern int nb_drives; +extern DriveInfo drives_table[MAX_DRIVES +1 ]; +extern int drive_get_index (BlockInterfaceType interface,int bus,int unit); +extern int drive_get_max_bus (BlockInterfaceType interface); + +/* ide.c */ +#define MAX_IDE_DEVS 2void isa_ide_init (int iobase,int iobase2,qemu_irq irq,BlockDriverState *hd0,BlockDriverState *hd1); void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table,
@@ -836,7 +850,6 @@ void DMA_register_channel (int nchan, void *opaque);/* fdc.c */ #define MAX_FD 2 -extern BlockDriverState *fd_table[MAX_FD ];typedef struct fdctrl_t fdctrl_t ;
@@ -1103,8 +1116,11 @@ void *slavio_misc_init(target_phys_addr_void slavio_set_power_fail (void *opaque,int power_failing);/* esp.c */ +/* The HBA is ID 7, so for simplicitly limit to 7 devices. */ +#define MAX_SCSI_DEVS 7 +#define ESP_MAX_DEVS MAX_SCSI_DEVSvoid esp_scsi_attach (void *opaque,BlockDriverState *bd,int id); -void *esp_init (BlockDriverState **bd,target_phys_addr_t espaddr, +void *esp_init (target_phys_addr_t espaddr,void *dma_opaque,qemu_irq irq,qemu_irq *reset);/* sparc32_dma.c */
@@ -1234,6 +1250,7 @@ void scsi_cancel_io(SCSIDevice *s, uint3uint8_t *scsi_get_buf (SCSIDevice *s,uint32_t tag);/* lsi53c895a.c */ +#define LSI_MAX_DEVS MAX_SCSI_DEVSvoid lsi_scsi_attach (void *opaque,BlockDriverState *bd,int id);void *lsi_scsi_init (PCIBus *bus,int devfn);
@@ -1376,7 +1393,6 @@ int tc58128_init(struct SH7750State *s,/* NOR flash devices */ #define MAX_PFLASH 4 -extern BlockDriverState *pflash_table[MAX_PFLASH ];typedef struct pflash_t pflash_t ; pflash_t *pflash_register (target_phys_addr_t base, ram_addr_t off,
monitor.c +3 -8
@@ -204,16 +204,11 @@ static void do_commit(const char *deviceint i, all_devices; all_devices = !strcmp (device,"all" ); -for (i =0 ; i <MAX_DISKS ; i++) { -if (bs_table[i]) { +for (i =0 ; i < nb_drives; i++) {if (all_devices || - !strcmp (bdrv_get_device_name (bs_table[i]), device)) -bdrv_commit (bs_table[i]); - } + !strcmp (bdrv_get_device_name (drives_table[i].bdrv), device)) +bdrv_commit (drives_table[i].bdrv); } -if (mtd_bdrv) -if (all_devices || !strcmp (bdrv_get_device_name (mtd_bdrv), device)) -bdrv_commit (mtd_bdrv); }static void do_info (const char *item)
hw/mips_pica61.c +18 -3
@@ -38,6 +38,8 @@#define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000)) +#define MAX_IDE_BUS 2 +static const int ide_iobase[2 ] = {0x1f0 ,0x170 };static const int ide_iobase2[2 ] = {0x3f6 ,0x376 };static const int ide_irq[2 ] = {14 ,15 };
@@ -66,6 +68,8 @@ void mips_pica61_init (int ram_size, intint i;int available_ram;qemu_irq *i8259; +int index; +BlockDriverState *fd[MAX_FD ];/* init CPUs */ if (cpu_model ==NULL ) {
@@ -135,9 +139,14 @@ void mips_pica61_init (int ram_size, inti8042_mm_init (i8259[6 ], i8259[7 ],0x80005060 ,0 );/* IDE controller */ -for (i =0 ; i <2 ; i++) +for (i =0 ; i <MAX_IDE_BUS ; i++) { +int hd0, hd1; + hd0 =drive_get_index (IF_IDE , i,0 ); + hd1 =drive_get_index (IF_IDE , i,1 );isa_ide_init (ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], - bs_table[2 * i], bs_table[2 * i +1 ]); + hd0 ==-1 ?NULL : drives_table[hd0].bdrv, + hd1 ==-1 ?NULL : drives_table[hd1].bdrv); + }/* Network controller */ /* FIXME: missing NS SONIC DP83932 */
@@ -146,7 +155,13 @@ void mips_pica61_init (int ram_size, int/* FIXME: missing NCR 53C94 */ /* ISA devices (floppy, serial, parallel) */ -fdctrl_init (i8259[1 ],1 ,1 ,0x80003000 , fd_table); +for (i =0 ; i <2 ; i++) { + index =drive_get_index (IF_FLOPPY ,0 , i); +if (index ==-1 ) +continue ; + fd[i] = drives_table[index].bdrv; + } +fdctrl_init (i8259[1 ],1 ,1 ,0x80003000 , fd);for (i =0 ; i <MAX_SERIAL_PORTS ; i++) {if (serial_hds[i]) {serial_mm_init (serial_base[i],0 , i8259[serial_irq[i]], serial_hds[i],1 );
hw/mips_r4k.c +15 -2
@@ -19,6 +19,8 @@#define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000)) +#define MAX_IDE_BUS 2 +static const int ide_iobase[2 ] = {0x1f0 ,0x170 };static const int ide_iobase2[2 ] = {0x3f6 ,0x376 };static const int ide_irq[2 ] = {14 ,15 };
@@ -149,6 +151,8 @@ void mips_r4k_init (int ram_size, int vgRTCState *rtc_state;int i;qemu_irq *i8259; +int index; +BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];/* init CPUs */ if (cpu_model ==NULL ) {
@@ -239,9 +243,18 @@ void mips_r4k_init (int ram_size, int vg } } -for (i =0 ; i <2 ; i++) +for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { + index =drive_get_index (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); +if (index !=-1 ) + hd[i] = drives_table[index].bdrv; +else + hd[i] =NULL ; + } + +for (i =0 ; i <MAX_IDE_BUS ; i++)isa_ide_init (ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], - bs_table[2 * i], bs_table[2 * i +1 ]); + hd[MAX_IDE_DEVS * i], + hd[MAX_IDE_DEVS * i +1 ]);i8042_init (i8259[1 ], i8259[12 ],0x60 );ds1225y_init (0x9000 ,"nvram" );
hw/pc.c +44 -21
122 lines not on this page · raw message
hw/ppc_prep.c +24 -3
@@ -29,6 +29,8 @@/* SMP is not enabled, for now */ #define MAX_CPUS 1 +#define MAX_IDE_BUS 2 +#define BIOS_FILENAME "ppc_rom.bin"#define KERNEL_LOAD_ADDR 0x01000000#define INITRD_LOAD_ADDR 0x01800000
@@ -539,6 +541,9 @@ static void ppc_prep_init (int ram_size,PCIBus *pci_bus;qemu_irq *i8259;int ppc_boot_device; +int index; +BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; +BlockDriverState *fd[MAX_FD ]; sysctrl =qemu_mallocz (sizeof (sysctrl_t));if (sysctrl ==NULL )
@@ -658,16 +663,32 @@ static void ppc_prep_init (int ram_size, } } -for (i =0 ; i <2 ; i++) { +for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { + index =drive_get_index (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); +if (index !=-1 ) + hd[i] = drives_table[index].bdrv; +else + hd[i] =NULL ; + } + +for (i =0 ; i <MAX_IDE_BUS ; i++) {isa_ide_init (ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], - bs_table[2 * i], bs_table[2 * i +1 ]); + hd[2 * i], + hd[2 * i +1 ]); }i8042_init (i8259[1 ], i8259[12 ],0x60 );DMA_init (1 );// AUD_init(); // SB16_init(); -fdctrl_init (i8259[6 ],2 ,0 ,0x3f0 , fd_table); +for (i =0 ; i <MAX_FD ; i++) { + index =drive_get_index (IF_FLOPPY ,0 , i); +if (index !=-1 ) + fd[i] = drives_table[index].bdrv; +else + fd[i] =NULL ; + } +fdctrl_init (i8259[6 ],2 ,0 ,0x3f0 , fd);/* Register speaker port */ register_ioport_read (0x61 ,1 ,1 , speaker_ioport_read,NULL );
hw/esp.c +3 -7
@@ -45,14 +45,11 @@ do { printf("ESP: " fmt , ##args); } whi#define ESP_REGS 16#define ESP_SIZE (ESP_REGS * 4)#define TI_BUFSZ 32 -/* The HBA is ID 7, so for simplicitly limit to 7 devices. */ -#define ESP_MAX_DEVS 7typedef struct ESPState ESPState ;struct ESPState {qemu_irq irq; -BlockDriverState **bd;uint8_t rregs[ESP_REGS ];uint8_t wregs[ESP_REGS ];int32_t ti_size;
@@ -60,7 +57,7 @@ struct ESPState {uint8_t ti_buf[TI_BUFSZ ];int sense;int dma; -SCSIDevice *scsi_dev[MAX_DISKS ]; +SCSIDevice *scsi_dev[ESP_MAX_DEVS ];SCSIDevice *current_dev;uint8_t cmdbuf[TI_BUFSZ ];int cmdlen;
@@ -122,7 +119,7 @@ static int get_cmd(ESPState *s, uint8_t s->async_len =0 ; } -if (target >=MAX_DISKS || !s->scsi_dev[target]) { +if (target >=ESP_MAX_DEVS || !s->scsi_dev[target]) {// No such drive s->rregs[4 ] =STAT_IN ; s->rregs[5 ] =INTR_DC ;
@@ -574,7 +571,7 @@ void esp_scsi_attach(void *opaque, Block s->scsi_dev[id] =scsi_disk_init (bd,0 , esp_command_complete, s); } -void *esp_init (BlockDriverState **bd,target_phys_addr_t espaddr, +void *esp_init (target_phys_addr_t espaddr,void *dma_opaque,qemu_irq irq,qemu_irq *reset) {ESPState *s;
@@ -584,7 +581,6 @@ void *esp_init(BlockDriverState **bd, taif (!s)return NULL ; - s->bd = bd; s->irq = irq; s->dma_opaque = dma_opaque;
hw/realview.c +12 -5
@@ -26,6 +26,7 @@ static void realview_init(int ram_size,int done_smc =0 ;qemu_irq cpu_irq[4 ];int ncpu; +int index;if (!cpu_model) cpu_model ="arm926" ;
@@ -83,7 +84,12 @@ static void realview_init(int ram_size,pl110_init (ds,0x10020000 , pic[23 ],1 ); -pl181_init (0x10005000 , sd_bdrv, pic[17 ], pic[18 ]); + index =drive_get_index (IF_SD ,0 ,0 ); +if (index ==-1 ) { +fprintf (stderr,"qemu: missing SecureDigital card\n" ); +exit (1 ); + } +pl181_init (0x10005000 , drives_table[index].bdrv, pic[17 ], pic[18 ]);pl031_init (0x10017000 , pic[10 ]);
@@ -92,10 +98,11 @@ static void realview_init(int ram_size,usb_ohci_init_pci (pci_bus,3 ,-1 ); } scsi_hba =lsi_scsi_init (pci_bus,-1 ); -for (n =0 ; n <MAX_DISKS ; n++) { -if (bs_table[n]) { -lsi_scsi_attach (scsi_hba, bs_table[n], n); - } +for (n =0 ; n <LSI_MAX_DEVS ; n++) { + index =drive_get_index (IF_SCSI ,0 , n); +if (index ==-1 ) +continue ; +lsi_scsi_attach (scsi_hba, drives_table[index].bdrv, n); }for (n =0 ; n < nb_nics; n++) { nd = &nd_table[n];
hw/sun4m.c +19 -7
@@ -316,6 +316,8 @@ static void *sun4m_hw_init(const structqemu_irq *cpu_irqs[MAX_CPUS ], *slavio_irq, *slavio_cpu_irq, *espdma_irq, *ledma_irq;qemu_irq *esp_reset, *le_reset; +BlockDriverState *fd[MAX_FD ]; +int index;/* init CPUs */
@@ -388,16 +390,26 @@ static void *sun4m_hw_init(const structslavio_serial_init (hwdef->serial_base, slavio_irq[hwdef->ser_irq], serial_hds[1 ], serial_hds[0 ]); -if (hwdef->fd_base != (target_phys_addr_t)-1 ) -sun4m_fdctrl_init (slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd_table); +if (hwdef->fd_base != (target_phys_addr_t)-1 ) { +for (i =0 ; i <MAX_FD ; i++) { + index =drive_get_index (IF_FLOPPY ,0 , i); +if (index !=-1 ) + fd[i] = drives_table[index].bdrv; +else + fd[i] =NULL ; + } + +sun4m_fdctrl_init (slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd); + } - main_esp =esp_init (bs_table, hwdef->esp_base, espdma, *espdma_irq, + main_esp =esp_init (hwdef->esp_base, espdma, *espdma_irq, esp_reset); -for (i =0 ; i <MAX_DISKS ; i++) { -if (bs_table[i]) { -esp_scsi_attach (main_esp, bs_table[i], i); - } +for (i =0 ; i <ESP_MAX_DEVS ; i++) { + index =drive_get_index (IF_SCSI ,0 , i); +if (index ==-1 ) +continue ; +esp_scsi_attach (main_esp, drives_table[index].bdrv, i); } slavio_misc = slavio_misc_init(hwdef->slavio_base, hwdef->power_base,
hw/versatilepb.c +13 -5
@@ -165,6 +165,7 @@ static void versatile_init(int ram_size,NICInfo *nd;int n;int done_smc =0 ; +int index;if (!cpu_model) cpu_model ="arm926" ;
@@ -201,10 +202,11 @@ static void versatile_init(int ram_size,usb_ohci_init_pci (pci_bus,3 ,-1 ); } scsi_hba =lsi_scsi_init (pci_bus,-1 ); -for (n =0 ; n <MAX_DISKS ; n++) { -if (bs_table[n]) { -lsi_scsi_attach (scsi_hba, bs_table[n], n); - } +for (n =0 ; n <LSI_MAX_DEVS ; n++) { + index =drive_get_index (IF_SCSI ,0 , n); +if (index ==-1 ) +continue ; +lsi_scsi_attach (scsi_hba, drives_table[index].bdrv, n); }pl011_init (0x101f1000 , pic[12 ], serial_hds[0 ],PL011_ARM );
@@ -220,7 +222,13 @@ static void versatile_init(int ram_size,that includes hardware cursor support from the PL111. */ pl110_init (ds,0x10120000 , pic[16 ],1 ); -pl181_init (0x10005000 , sd_bdrv, sic[22 ], sic[1 ]); + index =drive_get_index (IF_SD ,0 ,0 ); +if (index ==-1 ) { +fprintf (stderr,"qemu: missing SecureDigital card\n" ); +exit (1 ); + } + +pl181_init (0x10005000 , drives_table[index].bdrv, sic[22 ], sic[1 ]);#if 0 /* Disabled because there's no way of specifying a block device. */ pl181_init (0x1000b000 ,NULL , sic,23 ,2 );
hw/integratorcp.c +7 -1
@@ -473,6 +473,7 @@ static void integratorcp_init(int ram_siuint32_t bios_offset;qemu_irq *pic;qemu_irq *cpu_pic; +int sd;if (!cpu_model) cpu_model ="arm926" ;
@@ -501,7 +502,12 @@ static void integratorcp_init(int ram_siicp_control_init (0xcb000000 );pl050_init (0x18000000 , pic[3 ],0 );pl050_init (0x19000000 , pic[4 ],1 ); -pl181_init (0x1c000000 , sd_bdrv, pic[23 ], pic[24 ]); + sd =drive_get_index (IF_SD ,0 ,0 ); +if (sd ==-1 ) { +fprintf (stderr,"qemu: missing SecureDigital card for integratorcp\n" ); +exit (1 ); + } +pl181_init (0x1c000000 , drives_table[sd].bdrv, pic[23 ], pic[24 ]);if (nd_table[0 ].vlan) {if (nd_table[0 ].model ==NULL ||strcmp (nd_table[0 ].model,"smc91c111" ) ==0 ) {
hw/lsi53c895a.c +0 -3
@@ -149,9 +149,6 @@ do { fprintf(stderr, "lsi_scsi: error: "#define PHASE_MI 7#define PHASE_MASK 7 -/* The HBA is ID 7, so for simplicitly limit to 7 devices. */ -#define LSI_MAX_DEVS 7 -/* Maximum length of MSG IN data. */ #define LSI_MAX_MSGIN_LEN 8
hw/nand.c +1 -1
@@ -447,7 +447,7 @@ struct nand_flash_s *nand_init(int manf_ } s = (struct nand_flash_s *)qemu_mallocz (sizeof (struct nand_flash_s )); - s->bdrv = mtd_bdrv; + s->bdrv = drives_table[drive_get_index (IF_MTD ,0 ,0 )].bdrv; s->manf_id = manf_id; s->chip_id = chip_id; s->size = nand_flash_ids[s->chip_id].size <<20 ;
hw/omap_mmc.c +1 -1
@@ -540,7 +540,7 @@ struct omap_mmc_s *omap_mmc_init(target_cpu_register_physical_memory (s->base,0x800 , iomemtype);/* Instantiate the storage */ - s->card =sd_init (sd_bdrv); + s->card =sd_init (drives_table[drive_get_index (IF_SD ,0 ,0 )].bdrv);sd_set_cb (s->card, s, omap_mmc_ro_cb, omap_mmc_cover_cb);
hw/ppc405_boards.c +17 -12
@@ -191,6 +191,7 @@ static void ref405ep_init (int ram_size,int linux_boot;int fl_idx, fl_sectors, len;int ppc_boot_device = boot_device[0 ]; +int index;/* XXX: fix this */ ram_bases[0 ] =0x00000000 ;
@@ -217,17 +218,18 @@ static void ref405ep_init (int ram_size, bios_offset = sram_offset + sram_size; fl_idx =0 ;#ifdef USE_FLASH_BIOS -if (pflash_table[fl_idx] !=NULL ) { - bios_size =bdrv_getlength (pflash_table[fl_idx]); + index =drive_get_index (IF_PFLASH ,0 , fl_idx); +if (index !=-1 ) { + bios_size =bdrv_getlength (drives_table[index].bdrv); fl_sectors = (bios_size +65535 ) >>16 ;#ifdef DEBUG_BOARD_INIT printf ("Register parallel flash %d size " ADDRX " at offset %08lx " " addr " ADDRX " '%s' %d\n" , fl_idx, bios_size, bios_offset, -bios_size, -bdrv_get_device_name (pflash_table[fl_idx]), fl_sectors); +bdrv_get_device_name (drives_table[index].bdrv), fl_sectors);#endif pflash_register ((uint32_t )(-bios_size), bios_offset, - pflash_table[fl_idx],65536 , fl_sectors,2 , + drives_table[index].bdrv,65536 , fl_sectors,2 ,0x0001 ,0x22DA ,0x0000 ,0x0000 ); fl_idx++; }else
@@ -513,6 +515,7 @@ static void taihu_405ep_init(int ram_sizint linux_boot;int fl_idx, fl_sectors;int ppc_boot_device = boot_device[0 ]; +int index;/* RAM is soldered to the board so the size cannot be changed */ ram_bases[0 ] =0x00000000 ;
@@ -530,8 +533,9 @@ static void taihu_405ep_init(int ram_siz#endif fl_idx =0 ;#if defined(USE_FLASH_BIOS ) -if (pflash_table[fl_idx] !=NULL ) { - bios_size =bdrv_getlength (pflash_table[fl_idx]); + index =drive_get_index (IF_PFLASH ,0 , fl_idx); +if (index !=-1 ) { + bios_size =bdrv_getlength (drives_table[index].bdrv);/* XXX: should check that size is 2MB */ // bios_size = 2 * 1024 * 1024; fl_sectors = (bios_size +65535 ) >>16 ;
@@ -539,10 +543,10 @@ static void taihu_405ep_init(int ram_sizprintf ("Register parallel flash %d size " ADDRX " at offset %08lx " " addr " ADDRX " '%s' %d\n" , fl_idx, bios_size, bios_offset, -bios_size, -bdrv_get_device_name (pflash_table[fl_idx]), fl_sectors); +bdrv_get_device_name (drives_table[index].bdrv), fl_sectors);#endif pflash_register ((uint32_t )(-bios_size), bios_offset, - pflash_table[fl_idx],65536 , fl_sectors,4 , + drives_table[index].bdrv,65536 , fl_sectors,4 ,0x0001 ,0x22DA ,0x0000 ,0x0000 ); fl_idx++; }else
@@ -565,8 +569,9 @@ static void taihu_405ep_init(int ram_siz } bios_offset += bios_size;/* Register Linux flash */ -if (pflash_table[fl_idx] !=NULL ) { - bios_size =bdrv_getlength (pflash_table[fl_idx]); + index =drive_get_index (IF_PFLASH ,0 , fl_idx); +if (index !=-1 ) { + bios_size =bdrv_getlength (drives_table[index].bdrv);/* XXX: should check that size is 32MB */ bios_size =32 *1024 *1024 ; fl_sectors = (bios_size +65535 ) >>16 ;
@@ -574,9 +579,9 @@ static void taihu_405ep_init(int ram_sizprintf ("Register parallel flash %d size " ADDRX " at offset %08lx " " addr " ADDRX " '%s'\n" , fl_idx, bios_size, bios_offset, (target_ulong )0xfc000000 , -bdrv_get_device_name (pflash_table[fl_idx])); +bdrv_get_device_name (drives_table[index].bdrv));#endif -pflash_register (0xfc000000 , bios_offset, pflash_table[fl_idx], +pflash_register (0xfc000000 , bios_offset, drives_table[index].bdrv,65536 , fl_sectors,4 ,0x0001 ,0x22DA ,0x0000 ,0x0000 ); fl_idx++;
hw/ppc_chrp.c +14 -3
@@ -25,6 +25,8 @@#include "vl.h" #include "ppc_mac.h" +#define MAX_IDE_BUS 2 +/* UniN device */ static void unin_writel (void *opaque,target_phys_addr_t addr,uint32_t value) {
@@ -74,6 +76,8 @@ static void ppc_core99_init (int ram_sizint pic_mem_index, dbdma_mem_index, cuda_mem_index;int ide_mem_index[2 ];int ppc_boot_device; +int index; +BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; linux_boot = (kernel_filename !=NULL );
@@ -259,11 +263,18 @@ static void ppc_core99_init (int ram_siz nd_table[i].model ="ne2k_pci" ;pci_nic_init (pci_bus, &nd_table[i],-1 ); } +for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { + index =drive_get_index (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); +if (index !=-1 ) + hd[i] = drives_table[index].bdrv; +else + hd[i] =NULL ; + }#if 1 - ide_mem_index[0 ] =pmac_ide_init (&bs_table[0 ], pic[0x13 ]); - ide_mem_index[1 ] =pmac_ide_init (&bs_table[2 ], pic[0x14 ]); + ide_mem_index[0 ] =pmac_ide_init (&hd[0 ], pic[0x13 ]); + ide_mem_index[1 ] =pmac_ide_init (&hd[2 ], pic[0x14 ]);#else -pci_cmd646_ide_init (pci_bus, &bs_table[0 ],0 ); +pci_cmd646_ide_init (pci_bus, &hd[0 ],0 );#endif /* cuda also initialize ADB */ cuda_init (&cuda_mem_index, pic[0x19 ]);
hw/pxa2xx_mmci.c +2 -1
@@ -537,7 +537,8 @@ struct pxa2xx_mmci_s *pxa2xx_mmci_init(tcpu_register_physical_memory (base,0x00100000 , iomemtype);/* Instantiate the actual storage */ - s->card =sd_init (sd_bdrv); + + s->card =sd_init (drives_table[drive_get_index (IF_SD ,0 ,0 )].bdrv);register_savevm ("pxa2xx_mmci" ,0 ,0 , pxa2xx_mmci_save, pxa2xx_mmci_load, s);
hw/spitz.c +7 -2
@@ -928,9 +928,14 @@ static void spitz_ssp_attach(struct pxa2static void spitz_microdrive_attach (struct pxa2xx_state_s *cpu) {struct pcmcia_card_s *md; -BlockDriverState *bs = bs_table[0 ]; +int index; +BlockDriverState *bs; -if (bs &&bdrv_is_inserted (bs) && !bdrv_is_removable (bs)) { + index =drive_get_index (IF_IDE ,0 ,0 ); +if (index ==-1 ) +return ; + bs = drives_table[index].bdrv; +if (bdrv_is_inserted (bs) && !bdrv_is_removable (bs)) { md =dscm1xxxx_init (bs);pxa2xx_pcmcia_attach (cpu->pcmcia[1 ], md); }
hw/mips_malta.c +14 -1
@@ -42,6 +42,8 @@#define ENVP_NB_ENTRIES 16#define ENVP_ENTRY_SIZE 256 +#define MAX_IDE_BUS 2 +extern FILE *logfile; typedef struct {
@@ -765,6 +767,8 @@ void mips_malta_init (int ram_size, intuint8_t *eeprom_buf;i2c_bus *smbus;int i; +int index; +BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];/* init CPUs */ if (cpu_model ==NULL ) {
@@ -851,8 +855,17 @@ void mips_malta_init (int ram_size, int pci_bus =pci_gt64120_init (i8259);/* Southbridge */ + +for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { + index =drive_get_index (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); +if (index !=-1 ) + hd[i] = drives_table[index].bdrv; +else + hd[i] =NULL ; + } + piix4_devfn =piix4_init (pci_bus,80 ); -pci_piix4_ide_init (pci_bus, bs_table, piix4_devfn +1 , i8259); +pci_piix4_ide_init (pci_bus, hd, piix4_devfn +1 , i8259);usb_uhci_piix4_init (pci_bus, piix4_devfn +2 ); smbus =piix4_pm_init (pci_bus, piix4_devfn +3 ,0x1100 ); eeprom_buf =qemu_mallocz (8 *256 );/* XXX: make this persistent */
hw/sun4u.c +21 -3
@@ -320,6 +320,9 @@ static void sun4u_init(int ram_size, intPCIBus *pci_bus;QEMUBH *bh;qemu_irq *irq; +int index; +BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; +BlockDriverState *fd[MAX_FD ]; linux_boot = (kernel_filename !=NULL );
@@ -422,11 +425,26 @@ static void sun4u_init(int ram_size, int } irq =qemu_allocate_irqs (dummy_cpu_set_irq,NULL ,32 ); -// XXX pci_cmd646_ide_init(pci_bus, bs_table, 1); -pci_piix3_ide_init (pci_bus, bs_table,-1 , irq); +for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { + index =drive_get_index (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); +if (index !=-1 ) + hd[i] = drives_table[index].bdrv; +else + hd[i] =NULL ; + } + +// XXX pci_cmd646_ide_init(pci_bus, hd, 1); +pci_piix3_ide_init (pci_bus, hd,-1 , irq);/* FIXME: wire up interrupts. */ i8042_init (NULL /*1*/ ,NULL /*12*/ ,0x60 ); - floppy_controller =fdctrl_init (NULL /*6*/ ,2 ,0 ,0x3f0 , fd_table); +for (i =0 ; i <MAX_FD ; i++) { + index =drive_get_index (IF_FLOPPY ,0 , i); +if (index !=-1 ) + fd[i] = drives_table[index].bdrv; +else + fd[i] =NULL ; + } + floppy_controller =fdctrl_init (NULL /*6*/ ,2 ,0 ,0x3f0 , fd); nvram =m48t59_init (NULL /*8*/ ,0 ,0x0074 ,NVRAM_SIZE ,59 ); sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", ram_size, boot_device[0], KERNEL_LOAD_ADDR, kernel_size,
hw/ppc_oldworld.c +29 -2
@@ -25,6 +25,8 @@#include "vl.h" #include "ppc_mac.h" +#define MAX_IDE_BUS 2 +/* temporary frame buffer OSI calls for the video.x driver. The right solution is to modify the driver to use VGA PCI I/Os */ /* XXX: to be removed. This is no way related to emulation */
@@ -114,6 +116,8 @@ static void ppc_heathrow_init (int ram_sint pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index;int ide_mem_index[2 ];int ppc_boot_device; +BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; +int index; linux_boot = (kernel_filename !=NULL );
@@ -283,10 +287,33 @@ static void ppc_heathrow_init (int ram_s }/* First IDE channel is a CMD646 on the PCI bus */ -pci_cmd646_ide_init (pci_bus, &bs_table[0 ],0 ); + + index =drive_get_index (IF_IDE ,0 ,0 ); +if (index ==-1 ) + hd[0 ] =NULL ; +else + hd[0 ] = drives_table[index].bdrv; + index =drive_get_index (IF_IDE ,0 ,1 ); +if (index ==-1 ) + hd[1 ] =NULL ; +else + hd[1 ] = drives_table[index].bdrv; + hd[3 ] = hd[2 ] =NULL ; +pci_cmd646_ide_init (pci_bus, hd,0 ); +/* Second IDE channel is a MAC IDE on the MacIO bus */ + index =drive_get_index (IF_IDE ,1 ,0 ); +if (index ==-1 ) + hd[0 ] =NULL ; +else + hd[0 ] = drives_table[index].bdrv; + index =drive_get_index (IF_IDE ,1 ,1 ); +if (index ==-1 ) + hd[1 ] =NULL ; +else + hd[1 ] = drives_table[index].bdrv; ide_mem_index[0 ] =-1 ; - ide_mem_index[1 ] =pmac_ide_init (&bs_table[2 ], pic[0x0D ]); + ide_mem_index[1 ] =pmac_ide_init (hd, pic[0x0D ]);/* cuda also initialize ADB */ cuda_init (&cuda_mem_index, pic[0x12 ]);
Re: [Qemu-devel] [PATCH 1/2][UPDATE] remove unused parameters from QEMUMachineInitFunc
In reply to Laurent VivierQuoted 5 lines · Laurent Vivier
It appears that
fd_filenameand snapshot are not needed/used by machine init functions (QEMUMachineInitFunc).This patch removes them.
I don't know what was the idea for these parameters, so I can't comment on the correctness of the patch in general.
Quoted 9 lines
/* SPARCstation 5 hardware initialisation */
hw/sun4m.c +2
-2-static void ss5_init (int RAM_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void ss5_init (int RAM_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/sun4m.c static void ss5_init(int RAM_size, int v · line 622
Quoted 9 lines
hw/sun4m.c +2
-2@@ -616,8 +616,8 @@ static void ss5_init(int RAM_size, int v }/* SPARCstation 10 hardware initialisation */ -static void ss10_init (int RAM_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void ss10_init (int RAM_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model)
You didn't fix ss600mp_init, which was added yesterday.
Re: [Qemu-devel] [PATCH 1/2][UPDATE] remove unused parameters from QEMUMachineInitFunc
Quoted 9 lines · Blue Swirl
Quoted 5 lines · Laurent Vivier
It appears that
fd_filenameand snapshot are not needed/used by machine init functions (QEMUMachineInitFunc).This patch removes them.
I don't know what was the idea for these parameters, so I can't comment on the correctness of the patch in general.
fd_filename cannot be managed because I suppressed the array in vl.c and Fabrice (when he commented the first revision of this patch) proposed to remove "snapshot" too:
"- While modifying the machine init function, you can suppress the snapshot parameter."
Quoted 11 lines
Quoted 11 lines
/* SPARCstation 5 hardware initialisation */
hw/sun4m.c +2
-2-static void ss5_init (int RAM_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void ss5_init (int RAM_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {@@ -616,8 +616,8 @@ static void ss5_init(int RAM_size, int v }
Quoted 9 lines
hw/sun4m.c static void ss5_init(int RAM_size, int v · line 622
Quoted 7 lines
hw/sun4m.c +2
-2/* SPARCstation 10 hardware initialisation */ -static void ss10_init (int RAM_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void ss10_init (int RAM_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model)You didn't fix
ss600mp_init, which was added yesterday.
Oops, sorry, I missed it.
Thank you for your comments,
Laurent
Signature · 3 lines
------------- [email protected] -------------- "In short: just say NO TO DRUGS and maybe you won't end up like the Hurd people." -- Linus Torvald
Re: [Qemu-devel] [PATCH 2/2][UPDATE] Add arg -drive to define new drive with more features
In reply to Laurent VivierQuoted 3 lines · Laurent Vivier
It also defines the default interface type to "scsi" for targets "realview", "SS-5", "SS-10", "versatilepb", "versatileab" to keep old behavior, where "-hda" is a SCSI disk.
For maximal compatibility, I'd like the following mappings for SS-5, SS-10, and SS-600MP:
-hda = SCSI ID 0
-hdb = SCSI ID 1
-hdc = -cdrom = SCSI ID 2
-hdd = SCSI ID 3
There is no bus 1, only 0. Maybe a warning should be issued for bus=1.
I didn't find where this was implemented, so is the above in line with the patch?
Quoted 5 lines
Index:
qemu/hw/sun4m.chw/sun4m.c +1
-2-if (hwdef->fd_base != (target_phys_addr_t)-1 ) -sun4m_fdctrl_init (slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd_table); +if (hwdef->fd_base != (target_phys_addr_t)-1 ) {
hw/sun4m.c static void *sun4m_hw_init(const struct · line 403
Quoted 10 lines
hw/sun4m.c +10
-0+for (i =0 ; i <MAX_FD ; i++) { + index =drive_get_index (IF_FLOPPY ,0 , i); +if (index !=-1 ) + fd[i] = drives_table[index].bdrv; +else + fd[i] =NULL ; + } + +sun4m_fdctrl_init (slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd); + }
This is broken, there are zero or one floppy drives, never more.
hw/sun4u.c static void sun4u_init(int ram_size, int · line 447
Quoted 11 lines
Index:
qemu/hw/sun4u.chw/sun4u.c +8
-1- floppy_controller =fdctrl_init (NULL /*6*/ ,2 ,0 ,0x3f0 , fd_table); +for (i =0 ; i <MAX_FD ; i++) { + index =drive_get_index (IF_FLOPPY ,0 , i); +if (index !=-1 ) + fd[i] = drives_table[index].bdrv; +else + fd[i] =NULL ; + } + floppy_controller =fdctrl_init (NULL /*6*/ ,2 ,0 ,0x3f0 , fd);
I think same applies here (0 to 1 drives), but as the hardware is PC-like, technically it may be possible that someone could replace the cables and insert additional floppy drives.
Re: [Qemu-devel] [PATCH 2/2][UPDATE] Add arg -drive to define new drive with more features
Review
Quoted 11 lines · Blue Swirl
Quoted 3 lines · Laurent Vivier
It also defines the default interface type to "scsi" for targets "realview", "SS-5", "SS-10", "versatilepb", "versatileab" to keep old behavior, where "-hda" is a SCSI disk.
For maximal compatibility, I'd like the following mappings for SS-5, SS-10, and SS-600MP:
(quoted diff) +0
-4-hda = SCSI ID 0 -hdb = SCSI ID 1 -hdc = -cdrom = SCSI ID 2 -hdd = SCSI ID 3
Yes, there is mistake there.
Quoted 4 lines
There is no bus 1, only 0. Maybe a warning should be issued for bus=1.
I didn't find where this was implemented, so is the above in line with the patch?
See following lines:
...
#define HD_ALIAS "file=%s,bus=%d,unit=%d,media=disk"
...
if (!strcmp(machine->name, "realview") ||
!strcmp(machine->name, "SS-5") ||
!strcmp(machine->name, "SS-10") ||
!strcmp(machine->name, "versatilepb") ||
!strcmp(machine->name, "versatileab")) {
interface = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
} else {
interface = IF_IDE;
max_devs = MAX_IDE_DEVS;
}...
case QEMU_OPTION_hdb:
case QEMU_OPTION_hdc:
case QEMU_OPTION_hdd:
drive_add(HD_ALIAS, optarg, hd_index / MAX_IDE_DEVS,
hd_index % MAX_IDE_DEVS);
...
Of course this last line is wrong...
Quoted 16 lines
Quoted 5 lines
Index:
qemu/hw/sun4m.chw/sun4m.c +1
-2-if (hwdef->fd_base != (target_phys_addr_t)-1 ) -sun4m_fdctrl_init (slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd_table); +if (hwdef->fd_base != (target_phys_addr_t)-1 ) {hw/sun4m.c static void *sun4m_hw_init(const struct · line 403
Quoted 10 lines
hw/sun4m.c +10
-0+for (i =0 ; i <MAX_FD ; i++) { + index =drive_get_index (IF_FLOPPY ,0 , i); +if (index !=-1 ) + fd[i] = drives_table[index].bdrv; +else + fd[i] =NULL ; + } + +sun4m_fdctrl_init (slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd); + }
Quoted 1 line
This is broken, there are zero or one floppy drives, never more.
I just try to mimic original behavior.
I'll correct this.
Quoted 12 lines
hw/sun4u.c static void sun4u_init(int ram_size, int · line 447
Quoted 11 lines
Index:
qemu/hw/sun4u.chw/sun4u.c +8
-1- floppy_controller =fdctrl_init (NULL /*6*/ ,2 ,0 ,0x3f0 , fd_table); +for (i =0 ; i <MAX_FD ; i++) { + index =drive_get_index (IF_FLOPPY ,0 , i); +if (index !=-1 ) + fd[i] = drives_table[index].bdrv; +else + fd[i] =NULL ; + } + floppy_controller =fdctrl_init (NULL /*6*/ ,2 ,0 ,0x3f0 , fd);
Quoted 3 lines
I think same applies here (0 to 1 drives), but as the hardware is PC-like, technically it may be possible that someone could replace the cables and insert additional floppy drives.
ditto
Laurent
Signature · 3 lines
------------- [email protected] -------------- "In short: just say NO TO DRUGS and maybe you won't end up like the Hurd people." -- Linus Torvald
Re: [Qemu-devel] [PATCH 1/2][UPDATE] remove unused parameters from QEMUMachineInitFunc
In reply to Laurent VivierFind attached an updated^2 patch.
Laurent
Quoted 43 lines · Laurent Vivier
Quoted 9 lines · Blue Swirl
Quoted 5 lines · Laurent Vivier
It appears that
fd_filenameand snapshot are not needed/used by machine init functions (QEMUMachineInitFunc).This patch removes them.
I don't know what was the idea for these parameters, so I can't comment on the correctness of the patch in general.
fd_filenamecannot be managed because I suppressed the array invl.cand Fabrice (when he commented the first revision of this patch) proposed to remove "snapshot" too:"- While modifying the machine init function, you can suppress the snapshot parameter."
Quoted 11 lines
Quoted 11 lines
/* SPARCstation 5 hardware initialisation */
(quoted diff) +2
-2-static void ss5_init(int RAM_size, int vga_ram_size, const char *boot_device, - DisplayState *ds, const char **fd_filename, int snapshot, +static void ss5_init(int RAM_size, int vga_ram_size, + const char *boot_device, DisplayState *ds, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) {@@ -616,8 +616,8 @@ static void ss5_init(int RAM_size, int v }Quoted 9 lines
Review static void ss5_init(int RAM_size, int v · line 622
Quoted 7 lines
(quoted diff) +2
-2/* SPARCstation 10 hardware initialisation */ -static void ss10_init(int RAM_size, int vga_ram_size, const char *boot_device, - DisplayState *ds, const char **fd_filename, int snapshot, +static void ss10_init(int RAM_size, int vga_ram_size, + const char *boot_device, DisplayState *ds, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model)You didn't fix
ss600mp_init, which was added yesterday.Oops, sorry, I missed it.
Thank you for your comments,
Laurent
Signature · 3 lines
------------- [email protected] -------------- "In short: just say NO TO DRUGS and maybe you won't end up like the Hurd people." -- Linus Torvald
It appears that fd_filename and snapshot are not needed/used by machine init functions (QEMUMachineInitFunc).
This patch removes them.
--- hw/an5206.c | 4 ++-- hw/dummy_m68k.c | 1 - hw/etraxfs.c | 4 ++-- hw/integratorcp.c | 1 - hw/mcf5208.c | 1 - hw/mips_malta.c | 4 ++-- hw/mips_mipssim.c | 4 ++-- hw/mips_pica61.c | 4 ++-- hw/mips_r4k.c | 4 ++-- hw/palm.c | 1 - hw/pc.c | 20 ++++++++------------ hw/ppc405_boards.c | 2 -- hw/ppc_chrp.c | 1 - hw/ppc_oldworld.c | 1 - hw/ppc_prep.c | 5 ++--- hw/r2d.c | 4 ++-- hw/realview.c | 1 - hw/shix.c | 4 ++-- hw/spitz.c | 4 ---- hw/stellaris.c | 2 -- hw/sun4m.c | 12 ++++++------ hw/sun4u.c | 4 ++-- hw/versatilepb.c | 17 ++++++++--------- vl.c | 3 +-- vl.h | 3 +-- 25 files changed, 44 insertions(+), 67 deletions(-)
vl.h +1 -2
@@ -582,8 +582,7 @@ extern uint8_t _translate_keycode(const#ifdef NEED_CPU_H typedef void QEMUMachineInitFunc (int ram_size,int vga_ram_size, -const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model);
hw/an5206.c +2 -2
@@ -27,8 +27,8 @@ void DMA_run (void)/* Board init. */ -static void an5206_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void an5206_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/etraxfs.c +2 -2
@@ -107,8 +107,8 @@ static void dummy_cpu_set_irq(void *opaq }static -void bareetraxfs_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +void bareetraxfs_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/integratorcp.c +0 -1
@@ -466,7 +466,6 @@ static void icp_control_init(uint32_t bastatic void integratorcp_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/mcf5208.c +0 -1
@@ -199,7 +199,6 @@ static void mcf5208_sys_init(qemu_irq *pstatic void mcf5208evb_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/mips_malta.c +2 -2
@@ -746,8 +746,8 @@ static void main_cpu_reset(void *opaque) }static -void mips_malta_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +void mips_malta_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/mips_mipssim.c +2 -2
@@ -100,8 +100,8 @@ static void main_cpu_reset(void *opaque) }static void -mips_mipssim_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +mips_mipssim_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/palm.c +0 -1
@@ -179,7 +179,6 @@ static void palmte_gpio_setup(struct omastatic void palmte_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/ppc405_boards.c +0 -2
@@ -173,7 +173,6 @@ static void ref405ep_fpga_init (uint32_t static void ref405ep_init (int ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, - const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename,
@@ -499,7 +498,6 @@ static void taihu_cpld_init (uint32_t ba static void taihu_405ep_init(int ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, - const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename,
hw/ppc_chrp.c +0 -1
@@ -50,7 +50,6 @@ static CPUReadMemoryFunc *unin_read[] =/* PowerPC Mac99 hardware initialisation */ static void ppc_core99_init (int ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, - const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename,
hw/ppc_oldworld.c +0 -1
@@ -94,7 +94,6 @@ static int vga_osi_call (CPUState *env) static void ppc_heathrow_init (int ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, - const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename,
hw/r2d.c +2 -2
@@ -27,8 +27,8 @@#define SDRAM_BASE 0x0c000000/* Physical location of SDRAM: Area 3 */ #define SDRAM_SIZE 0x04000000 -static void r2d_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState * ds,const char **fd_filename,int snapshot, +static void r2d_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState * ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/shix.c +2 -2
@@ -62,8 +62,8 @@ void vga_screen_dump(const char *filenam/* XXXXX */ } -static void shix_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState * ds,const char **fd_filename,int snapshot, +static void shix_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState * ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/spitz.c +0 -4
@@ -1234,7 +1234,6 @@ static void spitz_common_init(int ram_sistatic void spitz_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
@@ -1244,7 +1243,6 @@ static void spitz_init(int ram_size, intstatic void borzoi_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
@@ -1254,7 +1252,6 @@ static void borzoi_init(int ram_size, instatic void akita_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
@@ -1264,7 +1261,6 @@ static void akita_init(int ram_size, intstatic void terrier_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/sun4u.c +2 -2
@@ -306,8 +306,8 @@ static const int parallel_irq[MAX_PARALLstatic fdctrl_t *floppy_controller;/* Sun4u hardware initialisation */ -static void sun4u_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void sun4u_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/mips_pica61.c +2 -2
@@ -54,8 +54,8 @@ static void main_cpu_reset(void *opaque) }static -void mips_pica61_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +void mips_pica61_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/mips_r4k.c +2 -2
@@ -137,8 +137,8 @@ static void main_cpu_reset(void *opaque) }static -void mips_r4k_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +void mips_r4k_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/pc.c +8 -12
@@ -684,8 +684,8 @@ static void pc_init_ne2k_isa(NICInfo *nd }/* PC hardware initialisation */ -static void pc_init1 (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void pc_init1 (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,int pci_enabled,const char *cpu_model)
@@ -973,30 +973,26 @@ static void pc_init1(int ram_size, int v#endif } -static void pc_init_pci (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename, -int snapshot, +static void pc_init_pci (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) { -pc_init1 (ram_size, vga_ram_size, boot_device, - ds, fd_filename, snapshot, +pc_init1 (ram_size, vga_ram_size, boot_device, ds, kernel_filename, kernel_cmdline, initrd_filename,1 , cpu_model); } -static void pc_init_isa (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename, -int snapshot, +static void pc_init_isa (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) { -pc_init1 (ram_size, vga_ram_size, boot_device, - ds, fd_filename, snapshot, +pc_init1 (ram_size, vga_ram_size, boot_device, ds, kernel_filename, kernel_cmdline, initrd_filename,0 , cpu_model); }
hw/ppc_prep.c +2 -3
@@ -522,9 +522,8 @@ CPUReadMemoryFunc *PPC_prep_io_read[] =/* PowerPC PREP hardware initialisation */ static void ppc_prep_init (int ram_size,int vga_ram_size, -const char *boot_device, -DisplayState *ds,const char **fd_filename, -int snapshot,const char *kernel_filename, +const char *boot_device,DisplayState *ds, +const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model)
hw/realview.c +0 -1
@@ -14,7 +14,6 @@static void realview_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/sun4m.c +6 -6
@@ -603,8 +603,8 @@ static void sun4m_common_init(int RAM_si }/* SPARCstation 5 hardware initialisation */ -static void ss5_init (int RAM_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void ss5_init (int RAM_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
@@ -616,8 +616,8 @@ static void ss5_init(int RAM_size, int v }/* SPARCstation 10 hardware initialisation */ -static void ss10_init (int RAM_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void ss10_init (int RAM_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
@@ -629,8 +629,8 @@ static void ss10_init(int RAM_size, int }/* SPARCserver 600MP hardware initialisation */ -static void ss600mp_init (int RAM_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void ss600mp_init (int RAM_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/versatilepb.c +8 -9
@@ -153,7 +153,6 @@ static qemu_irq *vpb_sic_init(uint32_t bstatic void versatile_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model,int board_id)
@@ -270,24 +269,24 @@ static void versatile_init(int ram_size, initrd_filename, board_id, 0x0); } -static void vpb_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void vpb_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) { -versatile_init (ram_size, vga_ram_size, boot_device, - ds, fd_filename, snapshot, +versatile_init (ram_size, vga_ram_size, + boot_device, ds, kernel_filename, kernel_cmdline, initrd_filename, cpu_model,0x183 ); } -static void vab_init (int ram_size,int vga_ram_size,const char *boot_device, -DisplayState *ds,const char **fd_filename,int snapshot, +static void vab_init (int ram_size,int vga_ram_size, +const char *boot_device,DisplayState *ds,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) { -versatile_init (ram_size, vga_ram_size, boot_device, - ds, fd_filename, snapshot, +versatile_init (ram_size, vga_ram_size, + boot_device, ds, kernel_filename, kernel_cmdline, initrd_filename, cpu_model,0x25e ); }
vl.c +1 -2
@@ -8511,8 +8511,7 @@ int main(int argc, char **argv) } } - machine->init (ram_size, vga_ram_size, boot_devices, - ds, fd_filename, snapshot, + machine->init (ram_size, vga_ram_size, boot_devices, ds, kernel_filename, kernel_cmdline, initrd_filename, cpu_model);/* init USB devices */
hw/dummy_m68k.c +0 -1
@@ -14,7 +14,6 @@static void dummy_m68k_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
hw/stellaris.c +0 -2
@@ -1072,7 +1072,6 @@ static void stellaris_init(const char *k/* FIXME: Figure out how to generate these from stellaris_boards. */ static void lm3s811evb_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
@@ -1081,7 +1080,6 @@ static void lm3s811evb_init(int ram_sizestatic void lm3s6965evb_init (int ram_size,int vga_ram_size,const char *boot_device,DisplayState *ds, -const char **fd_filename,int snapshot,const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *cpu_model) {
Re: [Qemu-devel] [PATCH 2/2][UPDATE] Add arg -drive to define new drive with more features
In reply to Blue SwirlAttached is an updated patch (corrected as you want and with more check on -drive arguments)
Hope you'll like it.
Regards,
Laurent
Quoted 49 lines · Blue Swirl
Quoted 3 lines · Laurent Vivier
It also defines the default interface type to "scsi" for targets "realview", "SS-5", "SS-10", "versatilepb", "versatileab" to keep old behavior, where "-hda" is a SCSI disk.
For maximal compatibility, I'd like the following mappings for SS-5, SS-10, and SS-600MP:
(quoted diff) +0
-4-hda = SCSI ID 0 -hdb = SCSI ID 1 -hdc = -cdrom = SCSI ID 2 -hdd = SCSI ID 3There is no bus 1, only 0. Maybe a warning should be issued for bus=1.
I didn't find where this was implemented, so is the above in line with the patch?
Quoted 5 lines
Index:
qemu/hw/sun4m.c(quoted diff) +1
-2- if (hwdef->fd_base != (target_phys_addr_t)-1) - sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd_table); + if (hwdef->fd_base != (target_phys_addr_t)-1) {Review
Quoted 10 lines
(quoted diff) +10
-0+ for(i = 0; i < MAX_FD; i++) { + index = drive_get_index(IF_FLOPPY, 0, i); + if (index != -1) + fd[i] = drives_table[index].bdrv; + else + fd[i] = NULL; + } + + sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd); + }This is broken, there are zero or one floppy drives, never more.
Review
Quoted 11 lines
Index:
qemu/hw/sun4u.c(quoted diff) +8
-1- floppy_controller = fdctrl_init(NULL/*6*/, 2, 0, 0x3f0, fd_table); + for(i = 0; i < MAX_FD; i++) { + index = drive_get_index(IF_FLOPPY, 0, i); + if (index != -1) + fd[i] = drives_table[index].bdrv; + else + fd[i] = NULL; + } + floppy_controller = fdctrl_init(NULL/*6*/, 2, 0, 0x3f0, fd);I think same applies here (0 to 1 drives), but as the hardware is PC-like, technically it may be possible that someone could replace the cables and insert additional floppy drives.
Signature · 3 lines
------------- [email protected] -------------- "Any sufficiently advanced technology is indistinguishable from magic." - Arthur C. Clarke
This patch introduces a new parameter allowing to define drives.
The new parameter is "-drive":
-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][index=i][,cyls=c,heads=h,secs=s[,trans=t]][snapshot=on|off]
where:
file is the disk image
type is the interface type (ide, scsi, sd, mtd, floppy, pflash) n is the bus number of the given type
m is the unit number on the given bus
d is the type of the media (disk, cdrom)
c,h,s,t are the parameters usually given by -hdachs snapshot allows to enable or not the snapshot for this disk i is an index number within the given type (replace bus,unit)
"-cdrom file" is an alias for "-drive file=file,index=2,media=cdrom" "-hda file" is an alias for "-drive file=file,index=0,media=disk" "-hdb file" is an alias for "-drive file=file,index=1,media=disk" "-hdc file" is an alias for "-drive file=file,index=2,media=disk" "-hdd file" is an alias for "-drive file=file,index=3,media=disk" "-hda file -hdachs a,b,c" is an alias for
"-drive file=file,index=0,cyls=a,heads=b,secs=c"
You can also define a cdrom on the slace of ide0 with:
"-drive file=file,if=ide,index=1,media=cdrom"
You can define an empty cdrom:
"-drive if=ide,index=1,media=cdrom"
"-drive file=file,if=scsi,bus=0,unit=6" allows to connect the disk image file to the scsi bus 0 with the unit id 6.
if there is no SCSI disk, the SCSI interface is not created.
It also defines the default interface type to "scsi" for targets "realview", "SS-5", "SS-10", "versatilepb", "versatileab" to keep old behavior, where "-hda" is a SCSI disk.
"-fda file" is an alias for "-drive file=file,index=0,if=floppy" "-fdb file" is an alias for "-drive file=file,index=1,if=floppy" "-pflash file" is an alias for "-drive file=file,if=pflash" "-mtdblock file" is an alias for "-drive file=file,if=mtd" "-sd file" becomes the alias of "-drive file=file,if=sd"
"-drive file=a -drive file=b" will be interpreted like "-hda a -hdb b"
--- hw/esp.c | 10 - hw/integratorcp.c | 8 hw/lsi53c895a.c | 3 hw/mips_malta.c | 15 + hw/mips_pica61.c | 21 +- hw/mips_r4k.c | 17 + hw/nand.c | 2 hw/omap_mmc.c | 2 hw/pc.c | 65 ++++-- hw/ppc405_boards.c | 29 +- hw/ppc_chrp.c | 17 + hw/ppc_oldworld.c | 31 ++- hw/ppc_prep.c | 27 ++ hw/pxa2xx_mmci.c | 3 hw/realview.c | 17 + hw/spitz.c | 9 hw/esp.c | 10 hw/integratorcp.c | 8 hw/lsi53c895a.c | 3 hw/mips_malta.c | 20 + hw/mips_pica61.c | 29 ++ hw/mips_r4k.c | 22 + hw/nand.c | 8 hw/omap_mmc.c | 8 hw/pc.c | 70 +++-- hw/ppc405_boards.c | 29 +- hw/ppc_chrp.c | 21 + hw/ppc_oldworld.c | 35 ++ hw/ppc_prep.c | 32 ++ hw/pxa2xx_mmci.c | 9 hw/realview.c | 21 + hw/spitz.c | 9 hw/sun4m.c | 29 +- hw/sun4u.c | 28 ++ hw/versatilepb.c | 22 + monitor.c | 11 vl.c | 653 +++++++++++++++++++++++++++++++++++++---------------- vl.h | 32 +- 22 files changed, 816 insertions(+), 293 deletions(-)
vl.c +459 -194
@@ -149,12 +149,10 @@ char phys_ram_file[1024];void *ioport_opaque[MAX_IOPORTS ];IOPortReadFunc *ioport_read_table[3 ][MAX_IOPORTS ];IOPortWriteFunc *ioport_write_table[3 ][MAX_IOPORTS ]; -/* Note: bs_table[MAX_DISKS] is a dummy block driver if none available +/* Note: drives_table[MAX_DRIVES] is a dummy block driver if none available to store the VM snapshots */ -BlockDriverState *bs_table[MAX_DISKS +1 ], *fd_table[MAX_FD ]; -BlockDriverState *pflash_table[MAX_PFLASH ]; -BlockDriverState *sd_bdrv; -BlockDriverState *mtd_bdrv; +DriveInfo drives_table[MAX_DRIVES +1 ]; +int nb_drives;/* point to the block driver where the snapshots are managed */ BlockDriverState *bs_snapshots;int vga_ram_size;
@@ -218,6 +216,8 @@ int alt_grab = 0;unsigned int nb_prom_envs =0 ;const char *prom_envs[MAX_PROM_ENVS ];#endif +int nb_drives_opt; +char drives_opt[MAX_DRIVES ][1024 ];#define TFR (expr) do { if ((expr) != -1) break; } while (errno == EINTR)
@@ -1734,12 +1734,9 @@ static int mux_proc_byte(CharDriverStatecase 's' : {int i; -for (i =0 ; i <MAX_DISKS ; i++) { -if (bs_table[i]) -bdrv_commit (bs_table[i]); +for (i =0 ; i < nb_drives; i++) { +bdrv_commit (drives_table[i].bdrv); } -if (mtd_bdrv) -bdrv_commit (mtd_bdrv); }break ;case 'b' :
@@ -4502,38 +4499,51 @@ static int net_socket_mcast_init(VLANSta } +static const char *get_word (char *buf,int buf_size,const char *p) +{ +char *q; +int substring; + + substring =0 ; + q = buf; +while (*p !='\0' ) { +if (*p =='\\' ) { + p++; +if (*p =='\0' ) +break ; + }else if (*p =='\"' ) { + substring = !substring; + p++; +continue ; + }else if (!substring && (*p ==',' || *p =='=' )) +break ; +if (q && (q - buf) < buf_size -1 ) + *q++ = *p; + p++; + } +if (q) + *q ='\0' ; + +return p; +} +static int get_param_value (char *buf,int buf_size,const char *tag,const char *str) {const char *p; -char *q;char option[128 ]; p = str;for (;;) { - q = option; -while (*p !='\0' && *p !='=' ) { -if ((q - option) <sizeof (option) -1 ) - *q++ = *p; - p++; - } - *q ='\0' ; + p =get_word (option,sizeof (option), p);if (*p !='=' )break ; p++;if (!strcmp (tag, option)) { - q = buf; -while (*p !='\0' && *p !=',' ) { -if ((q - buf) < buf_size -1 ) - *q++ = *p; - p++; - } - *q ='\0' ; -return q - buf; + (void )get_word (buf, buf_size, p); +return strlen (buf); }else { -while (*p !='\0' && *p !=',' ) { - p++; - } + p =get_word (NULL ,0 , p); }if (*p !=',' )break ;
@@ -4542,6 +4552,32 @@ static int get_param_value(char *buf, inreturn 0 ; } +static int check_params (char *buf,int buf_size, +char **params,const char *str) +{ +const char *p; +int i; + + p = str; +for (;;) { + p =get_word (buf, buf_size, p); +if (*p !='=' ) +return -1 ; + p++; +for (i =0 ; params[i] !=NULL ; i++) +if (!strcmp (params[i], buf)) +break ; +if (params[i] ==NULL ) +return -1 ; + p =get_word (NULL ,0 , p); +if (*p !=',' ) +break ; + p++; + } +return 0 ; +} + +static int net_client_init (const char *str) {const char *p;
@@ -4692,6 +4728,322 @@ void do_info_network(void) } } +#define HD_ALIAS "file=\"%s\",index=%d,media=disk" +#ifdef TARGET_PPC +#define CDROM_ALIAS "index=1,media=cdrom" +#else +#define CDROM_ALIAS "index=2,media=cdrom" +#endif +#define FD_ALIAS "index=%d,if=floppy" +#define PFLASH_ALIAS "file=\"%s\",if=pflash" +#define MTD_ALIAS "file=\"%s\",if=mtd" +#define SD_ALIAS "file=\"%s\",if=sd" + +static int drive_add (const char *fmt, ...) +{ +va_list ap; + +if (nb_drives_opt >=MAX_DRIVES ) { +fprintf (stderr,"qemu: too many drives\n" ); +exit (1 ); + } + +va_start (ap, fmt); +vsnprintf (drives_opt[nb_drives_opt],sizeof (drives_opt[0 ]), fmt, ap); +va_end (ap); + +return nb_drives_opt++; +} + +int drive_get_index (BlockInterfaceType interface,int bus,int unit) +{ +int index; + +/* seek interface, bus and unit */ + +for (index =0 ; index < nb_drives; index++) +if (drives_table[index].interface == interface && + drives_table[index].bus == bus && + drives_table[index].unit == unit) +return index; + +return -1 ; +} + +int drive_get_max_bus (BlockInterfaceType interface) +{ +int max_bus; +int index; + + max_bus =-1 ; +for (index =0 ; index < nb_drives; index++) { +if (drives_table[index].interface == interface && + drives_table[index].bus > max_bus) + max_bus = drives_table[index].bus; + } +return max_bus; +} + +static int drive_init (const char *str,int snapshot,QEMUMachine *machine) +{ +char buf[128 ]; +char file[1024 ]; +BlockInterfaceType interface; +enum {MEDIA_DISK ,MEDIA_CDROM } media; +int bus_id, unit_id; +int cyls, heads, secs, translation; +BlockDriverState *bdrv; +int max_devs; +int index; +char *params[] = {"bus" ,"unit" ,"if" ,"index" ,"cyls" ,"heads" , +"secs" ,"trans" ,"media" ,"snapshot" ,"file" ,NULL }; + +if (check_params (buf,sizeof (buf), params, str) <0 ) { +fprintf (stderr,"qemu: unknowm parameter '%s' in '%s'\n" , + buf, str); +return -1 ; + } + + file[0 ] =0 ; + cyls = heads = secs =0 ; + bus_id =0 ; + unit_id =-1 ; + translation =BIOS_ATA_TRANSLATION_AUTO ; + index =-1 ; + +if (!strcmp (machine->name,"realview" ) || + !strcmp (machine->name,"SS-5" ) || + !strcmp (machine->name,"SS-10" ) || + !strcmp (machine->name,"versatilepb" ) || + !strcmp (machine->name,"versatileab" )) { + interface =IF_SCSI ; + max_devs =MAX_SCSI_DEVS ; + }else { + interface =IF_IDE ; + max_devs =MAX_IDE_DEVS ; + } + media =MEDIA_DISK ; + +/* extract parameters */ + +if (get_param_value (buf,sizeof (buf),"bus" , str)) { + bus_id =strtol (buf,NULL ,0 ); +if (bus_id <0 ) { +fprintf (stderr,"qemu: '%s' invalid bus id\n" , str); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"unit" , str)) { + unit_id =strtol (buf,NULL ,0 ); +if (unit_id <0 ) { +fprintf (stderr,"qemu: '%s' invalid unit id\n" , str); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"if" , str)) { +if (!strcmp (buf,"ide" )) { + interface =IF_IDE ; + max_devs =MAX_IDE_DEVS ; + }else if (!strcmp (buf,"scsi" )) { + interface =IF_SCSI ; + max_devs =MAX_SCSI_DEVS ; + }else if (!strcmp (buf,"floppy" )) { + interface =IF_FLOPPY ; + max_devs =0 ; + }else if (!strcmp (buf,"pflash" )) { + interface =IF_PFLASH ; + max_devs =0 ; + }else if (!strcmp (buf,"mtd" )) { + interface =IF_MTD ; + max_devs =0 ; + }else if (!strcmp (buf,"sd" )) { + interface =IF_SD ; + max_devs =0 ; + }else { +fprintf (stderr,"qemu: '%s' unsupported bus type '%s'\n" , str, buf); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"index" , str)) { + index =strtol (buf,NULL ,0 ); +if (index <0 ) { +fprintf (stderr,"qemu: '%s' invalid index\n" , str); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"cyls" , str)) { + cyls =strtol (buf,NULL ,0 ); + } + +if (get_param_value (buf,sizeof (buf),"heads" , str)) { + heads =strtol (buf,NULL ,0 ); + } + +if (get_param_value (buf,sizeof (buf),"secs" , str)) { + secs =strtol (buf,NULL ,0 ); + } + +if (cyls || heads || secs) { +if (cyls <1 || cyls >16383 ) { +fprintf (stderr,"qemu: '%s' invalid physical cyls number\n" , str); +return -1 ; + } +if (heads <1 || heads >16 ) { +fprintf (stderr,"qemu: '%s' invalid physical heads number\n" , str); +return -1 ; + } +if (secs <1 || secs >63 ) { +fprintf (stderr,"qemu: '%s' invalid physical secs number\n" , str); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"trans" , str)) { +if (!cyls) { +fprintf (stderr, +"qemu: '%s' trans must be used with cyls,heads and secs\n" , + str); +return -1 ; + } +if (!strcmp (buf,"none" )) + translation =BIOS_ATA_TRANSLATION_NONE ; +else if (!strcmp (buf,"lba" )) + translation =BIOS_ATA_TRANSLATION_LBA ; +else if (!strcmp (buf,"auto" )) + translation =BIOS_ATA_TRANSLATION_AUTO ; +else { +fprintf (stderr,"qemu: '%s' invalid translation type\n" , str); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"media" , str)) { +if (!strcmp (buf,"disk" )) { + media =MEDIA_DISK ; + }else if (!strcmp (buf,"cdrom" )) { +if (cyls || secs || heads) { +fprintf (stderr, +"qemu: '%s' invalid physical CHS format\n" , str); +return -1 ; + } + media =MEDIA_CDROM ; + }else { +fprintf (stderr,"qemu: '%s' invalid media\n" , str); +return -1 ; + } + } + +if (get_param_value (buf,sizeof (buf),"snapshot" , str)) { +if (!strcmp (buf,"on" )) + snapshot =1 ; +else if (!strcmp (buf,"off" )) + snapshot =0 ; +else { +fprintf (stderr,"qemu: '%s' invalid snapshot option\n" , str); +return -1 ; + } + } + +get_param_value (file,sizeof (file),"file" , str); + +/* compute bus and unit according index */ + +if (index !=-1 ) { +if (bus_id !=0 || unit_id !=-1 ) { +fprintf (stderr, +"qemu: '%s' index cannot be used with bus and unit\n" , str); +return -1 ; + } +if (max_devs ==0 ) + { + unit_id = index; + bus_id =0 ; + }else { + unit_id = index % max_devs; + bus_id = index / max_devs; + } + } + +/* if user doesn't specify a unit_id, +* try to find the first free +*/ + +if (unit_id ==-1 ) { + unit_id =0 ; +while (drive_get_index (interface, bus_id, unit_id) !=-1 ) { + unit_id++; +if (max_devs && unit_id >= max_devs) { + unit_id -= max_devs; + bus_id++; + } + } + } + +/* check unit id */ + +if (max_devs && unit_id >= max_devs) { +fprintf (stderr,"qemu: '%s' unit %d too big (max is %d)\n" , + str, unit_id, max_devs -1 ); +return -1 ; + } + +/* +* ignore multiple definitions +*/ + +if (drive_get_index (interface, bus_id, unit_id) !=-1 ) +return 0 ; + +/* init */ + +snprintf (buf,sizeof (buf),"drive%d" , nb_drives); + bdrv =bdrv_new (buf); + drives_table[nb_drives].bdrv = bdrv; + drives_table[nb_drives].interface = interface; + drives_table[nb_drives].bus = bus_id; + drives_table[nb_drives].unit = unit_id; + nb_drives++; + +switch (interface) { +case IF_IDE : +case IF_SCSI : +switch (media) { +case MEDIA_DISK : +if (cyls !=0 ) { +bdrv_set_geometry_hint (bdrv, cyls, heads, secs); +bdrv_set_translation_hint (bdrv, translation); + } +break ; +case MEDIA_CDROM : +bdrv_set_type_hint (bdrv,BDRV_TYPE_CDROM ); +break ; + } +break ; +case IF_SD : +/* FIXME: This isn't really a floppy, but it's a reasonable +approximation. */ +case IF_FLOPPY : +bdrv_set_type_hint (bdrv,BDRV_TYPE_FLOPPY ); +break ; +case IF_PFLASH : +case IF_MTD : +break ; + } +if (!file[0 ]) +return 0 ; +if (bdrv_open (bdrv, file, snapshot ?BDRV_O_SNAPSHOT :0 ) <0 || +qemu_key_check (bdrv, file)) { +fprintf (stderr,"qemu: could not open disk image %s\n" , + file); +return -1 ; + } +return 0 ; +} +/***********************************************************/ /* USB devices */
@@ -5475,8 +5827,8 @@ static BlockDriverState *get_bs_snapshotif (bs_snapshots)return bs_snapshots; -for (i =0 ; i <=MAX_DISKS ; i++) { - bs = bs_table[i]; +for (i =0 ; i <= nb_drives; i++) { + bs = drives_table[i].bdrv;if (bdrv_can_snapshot (bs)) goto ok; }
@@ -5584,8 +5936,8 @@ void do_savevm(const char *name)/* create the snapshots */ -for (i =0 ; i <MAX_DISKS ; i++) { - bs1 = bs_table[i]; +for (i =0 ; i < nb_drives; i++) { + bs1 = drives_table[i].bdrv;if (bdrv_has_snapshot (bs1)) {if (must_delete) { ret =bdrv_snapshot_delete (bs1, old_sn->id_str);
@@ -5627,8 +5979,8 @@ void do_loadvm(const char *name) saved_vm_running = vm_running;vm_stop (0 ); -for (i =0 ; i <=MAX_DISKS ; i++) { - bs1 = bs_table[i]; +for (i =0 ; i <= nb_drives; i++) { + bs1 = drives_table[i].bdrv;if (bdrv_has_snapshot (bs1)) { ret =bdrv_snapshot_goto (bs1, name);if (ret <0 ) {
@@ -5688,8 +6040,8 @@ void do_delvm(const char *name)return ; } -for (i =0 ; i <=MAX_DISKS ; i++) { - bs1 = bs_table[i]; +for (i =0 ; i <= nb_drives; i++) { + bs1 = drives_table[i].bdrv;if (bdrv_has_snapshot (bs1)) { ret =bdrv_snapshot_delete (bs1, name);if (ret <0 ) {
@@ -5717,8 +6069,8 @@ void do_info_snapshots(void)return ; }term_printf ("Snapshot devices:" ); -for (i =0 ; i <=MAX_DISKS ; i++) { - bs1 = bs_table[i]; +for (i =0 ; i <= nb_drives; i++) { + bs1 = drives_table[i].bdrv;if (bdrv_has_snapshot (bs1)) {if (bs == bs1)term_printf (" %s" ,bdrv_get_device_name (bs1));
@@ -6468,15 +6820,14 @@ static void ram_save(QEMUFile *f, void */* find if the memory block is available on a virtual block device */ sector_num =-1 ; -for (j =0 ; j <MAX_DISKS ; j++) { -if (bs_table[j]) { - sector_num =bdrv_hash_find (bs_table[j], - phys_ram_base + i,BDRV_HASH_BLOCK_SIZE ); -if (sector_num >=0 ) -break ; - } +for (j =0 ; j < nb_drives; j++) { + sector_num =bdrv_hash_find (drives_table[j].bdrv, + phys_ram_base + i, +BDRV_HASH_BLOCK_SIZE ); +if (sector_num >=0 ) +break ; } -if (j ==MAX_DISKS ) +if (j == nb_drives) goto normal_compress; buf[0 ] =1 ; buf[1 ] = j;
@@ -6527,11 +6878,12 @@ static int ram_load(QEMUFile *f, void *oram_decompress_buf (s, buf +1 ,9 ); bs_index = buf[1 ]; sector_num =be64_to_cpupu ((const uint64_t *)(buf +2 )); -if (bs_index >=MAX_DISKS || bs_table[bs_index] ==NULL ) { +if (bs_index >= nb_drives) {fprintf (stderr,"Invalid block device index %d\n" , bs_index); goto error; } -if (bdrv_read (bs_table[bs_index], sector_num, phys_ram_base + i, +if (bdrv_read (drives_table[bs_index].bdrv, sector_num, + phys_ram_base + i,BDRV_HASH_BLOCK_SIZE /512 ) <0 ) {fprintf (stderr,"Error while reading sector %d:%" PRId64"\n" , bs_index, sector_num);
@@ -7028,6 +7380,8 @@ static void help(int exitcode)"-hda/-hdb file use 'file' as IDE hard disk 0/1 image\n" "-hdc/-hdd file use 'file' as IDE hard disk 2/3 image\n" "-cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master)\n" +"-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][index=i][,cyls=c,heads=h,secs=s[,trans=t]][snapshot=on|off]\n" +" use 'file' as a drive image\n" "-mtdblock file use 'file' as on-board Flash memory image\n" "-sd file use 'file' as SecureDigital card image\n" "-pflash file use 'file' as a parallel flash image\n"
@@ -7173,6 +7527,7 @@ enum { QEMU_OPTION_hdb, QEMU_OPTION_hdc, QEMU_OPTION_hdd, + QEMU_OPTION_drive, QEMU_OPTION_cdrom, QEMU_OPTION_mtdblock, QEMU_OPTION_sd,
@@ -7262,6 +7617,7 @@ const QEMUOption qemu_options[] = { { "hdb", HAS_ARG, QEMU_OPTION_hdb }, { "hdc", HAS_ARG, QEMU_OPTION_hdc }, { "hdd", HAS_ARG, QEMU_OPTION_hdd }, + { "drive", HAS_ARG, QEMU_OPTION_drive }, { "cdrom", HAS_ARG, QEMU_OPTION_cdrom }, { "mtdblock", HAS_ARG, QEMU_OPTION_mtdblock }, { "sd", HAS_ARG, QEMU_OPTION_sd },
@@ -7374,16 +7730,9 @@ int qemu_key_check(BlockDriverState *bs,static BlockDriverState *get_bdrv (int index) { -BlockDriverState *bs; - -if (index <4 ) { - bs = bs_table[index]; - }else if (index <6 ) { - bs = fd_table[index -4 ]; - }else { - bs =NULL ; - } -return bs; +if (index > nb_drives) +return NULL ; +return drives_table[index].bdrv; }static void read_passwords (void )
@@ -7583,19 +7932,16 @@ int main(int argc, char **argv)const char *gdbstub_port;#endif uint32_t boot_devices_bitmap =0 ; -int i, cdrom_index, pflash_index; +int i;int snapshot, linux_boot, net_boot;const char *initrd_filename; -const char *hd_filename[MAX_DISKS ], *fd_filename[MAX_FD ]; -const char *pflash_filename[MAX_PFLASH ]; -const char *sd_filename; -const char *mtd_filename;const char *kernel_filename, *kernel_cmdline;const char *boot_devices ="" ;DisplayState *ds = &display_state;int cyls, heads, secs, translation;char net_clients[MAX_NET_CLIENTS ][256 ];int nb_net_clients; +int hda_index;int optind;const char *r, *optarg;CharDriverState *monitor_hd;
@@ -7648,15 +7994,6 @@ int main(int argc, char **argv) machine = first_machine; cpu_model =NULL ; initrd_filename =NULL ; -for (i =0 ; i <MAX_FD ; i++) - fd_filename[i] =NULL ; -for (i =0 ; i <MAX_DISKS ; i++) - hd_filename[i] =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 ; vga_ram_size =VGA_RAM_SIZE ;#ifdef CONFIG_GDBSTUB
@@ -7667,11 +8004,6 @@ int main(int argc, char **argv) nographic =0 ; kernel_filename =NULL ; kernel_cmdline ="" ; -#ifdef TARGET_PPC - cdrom_index =1 ; -#else - cdrom_index =2 ; -#endif cyls = heads = secs =0 ; translation =BIOS_ATA_TRANSLATION_AUTO ;pstrcpy (monitor_device,sizeof (monitor_device),"vc" );
@@ -7689,6 +8021,9 @@ int main(int argc, char **argv) usb_devices_index =0 ; nb_net_clients =0 ; + nb_drives =0 ; + nb_drives_opt =0 ; + hda_index =-1 ; nb_nics =0 ;/* default mac address of the first network interface */
@@ -7699,7 +8034,7 @@ int main(int argc, char **argv)break ; r = argv[optind];if (r[0 ] !='-' ) { - hd_filename[0 ] = argv[optind++]; + hda_index =drive_add (HD_ALIAS , argv[optind++],0 ); }else {const QEMUOption *popt;
@@ -7759,29 +8094,33 @@ int main(int argc, char **argv) initrd_filename = optarg;break ;case QEMU_OPTION_hda: +if (cyls ==0 ) + hda_index =drive_add (HD_ALIAS , optarg,0 ); +else + hda_index =drive_add (HD_ALIAS +",cyls=%d,heads=%d,secs=%d%s" , + optarg,0 , cyls, heads, secs, + translation ==BIOS_ATA_TRANSLATION_LBA ? +",trans=lba" : + translation ==BIOS_ATA_TRANSLATION_NONE ? +",trans=none" :"" ); +break ;case QEMU_OPTION_hdb:case QEMU_OPTION_hdc:case QEMU_OPTION_hdd: - { -int hd_index; - hd_index = popt->index - QEMU_OPTION_hda; - hd_filename[hd_index] = optarg; -if (hd_index == cdrom_index) - cdrom_index =-1 ; - } +drive_add (HD_ALIAS , optarg, popt->index - QEMU_OPTION_hda);break ; +case QEMU_OPTION_drive: +drive_add ("%s" , optarg); +break ;case QEMU_OPTION_mtdblock: - mtd_filename = optarg; +drive_add (MTD_ALIAS , optarg);break ;case QEMU_OPTION_sd: - sd_filename = optarg; +drive_add (SD_ALIAS , optarg);break ;case QEMU_OPTION_pflash: -if (pflash_index >=MAX_PFLASH ) { -fprintf (stderr,"qemu: too many parallel flash images\n" ); -exit (1 ); - } - pflash_filename[pflash_index++] = optarg; +drive_add (PFLASH_ALIAS , optarg);break ;case QEMU_OPTION_snapshot: snapshot =1 ;
@@ -7820,6 +8159,17 @@ int main(int argc, char **argv)fprintf (stderr,"qemu: invalid physical CHS format\n" );exit (1 ); } +if (hda_index !=-1 ) +snprintf (drives_opt[hda_index] + +strlen (drives_opt[hda_index]), +sizeof (drives_opt[0 ]) - +strlen (drives_opt[hda_index]), +",cyls=%d,heads=%d,secs=%d%s" , + cyls, heads, secs, + translation ==BIOS_ATA_TRANSLATION_LBA ? +",trans=lba" : + translation ==BIOS_ATA_TRANSLATION_NONE ? +",trans=none" :"" ); }break ;case QEMU_OPTION_nographic:
@@ -7838,9 +8188,7 @@ int main(int argc, char **argv) kernel_cmdline = optarg;break ;case QEMU_OPTION_cdrom: -if (cdrom_index >=0 ) { - hd_filename[cdrom_index] = optarg; - } +drive_add ("file=\"%s\"," CDROM_ALIAS , optarg);break ;case QEMU_OPTION_boot: boot_devices = optarg;
@@ -7874,10 +8222,9 @@ int main(int argc, char **argv) }break ;case QEMU_OPTION_fda: - fd_filename[0 ] = optarg; -break ;case QEMU_OPTION_fdb: - fd_filename[1 ] = optarg; +drive_add ("file=\"%s\"," FD_ALIAS , optarg, + popt->index - QEMU_OPTION_fda);break ;#ifdef TARGET_I386 case QEMU_OPTION_no_fd_bootchk:
@@ -8258,19 +8605,11 @@ int main(int argc, char **argv)/* XXX: this should not be: some embedded targets just have flash */ if (!linux_boot && net_boot ==0 && - hd_filename[0 ] =='\0' && - (cdrom_index >=0 && hd_filename[cdrom_index] =='\0' ) && - fd_filename[0 ] =='\0' ) + nb_drives_opt ==0 )help (1 ); -/* boot to floppy or the default cd if no hard disk defined yet */ if (!boot_devices[0 ]) { -if (hd_filename[0 ] !='\0' ) - boot_devices ="c" ; -else if (fd_filename[0 ] !='\0' ) - boot_devices ="a" ; -else - boot_devices ="d" ; + boot_devices ="cad" ; }setvbuf (stdout,NULL , _IOLBF,0 );
@@ -8347,97 +8686,23 @@ int main(int argc, char **argv)exit (1 ); } -/* we always create the cdrom drive, even if no disk is there */ bdrv_init (); -if (cdrom_index >=0 ) { - bs_table[cdrom_index] =bdrv_new ("cdrom" ); -bdrv_set_type_hint (bs_table[cdrom_index],BDRV_TYPE_CDROM ); - } -/* open the virtual block devices */ -for (i =0 ; i <MAX_DISKS ; i++) { -if (hd_filename[i]) { -if (!bs_table[i]) { -char buf[64 ]; -snprintf (buf,sizeof (buf),"hd%c" , i +'a' ); - bs_table[i] =bdrv_new (buf); - } -if (bdrv_open (bs_table[i], hd_filename[i], snapshot ?BDRV_O_SNAPSHOT :0 ) <0 ) { -fprintf (stderr,"qemu: could not open hard disk image '%s'\n" , - hd_filename[i]); -exit (1 ); - } -if (i ==0 && cyls !=0 ) { -bdrv_set_geometry_hint (bs_table[i], cyls, heads, secs); -bdrv_set_translation_hint (bs_table[i], translation); - } - } - } +/* we always create the cdrom drive, even if no disk is there */ -/* we always create at least one floppy disk */ - fd_table[0 ] =bdrv_new ("fda" ); -bdrv_set_type_hint (fd_table[0 ],BDRV_TYPE_FLOPPY ); - -for (i =0 ; i <MAX_FD ; i++) { -if (fd_filename[i]) { -if (!fd_table[i]) { -char buf[64 ]; -snprintf (buf,sizeof (buf),"fd%c" , i +'a' ); - fd_table[i] =bdrv_new (buf); -bdrv_set_type_hint (fd_table[i],BDRV_TYPE_FLOPPY ); - } -if (fd_filename[i][0 ] !='\0' ) { -if (bdrv_open (fd_table[i], fd_filename[i], - snapshot ?BDRV_O_SNAPSHOT :0 ) <0 ) { -fprintf (stderr,"qemu: could not open floppy disk image '%s'\n" , - fd_filename[i]); -exit (1 ); - } - } - } - } +if (nb_drives_opt <MAX_DRIVES ) +drive_add (CDROM_ALIAS ); -/* 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 ); - } - } - } +/* we always create at least on floppy */ - sd_bdrv =bdrv_new ("sd" ); -/* FIXME: This isn't really a floppy, but it's a reasonable -approximation. */ -bdrv_set_type_hint (sd_bdrv,BDRV_TYPE_FLOPPY ); -if (sd_filename) { -if (bdrv_open (sd_bdrv, sd_filename, - snapshot ?BDRV_O_SNAPSHOT :0 ) <0 ) { -fprintf (stderr,"qemu: could not open SD card image %s\n" , - sd_filename); - }else -qemu_key_check (sd_bdrv, sd_filename); - } +if (nb_drives_opt <MAX_DRIVES ) +drive_add (FD_ALIAS ,0 ); -if (mtd_filename) { - mtd_bdrv =bdrv_new ("mtd" ); -if (bdrv_open (mtd_bdrv, mtd_filename, - snapshot ?BDRV_O_SNAPSHOT :0 ) <0 || -qemu_key_check (mtd_bdrv, mtd_filename)) { -fprintf (stderr,"qemu: could not open Flash image %s\n" , - mtd_filename); -bdrv_delete (mtd_bdrv); - mtd_bdrv =0 ; - } - } +/* open the virtual block devices */ + +for (i =0 ; i < nb_drives_opt; i++) +if (drive_init (drives_opt[i], snapshot, machine) ==-1 ) +exit (1 );register_savevm ("timer" ,0 ,2 , timer_save, timer_load,NULL );register_savevm ("ram" ,0 ,2 , ram_save, ram_load,NULL );
vl.h +24 -8
@@ -785,13 +785,27 @@ void isa_cirrus_vga_init(DisplayState *dvoid pci_vmsvga_init (PCIBus *bus,DisplayState *ds,uint8_t *vga_ram_base,unsigned long vga_ram_offset,int vga_ram_size); -/* ide.c */ -#define MAX_DISKS 4 +typedef enum { +IF_IDE ,IF_SCSI ,IF_FLOPPY ,IF_PFLASH ,IF_MTD ,IF_SD +}BlockInterfaceType ; + +typedef struct DriveInfo { +BlockDriverState *bdrv; +BlockInterfaceType interface; +int bus; +int unit; +}DriveInfo ; + +#define MAX_DRIVES 32 -extern BlockDriverState *bs_table[MAX_DISKS +1 ]; -extern BlockDriverState *sd_bdrv; -extern BlockDriverState *mtd_bdrv; +extern int nb_drives; +extern DriveInfo drives_table[MAX_DRIVES +1 ]; +extern int drive_get_index (BlockInterfaceType interface,int bus,int unit); +extern int drive_get_max_bus (BlockInterfaceType interface); + +/* ide.c */ +#define MAX_IDE_DEVS 2void isa_ide_init (int iobase,int iobase2,qemu_irq irq,BlockDriverState *hd0,BlockDriverState *hd1); void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table,
@@ -836,7 +850,6 @@ void DMA_register_channel (int nchan, void *opaque);/* fdc.c */ #define MAX_FD 2 -extern BlockDriverState *fd_table[MAX_FD ];typedef struct fdctrl_t fdctrl_t ;
@@ -1103,8 +1116,11 @@ void *slavio_misc_init(target_phys_addr_void slavio_set_power_fail (void *opaque,int power_failing);/* esp.c */ +/* The HBA is ID 7, so for simplicitly limit to 7 devices. */ +#define MAX_SCSI_DEVS 7 +#define ESP_MAX_DEVS MAX_SCSI_DEVSvoid esp_scsi_attach (void *opaque,BlockDriverState *bd,int id); -void *esp_init (BlockDriverState **bd,target_phys_addr_t espaddr, +void *esp_init (target_phys_addr_t espaddr,void *dma_opaque,qemu_irq irq,qemu_irq *reset);/* sparc32_dma.c */
@@ -1234,6 +1250,7 @@ void scsi_cancel_io(SCSIDevice *s, uint3uint8_t *scsi_get_buf (SCSIDevice *s,uint32_t tag);/* lsi53c895a.c */ +#define LSI_MAX_DEVS MAX_SCSI_DEVSvoid lsi_scsi_attach (void *opaque,BlockDriverState *bd,int id);void *lsi_scsi_init (PCIBus *bus,int devfn);
@@ -1376,7 +1393,6 @@ int tc58128_init(struct SH7750State *s,/* NOR flash devices */ #define MAX_PFLASH 4 -extern BlockDriverState *pflash_table[MAX_PFLASH ];typedef struct pflash_t pflash_t ; pflash_t *pflash_register (target_phys_addr_t base, ram_addr_t off,
monitor.c +3 -8
@@ -204,16 +204,11 @@ static void do_commit(const char *deviceint i, all_devices; all_devices = !strcmp (device,"all" ); -for (i =0 ; i <MAX_DISKS ; i++) { -if (bs_table[i]) { +for (i =0 ; i < nb_drives; i++) {if (all_devices || - !strcmp (bdrv_get_device_name (bs_table[i]), device)) -bdrv_commit (bs_table[i]); - } + !strcmp (bdrv_get_device_name (drives_table[i].bdrv), device)) +bdrv_commit (drives_table[i].bdrv); } -if (mtd_bdrv) -if (all_devices || !strcmp (bdrv_get_device_name (mtd_bdrv), device)) -bdrv_commit (mtd_bdrv); }static void do_info (const char *item)
hw/mips_pica61.c +26 -3
@@ -38,6 +38,9 @@#define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000)) +#define MAX_IDE_BUS 2 +#define MAX_FD 2 +static const int ide_iobase[2 ] = {0x1f0 ,0x170 };static const int ide_iobase2[2 ] = {0x3f6 ,0x376 };static const int ide_irq[2 ] = {14 ,15 };
@@ -66,6 +69,8 @@ void mips_pica61_init (int ram_size, intint i;int available_ram;qemu_irq *i8259; +int index; +BlockDriverState *fd[MAX_FD ];/* init CPUs */ if (cpu_model ==NULL ) {
@@ -135,9 +140,20 @@ void mips_pica61_init (int ram_size, inti8042_mm_init (i8259[6 ], i8259[7 ],0x80005060 ,0 );/* IDE controller */ -for (i =0 ; i <2 ; i++) + +if (drive_get_max_bus (IF_IDE ) >=MAX_IDE_BUS ) { +fprintf (stderr,"qemu: too many IDE bus\n" ); +exit (1 ); + } + +for (i =0 ; i <MAX_IDE_BUS ; i++) { +int hd0, hd1; + hd0 =drive_get_index (IF_IDE , i,0 ); + hd1 =drive_get_index (IF_IDE , i,1 );isa_ide_init (ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], - bs_table[2 * i], bs_table[2 * i +1 ]); + hd0 ==-1 ?NULL : drives_table[hd0].bdrv, + hd1 ==-1 ?NULL : drives_table[hd1].bdrv); + }/* Network controller */ /* FIXME: missing NS SONIC DP83932 */
@@ -146,7 +162,14 @@ void mips_pica61_init (int ram_size, int/* FIXME: missing NCR 53C94 */ /* ISA devices (floppy, serial, parallel) */ -fdctrl_init (i8259[1 ],1 ,1 ,0x80003000 , fd_table); + +for (i =0 ; i <MAX_FD ; i++) { + index =drive_get_index (IF_FLOPPY ,0 , i); +if (index ==-1 ) +continue ; + fd[i] = drives_table[index].bdrv; + } +fdctrl_init (i8259[1 ],1 ,1 ,0x80003000 , fd);for (i =0 ; i <MAX_SERIAL_PORTS ; i++) {if (serial_hds[i]) {serial_mm_init (serial_base[i],0 , i8259[serial_irq[i]], serial_hds[i],1 );
hw/mips_r4k.c +20 -2
@@ -19,6 +19,8 @@#define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000)) +#define MAX_IDE_BUS 2 +static const int ide_iobase[2 ] = {0x1f0 ,0x170 };static const int ide_iobase2[2 ] = {0x3f6 ,0x376 };static const int ide_irq[2 ] = {14 ,15 };
@@ -149,6 +151,8 @@ void mips_r4k_init (int ram_size, int vgRTCState *rtc_state;int i;qemu_irq *i8259; +int index; +BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];/* init CPUs */ if (cpu_model ==NULL ) {
@@ -239,9 +243,23 @@ void mips_r4k_init (int ram_size, int vg } } -for (i =0 ; i <2 ; i++) +if (drive_get_max_bus (IF_IDE ) >=MAX_IDE_BUS ) { +fprintf (stderr,"qemu: too many IDE bus\n" ); +exit (1 ); + } + +for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { + index =drive_get_index (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); +if (index !=-1 ) + hd[i] = drives_table[index].bdrv; +else + hd[i] =NULL ; + } + +for (i =0 ; i <MAX_IDE_BUS ; i++)isa_ide_init (ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], - bs_table[2 * i], bs_table[2 * i +1 ]); + hd[MAX_IDE_DEVS * i], + hd[MAX_IDE_DEVS * i +1 ]);i8042_init (i8259[1 ], i8259[12 ],0x60 );ds1225y_init (0x9000 ,"nvram" );
hw/pc.c +49 -21
127 lines not on this page · raw message
hw/ppc_prep.c +29 -3
@@ -29,6 +29,8 @@/* SMP is not enabled, for now */ #define MAX_CPUS 1 +#define MAX_IDE_BUS 2 +#define BIOS_FILENAME "ppc_rom.bin"#define KERNEL_LOAD_ADDR 0x01000000#define INITRD_LOAD_ADDR 0x01800000
@@ -539,6 +541,9 @@ static void ppc_prep_init (int ram_size,PCIBus *pci_bus;qemu_irq *i8259;int ppc_boot_device; +int index; +BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; +BlockDriverState *fd[MAX_FD ]; sysctrl =qemu_mallocz (sizeof (sysctrl_t));if (sysctrl ==NULL )
@@ -658,16 +663,37 @@ static void ppc_prep_init (int ram_size, } } -for (i =0 ; i <2 ; i++) { +if (drive_get_max_bus (IF_IDE ) >=MAX_IDE_BUS ) { +fprintf (stderr,"qemu: too many IDE bus\n" ); +exit (1 ); + } + +for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { + index =drive_get_index (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); +if (index !=-1 ) + hd[i] = drives_table[index].bdrv; +else + hd[i] =NULL ; + } + +for (i =0 ; i <MAX_IDE_BUS ; i++) {isa_ide_init (ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], - bs_table[2 * i], bs_table[2 * i +1 ]); + hd[2 * i], + hd[2 * i +1 ]); }i8042_init (i8259[1 ], i8259[12 ],0x60 );DMA_init (1 );// AUD_init(); // SB16_init(); -fdctrl_init (i8259[6 ],2 ,0 ,0x3f0 , fd_table); +for (i =0 ; i <MAX_FD ; i++) { + index =drive_get_index (IF_FLOPPY ,0 , i); +if (index !=-1 ) + fd[i] = drives_table[index].bdrv; +else + fd[i] =NULL ; + } +fdctrl_init (i8259[6 ],2 ,0 ,0x3f0 , fd);/* Register speaker port */ register_ioport_read (0x61 ,1 ,1 , speaker_ioport_read,NULL );
hw/esp.c +3 -7
@@ -45,14 +45,11 @@ do { printf("ESP: " fmt , ##args); } whi#define ESP_REGS 16#define ESP_SIZE (ESP_REGS * 4)#define TI_BUFSZ 32 -/* The HBA is ID 7, so for simplicitly limit to 7 devices. */ -#define ESP_MAX_DEVS 7typedef struct ESPState ESPState ;struct ESPState {qemu_irq irq; -BlockDriverState **bd;uint8_t rregs[ESP_REGS ];uint8_t wregs[ESP_REGS ];int32_t ti_size;
@@ -60,7 +57,7 @@ struct ESPState {uint8_t ti_buf[TI_BUFSZ ];int sense;int dma; -SCSIDevice *scsi_dev[MAX_DISKS ]; +SCSIDevice *scsi_dev[ESP_MAX_DEVS ];SCSIDevice *current_dev;uint8_t cmdbuf[TI_BUFSZ ];int cmdlen;
@@ -122,7 +119,7 @@ static int get_cmd(ESPState *s, uint8_t s->async_len =0 ; } -if (target >=MAX_DISKS || !s->scsi_dev[target]) { +if (target >=ESP_MAX_DEVS || !s->scsi_dev[target]) {// No such drive s->rregs[4 ] =STAT_IN ; s->rregs[5 ] =INTR_DC ;
@@ -574,7 +571,7 @@ void esp_scsi_attach(void *opaque, Block s->scsi_dev[id] =scsi_disk_init (bd,0 , esp_command_complete, s); } -void *esp_init (BlockDriverState **bd,target_phys_addr_t espaddr, +void *esp_init (target_phys_addr_t espaddr,void *dma_opaque,qemu_irq irq,qemu_irq *reset) {ESPState *s;
@@ -584,7 +581,6 @@ void *esp_init(BlockDriverState **bd, taif (!s)return NULL ; - s->bd = bd; s->irq = irq; s->dma_opaque = dma_opaque;
hw/realview.c +16 -5
@@ -26,6 +26,7 @@ static void realview_init(int ram_size,int done_smc =0 ;qemu_irq cpu_irq[4 ];int ncpu; +int index;if (!cpu_model) cpu_model ="arm926" ;
@@ -83,7 +84,12 @@ static void realview_init(int ram_size,pl110_init (ds,0x10020000 , pic[23 ],1 ); -pl181_init (0x10005000 , sd_bdrv, pic[17 ], pic[18 ]); + index =drive_get_index (IF_SD ,0 ,0 ); +if (index ==-1 ) { +fprintf (stderr,"qemu: missing SecureDigital card\n" ); +exit (1 ); + } +pl181_init (0x10005000 , drives_table[index].bdrv, pic[17 ], pic[18 ]);pl031_init (0x10017000 , pic[10 ]);
@@ -91,11 +97,16 @@ static void realview_init(int ram_size,if (usb_enabled) {usb_ohci_init_pci (pci_bus,3 ,-1 ); } +if (drive_get_max_bus (IF_SCSI ) >0 ) { +fprintf (stderr,"qemu: too many SCSI bus\n" ); +exit (1 ); + } scsi_hba =lsi_scsi_init (pci_bus,-1 ); -for (n =0 ; n <MAX_DISKS ; n++) { -if (bs_table[n]) { -lsi_scsi_attach (scsi_hba, bs_table[n], n); - } +for (n =0 ; n <LSI_MAX_DEVS ; n++) { + index =drive_get_index (IF_SCSI ,0 , n); +if (index ==-1 ) +continue ; +lsi_scsi_attach (scsi_hba, drives_table[index].bdrv, n); }for (n =0 ; n < nb_nics; n++) { nd = &nd_table[n];
hw/sun4m.c +22 -7
@@ -316,6 +316,8 @@ static void *sun4m_hw_init(const structqemu_irq *cpu_irqs[MAX_CPUS ], *slavio_irq, *slavio_cpu_irq, *espdma_irq, *ledma_irq;qemu_irq *esp_reset, *le_reset; +BlockDriverState *fd[MAX_FD ]; +int index;/* init CPUs */
@@ -388,16 +390,29 @@ static void *sun4m_hw_init(const structslavio_serial_init (hwdef->serial_base, slavio_irq[hwdef->ser_irq], serial_hds[1 ], serial_hds[0 ]); -if (hwdef->fd_base != (target_phys_addr_t)-1 ) -sun4m_fdctrl_init (slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd_table); +if (hwdef->fd_base != (target_phys_addr_t)-1 ) { +/* there is zero or one floppy drive */ + fd[1 ] = fd[0 ] =NULL ; + index =drive_get_index (IF_FLOPPY ,0 ,0 ); +if (index !=-1 ) + fd[0 ] = drives_table[index].bdrv; - main_esp =esp_init (bs_table, hwdef->esp_base, espdma, *espdma_irq, +sun4m_fdctrl_init (slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd); + } + +if (drive_get_max_bus (IF_SCSI ) >0 ) { +fprintf (stderr,"qemu: too many SCSI bus\n" ); +exit (1 ); + } + + main_esp =esp_init (hwdef->esp_base, espdma, *espdma_irq, esp_reset); -for (i =0 ; i <MAX_DISKS ; i++) { -if (bs_table[i]) { -esp_scsi_attach (main_esp, bs_table[i], i); - } +for (i =0 ; i <ESP_MAX_DEVS ; i++) { + index =drive_get_index (IF_SCSI ,0 , i); +if (index ==-1 ) +continue ; +esp_scsi_attach (main_esp, drives_table[index].bdrv, i); } slavio_misc = slavio_misc_init(hwdef->slavio_base, hwdef->power_base,
hw/versatilepb.c +17 -5
@@ -165,6 +165,7 @@ static void versatile_init(int ram_size,NICInfo *nd;int n;int done_smc =0 ; +int index;if (!cpu_model) cpu_model ="arm926" ;
@@ -200,11 +201,16 @@ static void versatile_init(int ram_size,if (usb_enabled) {usb_ohci_init_pci (pci_bus,3 ,-1 ); } +if (drive_get_max_bus (IF_SCSI ) >0 ) { +fprintf (stderr,"qemu: too many SCSI bus\n" ); +exit (1 ); + } scsi_hba =lsi_scsi_init (pci_bus,-1 ); -for (n =0 ; n <MAX_DISKS ; n++) { -if (bs_table[n]) { -lsi_scsi_attach (scsi_hba, bs_table[n], n); - } +for (n =0 ; n <LSI_MAX_DEVS ; n++) { + index =drive_get_index (IF_SCSI ,0 , n); +if (index ==-1 ) +continue ; +lsi_scsi_attach (scsi_hba, drives_table[index].bdrv, n); }pl011_init (0x101f1000 , pic[12 ], serial_hds[0 ],PL011_ARM );
@@ -220,7 +226,13 @@ static void versatile_init(int ram_size,that includes hardware cursor support from the PL111. */ pl110_init (ds,0x10120000 , pic[16 ],1 ); -pl181_init (0x10005000 , sd_bdrv, sic[22 ], sic[1 ]); + index =drive_get_index (IF_SD ,0 ,0 ); +if (index ==-1 ) { +fprintf (stderr,"qemu: missing SecureDigital card\n" ); +exit (1 ); + } + +pl181_init (0x10005000 , drives_table[index].bdrv, sic[22 ], sic[1 ]);#if 0 /* Disabled because there's no way of specifying a block device. */ pl181_init (0x1000b000 ,NULL , sic,23 ,2 );
hw/integratorcp.c +7 -1
@@ -473,6 +473,7 @@ static void integratorcp_init(int ram_siuint32_t bios_offset;qemu_irq *pic;qemu_irq *cpu_pic; +int sd;if (!cpu_model) cpu_model ="arm926" ;
@@ -501,7 +502,12 @@ static void integratorcp_init(int ram_siicp_control_init (0xcb000000 );pl050_init (0x18000000 , pic[3 ],0 );pl050_init (0x19000000 , pic[4 ],1 ); -pl181_init (0x1c000000 , sd_bdrv, pic[23 ], pic[24 ]); + sd =drive_get_index (IF_SD ,0 ,0 ); +if (sd ==-1 ) { +fprintf (stderr,"qemu: missing SecureDigital card\n" ); +exit (1 ); + } +pl181_init (0x1c000000 , drives_table[sd].bdrv, pic[23 ], pic[24 ]);if (nd_table[0 ].vlan) {if (nd_table[0 ].model ==NULL ||strcmp (nd_table[0 ].model,"smc91c111" ) ==0 ) {
hw/lsi53c895a.c +0 -3
@@ -149,9 +149,6 @@ do { fprintf(stderr, "lsi_scsi: error: "#define PHASE_MI 7#define PHASE_MASK 7 -/* The HBA is ID 7, so for simplicitly limit to 7 devices. */ -#define LSI_MAX_DEVS 7 -/* Maximum length of MSG IN data. */ #define LSI_MAX_MSGIN_LEN 8
hw/nand.c +7 -1
@@ -440,14 +440,20 @@ struct nand_flash_s *nand_init(int manf_ {int pagesize;struct nand_flash_s *s; +int index;if (nand_flash_ids[chip_id].size ==0 ) {cpu_abort (cpu_single_env,"%s: Unsupported NAND chip ID.\n" , __FUNCTION__); } + index =drive_get_index (IF_MTD ,0 ,0 ); +if (index ==-1 ) { +cpu_abort (cpu_single_env,"%s: missing MTD device\n" , + __FUNCTION__); + } s = (struct nand_flash_s *)qemu_mallocz (sizeof (struct nand_flash_s )); - s->bdrv = mtd_bdrv; + s->bdrv = drives_table[index].bdrv; s->manf_id = manf_id; s->chip_id = chip_id; s->size = nand_flash_ids[s->chip_id].size <<20 ;
hw/omap_mmc.c +7 -1
@@ -529,6 +529,7 @@ struct omap_mmc_s *omap_mmc_init(target_int iomemtype;struct omap_mmc_s *s = (struct omap_mmc_s *)qemu_mallocz (sizeof (struct omap_mmc_s )); +int index; s->irq = irq; s->base = base;
@@ -540,7 +541,12 @@ struct omap_mmc_s *omap_mmc_init(target_cpu_register_physical_memory (s->base,0x800 , iomemtype);/* Instantiate the storage */ - s->card =sd_init (sd_bdrv); + index =drive_get_index (IF_SD ,0 ,0 ); +if (index ==-1 ) { +cpu_abort (cpu_single_env,"%s: missing SecureDigital device\n" , + __FUNCTION__); + } + s->card =sd_init (drives_table[index].bdrv);sd_set_cb (s->card, s, omap_mmc_ro_cb, omap_mmc_cover_cb);
hw/ppc405_boards.c +17 -12
@@ -191,6 +191,7 @@ static void ref405ep_init (int ram_size,int linux_boot;int fl_idx, fl_sectors, len;int ppc_boot_device = boot_device[0 ]; +int index;/* XXX: fix this */ ram_bases[0 ] =0x00000000 ;
@@ -217,17 +218,18 @@ static void ref405ep_init (int ram_size, bios_offset = sram_offset + sram_size; fl_idx =0 ;#ifdef USE_FLASH_BIOS -if (pflash_table[fl_idx] !=NULL ) { - bios_size =bdrv_getlength (pflash_table[fl_idx]); + index =drive_get_index (IF_PFLASH ,0 , fl_idx); +if (index !=-1 ) { + bios_size =bdrv_getlength (drives_table[index].bdrv); fl_sectors = (bios_size +65535 ) >>16 ;#ifdef DEBUG_BOARD_INIT printf ("Register parallel flash %d size " ADDRX " at offset %08lx " " addr " ADDRX " '%s' %d\n" , fl_idx, bios_size, bios_offset, -bios_size, -bdrv_get_device_name (pflash_table[fl_idx]), fl_sectors); +bdrv_get_device_name (drives_table[index].bdrv), fl_sectors);#endif pflash_register ((uint32_t )(-bios_size), bios_offset, - pflash_table[fl_idx],65536 , fl_sectors,2 , + drives_table[index].bdrv,65536 , fl_sectors,2 ,0x0001 ,0x22DA ,0x0000 ,0x0000 ); fl_idx++; }else
@@ -513,6 +515,7 @@ static void taihu_405ep_init(int ram_sizint linux_boot;int fl_idx, fl_sectors;int ppc_boot_device = boot_device[0 ]; +int index;/* RAM is soldered to the board so the size cannot be changed */ ram_bases[0 ] =0x00000000 ;
@@ -530,8 +533,9 @@ static void taihu_405ep_init(int ram_siz#endif fl_idx =0 ;#if defined(USE_FLASH_BIOS ) -if (pflash_table[fl_idx] !=NULL ) { - bios_size =bdrv_getlength (pflash_table[fl_idx]); + index =drive_get_index (IF_PFLASH ,0 , fl_idx); +if (index !=-1 ) { + bios_size =bdrv_getlength (drives_table[index].bdrv);/* XXX: should check that size is 2MB */ // bios_size = 2 * 1024 * 1024; fl_sectors = (bios_size +65535 ) >>16 ;
@@ -539,10 +543,10 @@ static void taihu_405ep_init(int ram_sizprintf ("Register parallel flash %d size " ADDRX " at offset %08lx " " addr " ADDRX " '%s' %d\n" , fl_idx, bios_size, bios_offset, -bios_size, -bdrv_get_device_name (pflash_table[fl_idx]), fl_sectors); +bdrv_get_device_name (drives_table[index].bdrv), fl_sectors);#endif pflash_register ((uint32_t )(-bios_size), bios_offset, - pflash_table[fl_idx],65536 , fl_sectors,4 , + drives_table[index].bdrv,65536 , fl_sectors,4 ,0x0001 ,0x22DA ,0x0000 ,0x0000 ); fl_idx++; }else
@@ -565,8 +569,9 @@ static void taihu_405ep_init(int ram_siz } bios_offset += bios_size;/* Register Linux flash */ -if (pflash_table[fl_idx] !=NULL ) { - bios_size =bdrv_getlength (pflash_table[fl_idx]); + index =drive_get_index (IF_PFLASH ,0 , fl_idx); +if (index !=-1 ) { + bios_size =bdrv_getlength (drives_table[index].bdrv);/* XXX: should check that size is 32MB */ bios_size =32 *1024 *1024 ; fl_sectors = (bios_size +65535 ) >>16 ;
@@ -574,9 +579,9 @@ static void taihu_405ep_init(int ram_sizprintf ("Register parallel flash %d size " ADDRX " at offset %08lx " " addr " ADDRX " '%s'\n" , fl_idx, bios_size, bios_offset, (target_ulong )0xfc000000 , -bdrv_get_device_name (pflash_table[fl_idx])); +bdrv_get_device_name (drives_table[index].bdrv));#endif -pflash_register (0xfc000000 , bios_offset, pflash_table[fl_idx], +pflash_register (0xfc000000 , bios_offset, drives_table[index].bdrv,65536 , fl_sectors,4 ,0x0001 ,0x22DA ,0x0000 ,0x0000 ); fl_idx++;
hw/ppc_chrp.c +18 -3
@@ -25,6 +25,8 @@#include "vl.h" #include "ppc_mac.h" +#define MAX_IDE_BUS 2 +/* UniN device */ static void unin_writel (void *opaque,target_phys_addr_t addr,uint32_t value) {
@@ -74,6 +76,8 @@ static void ppc_core99_init (int ram_sizint pic_mem_index, dbdma_mem_index, cuda_mem_index;int ide_mem_index[2 ];int ppc_boot_device; +int index; +BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; linux_boot = (kernel_filename !=NULL );
@@ -259,11 +263,22 @@ static void ppc_core99_init (int ram_siz nd_table[i].model ="ne2k_pci" ;pci_nic_init (pci_bus, &nd_table[i],-1 ); } +if (drive_get_max_bus (IF_IDE ) >=MAX_IDE_BUS ) { +fprintf (stderr,"qemu: too many IDE bus\n" ); +exit (1 ); + } +for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { + index =drive_get_index (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); +if (index !=-1 ) + hd[i] = drives_table[index].bdrv; +else + hd[i] =NULL ; + }#if 1 - ide_mem_index[0 ] =pmac_ide_init (&bs_table[0 ], pic[0x13 ]); - ide_mem_index[1 ] =pmac_ide_init (&bs_table[2 ], pic[0x14 ]); + ide_mem_index[0 ] =pmac_ide_init (&hd[0 ], pic[0x13 ]); + ide_mem_index[1 ] =pmac_ide_init (&hd[2 ], pic[0x14 ]);#else -pci_cmd646_ide_init (pci_bus, &bs_table[0 ],0 ); +pci_cmd646_ide_init (pci_bus, &hd[0 ],0 );#endif /* cuda also initialize ADB */ cuda_init (&cuda_mem_index, pic[0x19 ]);
hw/pxa2xx_mmci.c +8 -1
@@ -526,6 +526,7 @@ struct pxa2xx_mmci_s *pxa2xx_mmci_init(t {int iomemtype;struct pxa2xx_mmci_s *s; +int index; s = (struct pxa2xx_mmci_s *)qemu_mallocz (sizeof (struct pxa2xx_mmci_s )); s->base = base;
@@ -537,7 +538,13 @@ struct pxa2xx_mmci_s *pxa2xx_mmci_init(tcpu_register_physical_memory (base,0x00100000 , iomemtype);/* Instantiate the actual storage */ - s->card =sd_init (sd_bdrv); + + index =drive_get_index (IF_SD ,0 ,0 ); +if (index ==-1 ) { +fprintf (stderr,"qemu: missing SecureDigital device\n" ); +exit (1 ); + } + s->card =sd_init (drives_table[index].bdrv);register_savevm ("pxa2xx_mmci" ,0 ,0 , pxa2xx_mmci_save, pxa2xx_mmci_load, s);
hw/spitz.c +7 -2
@@ -928,9 +928,14 @@ static void spitz_ssp_attach(struct pxa2static void spitz_microdrive_attach (struct pxa2xx_state_s *cpu) {struct pcmcia_card_s *md; -BlockDriverState *bs = bs_table[0 ]; +int index; +BlockDriverState *bs; -if (bs &&bdrv_is_inserted (bs) && !bdrv_is_removable (bs)) { + index =drive_get_index (IF_IDE ,0 ,0 ); +if (index ==-1 ) +return ; + bs = drives_table[index].bdrv; +if (bdrv_is_inserted (bs) && !bdrv_is_removable (bs)) { md =dscm1xxxx_init (bs);pxa2xx_pcmcia_attach (cpu->pcmcia[1 ], md); }
hw/mips_malta.c +19 -1
@@ -42,6 +42,8 @@#define ENVP_NB_ENTRIES 16#define ENVP_ENTRY_SIZE 256 +#define MAX_IDE_BUS 2 +extern FILE *logfile; typedef struct {
@@ -765,6 +767,8 @@ void mips_malta_init (int ram_size, intuint8_t *eeprom_buf;i2c_bus *smbus;int i; +int index; +BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];/* init CPUs */ if (cpu_model ==NULL ) {
@@ -851,8 +855,22 @@ void mips_malta_init (int ram_size, int pci_bus =pci_gt64120_init (i8259);/* Southbridge */ + +if (drive_get_max_bus (IF_IDE ) >=MAX_IDE_BUS ) { +fprintf (stderr,"qemu: too many IDE bus\n" ); +exit (1 ); + } + +for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { + index =drive_get_index (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); +if (index !=-1 ) + hd[i] = drives_table[index].bdrv; +else + hd[i] =NULL ; + } + piix4_devfn =piix4_init (pci_bus,80 ); -pci_piix4_ide_init (pci_bus, bs_table, piix4_devfn +1 , i8259); +pci_piix4_ide_init (pci_bus, hd, piix4_devfn +1 , i8259);usb_uhci_piix4_init (pci_bus, piix4_devfn +2 ); smbus =piix4_pm_init (pci_bus, piix4_devfn +3 ,0x1100 ); eeprom_buf =qemu_mallocz (8 *256 );/* XXX: make this persistent */
hw/sun4u.c +25 -3
@@ -320,6 +320,9 @@ static void sun4u_init(int ram_size, intPCIBus *pci_bus;QEMUBH *bh;qemu_irq *irq; +int index; +BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; +BlockDriverState *fd[MAX_FD ]; linux_boot = (kernel_filename !=NULL );
@@ -422,11 +425,30 @@ static void sun4u_init(int ram_size, int } irq =qemu_allocate_irqs (dummy_cpu_set_irq,NULL ,32 ); -// XXX pci_cmd646_ide_init(pci_bus, bs_table, 1); -pci_piix3_ide_init (pci_bus, bs_table,-1 , irq); +if (drive_get_max_bus (IF_IDE ) >=MAX_IDE_BUS ) { +fprintf (stderr,"qemu: too many IDE bus\n" ); +exit (1 ); + } +for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { + index =drive_get_index (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); +if (index !=-1 ) + hd[i] = drives_table[index].bdrv; +else + hd[i] =NULL ; + } + +// XXX pci_cmd646_ide_init(pci_bus, hd, 1); +pci_piix3_ide_init (pci_bus, hd,-1 , irq);/* FIXME: wire up interrupts. */ i8042_init (NULL /*1*/ ,NULL /*12*/ ,0x60 ); - floppy_controller =fdctrl_init (NULL /*6*/ ,2 ,0 ,0x3f0 , fd_table); +for (i =0 ; i <MAX_FD ; i++) { + index =drive_get_index (IF_FLOPPY ,0 , i); +if (index !=-1 ) + fd[i] = drives_table[index].bdrv; +else + fd[i] =NULL ; + } + floppy_controller =fdctrl_init (NULL /*6*/ ,2 ,0 ,0x3f0 , fd); nvram =m48t59_init (NULL /*8*/ ,0 ,0x0074 ,NVRAM_SIZE ,59 ); sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", ram_size, boot_device[0], KERNEL_LOAD_ADDR, kernel_size,
hw/ppc_oldworld.c +33 -2
@@ -25,6 +25,8 @@#include "vl.h" #include "ppc_mac.h" +#define MAX_IDE_BUS 2 +/* temporary frame buffer OSI calls for the video.x driver. The right solution is to modify the driver to use VGA PCI I/Os */ /* XXX: to be removed. This is no way related to emulation */
@@ -114,6 +116,8 @@ static void ppc_heathrow_init (int ram_sint pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index;int ide_mem_index[2 ];int ppc_boot_device; +BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; +int index; linux_boot = (kernel_filename !=NULL );
@@ -283,10 +287,37 @@ static void ppc_heathrow_init (int ram_s }/* First IDE channel is a CMD646 on the PCI bus */ -pci_cmd646_ide_init (pci_bus, &bs_table[0 ],0 ); + +if (drive_get_max_bus (IF_IDE ) >=MAX_IDE_BUS ) { +fprintf (stderr,"qemu: too many IDE bus\n" ); +exit (1 ); + } + index =drive_get_index (IF_IDE ,0 ,0 ); +if (index ==-1 ) + hd[0 ] =NULL ; +else + hd[0 ] = drives_table[index].bdrv; + index =drive_get_index (IF_IDE ,0 ,1 ); +if (index ==-1 ) + hd[1 ] =NULL ; +else + hd[1 ] = drives_table[index].bdrv; + hd[3 ] = hd[2 ] =NULL ; +pci_cmd646_ide_init (pci_bus, hd,0 ); +/* Second IDE channel is a MAC IDE on the MacIO bus */ + index =drive_get_index (IF_IDE ,1 ,0 ); +if (index ==-1 ) + hd[0 ] =NULL ; +else + hd[0 ] = drives_table[index].bdrv; + index =drive_get_index (IF_IDE ,1 ,1 ); +if (index ==-1 ) + hd[1 ] =NULL ; +else + hd[1 ] = drives_table[index].bdrv; ide_mem_index[0 ] =-1 ; - ide_mem_index[1 ] =pmac_ide_init (&bs_table[2 ], pic[0x0D ]); + ide_mem_index[1 ] =pmac_ide_init (hd, pic[0x0D ]);/* cuda also initialize ADB */ cuda_init (&cuda_mem_index, pic[0x12 ]);
Re: [Qemu-devel] [PATCH 2/2][UPDATE] Add arg -drive to define new drive with more features
Quoted 2 lines · Laurent Vivier
Attached is an updated patch (corrected as you want and with more check on -drive arguments)
Sparc64 didn't compile until I added a MAX_IDE_BUS #define.
SS-600MP case is still missing from vl.c and the -drive help text is longer than 80 chars.
I'd prefer a space after 'for' and 'if', though these styles aren't very consistently used in the original files.
Good news is that after adding the #define, patched Qemu seems to work. I tested briefly both Sparc32 and Sparc64.
Re: [Qemu-devel] [PATCH 2/2][UPDATE] Add arg -drive to define new drive with more features
Quoted 6 lines · Blue Swirl
Quoted 2 lines · Laurent Vivier
Attached is an updated patch (corrected as you want and with more check on -drive arguments)
Sparc64 didn't compile until I added a
MAX_IDE_BUS#define.
Right. Do you know why "make" doesn't compile "hw/sun4u.c" ?
Quoted 2 lines
SS-600MP case is still missing from
vl.cand the -drive help text is longer than 80 chars.
I missed it should use SCSI by default. Corrected. I've corrected help text too.
Quoted 2 lines
I'd prefer a space after 'for' and 'if', though these styles aren't very consistently used in the original files.
I prefer too, but when I modify a file I take the style I find around the lines I modify...
Quoted 2 lines
Good news is that after adding the #define, patched Qemu seems to work. I tested briefly both Sparc32 and Sparc64.
Great.
Thank you for your help,
Laurent
Signature · 3 lines
------------- [email protected] -------------- "Any sufficiently advanced technology is indistinguishable from magic." - Arthur C. Clarke