ide: split + cleanup patches
cover ide: split + cleanup patches
Hi,
This is a respin of the ide split and cleanup patches. Rebased to master as of today, solved conflicts (smart support + mmio constify). It got a new patch (#11) which switches the ide init functions from BlockDriverState to DriveInfo. Otherwise unmodified.
cheers,
Gerd
PATCH 3/11 ide: split away ide-isa.c
create ide-isa.c and place isa bus support there. only build ide-isa support for platforms using it. also create ide.h header file.
--- Makefile.target | 7 ++++--- hw/ide-internal.h | 1 + hw/ide-isa.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ hw/ide.c | 14 -------------- hw/ide.h | 10 ++++++++++ hw/mips_r4k.c | 1 + hw/pc.c | 1 + hw/pc.h | 2 -- hw/ppc_prep.c | 1 + 9 files changed, 63 insertions(+), 19 deletions(-) create mode 100644 hw/ide-isa.c create mode 100644 hw/ide.h
Makefile.target +4 -3
@@ -187,14 +187,14 @@ obj-y += e1000.o obj-y += wdt_ib700.o wdt_i6300esb.o # Hardware support -obj-i386-y = ide.o pckbd.o vga.o $(sound-obj-y) dma.o isa-bus.o +obj-i386-y = ide.o ide-isa.o pckbd.o vga.o $(sound-obj-y) dma.o isa-bus.o obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o # shared objects -obj-ppc-y = ppc.o ide.o vga.o $(sound-obj-y) dma.o isa-bus.o openpic.o +obj-ppc-y = ppc.o ide.o ide-isa.o vga.o $(sound-obj-y) dma.o isa-bus.o openpic.o # PREP target obj-ppc-y += pckbd.o serial.o i8259.o i8254.o fdc.o mc146818rtc.o obj-ppc-y += prep_pci.o ppc_prep.o
@@ -215,7 +215,8 @@ obj-ppc-$(CONFIG_FDT) += device_tree.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o rc4030.o obj-mips-y += g364fb.o jazz_led.o dp8393x.o -obj-mips-y += ide.o gt64xxx.o pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o +obj-mips-y += ide.o ide-isa.o +obj-mips-y += gt64xxx.o pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o obj-mips-y += piix_pci.o parallel.o cirrus_vga.o isa-bus.o pcspk.o $(sound-obj-y) obj-mips-y += mipsnet.o obj-mips-y += pflash_cfi01.o
hw/ide-internal.h +1 -0
@@ -6,6 +6,7 @@* only hw/ide*.c is supposed to include this file. * non-internal declarations are in hw/ide.h */ +#include "ide.h" /* debug IDE devices */ //#define DEBUG_IDE
hw/ide-isa.c new file +45 -0
45 lines not on this page · raw message
hw/ide.c +0 -14
@@ -2674,20 +2674,6 @@ void idebus_load(QEMUFile* f, IDEBus *bus, int version_id) }/***********************************************************/ -/* ISA IDE definitions */ - -void isa_ide_init (int iobase,int iobase2,qemu_irq irq, -BlockDriverState *hd0,BlockDriverState *hd1) -{ -IDEBus *bus; - - bus =qemu_mallocz (sizeof (*bus)); - -ide_init2 (bus, hd0, hd1, irq); -ide_init_ioport (bus, iobase, iobase2); -} - -/***********************************************************/ /* PCI IDE definitions */ static void cmd646_update_irq (PCIIDEState *d);
hw/ide.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef HW_IDE_H +#define HW_IDE_H + +#include "qdev.h" + +/* ide-isa.c */ +void isa_ide_init (int iobase,int iobase2,qemu_irq irq, +BlockDriverState *hd0,BlockDriverState *hd1); + +#endif /* HW_IDE_H */
hw/mips_r4k.c +1 -0
@@ -17,6 +17,7 @@#include "flash.h" #include "qemu-log.h" #include "mips-bios.h" +#include "ide.h" #define PHYS_TO_VIRT (x) ((x) | ~(target_ulong)0x7fffffff)
hw/pc.c +1 -0
@@ -36,6 +36,7 @@#include "hpet_emul.h" #include "watchdog.h" #include "smbios.h" +#include "ide.h" /* output Bochs bios info messages */ //#define DEBUG_BIOS
hw/pc.h +0 -2
@@ -144,8 +144,6 @@ void pci_cirrus_vga_init(PCIBus *bus);void isa_cirrus_vga_init (void );/* ide.c */ -void isa_ide_init (int iobase,int iobase2,qemu_irq irq, -BlockDriverState *hd0,BlockDriverState *hd1);void pci_cmd646_ide_init (PCIBus *bus,BlockDriverState **hd_table,int secondary_ide_enabled); void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,
hw/ppc_prep.c +1 -0
@@ -32,6 +32,7 @@#include "ppc.h" #include "boards.h" #include "qemu-log.h" +#include "ide.h" //#define HARD_DEBUG_PPC_IO //#define DEBUG_PPC_IO
Signature · 1 line
1.6.2.5
PATCH 6/11 ide: split away ide-mmio.c
In reply to Gerd Hoffmanncreate ide-mmio.c and place mmio support there. only build ide-mmio support for platforms using it.
--- Makefile.target | 2 +- hw/ide-mmio.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/ide.c | 93 ----------------------------------------- hw/ide.h | 5 ++ hw/r2d.c | 1 + hw/sh.h | 4 -- 6 files changed, 130 insertions(+), 98 deletions(-) create mode 100644 hw/ide-mmio.c
Makefile.target +1 -1
@@ -281,7 +281,7 @@ obj-arm-y += syborg_virtio.o obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o serial.o -obj-sh4-y += ide.o +obj-sh4-y += ide.o ide-mmio.o obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o obj-m68k-y += m68k-semi.o dummy_m68k.o
hw/ide-mmio.c new file +123 -0
123 lines not on this page · raw message
hw/ide.c +0 -93
99 lines not on this page · raw message
hw/ide.h +5 -0
@@ -19,4 +19,9 @@ void pci_piix4_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,int pmac_ide_init (BlockDriverState **hd_table,qemu_irq irq,void *dbdma,int channel,qemu_irq dma_irq); +/* ide-mmio.c */ +void mmio_ide_init (target_phys_addr_t membase,target_phys_addr_t membase2, +qemu_irq irq,int shift, +BlockDriverState *hd0,BlockDriverState *hd1); +#endif /* HW_IDE_H */
hw/r2d.c +1 -0
@@ -31,6 +31,7 @@#include "pci.h" #include "net.h" #include "sh7750_regs.h" +#include "ide.h" #define SDRAM_BASE 0x0c000000/* Physical location of SDRAM: Area 3 */ #define SDRAM_SIZE 0x04000000
hw/sh.h +0 -4
@@ -51,8 +51,4 @@ qemu_irq sh7750_irl(struct SH7750State *s);/* tc58128.c */ int tc58128_init (struct SH7750State *s,const char *zone1,const char *zone2); -/* ide.c */ -void mmio_ide_init (target_phys_addr_t membase,target_phys_addr_t membase2, -qemu_irq irq,int shift, -BlockDriverState *hd0,BlockDriverState *hd1);#endif
Signature · 1 line
1.6.2.5
PATCH 4/11 ide: split away ide-pci.c
In reply to Gerd Hoffmanncreate ide-pci.c and place pci bus support there. only build ide-pci support for platforms using it.
--- Makefile.target | 9 +- hw/ide-pci.c | 519 +++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/ide.c | 483 ------------------------------------------------- hw/ide.h | 8 + hw/mips_malta.c | 1 + hw/pc.h | 8 - hw/ppc_newworld.c | 1 + hw/ppc_oldworld.c | 1 + hw/sun4u.c | 1 + 9 files changed, 536 insertions(+), 495 deletions(-) create mode 100644 hw/ide-pci.c
Makefile.target +5 -4
@@ -187,14 +187,15 @@ obj-y += e1000.o obj-y += wdt_ib700.o wdt_i6300esb.o # Hardware support -obj-i386-y = ide.o ide-isa.o pckbd.o vga.o $(sound-obj-y) dma.o isa-bus.o +obj-i386-y = ide.o ide-isa.o ide-pci.o pckbd.o vga.o $(sound-obj-y) dma.o isa-bus.o obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o # shared objects -obj-ppc-y = ppc.o ide.o ide-isa.o vga.o $(sound-obj-y) dma.o isa-bus.o openpic.o +obj-ppc-y = ppc.o ide.o ide-isa.o ide-pci.o +obj-ppc-y += vga.o $(sound-obj-y) dma.o isa-bus.o openpic.o # PREP target obj-ppc-y += pckbd.o serial.o i8259.o i8254.o fdc.o mc146818rtc.o obj-ppc-y += prep_pci.o ppc_prep.o
@@ -215,7 +216,7 @@ obj-ppc-$(CONFIG_FDT) += device_tree.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o rc4030.o obj-mips-y += g364fb.o jazz_led.o dp8393x.o -obj-mips-y += ide.o ide-isa.o +obj-mips-y += ide.o ide-isa.o ide-pci.o obj-mips-y += gt64xxx.o pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o obj-mips-y += piix_pci.o parallel.o cirrus_vga.o isa-bus.o pcspk.o $(sound-obj-y) obj-mips-y += mipsnet.o
@@ -247,7 +248,7 @@ obj-cris-y += etraxfs_ser.o obj-cris-y += pflash_cfi02.o ifeq ($(TARGET_ARCH), sparc64) -obj-sparc-y = sun4u.o ide.o isa-bus.o pckbd.o vga.o apb_pci.o +obj-sparc-y = sun4u.o ide.o ide-pci.o isa-bus.o pckbd.o vga.o apb_pci.o obj-sparc-y += fdc.o mc146818rtc.o serial.o obj-sparc-y += cirrus_vga.o parallel.o else
hw/ide-pci.c new file +519 -0
519 lines not on this page · raw message
hw/ide.c +0 -483
501 lines not on this page · raw message
hw/ide.h +8 -0
@@ -7,4 +7,12 @@void isa_ide_init (int iobase,int iobase2,qemu_irq irq,BlockDriverState *hd0,BlockDriverState *hd1); +/* ide-pci.c */ +void pci_cmd646_ide_init (PCIBus *bus,BlockDriverState **hd_table, +int secondary_ide_enabled); +void pci_piix3_ide_init (PCIBus *bus,BlockDriverState **hd_table,int devfn, +qemu_irq *pic); +void pci_piix4_ide_init (PCIBus *bus,BlockDriverState **hd_table,int devfn, +qemu_irq *pic); +#endif /* HW_IDE_H */
hw/mips_malta.c +1 -0
@@ -38,6 +38,7 @@#include "boards.h" #include "qemu-log.h" #include "mips-bios.h" +#include "ide.h" //#define DEBUG_BOARD_INIT
hw/pc.h +0 -8
@@ -143,14 +143,6 @@ int isa_vga_mm_init(target_phys_addr_t vram_base,void pci_cirrus_vga_init (PCIBus *bus);void isa_cirrus_vga_init (void ); -/* ide.c */ -void pci_cmd646_ide_init (PCIBus *bus,BlockDriverState **hd_table, -int secondary_ide_enabled); -void pci_piix3_ide_init (PCIBus *bus,BlockDriverState **hd_table,int devfn, -qemu_irq *pic); -void pci_piix4_ide_init (PCIBus *bus,BlockDriverState **hd_table,int devfn, -qemu_irq *pic); -/* ne2000.c */ void isa_ne2000_init (int base,qemu_irq irq,NICInfo *nd);
hw/ppc_newworld.c +1 -0
@@ -35,6 +35,7 @@#include "fw_cfg.h" #include "escc.h" #include "openpic.h" +#include "ide.h" #define MAX_IDE_BUS 2#define VGA_BIOS_SIZE 65536
hw/ppc_oldworld.c +1 -0
@@ -35,6 +35,7 @@#include "boards.h" #include "fw_cfg.h" #include "escc.h" +#include "ide.h" #define MAX_IDE_BUS 2#define VGA_BIOS_SIZE 65536
hw/sun4u.c +1 -0
@@ -33,6 +33,7 @@#include "firmware_abi.h" #include "fw_cfg.h" #include "sysbus.h" +#include "ide.h" //#define DEBUG_IRQ
Signature · 1 line
1.6.2.5
PATCH 2/11 ide: split away ide-internal.h
In reply to Gerd Hoffmannmove lots of IDE defines to the new file. also make a bunch of functions non-static and add declaration for them. Needed by the following patches of this series.
--- hw/ide-internal.h | 528 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/ide.c | 550 +++------------------------------------------------- 2 files changed, 560 insertions(+), 518 deletions(-) create mode 100644 hw/ide-internal.h
hw/ide-internal.h new file +528 -0
@@ -0,0 +1,528 @@ +#ifndef HW_IDE_INTERNAL_H +#define HW_IDE_INTERNAL_H + +/* +* QEMU IDE Emulation -- internal header file +* only hw/ide*.c is supposed to include this file. +* non-internal declarations are in hw/ide.h +*/ + +/* debug IDE devices */ +//#define DEBUG_IDE +//#define DEBUG_IDE_ATAPI +//#define DEBUG_AIO +#define USE_DMA_CDROM + +typedef struct IDEBus IDEBus ; +typedef struct IDEState IDEState ; +typedef struct BMDMAState BMDMAState ; + +typedef void EndTransferFunc (IDEState *); + +/* Bits of HD_STATUS */ +#define ERR_STAT 0x01 +#define INDEX_STAT 0x02 +#define ECC_STAT 0x04/* Corrected error */ +#define DRQ_STAT 0x08 +#define SEEK_STAT 0x10 +#define SRV_STAT 0x10 +#define WRERR_STAT 0x20 +#define READY_STAT 0x40 +#define BUSY_STAT 0x80 + +/* Bits for HD_ERROR */ +#define MARK_ERR 0x01/* Bad address mark */ +#define TRK0_ERR 0x02/* couldn't find track 0 */ +#define ABRT_ERR 0x04/* Command aborted */ +#define MCR_ERR 0x08/* media change request */ +#define ID_ERR 0x10/* ID field not found */ +#define MC_ERR 0x20/* media changed */ +#define ECC_ERR 0x40/* Uncorrectable ECC error */ +#define BBD_ERR 0x80/* pre-EIDE meaning: block marked bad */ +#define ICRC_ERR 0x80/* new meaning: CRC error during transfer */ + +/* Bits of HD_NSECTOR */ +#define CD 0x01 +#define IO 0x02 +#define REL 0x04 +#define TAG_MASK 0xf8 + +#define IDE_CMD_RESET 0x04 +#define IDE_CMD_DISABLE_IRQ 0x02 + +/* ATA/ATAPI Commands pre T13 Spec */ +#define WIN_NOP 0x00 +/* +* 0x01->0x02 Reserved +*/ +#define CFA_REQ_EXT_ERROR_CODE 0x03/* CFA Request Extended Error Code */ +/* +* 0x04->0x07 Reserved +*/ +#define WIN_SRST 0x08/* ATAPI soft reset command */ +#define WIN_DEVICE_RESET 0x08 +/* +* 0x09->0x0F Reserved +*/ +#define WIN_RECAL 0x10 +#define WIN_RESTORE WIN_RECAL +/* +* 0x10->0x1F Reserved +*/ +#define WIN_READ 0x20/* 28-Bit */ +#define WIN_READ_ONCE 0x21/* 28-Bit without retries */ +#define WIN_READ_LONG 0x22/* 28-Bit */ +#define WIN_READ_LONG_ONCE 0x23/* 28-Bit without retries */ +#define WIN_READ_EXT 0x24/* 48-Bit */ +#define WIN_READDMA_EXT 0x25/* 48-Bit */ +#define WIN_READDMA_QUEUED_EXT 0x26/* 48-Bit */ +#define WIN_READ_NATIVE_MAX_EXT 0x27/* 48-Bit */ +/* +* 0x28 +*/ +#define WIN_MULTREAD_EXT 0x29/* 48-Bit */ +/* +* 0x2A->0x2F Reserved +*/ +#define WIN_WRITE 0x30/* 28-Bit */ +#define WIN_WRITE_ONCE 0x31/* 28-Bit without retries */ +#define WIN_WRITE_LONG 0x32/* 28-Bit */ +#define WIN_WRITE_LONG_ONCE 0x33/* 28-Bit without retries */ +#define WIN_WRITE_EXT 0x34/* 48-Bit */ +#define WIN_WRITEDMA_EXT 0x35/* 48-Bit */ +#define WIN_WRITEDMA_QUEUED_EXT 0x36/* 48-Bit */ +#define WIN_SET_MAX_EXT 0x37/* 48-Bit */ +#define CFA_WRITE_SECT_WO_ERASE 0x38/* CFA Write Sectors without erase */ +#define WIN_MULTWRITE_EXT 0x39/* 48-Bit */ +/* +* 0x3A->0x3B Reserved +*/ +#define WIN_WRITE_VERIFY 0x3C/* 28-Bit */ +/* +* 0x3D->0x3F Reserved +*/ +#define WIN_VERIFY 0x40/* 28-Bit - Read Verify Sectors */ +#define WIN_VERIFY_ONCE 0x41/* 28-Bit - without retries */ +#define WIN_VERIFY_EXT 0x42/* 48-Bit */ +/* +* 0x43->0x4F Reserved +*/ +#define WIN_FORMAT 0x50 +/* +* 0x51->0x5F Reserved +*/ +#define WIN_INIT 0x60 +/* +* 0x61->0x5F Reserved +*/ +#define WIN_SEEK 0x70/* 0x70-0x7F Reserved */ +#define CFA_TRANSLATE_SECTOR 0x87/* CFA Translate Sector */ +#define WIN_DIAGNOSE 0x90 +#define WIN_SPECIFY 0x91/* set drive geometry translation */ +#define WIN_DOWNLOAD_MICROCODE 0x92 +#define WIN_STANDBYNOW2 0x94 +#define CFA_IDLEIMMEDIATE 0x95/* force drive to become "ready" */ +#define WIN_STANDBY2 0x96 +#define WIN_SETIDLE2 0x97 +#define WIN_CHECKPOWERMODE2 0x98 +#define WIN_SLEEPNOW2 0x99 +/* +* 0x9A VENDOR +*/ +#define WIN_PACKETCMD 0xA0/* Send a packet command. */ +#define WIN_PIDENTIFY 0xA1/* identify ATAPI device */ +#define WIN_QUEUED_SERVICE 0xA2 +#define WIN_SMART 0xB0/* self-monitoring and reporting */ +#define CFA_ACCESS_METADATA_STORAGE 0xB8 +#define CFA_ERASE_SECTORS 0xC0/* microdrives implement as NOP */ +#define WIN_MULTREAD 0xC4/* read sectors using multiple mode*/ +#define WIN_MULTWRITE 0xC5/* write sectors using multiple mode */ +#define WIN_SETMULT 0xC6/* enable/disable multiple mode */ +#define WIN_READDMA_QUEUED 0xC7/* read sectors using Queued DMA transfers */ +#define WIN_READDMA 0xC8/* read sectors using DMA transfers */ +#define WIN_READDMA_ONCE 0xC9/* 28-Bit - without retries */ +#define WIN_WRITEDMA 0xCA/* write sectors using DMA transfers */ +#define WIN_WRITEDMA_ONCE 0xCB/* 28-Bit - without retries */ +#define WIN_WRITEDMA_QUEUED 0xCC/* write sectors using Queued DMA transfers */ +#define CFA_WRITE_MULTI_WO_ERASE 0xCD/* CFA Write multiple without erase */ +#define WIN_GETMEDIASTATUS 0xDA +#define WIN_ACKMEDIACHANGE 0xDB/* ATA-1, ATA-2 vendor */ +#define WIN_POSTBOOT 0xDC +#define WIN_PREBOOT 0xDD +#define WIN_DOORLOCK 0xDE/* lock door on removable drives */ +#define WIN_DOORUNLOCK 0xDF/* unlock door on removable drives */ +#define WIN_STANDBYNOW1 0xE0 +#define WIN_IDLEIMMEDIATE 0xE1/* force drive to become "ready" */ +#define WIN_STANDBY 0xE2/* Set device in Standby Mode */ +#define WIN_SETIDLE1 0xE3 +#define WIN_READ_BUFFER 0xE4/* force read only 1 sector */ +#define WIN_CHECKPOWERMODE1 0xE5 +#define WIN_SLEEPNOW1 0xE6 +#define WIN_FLUSH_CACHE 0xE7 +#define WIN_WRITE_BUFFER 0xE8/* force write only 1 sector */ +#define WIN_WRITE_SAME 0xE9/* read ata-2 to use */ +/* SET_FEATURES 0x22 or 0xDD */ +#define WIN_FLUSH_CACHE_EXT 0xEA/* 48-Bit */ +#define WIN_IDENTIFY 0xEC/* ask drive to identify itself */ +#define WIN_MEDIAEJECT 0xED +#define WIN_IDENTIFY_DMA 0xEE/* same as WIN_IDENTIFY, but DMA */ +#define WIN_SETFEATURES 0xEF/* set special drive features */ +#define EXABYTE_ENABLE_NEST 0xF0 +#define IBM_SENSE_CONDITION 0xF0/* measure disk temperature */ +#define WIN_SECURITY_SET_PASS 0xF1 +#define WIN_SECURITY_UNLOCK 0xF2 +#define WIN_SECURITY_ERASE_PREPARE 0xF3 +#define WIN_SECURITY_ERASE_UNIT 0xF4 +#define WIN_SECURITY_FREEZE_LOCK 0xF5 +#define CFA_WEAR_LEVEL 0xF5/* microdrives implement as NOP */ +#define WIN_SECURITY_DISABLE 0xF6 +#define WIN_READ_NATIVE_MAX 0xF8/* return the native maximum address */ +#define WIN_SET_MAX 0xF9 +#define DISABLE_SEAGATE 0xFB + +/* set to 1 set disable mult support */ +#define MAX_MULT_SECTORS 16 + +#define IDE_DMA_BUF_SECTORS 256 + +#if (IDE_DMA_BUF_SECTORS <MAX_MULT_SECTORS ) +#error "IDE_DMA_BUF_SECTORS must be bigger or equal to MAX_MULT_SECTORS" +#endif + +/* ATAPI defines */ + +#define ATAPI_PACKET_SIZE 12 + +/* The generic packet command opcodes for CD/DVD Logical Units, +* From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ +#define GPCMD_BLANK 0xa1 +#define GPCMD_CLOSE_TRACK 0x5b +#define GPCMD_FLUSH_CACHE 0x35 +#define GPCMD_FORMAT_UNIT 0x04 +#define GPCMD_GET_CONFIGURATION 0x46 +#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a +#define GPCMD_GET_PERFORMANCE 0xac +#define GPCMD_INQUIRY 0x12 +#define GPCMD_LOAD_UNLOAD 0xa6 +#define GPCMD_MECHANISM_STATUS 0xbd +#define GPCMD_MODE_SELECT_10 0x55 +#define GPCMD_MODE_SENSE_10 0x5a +#define GPCMD_PAUSE_RESUME 0x4b +#define GPCMD_PLAY_AUDIO_10 0x45 +#define GPCMD_PLAY_AUDIO_MSF 0x47 +#define GPCMD_PLAY_AUDIO_TI 0x48 +#define GPCMD_PLAY_CD 0xbc +#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e +#define GPCMD_READ_10 0x28 +#define GPCMD_READ_12 0xa8 +#define GPCMD_READ_CDVD_CAPACITY 0x25 +#define GPCMD_READ_CD 0xbe +#define GPCMD_READ_CD_MSF 0xb9 +#define GPCMD_READ_DISC_INFO 0x51 +#define GPCMD_READ_DVD_STRUCTURE 0xad +#define GPCMD_READ_FORMAT_CAPACITIES 0x23 +#define GPCMD_READ_HEADER 0x44 +#define GPCMD_READ_TRACK_RZONE_INFO 0x52 +#define GPCMD_READ_SUBCHANNEL 0x42 +#define GPCMD_READ_TOC_PMA_ATIP 0x43 +#define GPCMD_REPAIR_RZONE_TRACK 0x58 +#define GPCMD_REPORT_KEY 0xa4 +#define GPCMD_REQUEST_SENSE 0x03 +#define GPCMD_RESERVE_RZONE_TRACK 0x53 +#define GPCMD_SCAN 0xba +#define GPCMD_SEEK 0x2b +#define GPCMD_SEND_DVD_STRUCTURE 0xad +#define GPCMD_SEND_EVENT 0xa2 +#define GPCMD_SEND_KEY 0xa3 +#define GPCMD_SEND_OPC 0x54 +#define GPCMD_SET_READ_AHEAD 0xa7 +#define GPCMD_SET_STREAMING 0xb6 +#define GPCMD_START_STOP_UNIT 0x1b +#define GPCMD_STOP_PLAY_SCAN 0x4e +#define GPCMD_TEST_UNIT_READY 0x00 +#define GPCMD_VERIFY_10 0x2f +#define GPCMD_WRITE_10 0x2a +#define GPCMD_WRITE_AND_VERIFY_10 0x2e +/* This is listed as optional in ATAPI 2.6, but is (curiously) +* missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji +* Table 377 as an MMC command for SCSi devices though... Most ATAPI +* drives support it. */ +#define GPCMD_SET_SPEED 0xbb +/* This seems to be a SCSI specific CD-ROM opcode +* to play data at track/index */ +#define GPCMD_PLAYAUDIO_TI 0x48 +/* +* From MS Media Status Notification Support Specification. For +* older drives only. +*/ +#define GPCMD_GET_MEDIA_STATUS 0xda +#define GPCMD_MODE_SENSE_6 0x1a + +/* Mode page codes for mode sense/set */ +#define GPMODE_R_W_ERROR_PAGE 0x01 +#define GPMODE_WRITE_PARMS_PAGE 0x05 +#define GPMODE_AUDIO_CTL_PAGE 0x0e +#define GPMODE_POWER_PAGE 0x1a +#define GPMODE_FAULT_FAIL_PAGE 0x1c +#define GPMODE_TO_PROTECT_PAGE 0x1d +#define GPMODE_CAPABILITIES_PAGE 0x2a +#define GPMODE_ALL_PAGES 0x3f +/* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor +* of MODE_SENSE_POWER_PAGE */ +#define GPMODE_CDROM_PAGE 0x0d + +/* +* Based on values from <linux/cdrom.h> but extending CD_MINS +* to the maximum common size allowed by the Orange's Book ATIP +* +* 90 and 99 min CDs are also available but using them as the +* upper limit reduces the effectiveness of the heuristic to +* detect DVDs burned to less than 25% of their maximum capacity +*/ + +/* Some generally useful CD-ROM information */ +#define CD_MINS 80/* max. minutes per CD */ +#define CD_SECS 60/* seconds per minute */ +#define CD_FRAMES 75/* frames per second */ +#define CD_FRAMESIZE 2048/* bytes per frame, "cooked" mode */ +#define CD_MAX_BYTES (CD_MINS * CD_SECS * CD_FRAMES * CD_FRAMESIZE) +#define CD_MAX_SECTORS (CD_MAX_BYTES / 512) + +/* +* The MMC values are not IDE specific and might need to be moved +* to a common header if they are also needed for the SCSI emulation +*/ + +/* Profile list from MMC-6 revision 1 table 91 */ +#define MMC_PROFILE_NONE 0x0000 +#define MMC_PROFILE_CD_ROM 0x0008 +#define MMC_PROFILE_CD_R 0x0009 +#define MMC_PROFILE_CD_RW 0x000A +#define MMC_PROFILE_DVD_ROM 0x0010 +#define MMC_PROFILE_DVD_R_SR 0x0011 +#define MMC_PROFILE_DVD_RAM 0x0012 +#define MMC_PROFILE_DVD_RW_RO 0x0013 +#define MMC_PROFILE_DVD_RW_SR 0x0014 +#define MMC_PROFILE_DVD_R_DL_SR 0x0015 +#define MMC_PROFILE_DVD_R_DL_JR 0x0016 +#define MMC_PROFILE_DVD_RW_DL 0x0017 +#define MMC_PROFILE_DVD_DDR 0x0018 +#define MMC_PROFILE_DVD_PLUS_RW 0x001A +#define MMC_PROFILE_DVD_PLUS_R 0x001B +#define MMC_PROFILE_DVD_PLUS_RW_DL 0x002A +#define MMC_PROFILE_DVD_PLUS_R_DL 0x002B +#define MMC_PROFILE_BD_ROM 0x0040 +#define MMC_PROFILE_BD_R_SRM 0x0041 +#define MMC_PROFILE_BD_R_RRM 0x0042 +#define MMC_PROFILE_BD_RE 0x0043 +#define MMC_PROFILE_HDDVD_ROM 0x0050 +#define MMC_PROFILE_HDDVD_R 0x0051 +#define MMC_PROFILE_HDDVD_RAM 0x0052 +#define MMC_PROFILE_HDDVD_RW 0x0053 +#define MMC_PROFILE_HDDVD_R_DL 0x0058 +#define MMC_PROFILE_HDDVD_RW_DL 0x005A +#define MMC_PROFILE_INVALID 0xFFFF + +#define ATAPI_INT_REASON_CD 0x01/* 0 = data transfer */ +#define ATAPI_INT_REASON_IO 0x02/* 1 = transfer to the host */ +#define ATAPI_INT_REASON_REL 0x04 +#define ATAPI_INT_REASON_TAG 0xf8 + +#define CFA_NO_ERROR 0x00 +#define CFA_MISC_ERROR 0x09 +#define CFA_INVALID_COMMAND 0x20 +#define CFA_INVALID_ADDRESS 0x21 +#define CFA_ADDRESS_OVERFLOW 0x2f + +/* same constants as bochs */ +#define ASC_ILLEGAL_OPCODE 0x20 +#define ASC_LOGICAL_BLOCK_OOR 0x21 +#define ASC_INV_FIELD_IN_CMD_PACKET 0x24 +#define ASC_MEDIUM_MAY_HAVE_CHANGED 0x28 +#define ASC_INCOMPATIBLE_FORMAT 0x30 +#define ASC_MEDIUM_NOT_PRESENT 0x3a +#define ASC_SAVING_PARAMETERS_NOT_SUPPORTED 0x39 +#define ASC_MEDIA_REMOVAL_PREVENTED 0x53 + +#define SENSE_NONE 0 +#define SENSE_NOT_READY 2 +#define SENSE_ILLEGAL_REQUEST 5 +#define SENSE_UNIT_ATTENTION 6 + +#define SMART_READ_DATA 0xd0 +#define SMART_READ_THRESH 0xd1 +#define SMART_ATTR_AUTOSAVE 0xd2 +#define SMART_SAVE_ATTR 0xd3 +#define SMART_EXECUTE_OFFLINE 0xd4 +#define SMART_READ_LOG 0xd5 +#define SMART_WRITE_LOG 0xd6 +#define SMART_ENABLE 0xd8 +#define SMART_DISABLE 0xd9 +#define SMART_STATUS 0xda + +/* NOTE: IDEState represents in fact one drive */ +struct IDEState { +IDEBus *bus; +uint8_t unit; +/* ide config */ +int is_cdrom; +int is_cf; +int cylinders, heads, sectors; +int64_t nb_sectors; +int mult_sectors; +int identify_set; +uint16_t identify_data[256 ]; +qemu_irq irq; +int drive_serial; +char drive_serial_str[21 ]; +/* ide regs */ +uint8_t feature; +uint8_t error; +uint32_t nsector; +uint8_t sector; +uint8_t lcyl; +uint8_t hcyl; +/* other part of tf for lba48 support */ +uint8_t hob_feature; +uint8_t hob_nsector; +uint8_t hob_sector; +uint8_t hob_lcyl; +uint8_t hob_hcyl; + +uint8_t select; +uint8_t status; + +/* 0x3f6 command, only meaningful for drive 0 */ +uint8_t cmd; +/* set for lba48 access */ +uint8_t lba48; +BlockDriverState *bs; +/* ATAPI specific */ +uint8_t sense_key; +uint8_t asc; +uint8_t cdrom_changed; +int packet_transfer_size; +int elementary_transfer_size; +int io_buffer_index; +int lba; +int cd_sector_size; +int atapi_dma;/* true if dma is requested for the packet cmd */ +/* ATA DMA state */ +int io_buffer_size; +QEMUSGList sg; +/* PIO transfer handling */ +int req_nb_sectors;/* number of sectors per interrupt */ +EndTransferFunc *end_transfer_func; +uint8_t *data_ptr; +uint8_t *data_end; +uint8_t *io_buffer; +QEMUTimer *sector_write_timer;/* only used for win2k install hack */ +uint32_t irq_count;/* counts IRQs when using win2k install hack */ +/* CF-ATA extended error */ +uint8_t ext_error; +/* CF-ATA metadata storage */ +uint32_t mdata_size; +uint8_t *mdata_storage; +int media_changed; +/* for pmac */ +int is_read; +/* SMART */ +uint8_t smart_enabled; +uint8_t smart_autosave; +int smart_errors; +uint8_t smart_selftest_count; +uint8_t *smart_selftest_data; +}; + +struct IDEBus { +BusState qbus; +BMDMAState *bmdma; +IDEState ifs[2 ]; +uint8_t unit; +}; + +#define BM_STATUS_DMAING 0x01 +#define BM_STATUS_ERROR 0x02 +#define BM_STATUS_INT 0x04 +#define BM_STATUS_DMA_RETRY 0x08 +#define BM_STATUS_PIO_RETRY 0x10 + +#define BM_CMD_START 0x01 +#define BM_CMD_READ 0x08 + +struct BMDMAState { +uint8_t cmd; +uint8_t status; +uint32_t addr; + +struct PCIIDEState *pci_dev; +IDEBus *bus; +/* current transfer state */ +uint32_t cur_addr; +uint32_t cur_prd_last; +uint32_t cur_prd_addr; +uint32_t cur_prd_len; +uint8_t unit; +BlockDriverCompletionFunc *dma_cb; +BlockDriverAIOCB *aiocb; +struct iovec iov; +QEMUIOVector qiov; +int64_t sector_num; +uint32_t nsector; +QEMUBH *bh; +}; + +static inline IDEState *idebus_active_if (IDEBus *bus) +{ +return bus->ifs + bus->unit; +} + +static inline IDEState *bmdma_active_if (BMDMAState *bmdma) +{ +assert (bmdma->unit !=-1 ); +return bmdma->bus->ifs + bmdma->unit; +} + +static inline void ide_set_irq (IDEState *s) +{ +BMDMAState *bm = s->bus->bmdma; +if (!(s->cmd &IDE_CMD_DISABLE_IRQ )) { +if (bm) { + bm->status |=BM_STATUS_INT ; + } +qemu_irq_raise (s->irq); + } +} + +/* ide.c */ +void ide_save (QEMUFile * f,IDEState *s); +void ide_load (QEMUFile * f,IDEState *s,int version_id); +void idebus_save (QEMUFile * f,IDEBus *bus); +void idebus_load (QEMUFile * f,IDEBus *bus,int version_id); + +void ide_reset (IDEState *s); +int64_t ide_get_sector (IDEState *s); +void ide_set_sector (IDEState *s,int64_t sector_num); + +void ide_dma_cancel (BMDMAState *bm); +void ide_dma_restart_cb (void *opaque,int running,int reason); +void ide_dma_error (IDEState *s); + +void ide_atapi_cmd_ok (IDEState *s); +void ide_atapi_cmd_error (IDEState *s,int sense_key,int asc); +void ide_atapi_io_error (IDEState *s,int ret); + +void ide_ioport_write (void *opaque,uint32_t addr,uint32_t val); +uint32_t ide_ioport_read (void *opaque,uint32_t addr1); +uint32_t ide_status_read (void *opaque,uint32_t addr); +void ide_cmd_write (void *opaque,uint32_t addr,uint32_t val); +void ide_data_writew (void *opaque,uint32_t addr,uint32_t val); +uint32_t ide_data_readw (void *opaque,uint32_t addr); +void ide_data_writel (void *opaque,uint32_t addr,uint32_t val); +uint32_t ide_data_readl (void *opaque,uint32_t addr); + +void ide_init2 (IDEBus *bus,BlockDriverState *hd0,BlockDriverState *hd1, +qemu_irq irq); +void ide_init_ioport (IDEBus *bus,int iobase,int iobase2); + +#endif /* HW_IDE_INTERNAL_H */
hw/ide.c +32 -518
723 lines not on this page · raw message
Signature · 1 line
1.6.2.5
PATCH 8/11 ide: add save/restore support for isa
In reply to Gerd Hoffmann--- hw/ide-isa.c | 33 +++++++++++++++++++++++++++++---- 1 files changed, 29 insertions(+), 4 deletions(-)
hw/ide-isa.c +29 -4
@@ -33,13 +33,38 @@/***********************************************************/ /* ISA IDE definitions */ +typedef struct ISAIDEState { +IDEBus *bus; +}ISAIDEState ; + +static void isa_ide_save (QEMUFile * f,void *opaque) +{ +ISAIDEState *s = opaque; + +idebus_save (f, s->bus); +ide_save (f, &s->bus->ifs[0 ]); +ide_save (f, &s->bus->ifs[1 ]); +} + +static int isa_ide_load (QEMUFile * f,void *opaque,int version_id) +{ +ISAIDEState *s = opaque; + +idebus_load (f, s->bus, version_id); +ide_load (f, &s->bus->ifs[0 ], version_id); +ide_load (f, &s->bus->ifs[1 ], version_id); +return 0 ; +} +void isa_ide_init (int iobase,int iobase2,qemu_irq irq,BlockDriverState *hd0,BlockDriverState *hd1) { -IDEBus *bus; +ISAIDEState *s; - bus =qemu_mallocz (sizeof (*bus)); + s =qemu_mallocz (sizeof (*s)); + s->bus =qemu_mallocz (sizeof (IDEBus)); -ide_init2 (bus, hd0, hd1, irq); -ide_init_ioport (bus, iobase, iobase2); +ide_init2 (s->bus, hd0, hd1, irq); +ide_init_ioport (s->bus, iobase, iobase2); +register_savevm ("isa-ide" ,0 ,3 , isa_ide_save, isa_ide_load, s); }
Signature · 1 line
1.6.2.5
PATCH 9/11 ide: add save/restore support for mmio
In reply to Gerd Hoffmann--- hw/ide-mmio.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
hw/ide-mmio.c +20 -0
@@ -102,6 +102,25 @@ static CPUWriteMemoryFunc * const mmio_ide_cmd[] = { mmio_ide_cmd_write, }; +static void mmio_ide_save (QEMUFile * f,void *opaque) +{ +MMIOState *s = opaque; + +idebus_save (f, s->bus); +ide_save (f, &s->bus->ifs[0 ]); +ide_save (f, &s->bus->ifs[1 ]); +} + +static int mmio_ide_load (QEMUFile * f,void *opaque,int version_id) +{ +MMIOState *s = opaque; + +idebus_load (f, s->bus, version_id); +ide_load (f, &s->bus->ifs[0 ], version_id); +ide_load (f, &s->bus->ifs[1 ], version_id); +return 0 ; +} +void mmio_ide_init (target_phys_addr_t membase,target_phys_addr_t membase2,qemu_irq irq,int shift,BlockDriverState *hd0,BlockDriverState *hd1)
@@ -119,5 +138,6 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2, mem2 =cpu_register_io_memory (mmio_ide_status, mmio_ide_cmd, s);cpu_register_physical_memory (membase,16 << shift, mem1);cpu_register_physical_memory (membase2,2 << shift, mem2); +register_savevm ("mmio-ide" ,0 ,3 , mmio_ide_save, mmio_ide_load, s); }
Signature · 1 line
1.6.2.5
PATCH 5/11 ide: split away ide-macio.c
In reply to Gerd Hoffmanncreate ide-macio.c and place macio support there. only build ide-macio support for platforms using it.
--- Makefile.target | 2 +- hw/ide-macio.c | 355 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/ide.c | 327 -------------------------------------------------- hw/ide.h | 4 + hw/ppc_mac.h | 4 - 5 files changed, 360 insertions(+), 332 deletions(-) create mode 100644 hw/ide-macio.c
Makefile.target +1 -1
@@ -194,7 +194,7 @@ obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o # shared objects -obj-ppc-y = ppc.o ide.o ide-isa.o ide-pci.o +obj-ppc-y = ppc.o ide.o ide-isa.o ide-pci.o ide-macio.o obj-ppc-y += vga.o $(sound-obj-y) dma.o isa-bus.o openpic.o # PREP target obj-ppc-y += pckbd.o serial.o i8259.o i8254.o fdc.o mc146818rtc.o
hw/ide-macio.c new file +355 -0
355 lines not on this page · raw message
hw/ide.c +0 -327
339 lines not on this page · raw message
hw/ide.h +4 -0
@@ -15,4 +15,8 @@ void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,void pci_piix4_ide_init (PCIBus *bus,BlockDriverState **hd_table,int devfn,qemu_irq *pic); +/* ide-macio.c */ +int pmac_ide_init (BlockDriverState **hd_table,qemu_irq irq, +void *dbdma,int channel,qemu_irq dma_irq); +#endif /* HW_IDE_H */
hw/ppc_mac.h +0 -4
@@ -49,10 +49,6 @@ void macio_init (PCIBus *bus, int device_id, int is_oldworld, int pic_mem_index, int dbdma_mem_index, int cuda_mem_index, void *nvram, int nb_ide, int *ide_mem_index, int escc_mem_index); -/* NewWorld PowerMac IDE */ -int pmac_ide_init (BlockDriverState **hd_table,qemu_irq irq, -void *dbdma,int channel,qemu_irq dma_irq); -/* Heathrow PIC */ qemu_irq *heathrow_pic_init (int *pmem_index,int nb_cpus,qemu_irq **irqs);
Signature · 1 line
1.6.2.5
PATCH 1/11 ide: add IDEBus struct, cleanups
In reply to Gerd HoffmannThe current IDE code uses an array of two IDEState structs to maintain the IDE bus. This patch adds a IDEBus to be used instead and does a bunch of cleanups:
* move ide bus state from IDEState to IDEBus.
* drop a bunch of ugly pointer arithmetics to figure the active interface, explicitly save the interface number instead.
* add helper functions to save/restore idebus state.
It also fixes a save/restore bug: loadvm allways stores the command in the master's IDEState, even when it was saved from the slave.
--- hw/ide.c | 471 ++++++++++++++++++++++++++++++++------------------------------ 1 files changed, 243 insertions(+), 228 deletions(-)
hw/ide.c +243 -228
@@ -36,6 +36,10 @@#include "sh.h" #include "dma.h" +typedef struct IDEBus IDEBus ; +typedef struct IDEState IDEState ; +typedef struct BMDMAState BMDMAState ; +/* debug IDE devices */ //#define DEBUG_IDE //#define DEBUG_IDE_ATAPI
@@ -392,14 +396,12 @@ static int smart_attributes[][5] = { { 0x00, 0x00, 0x00, 0x00, 0x00} }; - - -struct IDEState ; - -typedef void EndTransferFunc (struct IDEState *); +typedef void EndTransferFunc (IDEState *);/* NOTE: IDEState represents in fact one drive */ -typedef struct IDEState { +struct IDEState { +IDEBus *bus; +uint8_t unit;/* ide config */ int is_cdrom;int is_cf;
@@ -409,8 +411,6 @@ typedef struct IDEState {int identify_set;uint16_t identify_data[256 ];qemu_irq irq; -PCIDevice *pci_dev; -struct BMDMAState *bmdma;int drive_serial;char drive_serial_str[21 ];/* ide regs */
@@ -434,8 +434,6 @@ typedef struct IDEState {uint8_t cmd;/* set for lba48 access */ uint8_t lba48; -/* depends on bit 4 in select, only meaningful for drive 0 */ -struct IDEState *cur_drive;BlockDriverState *bs;/* ATAPI specific */ uint8_t sense_key;
@@ -472,8 +470,14 @@ typedef struct IDEState {int smart_errors;uint8_t smart_selftest_count;uint8_t *smart_selftest_data; +}; -} IDEState; +struct IDEBus { +BusState qbus; +BMDMAState *bmdma; +IDEState ifs[2 ]; +uint8_t unit; +};/* XXX: DVDs that could fit on a CD will be reported as a CD */ static inline int media_present (IDEState *s)
@@ -513,18 +517,19 @@ static inline int media_is_cd(IDEState *s)#define UDIDETCR0 0x73#define UDIDETCR1 0x7B -typedef struct BMDMAState { +struct BMDMAState {uint8_t cmd;uint8_t status;uint32_t addr;struct PCIIDEState *pci_dev; +IDEBus *bus;/* current transfer state */ uint32_t cur_addr;uint32_t cur_prd_last;uint32_t cur_prd_addr;uint32_t cur_prd_len; - IDEState *ide_if; +uint8_t unit;BlockDriverCompletionFunc *dma_cb;BlockDriverAIOCB *aiocb;struct iovec iov;
@@ -532,15 +537,26 @@ typedef struct BMDMAState {int64_t sector_num;uint32_t nsector;QEMUBH *bh; -} BMDMAState; +};typedef struct PCIIDEState {PCIDevice dev; -IDEState ide_if[4 ]; +IDEBus bus[2 ];BMDMAState bmdma[2 ];int type;/* see IDE_TYPE_xxx */ }PCIIDEState ; +static inline IDEState *bmdma_active_if (BMDMAState *bmdma) +{ +assert (bmdma->unit !=-1 ); +return bmdma->bus->ifs + bmdma->unit; +} + +static inline IDEState *idebus_active_if (IDEBus *bus) +{ +return bus->ifs + bus->unit; +} +static void ide_dma_start (IDEState *s,BlockDriverCompletionFunc *dma_cb);static void ide_dma_restart (IDEState *s);static void ide_atapi_cmd_read_dma_cb (void *opaque,int ret);
@@ -794,7 +810,7 @@ static inline void ide_dma_submit_check(IDEState *s,static inline void ide_set_irq (IDEState *s) { -BMDMAState *bm = s->bmdma; +BMDMAState *bm = s->bus->bmdma;if (!(s->cmd &IDE_CMD_DISABLE_IRQ )) {if (bm) { bm->status |=BM_STATUS_INT ;
@@ -910,7 +926,7 @@ static void ide_sector_read(IDEState *s)/* return 0 if buffer completed */ static int dma_buf_prepare (BMDMAState *bm,int is_write) { -IDEState *s = bm->ide_if; +IDEState *s =bmdma_active_if (bm);struct {uint32_t addr;uint32_t size;
@@ -969,8 +985,8 @@ static int ide_handle_write_error(IDEState *s, int error, int op)if ((error ==ENOSPC && action ==BLOCK_ERR_STOP_ENOSPC ) || action ==BLOCK_ERR_STOP_ANY ) { - s->bmdma->ide_if = s; - s->bmdma->status |= op; + s->bus->bmdma->unit = s->unit; + s->bus->bmdma->status |= op;vm_stop (0 ); }else {if (op ==BM_STATUS_DMA_RETRY ) {
@@ -987,7 +1003,7 @@ static int ide_handle_write_error(IDEState *s, int error, int op)/* return 0 if buffer completed */ static int dma_buf_rw (BMDMAState *bm,int is_write) { -IDEState *s = bm->ide_if; +IDEState *s =bmdma_active_if (bm);struct {uint32_t addr;uint32_t size;
@@ -1035,7 +1051,7 @@ static int dma_buf_rw(BMDMAState *bm, int is_write)static void ide_read_dma_cb (void *opaque,int ret) {BMDMAState *bm = opaque; -IDEState *s = bm->ide_if; +IDEState *s =bmdma_active_if (bm);int n;int64_t sector_num;
@@ -1062,7 +1078,7 @@ static void ide_read_dma_cb(void *opaque, int ret) bm->status &= ~BM_STATUS_DMAING ; bm->status |=BM_STATUS_INT ; bm->dma_cb =NULL ; - bm->ide_if =NULL ; + bm->unit =-1 ; bm->aiocb =NULL ;return ; }
@@ -1153,10 +1169,10 @@ static void ide_dma_restart_bh(void *opaque)if (bm->status &BM_STATUS_DMA_RETRY ) { bm->status &= ~BM_STATUS_DMA_RETRY ; -ide_dma_restart (bm->ide_if); +ide_dma_restart (bmdma_active_if (bm)); }else if (bm->status &BM_STATUS_PIO_RETRY ) { bm->status &= ~BM_STATUS_PIO_RETRY ; -ide_sector_write (bm->ide_if); +ide_sector_write (bmdma_active_if (bm)); } }
@@ -1176,7 +1192,7 @@ static void ide_dma_restart_cb(void *opaque, int running, int reason)static void ide_write_dma_cb (void *opaque,int ret) {BMDMAState *bm = opaque; -IDEState *s = bm->ide_if; +IDEState *s =bmdma_active_if (bm);int n;int64_t sector_num;
@@ -1202,7 +1218,7 @@ static void ide_write_dma_cb(void *opaque, int ret) bm->status &= ~BM_STATUS_DMAING ; bm->status |=BM_STATUS_INT ; bm->dma_cb =NULL ; - bm->ide_if =NULL ; + bm->unit =-1 ; bm->aiocb =NULL ;return ; }
@@ -1462,7 +1478,7 @@ static void ide_atapi_cmd_read_pio(IDEState *s, int lba, int nb_sectors,static void ide_atapi_cmd_read_dma_cb (void *opaque,int ret) {BMDMAState *bm = opaque; -IDEState *s = bm->ide_if; +IDEState *s =bmdma_active_if (bm);int data_offset, n;if (ret <0 ) {
@@ -1500,7 +1516,7 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret) bm->status &= ~BM_STATUS_DMAING ; bm->status |=BM_STATUS_INT ; bm->dma_cb =NULL ; - bm->ide_if =NULL ; + bm->unit =-1 ; bm->aiocb =NULL ;return ; }
@@ -2184,18 +2200,18 @@ static void ide_cmd_lba48_transform(IDEState *s, int lba48) } } -static void ide_clear_hob (IDEState *ide_if) +static void ide_clear_hob (IDEBus *bus) {/* any write clears HOB high bit of device control register */ - ide_if[0 ].select &= ~(1 <<7 ); - ide_if[1 ].select &= ~(1 <<7 ); + bus->ifs[0 ].select &= ~(1 <<7 ); + bus->ifs[1 ].select &= ~(1 <<7 ); }static void ide_ioport_write (void *opaque,uint32_t addr,uint32_t val) { -IDEState *ide_if = opaque; +IDEBus *bus = opaque;IDEState *s; -int unit, n; +int n;int lba48 =0 ;#ifdef DEBUG_IDE
@@ -2205,56 +2221,54 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) addr &=7 ;/* ignore writes to command block while busy with previous command */ -if (addr !=7 && (ide_if->cur_drive->status & (BUSY_STAT |DRQ_STAT ))) +if (addr !=7 && (idebus_active_if (bus)->status & (BUSY_STAT |DRQ_STAT )))return ;switch (addr) {case 0 :break ;case 1 : -ide_clear_hob (ide_if); +ide_clear_hob (bus);/* NOTE: data is written to the two drives */ - ide_if[0 ].hob_feature = ide_if[0 ].feature; - ide_if[1 ].hob_feature = ide_if[1 ].feature; - ide_if[0 ].feature = val; - ide_if[1 ].feature = val; + bus->ifs[0 ].hob_feature = bus->ifs[0 ].feature; + bus->ifs[1 ].hob_feature = bus->ifs[1 ].feature; + bus->ifs[0 ].feature = val; + bus->ifs[1 ].feature = val;break ;case 2 : -ide_clear_hob (ide_if); - ide_if[0 ].hob_nsector = ide_if[0 ].nsector; - ide_if[1 ].hob_nsector = ide_if[1 ].nsector; - ide_if[0 ].nsector = val; - ide_if[1 ].nsector = val; +ide_clear_hob (bus); + bus->ifs[0 ].hob_nsector = bus->ifs[0 ].nsector; + bus->ifs[1 ].hob_nsector = bus->ifs[1 ].nsector; + bus->ifs[0 ].nsector = val; + bus->ifs[1 ].nsector = val;break ;case 3 : -ide_clear_hob (ide_if); - ide_if[0 ].hob_sector = ide_if[0 ].sector; - ide_if[1 ].hob_sector = ide_if[1 ].sector; - ide_if[0 ].sector = val; - ide_if[1 ].sector = val; +ide_clear_hob (bus); + bus->ifs[0 ].hob_sector = bus->ifs[0 ].sector; + bus->ifs[1 ].hob_sector = bus->ifs[1 ].sector; + bus->ifs[0 ].sector = val; + bus->ifs[1 ].sector = val;break ;case 4 : -ide_clear_hob (ide_if); - ide_if[0 ].hob_lcyl = ide_if[0 ].lcyl; - ide_if[1 ].hob_lcyl = ide_if[1 ].lcyl; - ide_if[0 ].lcyl = val; - ide_if[1 ].lcyl = val; +ide_clear_hob (bus); + bus->ifs[0 ].hob_lcyl = bus->ifs[0 ].lcyl; + bus->ifs[1 ].hob_lcyl = bus->ifs[1 ].lcyl; + bus->ifs[0 ].lcyl = val; + bus->ifs[1 ].lcyl = val;break ;case 5 : -ide_clear_hob (ide_if); - ide_if[0 ].hob_hcyl = ide_if[0 ].hcyl; - ide_if[1 ].hob_hcyl = ide_if[1 ].hcyl; - ide_if[0 ].hcyl = val; - ide_if[1 ].hcyl = val; +ide_clear_hob (bus); + bus->ifs[0 ].hob_hcyl = bus->ifs[0 ].hcyl; + bus->ifs[1 ].hob_hcyl = bus->ifs[1 ].hcyl; + bus->ifs[0 ].hcyl = val; + bus->ifs[1 ].hcyl = val;break ;case 6 :/* FIXME: HOB readback uses bit 7 */ - ide_if[0 ].select = (val & ~0x10 ) |0xa0 ; - ide_if[1 ].select = (val |0x10 ) |0xa0 ; + bus->ifs[0 ].select = (val & ~0x10 ) |0xa0 ; + bus->ifs[1 ].select = (val |0x10 ) |0xa0 ;/* select drive */ - unit = (val >>4 ) &1 ; - s = ide_if + unit; - ide_if->cur_drive = s; + bus->unit = (val >>4 ) &1 ;break ;default :case 7 :
@@ -2262,9 +2276,9 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)#if defined(DEBUG_IDE )printf ("ide: CMD=%02x\n" , val);#endif - s = ide_if->cur_drive; + s =idebus_active_if (bus);/* ignore commands to non existant slave */ -if (s != ide_if && !s->bs) +if (s != bus->ifs && !s->bs)break ;/* Only DEVICE RESET is allowed while BSY or/and DRQ are set */
@@ -2767,8 +2781,8 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)static uint32_t ide_ioport_read (void *opaque,uint32_t addr1) { -IDEState *ide_if = opaque; -IDEState *s = ide_if->cur_drive; +IDEBus *bus = opaque; +IDEState *s =idebus_active_if (bus);uint32_t addr;int ret, hob;
@@ -2781,8 +2795,8 @@ static uint32_t ide_ioport_read(void *opaque, uint32_t addr1) ret =0xff ;break ;case 1 : -if ((!ide_if[0 ].bs && !ide_if[1 ].bs) || - (s != ide_if && !s->bs)) +if ((!bus->ifs[0 ].bs && !bus->ifs[1 ].bs) || + (s != bus->ifs && !s->bs)) ret =0 ;else if (!hob) ret = s->error;
@@ -2790,7 +2804,7 @@ static uint32_t ide_ioport_read(void *opaque, uint32_t addr1) ret = s->hob_feature;break ;case 2 : -if (!ide_if[0 ].bs && !ide_if[1 ].bs) +if (!bus->ifs[0 ].bs && !bus->ifs[1 ].bs) ret =0 ;else if (!hob) ret = s->nsector &0xff ;
@@ -2798,7 +2812,7 @@ static uint32_t ide_ioport_read(void *opaque, uint32_t addr1) ret = s->hob_nsector;break ;case 3 : -if (!ide_if[0 ].bs && !ide_if[1 ].bs) +if (!bus->ifs[0 ].bs && !bus->ifs[1 ].bs) ret =0 ;else if (!hob) ret = s->sector;
@@ -2806,7 +2820,7 @@ static uint32_t ide_ioport_read(void *opaque, uint32_t addr1) ret = s->hob_sector;break ;case 4 : -if (!ide_if[0 ].bs && !ide_if[1 ].bs) +if (!bus->ifs[0 ].bs && !bus->ifs[1 ].bs) ret =0 ;else if (!hob) ret = s->lcyl;
@@ -2814,7 +2828,7 @@ static uint32_t ide_ioport_read(void *opaque, uint32_t addr1) ret = s->hob_lcyl;break ;case 5 : -if (!ide_if[0 ].bs && !ide_if[1 ].bs) +if (!bus->ifs[0 ].bs && !bus->ifs[1 ].bs) ret =0 ;else if (!hob) ret = s->hcyl;
@@ -2822,15 +2836,15 @@ static uint32_t ide_ioport_read(void *opaque, uint32_t addr1) ret = s->hob_hcyl;break ;case 6 : -if (!ide_if[0 ].bs && !ide_if[1 ].bs) +if (!bus->ifs[0 ].bs && !bus->ifs[1 ].bs) ret =0 ;else ret = s->select;break ;default :case 7 : -if ((!ide_if[0 ].bs && !ide_if[1 ].bs) || - (s != ide_if && !s->bs)) +if ((!bus->ifs[0 ].bs && !bus->ifs[1 ].bs) || + (s != bus->ifs && !s->bs)) ret =0 ;else ret = s->status;
@@ -2845,12 +2859,12 @@ static uint32_t ide_ioport_read(void *opaque, uint32_t addr1)static uint32_t ide_status_read (void *opaque,uint32_t addr) { -IDEState *ide_if = opaque; -IDEState *s = ide_if->cur_drive; +IDEBus *bus = opaque; +IDEState *s =idebus_active_if (bus);int ret; -if ((!ide_if[0 ].bs && !ide_if[1 ].bs) || - (s != ide_if && !s->bs)) +if ((!bus->ifs[0 ].bs && !bus->ifs[1 ].bs) || + (s != bus->ifs && !s->bs)) ret =0 ;else ret = s->status;
@@ -2862,7 +2876,7 @@ static uint32_t ide_status_read(void *opaque, uint32_t addr)static void ide_cmd_write (void *opaque,uint32_t addr,uint32_t val) { -IDEState *ide_if = opaque; +IDEBus *bus = opaque;IDEState *s;int i;
@@ -2870,19 +2884,19 @@ static void ide_cmd_write(void *opaque, uint32_t addr, uint32_t val)printf ("ide: write control addr=0x%x val=%02x\n" , addr, val);#endif /* common for both drives */ -if (!(ide_if[0 ].cmd &IDE_CMD_RESET ) && +if (!(bus->ifs[0 ].cmd &IDE_CMD_RESET ) && (val &IDE_CMD_RESET )) {/* reset low to high */ for (i =0 ;i <2 ; i++) { - s = &ide_if[i]; + s = &bus->ifs[i]; s->status =BUSY_STAT |SEEK_STAT ; s->error =0x01 ; } - }else if ((ide_if[0 ].cmd &IDE_CMD_RESET ) && + }else if ((bus->ifs[0 ].cmd &IDE_CMD_RESET ) && !(val &IDE_CMD_RESET )) {/* high to low */ for (i =0 ;i <2 ; i++) { - s = &ide_if[i]; + s = &bus->ifs[i];if (s->is_cdrom) s->status =0x00 ;/* NOTE: READY is _not_ set */ else
@@ -2891,13 +2905,14 @@ static void ide_cmd_write(void *opaque, uint32_t addr, uint32_t val) } } - ide_if[0 ].cmd = val; - ide_if[1 ].cmd = val; + bus->ifs[0 ].cmd = val; + bus->ifs[1 ].cmd = val; }static void ide_data_writew (void *opaque,uint32_t addr,uint32_t val) { -IDEState *s = ((IDEState *)opaque)->cur_drive; +IDEBus *bus = opaque; +IDEState *s =idebus_active_if (bus);uint8_t *p;/* PIO data access allowed only when DRQ bit is set */
@@ -2914,7 +2929,8 @@ static void ide_data_writew(void *opaque, uint32_t addr, uint32_t val)static uint32_t ide_data_readw (void *opaque,uint32_t addr) { -IDEState *s = ((IDEState *)opaque)->cur_drive; +IDEBus *bus = opaque; +IDEState *s =idebus_active_if (bus);uint8_t *p;int ret;
@@ -2933,7 +2949,8 @@ static uint32_t ide_data_readw(void *opaque, uint32_t addr)static void ide_data_writel (void *opaque,uint32_t addr,uint32_t val) { -IDEState *s = ((IDEState *)opaque)->cur_drive; +IDEBus *bus = opaque; +IDEState *s =idebus_active_if (bus);uint8_t *p;/* PIO data access allowed only when DRQ bit is set */
@@ -2950,7 +2967,8 @@ static void ide_data_writel(void *opaque, uint32_t addr, uint32_t val)static uint32_t ide_data_readl (void *opaque,uint32_t addr) { -IDEState *s = ((IDEState *)opaque)->cur_drive; +IDEBus *bus = opaque; +IDEState *s =idebus_active_if (bus);uint8_t *p;int ret;
@@ -2979,11 +2997,13 @@ static void ide_dummy_transfer_stop(IDEState *s)static void ide_reset (IDEState *s) { +IDEBus *bus = s->bus; +if (s->is_cf) s->mult_sectors =0 ;else s->mult_sectors =MAX_MULT_SECTORS ; - s->cur_drive = s; + bus->unit = s->unit; s->select =0xa0 ; s->status =READY_STAT |SEEK_STAT ;ide_set_signature (s);
@@ -2994,7 +3014,7 @@ static void ide_reset(IDEState *s) s->media_changed =0 ; } -static void ide_init2 (IDEState *ide_state, +static void ide_init2 (IDEBus *bus,BlockDriverState *hd0,BlockDriverState *hd1,qemu_irq irq) {
@@ -3004,11 +3024,10 @@ static void ide_init2(IDEState *ide_state,uint64_t nb_sectors;for (i =0 ; i <2 ; i++) { - s = ide_state + i; -if (i ==0 ) - s->bs = hd0; -else - s->bs = hd1; + s = bus->ifs + i; + s->bus = bus; + s->unit = i; + s->bs = (i ==0 ) ? hd0 : hd1; s->io_buffer =qemu_blockalign (s->bs,IDE_DMA_BUF_SECTORS *512 +4 );if (s->bs) {bdrv_get_geometry (s->bs, &nb_sectors);
@@ -3042,20 +3061,20 @@ static void ide_init2(IDEState *ide_state, } } -static void ide_init_ioport (IDEState *ide_state,int iobase,int iobase2) +static void ide_init_ioport (IDEBus *bus,int iobase,int iobase2) { -register_ioport_write (iobase,8 ,1 , ide_ioport_write, ide_state); -register_ioport_read (iobase,8 ,1 , ide_ioport_read, ide_state); +register_ioport_write (iobase,8 ,1 , ide_ioport_write, bus); +register_ioport_read (iobase,8 ,1 , ide_ioport_read, bus);if (iobase2) { -register_ioport_read (iobase2,1 ,1 , ide_status_read, ide_state); -register_ioport_write (iobase2,1 ,1 , ide_cmd_write, ide_state); +register_ioport_read (iobase2,1 ,1 , ide_status_read, bus); +register_ioport_write (iobase2,1 ,1 , ide_cmd_write, bus); }/* data ports */ -register_ioport_write (iobase,2 ,2 , ide_data_writew, ide_state); -register_ioport_read (iobase,2 ,2 , ide_data_readw, ide_state); -register_ioport_write (iobase,4 ,4 , ide_data_writel, ide_state); -register_ioport_read (iobase,4 ,4 , ide_data_readl, ide_state); +register_ioport_write (iobase,2 ,2 , ide_data_writew, bus); +register_ioport_read (iobase,2 ,2 , ide_data_readw, bus); +register_ioport_write (iobase,4 ,4 , ide_data_writel, bus); +register_ioport_read (iobase,4 ,4 , ide_data_readl, bus); }/* save per IDE drive data */
@@ -3122,18 +3141,36 @@ static void ide_load(QEMUFile* f, IDEState *s, int version_id)/* XXX: if a transfer is pending, we do not save it yet */ } +static void idebus_save (QEMUFile * f,IDEBus *bus) +{ +IDEState *s =idebus_active_if (bus); +qemu_put_8s (f, &s->cmd); +qemu_put_8s (f, &bus->unit); +} + +static void idebus_load (QEMUFile * f,IDEBus *bus,int version_id) +{ +IDEState *s; +uint8_t cmd; + +qemu_get_8s (f, &cmd); +qemu_get_8s (f, &bus->unit); + s =idebus_active_if (bus); + s->cmd = cmd; +} +/***********************************************************/ /* ISA IDE definitions */ void isa_ide_init (int iobase,int iobase2,qemu_irq irq,BlockDriverState *hd0,BlockDriverState *hd1) { -IDEState *ide_state; +IDEBus *bus; - ide_state =qemu_mallocz (sizeof (IDEState) *2 ); + bus =qemu_mallocz (sizeof (*bus)); -ide_init2 (ide_state, hd0, hd1, irq); -ide_init_ioport (ide_state, iobase, iobase2); +ide_init2 (bus, hd0, hd1, irq); +ide_init_ioport (bus, iobase, iobase2); }/***********************************************************/
@@ -3145,32 +3182,32 @@ static void ide_map(PCIDevice *pci_dev, int region_num, uint32_t addr, uint32_t size, int type) { PCIIDEState *d = (PCIIDEState *)pci_dev; -IDEState *ide_state; +IDEBus *bus;if (region_num <=3 ) { - ide_state = &d->ide_if[(region_num >>1 ) *2 ]; + bus = &d->bus[(region_num >>1 )];if (region_num &1 ) { -register_ioport_read (addr +2 ,1 ,1 , ide_status_read, ide_state); -register_ioport_write (addr +2 ,1 ,1 , ide_cmd_write, ide_state); +register_ioport_read (addr +2 ,1 ,1 , ide_status_read, bus); +register_ioport_write (addr +2 ,1 ,1 , ide_cmd_write, bus); }else { -register_ioport_write (addr,8 ,1 , ide_ioport_write, ide_state); -register_ioport_read (addr,8 ,1 , ide_ioport_read, ide_state); +register_ioport_write (addr,8 ,1 , ide_ioport_write, bus); +register_ioport_read (addr,8 ,1 , ide_ioport_read, bus);/* data ports */ -register_ioport_write (addr,2 ,2 , ide_data_writew, ide_state); -register_ioport_read (addr,2 ,2 , ide_data_readw, ide_state); -register_ioport_write (addr,4 ,4 , ide_data_writel, ide_state); -register_ioport_read (addr,4 ,4 , ide_data_readl, ide_state); +register_ioport_write (addr,2 ,2 , ide_data_writew, bus); +register_ioport_read (addr,2 ,2 , ide_data_readw, bus); +register_ioport_write (addr,4 ,4 , ide_data_writel, bus); +register_ioport_read (addr,4 ,4 , ide_data_readl, bus); } } }static void ide_dma_start (IDEState *s,BlockDriverCompletionFunc *dma_cb) { -BMDMAState *bm = s->bmdma; +BMDMAState *bm = s->bus->bmdma;if (!bm)return ; - bm->ide_if = s; + bm->unit = s->unit; bm->dma_cb = dma_cb; bm->cur_prd_last =0 ; bm->cur_prd_addr =0 ;
@@ -3184,7 +3221,7 @@ static void ide_dma_start(IDEState *s, BlockDriverCompletionFunc *dma_cb)static void ide_dma_restart (IDEState *s) { -BMDMAState *bm = s->bmdma; +BMDMAState *bm = s->bus->bmdma;ide_set_sector (s, bm->sector_num); s->io_buffer_index =0 ; s->io_buffer_size =0 ;
@@ -3199,7 +3236,7 @@ static void ide_dma_cancel(BMDMAState *bm)if (bm->status &BM_STATUS_DMAING ) { bm->status &= ~BM_STATUS_DMAING ;/* cancel DMA request */ - bm->ide_if =NULL ; + bm->unit =-1 ; bm->dma_cb =NULL ;if (bm->aiocb) {#ifdef DEBUG_AIO
@@ -3380,9 +3417,9 @@ static void bmdma_map(PCIDevice *pci_dev, int region_num,for (i =0 ;i <2 ; i++) {BMDMAState *bm = &d->bmdma[i]; - d->ide_if[2 * i].bmdma = bm; - d->ide_if[2 * i +1 ].bmdma = bm; - bm->pci_dev = (PCIIDEState *)pci_dev; + d->bus[i].bmdma = bm; + bm->pci_dev =DO_UPCAST (PCIIDEState, dev, pci_dev); + bm->bus = d->bus+i;qemu_add_vm_change_state_handler (ide_dma_restart_cb, bm);register_ioport_write (addr,1 ,1 , bmdma_cmd_writeb, bm);
@@ -3415,23 +3452,20 @@ static void pci_ide_save(QEMUFile* f, void *opaque)qemu_put_be32s (f, &bm->addr);qemu_put_sbe64s (f, &bm->sector_num);qemu_put_be32s (f, &bm->nsector); - ifidx = bm->ide_if ? bm->ide_if - d->ide_if :0 ; + ifidx = bm->unit +2 *i;qemu_put_8s (f, &ifidx);/* XXX: if a transfer is pending, we do not save it yet */ }/* per IDE interface data */ for (i =0 ; i <2 ; i++) { -IDEState *s = &d->ide_if[i *2 ]; -uint8_t drive1_selected; -qemu_put_8s (f, &s->cmd); - drive1_selected = (s->cur_drive != s); -qemu_put_8s (f, &drive1_selected); +idebus_save (f, &d->bus[i]); }/* per IDE drive data */ -for (i =0 ; i <4 ; i++) { -ide_save (f, &d->ide_if[i]); +for (i =0 ; i <2 ; i++) { +ide_save (f, &d->bus[i].ifs[0 ]); +ide_save (f, &d->bus[i].ifs[1 ]); } }
@@ -3455,22 +3489,19 @@ static int pci_ide_load(QEMUFile* f, void *opaque, int version_id)qemu_get_sbe64s (f, &bm->sector_num);qemu_get_be32s (f, &bm->nsector);qemu_get_8s (f, &ifidx); - bm->ide_if = &d->ide_if[ifidx]; + bm->unit = ifidx &1 ;/* XXX: if a transfer is pending, we do not save it yet */ }/* per IDE interface data */ for (i =0 ; i <2 ; i++) { -IDEState *s = &d->ide_if[i *2 ]; -uint8_t drive1_selected; -qemu_get_8s (f, &s->cmd); -qemu_get_8s (f, &drive1_selected); - s->cur_drive = &d->ide_if[i *2 + (drive1_selected !=0 )]; +idebus_load (f, &d->bus[i], version_id); }/* per IDE drive data */ -for (i =0 ; i <4 ; i++) { -ide_load (f, &d->ide_if[i], version_id); +for (i =0 ; i <2 ; i++) { +ide_load (f, &d->bus[i].ifs[0 ], version_id); +ide_load (f, &d->bus[i].ifs[1 ], version_id); }return 0 ; }
@@ -3516,7 +3547,6 @@ void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table, {PCIIDEState *d;uint8_t *pci_conf; -int i;qemu_irq *irq; d = (PCIIDEState *)pci_register_device(bus, "CMD646 IDE",
@@ -3553,12 +3583,9 @@ void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table, pci_conf[0x3d ] =0x01 ;// interrupt on pin 1 -for (i =0 ; i <4 ; i++) - d->ide_if[i].pci_dev = (PCIDevice *)d; - irq =qemu_allocate_irqs (cmd646_set_irq, d,2 ); -ide_init2 (&d->ide_if[0 ], hd_table[0 ], hd_table[1 ], irq[0 ]); -ide_init2 (&d->ide_if[2 ], hd_table[2 ], hd_table[3 ], irq[1 ]); +ide_init2 (&d->bus[0 ], hd_table[0 ], hd_table[1 ], irq[0 ]); +ide_init2 (&d->bus[1 ], hd_table[2 ], hd_table[3 ], irq[1 ]);register_savevm ("ide" ,0 ,3 , pci_ide_save, pci_ide_load, d);qemu_register_reset (cmd646_reset, d);
@@ -3610,10 +3637,10 @@ void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,pci_register_bar ((PCIDevice *)d,4 ,0x10 ,PCI_ADDRESS_SPACE_IO , bmdma_map); -ide_init2 (&d->ide_if[0 ], hd_table[0 ], hd_table[1 ], pic[14 ]); -ide_init2 (&d->ide_if[2 ], hd_table[2 ], hd_table[3 ], pic[15 ]); -ide_init_ioport (&d->ide_if[0 ],0x1f0 ,0x3f6 ); -ide_init_ioport (&d->ide_if[2 ],0x170 ,0x376 ); +ide_init2 (&d->bus[0 ], hd_table[0 ], hd_table[1 ], pic[14 ]); +ide_init2 (&d->bus[1 ], hd_table[2 ], hd_table[3 ], pic[15 ]); +ide_init_ioport (&d->bus[0 ],0x1f0 ,0x3f6 ); +ide_init_ioport (&d->bus[1 ],0x170 ,0x376 );for (i =0 ; i <4 ; i++)if (hd_table[i])
@@ -3650,10 +3677,10 @@ void pci_piix4_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,pci_register_bar ((PCIDevice *)d,4 ,0x10 ,PCI_ADDRESS_SPACE_IO , bmdma_map); -ide_init2 (&d->ide_if[0 ], hd_table[0 ], hd_table[1 ], pic[14 ]); -ide_init2 (&d->ide_if[2 ], hd_table[2 ], hd_table[3 ], pic[15 ]); -ide_init_ioport (&d->ide_if[0 ],0x1f0 ,0x3f6 ); -ide_init_ioport (&d->ide_if[2 ],0x170 ,0x376 ); +ide_init2 (&d->bus[0 ], hd_table[0 ], hd_table[1 ], pic[14 ]); +ide_init2 (&d->bus[1 ], hd_table[2 ], hd_table[3 ], pic[15 ]); +ide_init_ioport (&d->bus[0 ],0x1f0 ,0x3f6 ); +ide_init_ioport (&d->bus[1 ],0x170 ,0x376 );register_savevm ("ide" ,0 ,3 , pci_ide_save, pci_ide_load, d); }
@@ -3663,7 +3690,7 @@ void pci_piix4_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,/* MacIO based PowerPC IDE */ typedef struct MACIOIDEState { -IDEState ide_if[2 ]; +IDEBus bus;BlockDriverAIOCB *aiocb; }MACIOIDEState ;
@@ -3671,7 +3698,7 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) {DBDMA_io *io = opaque;MACIOIDEState *m = io->opaque; -IDEState *s = m->ide_if->cur_drive; +IDEState *s =idebus_active_if (&m->bus);if (ret <0 ) { m->aiocb =NULL ;
@@ -3726,7 +3753,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret) {DBDMA_io *io = opaque;MACIOIDEState *m = io->opaque; -IDEState *s = m->ide_if->cur_drive; +IDEState *s =idebus_active_if (&m->bus);int n;int64_t sector_num;
@@ -3784,7 +3811,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)static void pmac_ide_transfer (DBDMA_io *io) {MACIOIDEState *m = io->opaque; -IDEState *s = m->ide_if->cur_drive; +IDEState *s =idebus_active_if (&m->bus); s->io_buffer_size =0 ;if (s->is_cdrom) {
@@ -3812,11 +3839,11 @@ static void pmac_ide_writeb (void *opaque, addr = (addr &0xFFF ) >>4 ;switch (addr) { case 1 ... 7: -ide_ioport_write (d->ide_if, addr, val); +ide_ioport_write (&d->bus, addr, val);break ;case 8 :case 22 : -ide_cmd_write (d->ide_if,0 , val); +ide_cmd_write (&d->bus,0 , val);break ;default :break ;
@@ -3831,11 +3858,11 @@ static uint32_t pmac_ide_readb (void *opaque,target_phys_addr_t addr) addr = (addr &0xFFF ) >>4 ;switch (addr) { case 1 ... 7: - retval =ide_ioport_read (d->ide_if, addr); + retval =ide_ioport_read (&d->bus, addr);break ;case 8 :case 22 : - retval =ide_status_read (d->ide_if,0 ); + retval =ide_status_read (&d->bus,0 );break ;default : retval =0xFF ;
@@ -3854,7 +3881,7 @@ static void pmac_ide_writew (void *opaque, val =bswap16 (val);#endif if (addr ==0 ) { -ide_data_writew (d->ide_if,0 , val); +ide_data_writew (&d->bus,0 , val); } }
@@ -3865,7 +3892,7 @@ static uint32_t pmac_ide_readw (void *opaque,target_phys_addr_t addr) addr = (addr &0xFFF ) >>4 ;if (addr ==0 ) { - retval =ide_data_readw (d->ide_if,0 ); + retval =ide_data_readw (&d->bus,0 ); }else { retval =0xFFFF ; }
@@ -3885,7 +3912,7 @@ static void pmac_ide_writel (void *opaque, val =bswap32 (val);#endif if (addr ==0 ) { -ide_data_writel (d->ide_if,0 , val); +ide_data_writel (&d->bus,0 , val); } }
@@ -3896,7 +3923,7 @@ static uint32_t pmac_ide_readl (void *opaque,target_phys_addr_t addr) addr = (addr &0xFFF ) >>4 ;if (addr ==0 ) { - retval =ide_data_readl (d->ide_if,0 ); + retval =ide_data_readl (&d->bus,0 ); }else { retval =0xFFFFFFFF ; }
@@ -3921,39 +3948,31 @@ static CPUReadMemoryFunc * const pmac_ide_read[] = {static void pmac_ide_save (QEMUFile *f,void *opaque) {MACIOIDEState *d = opaque; -IDEState *s = d->ide_if; -uint8_t drive1_selected;unsigned int i;/* per IDE interface data */ -qemu_put_8s (f, &s->cmd); - drive1_selected = (s->cur_drive != s); -qemu_put_8s (f, &drive1_selected); +idebus_save (f, &d->bus);/* per IDE drive data */ for (i =0 ; i <2 ; i++) { -ide_save (f, &s[i]); +ide_save (f, &d->bus.ifs[i]); } }static int pmac_ide_load (QEMUFile *f,void *opaque,int version_id) {MACIOIDEState *d = opaque; -IDEState *s = d->ide_if; -uint8_t drive1_selected;unsigned int i;if (version_id !=1 && version_id !=3 )return -EINVAL ;/* per IDE interface data */ -qemu_get_8s (f, &s->cmd); -qemu_get_8s (f, &drive1_selected); - s->cur_drive = &s[(drive1_selected !=0 )]; +idebus_load (f, &d->bus, version_id);/* per IDE drive data */ for (i =0 ; i <2 ; i++) { -ide_load (f, &s[i], version_id); +ide_load (f, &d->bus.ifs[i], version_id); }return 0 ; }
@@ -3961,10 +3980,9 @@ static int pmac_ide_load(QEMUFile *f, void *opaque, int version_id)static void pmac_ide_reset (void *opaque) {MACIOIDEState *d = opaque; -IDEState *s = d->ide_if; -ide_reset (&s[0 ]); -ide_reset (&s[1 ]); +ide_reset (d->bus.ifs +0 ); +ide_reset (d->bus.ifs +1 ); }/* hd_table must contain 4 block drivers */
@@ -3977,7 +3995,7 @@ int pmac_ide_init (BlockDriverState **hd_table, qemu_irq irq,int pmac_ide_memory; d =qemu_mallocz (sizeof (MACIOIDEState)); -ide_init2 (d->ide_if, hd_table[0 ], hd_table[1 ], irq); +ide_init2 (&d->bus, hd_table[0 ], hd_table[1 ], irq);if (dbdma)DBDMA_register_channel (dbdma, channel, dma_irq, pmac_ide_transfer, pmac_ide_flush, d);
@@ -3999,31 +4017,31 @@ int pmac_ide_init (BlockDriverState **hd_table, qemu_irq irq,*/ typedef struct { -void *dev; +IDEBus *bus;int shift; }MMIOState ;static uint32_t mmio_ide_read (void *opaque,target_phys_addr_t addr) {MMIOState *s = (MMIOState *)opaque; -IDEState *ide = (IDEState *)s->dev; +IDEBus *bus = s->bus; addr >>= s->shift;if (addr &7 ) -return ide_ioport_read (ide, addr); +return ide_ioport_read (bus, addr);else -return ide_data_readw (ide,0 ); +return ide_data_readw (bus,0 ); }static void mmio_ide_write (void *opaque,target_phys_addr_t addr,uint32_t val) {MMIOState *s = (MMIOState *)opaque; -IDEState *ide = (IDEState *)s->dev; +IDEBus *bus = s->bus; addr >>= s->shift;if (addr &7 ) -ide_ioport_write (ide, addr, val); +ide_ioport_write (bus, addr, val);else -ide_data_writew (ide,0 , val); +ide_data_writew (bus,0 , val); }static CPUReadMemoryFunc *const mmio_ide_reads[] = {
@@ -4041,16 +4059,16 @@ static CPUWriteMemoryFunc * const mmio_ide_writes[] = {static uint32_t mmio_ide_status_read (void *opaque,target_phys_addr_t addr) {MMIOState *s= (MMIOState *)opaque; -IDEState *ide = (IDEState *)s->dev; -return ide_status_read (ide,0 ); +IDEBus *bus = s->bus; +return ide_status_read (bus,0 ); }static void mmio_ide_cmd_write (void *opaque,target_phys_addr_t addr,uint32_t val) {MMIOState *s = (MMIOState *)opaque; -IDEState *ide = (IDEState *)s->dev; -ide_cmd_write (ide,0 , val); +IDEBus *bus = s->bus; +ide_cmd_write (bus,0 , val); }static CPUReadMemoryFunc *const mmio_ide_status[] = {
@@ -4070,12 +4088,12 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2, BlockDriverState *hd0, BlockDriverState *hd1) {MMIOState *s =qemu_mallocz (sizeof (MMIOState)); -IDEState *ide =qemu_mallocz (sizeof (IDEState) *2 ); +IDEBus *bus =qemu_mallocz (sizeof (*bus));int mem1, mem2; -ide_init2 (ide, hd0, hd1, irq); +ide_init2 (bus, hd0, hd1, irq); - s->dev = ide; + s->bus = bus; s->shift = shift; mem1 =cpu_register_io_memory (mmio_ide_reads, mmio_ide_writes, s);
@@ -4091,7 +4109,7 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2,/* DSCM-1XXXX Microdrive hard disk with CF+ II / PCMCIA interface. */ typedef struct { - IDEState ide[2]; + IDEBus bus; PCMCIACardState card; uint32_t attr_base; uint32_t io_base;
@@ -4162,7 +4180,7 @@ static void md_reset(MicroDriveState *s) s->pins =0 ; s->cycle =0 ; s->ctrl =0 ; -ide_reset (s->ide); +ide_reset (s->bus.ifs); }static uint8_t md_attr_read (void *opaque,uint32_t at)
@@ -4232,6 +4250,7 @@ static void md_attr_write(void *opaque, uint32_t at, uint8_t value)static uint16_t md_common_read (void *opaque,uint32_t at) {MicroDriveState *s = (MicroDriveState *) opaque; +IDEState *ifs;uint16_t ret; at -= s->io_base;
@@ -4259,13 +4278,13 @@ static uint16_t md_common_read(void *opaque, uint32_t at)switch (at) {case 0x0 :/* Even RD Data */ case 0x8 : -return ide_data_readw (s->ide,0 ); +return ide_data_readw (&s->bus,0 );/* TODO: 8-bit accesses */ if (s->cycle) ret = s->io >>8 ;else { - s->io =ide_data_readw (s->ide,0 ); + s->io =ide_data_readw (&s->bus,0 ); ret = s->io &0xff ; } s->cycle = !s->cycle;
@@ -4273,16 +4292,18 @@ static uint16_t md_common_read(void *opaque, uint32_t at)case 0x9 :/* Odd RD Data */ return s->io >>8 ;case 0xd :/* Error */ -return ide_ioport_read (s->ide,0x1 ); +return ide_ioport_read (&s->bus,0x1 );case 0xe :/* Alternate Status */ -if (s->ide->cur_drive->bs) -return s->ide->cur_drive->status; + ifs =idebus_active_if (&s->bus); +if (ifs->bs) +return ifs->status;else return 0 ;case 0xf :/* Device Address */ -return 0xc2 | ((~s->ide->select <<2 ) &0x3c ); + ifs =idebus_active_if (&s->bus); +return 0xc2 | ((~ifs->select <<2 ) &0x3c );default : -return ide_ioport_read (s->ide, at); +return ide_ioport_read (&s->bus, at); }return 0 ;
@@ -4317,12 +4338,12 @@ static void md_common_write(void *opaque, uint32_t at, uint16_t value)switch (at) {case 0x0 :/* Even WR Data */ case 0x8 : -ide_data_writew (s->ide,0 , value); +ide_data_writew (&s->bus,0 , value);break ;/* TODO: 8-bit accesses */ if (s->cycle) -ide_data_writew (s->ide,0 , s->io | (value <<8 )); +ide_data_writew (&s->bus,0 , s->io | (value <<8 ));else s->io = value &0xff ; s->cycle = !s->cycle;
@@ -4332,7 +4353,7 @@ static void md_common_write(void *opaque, uint32_t at, uint16_t value) s->cycle = !s->cycle;break ;case 0xd :/* Features */ -ide_ioport_write (s->ide,0x1 , value); +ide_ioport_write (&s->bus,0x1 , value);break ;case 0xe :/* Device Control */ s->ctrl = value;
@@ -4345,7 +4366,7 @@ static void md_common_write(void *opaque, uint32_t at, uint16_t value) s->pins |=PINS_CRDY ; s->stat &= ~STAT_PWRDWN ; } -ide_ioport_write (s->ide, at, value); +ide_ioport_write (&s->bus, at, value); } }
@@ -4353,7 +4374,6 @@ static void md_save(QEMUFile *f, void *opaque) {MicroDriveState *s = (MicroDriveState *) opaque;int i; -uint8_t drive1_selected;qemu_put_8s (f, &s->opt);qemu_put_8s (f, &s->stat);
@@ -4363,19 +4383,16 @@ static void md_save(QEMUFile *f, void *opaque)qemu_put_be16s (f, &s->io);qemu_put_byte (f, s->cycle); - drive1_selected = (s->ide->cur_drive != s->ide); -qemu_put_8s (f, &s->ide->cmd); -qemu_put_8s (f, &drive1_selected); +idebus_save (f, &s->bus);for (i =0 ; i <2 ; i ++) -ide_save (f, &s->ide[i]); +ide_save (f, &s->bus.ifs[i]); }static int md_load (QEMUFile *f,void *opaque,int version_id) {MicroDriveState *s = (MicroDriveState *) opaque;int i; -uint8_t drive1_selected;if (version_id !=0 && version_id !=3 )return -EINVAL ;
@@ -4388,12 +4405,10 @@ static int md_load(QEMUFile *f, void *opaque, int version_id)qemu_get_be16s (f, &s->io); s->cycle =qemu_get_byte (f); -qemu_get_8s (f, &s->ide->cmd); -qemu_get_8s (f, &drive1_selected); - s->ide->cur_drive = &s->ide[(drive1_selected !=0 )]; +idebus_load (f, &s->bus, version_id);for (i =0 ; i <2 ; i ++) -ide_load (f, &s->ide[i], version_id); +ide_load (f, &s->bus.ifs[i], version_id);return 0 ; }
@@ -4619,10 +4634,10 @@ PCMCIACardState *dscm1xxxx_init(BlockDriverState *bdrv) md->card.cis = dscm1xxxx_cis; md->card.cis_len =sizeof (dscm1xxxx_cis); -ide_init2 (md->ide, bdrv,NULL ,qemu_allocate_irqs (md_set_irq, md,1 )[0 ]); - md->ide->is_cf =1 ; - md->ide->mdata_size =METADATA_SIZE ; - md->ide->mdata_storage = (uint8_t *)qemu_mallocz (METADATA_SIZE ); +ide_init2 (&md->bus, bdrv,NULL ,qemu_allocate_irqs (md_set_irq, md,1 )[0 ]); + md->bus.ifs[0 ].is_cf =1 ; + md->bus.ifs[0 ].mdata_size =METADATA_SIZE ; + md->bus.ifs[0 ].mdata_storage = (uint8_t *)qemu_mallocz (METADATA_SIZE );register_savevm ("microdrive" ,-1 ,3 , md_save, md_load, md);
Signature · 1 line
1.6.2.5
PATCH 10/11 ide: move code to hw/ide/
In reply to Gerd Hoffmann---
Makefile.target | 12 ++++++------
configure | 1 +
hw/{ide.c => ide/core.c} | 12 ++++++------
hw/{ide-internal.h => ide/internal.h} | 4 ++--
hw/{ide-isa.c => ide/isa.c} | 7 ++++---
hw/{ide-macio.c => ide/macio.c} | 9 +++++----
hw/{ide-microdrive.c => ide/microdrive.c} | 9 +++++----
hw/{ide-mmio.c => ide/mmio.c} | 5 +++--
hw/{ide-pci.c => ide/pci.c} | 9 +++++----
9 files changed, 37 insertions(+), 31 deletions(-)
rename hw/{ide.c => ide/core.c} (99%)
rename hw/{ide-internal.h => ide/internal.h} (99%)
rename hw/{ide-isa.c => ide/isa.c} (97%)
rename hw/{ide-macio.c => ide/macio.c} (98%)
rename hw/{ide-microdrive.c => ide/microdrive.c} (99%)
rename hw/{ide-mmio.c => ide/mmio.c} (98%)
rename hw/{ide-pci.c => ide/pci.c} (99%)Makefile.target +6 -6
@@ -187,14 +187,14 @@ obj-y += e1000.o obj-y += wdt_ib700.o wdt_i6300esb.o # Hardware support -obj-i386-y = ide.o ide-isa.o ide-pci.o pckbd.o vga.o $(sound-obj-y) dma.o isa-bus.o +obj-i386-y = ide/core.o ide/isa.o ide/pci.o pckbd.o vga.o $(sound-obj-y) dma.o isa-bus.o obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o # shared objects -obj-ppc-y = ppc.o ide.o ide-isa.o ide-pci.o ide-macio.o +obj-ppc-y = ppc.o ide/core.o ide/isa.o ide/pci.o ide/macio.o obj-ppc-y += vga.o $(sound-obj-y) dma.o isa-bus.o openpic.o # PREP target obj-ppc-y += pckbd.o serial.o i8259.o i8254.o fdc.o mc146818rtc.o
@@ -216,7 +216,7 @@ obj-ppc-$(CONFIG_FDT) += device_tree.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o rc4030.o obj-mips-y += g364fb.o jazz_led.o dp8393x.o -obj-mips-y += ide.o ide-isa.o ide-pci.o +obj-mips-y += ide/core.o ide/isa.o ide/pci.o obj-mips-y += gt64xxx.o pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o obj-mips-y += piix_pci.o parallel.o cirrus_vga.o isa-bus.o pcspk.o $(sound-obj-y) obj-mips-y += mipsnet.o
@@ -248,7 +248,7 @@ obj-cris-y += etraxfs_ser.o obj-cris-y += pflash_cfi02.o ifeq ($(TARGET_ARCH), sparc64) -obj-sparc-y = sun4u.o ide.o ide-pci.o isa-bus.o pckbd.o vga.o apb_pci.o +obj-sparc-y = sun4u.o ide/core.o ide/pci.o isa-bus.o pckbd.o vga.o apb_pci.o obj-sparc-y += fdc.o mc146818rtc.o serial.o obj-sparc-y += cirrus_vga.o parallel.o else
@@ -267,7 +267,7 @@ obj-arm-y += arm-semi.o obj-arm-y += pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o obj-arm-y += pflash_cfi01.o gumstix.o -obj-arm-y += zaurus.o ide.o ide-microdrive.o serial.o spitz.o tosa.o tc6393xb.o +obj-arm-y += zaurus.o ide/core.o ide/microdrive.o serial.o spitz.o tosa.o tc6393xb.o obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o obj-arm-y += omap2.o omap_dss.o soc_dma.o obj-arm-y += omap_sx1.o palm.o tsc210x.o
@@ -281,7 +281,7 @@ obj-arm-y += syborg_virtio.o obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o serial.o -obj-sh4-y += ide.o ide-mmio.o +obj-sh4-y += ide/core.o ide/mmio.o obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o obj-m68k-y += m68k-semi.o dummy_m68k.o
configure +1 -0
@@ -1834,6 +1834,7 @@ test -f $config_h && mv $config_h ${config_h}~ mkdir -p $target_dir mkdir -p $target_dir/fpu mkdir -p $target_dir/tcg +mkdir -p $target_dir/ide if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then mkdir -p $target_dir/nwfpe fi
hw/ide/core.c renamed from hw/ide.c +6 -6
@@ -22,18 +22,18 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "hw.h" -#include "pc.h" -#include "pci.h" -#include "scsi-disk.h" +#include <hw/hw.h> +#include <hw/pc.h> +#include <hw/pci.h> +#include <hw/scsi-disk.h> +#include <hw/sh.h> #include "block.h" #include "block_int.h" #include "qemu-timer.h" #include "sysemu.h" -#include "sh.h" #include "dma.h" -#include "ide-internal.h" +#include <hw/ide/internal.h> static int smart_attributes[][5 ] = {/* id, flags, val, wrst, thrsh */
hw/ide/internal.h renamed from hw/ide-internal.h +2 -2
@@ -3,10 +3,10 @@/* * QEMU IDE Emulation -- internal header file -* only hw/ide*.c is supposed to include this file. +* only files in hw/ide/ are supposed to include this file. * non-internal declarations are in hw/ide.h */ -#include "ide.h" +#include <hw/ide.h> /* debug IDE devices */ //#define DEBUG_IDE
hw/ide/isa.c renamed from hw/ide-isa.c +4 -3
@@ -22,13 +22,14 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "hw.h" -#include "pc.h" +#include <hw/hw.h> +#include <hw/pc.h> #include "block.h" #include "block_int.h" #include "sysemu.h" #include "dma.h" -#include "ide-internal.h" + +#include <hw/ide/internal.h> /***********************************************************/ /* ISA IDE definitions */
hw/ide/macio.c renamed from hw/ide-macio.c +5 -4
@@ -22,14 +22,15 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "hw.h" +#include <hw/hw.h> +#include <hw/ppc_mac.h> +#include <hw/mac_dbdma.h> #include "block.h" #include "block_int.h" #include "sysemu.h" #include "dma.h" -#include "ppc_mac.h" -#include "mac_dbdma.h" -#include "ide-internal.h" + +#include <hw/ide/internal.h> /***********************************************************/ /* MacIO based PowerPC IDE */
hw/ide/microdrive.c renamed from hw/ide-microdrive.c +5 -4
@@ -22,14 +22,15 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "hw.h" -#include "pc.h" +#include <hw/hw.h> +#include <hw/pc.h> +#include <hw/pcmcia.h> #include "block.h" #include "block_int.h" #include "sysemu.h" #include "dma.h" -#include "ide-internal.h" -#include "pcmcia.h" + +#include <hw/ide/internal.h> /***********************************************************/ /* CF-ATA Microdrive */
hw/ide/mmio.c renamed from hw/ide-mmio.c +3 -2
@@ -22,12 +22,13 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "hw.h" +#include <hw/hw.h> #include "block.h" #include "block_int.h" #include "sysemu.h" #include "dma.h" -#include "ide-internal.h" + +#include <hw/ide/internal.h> /***********************************************************/ /* MMIO based ide port
hw/ide/pci.c renamed from hw/ide-pci.c +5 -4
@@ -22,14 +22,15 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "hw.h" -#include "pc.h" +#include <hw/hw.h> +#include <hw/pc.h> +#include <hw/pci.h> #include "block.h" #include "block_int.h" #include "sysemu.h" #include "dma.h" -#include "pci.h" -#include "ide-internal.h" + +#include <hw/ide/internal.h> /***********************************************************/ /* PCI IDE definitions */
Signature · 1 line
1.6.2.5
PATCH 11/11 ide: pass down DriveInfo instead of BlockDriverState
In reply to Gerd Hoffmann--- hw/ide.h | 12 ++++++------ hw/ide/core.c | 7 +++++-- hw/ide/internal.h | 2 +- hw/ide/isa.c | 2 +- hw/ide/macio.c | 2 +- hw/ide/microdrive.c | 2 +- hw/ide/mmio.c | 2 +- hw/ide/pci.c | 11 +++-------- hw/mips_malta.c | 5 ++--- hw/mips_r4k.c | 5 ++--- hw/pc.c | 15 +++++++-------- hw/pcmcia.h | 3 ++- hw/ppc_newworld.c | 6 ++---- hw/ppc_oldworld.c | 15 +++++---------- hw/ppc_prep.c | 5 ++--- hw/r2d.c | 2 +- hw/spitz.c | 2 +- hw/sun4u.c | 5 ++--- hw/tosa.c | 2 +- 19 files changed, 46 insertions(+), 59 deletions(-)
hw/ide.h +6 -6
@@ -5,23 +5,23 @@/* ide-isa.c */ void isa_ide_init (int iobase,int iobase2,qemu_irq irq, -BlockDriverState *hd0,BlockDriverState *hd1); +DriveInfo *hd0,DriveInfo *hd1);/* ide-pci.c */ -void pci_cmd646_ide_init (PCIBus *bus,BlockDriverState **hd_table, +void pci_cmd646_ide_init (PCIBus *bus,DriveInfo **hd_table,int secondary_ide_enabled); -void pci_piix3_ide_init (PCIBus *bus,BlockDriverState **hd_table,int devfn, +void pci_piix3_ide_init (PCIBus *bus,DriveInfo **hd_table,int devfn,qemu_irq *pic); -void pci_piix4_ide_init (PCIBus *bus,BlockDriverState **hd_table,int devfn, +void pci_piix4_ide_init (PCIBus *bus,DriveInfo **hd_table,int devfn,qemu_irq *pic);/* ide-macio.c */ -int pmac_ide_init (BlockDriverState **hd_table,qemu_irq irq, +int pmac_ide_init (DriveInfo **hd_table,qemu_irq irq,void *dbdma,int channel,qemu_irq dma_irq);/* ide-mmio.c */ void mmio_ide_init (target_phys_addr_t membase,target_phys_addr_t membase2,qemu_irq irq,int shift, -BlockDriverState *hd0,BlockDriverState *hd1); +DriveInfo *hd0,DriveInfo *hd1);#endif /* HW_IDE_H */
hw/ide/core.c +5 -2
@@ -2506,7 +2506,7 @@ void ide_reset(IDEState *s) s->media_changed =0 ; } -void ide_init2 (IDEBus *bus,BlockDriverState *hd0,BlockDriverState *hd1, +void ide_init2 (IDEBus *bus,DriveInfo *hd0,DriveInfo *hd1,qemu_irq irq) {IDEState *s;
@@ -2518,7 +2518,10 @@ void ide_init2(IDEBus *bus, BlockDriverState *hd0, BlockDriverState *hd1, s = bus->ifs + i; s->bus = bus; s->unit = i; - s->bs = (i ==0 ) ? hd0 : hd1; +if (i ==0 && hd0) + s->bs = hd0->bdrv; +if (i ==1 && hd1) + s->bs = hd1->bdrv; s->io_buffer =qemu_blockalign (s->bs,IDE_DMA_BUF_SECTORS *512 +4 );if (s->bs) {bdrv_get_geometry (s->bs, &nb_sectors);
hw/ide/internal.h +1 -1
@@ -522,7 +522,7 @@ uint32_t ide_data_readw(void *opaque, uint32_t addr);void ide_data_writel (void *opaque,uint32_t addr,uint32_t val);uint32_t ide_data_readl (void *opaque,uint32_t addr); -void ide_init2 (IDEBus *bus,BlockDriverState *hd0,BlockDriverState *hd1, +void ide_init2 (IDEBus *bus,DriveInfo *hd0,DriveInfo *hd1,qemu_irq irq);void ide_init_ioport (IDEBus *bus,int iobase,int iobase2);
hw/ide/isa.c +1 -1
@@ -58,7 +58,7 @@ static int isa_ide_load(QEMUFile* f, void *opaque, int version_id) }void isa_ide_init (int iobase,int iobase2,qemu_irq irq, -BlockDriverState *hd0,BlockDriverState *hd1) +DriveInfo *hd0,DriveInfo *hd1) {ISAIDEState *s;
hw/ide/macio.c +1 -1
@@ -334,7 +334,7 @@ static void pmac_ide_reset(void *opaque)/* hd_table must contain 4 block drivers */ /* PowerMac uses memory mapped registers, not I/O. Return the memory I/O index to access the ide. */ -int pmac_ide_init (BlockDriverState **hd_table,qemu_irq irq, +int pmac_ide_init (DriveInfo **hd_table,qemu_irq irq,void *dbdma,int channel,qemu_irq dma_irq) {MACIOIDEState *d;
hw/ide/microdrive.c +1 -1
@@ -555,7 +555,7 @@ static int dscm1xxxx_detach(void *opaque)return 0 ; } -PCMCIACardState *dscm1xxxx_init (BlockDriverState *bdrv) +PCMCIACardState *dscm1xxxx_init (DriveInfo *bdrv) {MicroDriveState *md = (MicroDriveState *)qemu_mallocz (sizeof (MicroDriveState)); md->card.state = md;
hw/ide/mmio.c +1 -1
@@ -124,7 +124,7 @@ static int mmio_ide_load(QEMUFile* f, void *opaque, int version_id)void mmio_ide_init (target_phys_addr_t membase,target_phys_addr_t membase2,qemu_irq irq,int shift, -BlockDriverState *hd0,BlockDriverState *hd1) +DriveInfo *hd0,DriveInfo *hd1) {MMIOState *s =qemu_mallocz (sizeof (MMIOState));IDEBus *bus =qemu_mallocz (sizeof (*bus));
hw/ide/pci.c +3 -8
@@ -375,7 +375,7 @@ static void cmd646_reset(void *opaque) }/* CMD646 PCI IDE controller */ -void pci_cmd646_ide_init (PCIBus *bus,BlockDriverState **hd_table, +void pci_cmd646_ide_init (PCIBus *bus,DriveInfo **hd_table,int secondary_ide_enabled) {PCIIDEState *d;
@@ -443,12 +443,11 @@ static void piix3_reset(void *opaque)/* hd_table must contain 4 block drivers */ /* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */ -void pci_piix3_ide_init (PCIBus *bus,BlockDriverState **hd_table,int devfn, +void pci_piix3_ide_init (PCIBus *bus,DriveInfo **hd_table,int devfn,qemu_irq *pic) {PCIIDEState *d;uint8_t *pci_conf; -int i;/* register a function 1 of PIIX3 */ d = (PCIIDEState *)pci_register_device(bus, "PIIX3 IDE",
@@ -475,16 +474,12 @@ void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,ide_init_ioport (&d->bus[0 ],0x1f0 ,0x3f6 );ide_init_ioport (&d->bus[1 ],0x170 ,0x376 ); -for (i =0 ; i <4 ; i++) -if (hd_table[i]) - hd_table[i]->private = &d->dev; -register_savevm ("ide" ,0 ,3 , pci_ide_save, pci_ide_load, d); }/* hd_table must contain 4 block drivers */ /* NOTE: for the PIIX4, the IRQs and IOports are hardcoded */ -void pci_piix4_ide_init (PCIBus *bus,BlockDriverState **hd_table,int devfn, +void pci_piix4_ide_init (PCIBus *bus,DriveInfo **hd_table,int devfn,qemu_irq *pic) {PCIIDEState *d;
hw/mips_malta.c +2 -3
@@ -775,7 +775,7 @@ void mips_malta_init (ram_addr_t ram_size,i2c_bus *smbus;int i;DriveInfo *dinfo; -BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; +DriveInfo *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];BlockDriverState *fd[MAX_FD ];int fl_idx =0 ;int fl_sectors =0 ;
@@ -899,8 +899,7 @@ void mips_malta_init (ram_addr_t ram_size, }for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { - dinfo =drive_get (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); - hd[i] = dinfo ? dinfo->bdrv :NULL ; + hd[i] =drive_get (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); } piix4_devfn =piix4_init (pci_bus,80 );
hw/mips_r4k.c +2 -3
@@ -156,7 +156,7 @@ void mips_r4k_init (ram_addr_t ram_size,RTCState *rtc_state;int i;qemu_irq *i8259; -BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; +DriveInfo *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];DriveInfo *dinfo;/* init CPUs */
@@ -268,8 +268,7 @@ void mips_r4k_init (ram_addr_t ram_size, }for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { - dinfo =drive_get (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); - hd[i] = dinfo ? dinfo->bdrv :NULL ; + hd[i] =drive_get (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); }for (i =0 ; i <MAX_IDE_BUS ; i++)
hw/pc.c +7 -8
@@ -264,7 +264,7 @@ static int pc_boot_set(void *opaque, const char *boot_device)/* hd_table must contain 4 block drivers */ static void cmos_init (ram_addr_t ram_size,ram_addr_t above_4g_mem_size, -const char *boot_device,BlockDriverState **hd_table) +const char *boot_device,DriveInfo **hd_table) {RTCState *s = rtc_state;int nbds, bds[3 ] = {0 , };
@@ -355,9 +355,9 @@ static void cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,rtc_set_memory (s,0x12 , (hd_table[0 ] ?0xf0 :0 ) | (hd_table[1 ] ?0x0f :0 ));if (hd_table[0 ]) -cmos_init_hd (0x19 ,0x1b , hd_table[0 ]); +cmos_init_hd (0x19 ,0x1b , hd_table[0 ]->bdrv);if (hd_table[1 ]) -cmos_init_hd (0x1a ,0x24 , hd_table[1 ]); +cmos_init_hd (0x1a ,0x24 , hd_table[1 ]->bdrv); val =0 ;for (i =0 ; i <4 ; i++) {
@@ -367,9 +367,9 @@ static void cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,geometry. It is always such that: 1 <= sects <= 63, 1 <= heads <= 16, 1 <= cylinders <= 16383. The BIOS geometry can be different if a translation is done. */ - translation =bdrv_get_translation_hint (hd_table[i]); + translation =bdrv_get_translation_hint (hd_table[i]->bdrv);if (translation ==BIOS_ATA_TRANSLATION_AUTO ) { -bdrv_get_geometry_hint (hd_table[i], &cylinders, &heads, §ors); +bdrv_get_geometry_hint (hd_table[i]->bdrv, &cylinders, &heads, §ors);if (cylinders <=1024 && heads <=16 && sectors <=63 ) {/* No translation. */ translation =0 ;
@@ -1131,7 +1131,7 @@ static void pc_init1(ram_addr_t ram_size,qemu_irq *i8259;IsaIrqState *isa_irq_state;DriveInfo *dinfo; -BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; +DriveInfo *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];BlockDriverState *fd[MAX_FD ];int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled;void *fw_cfg;
@@ -1359,8 +1359,7 @@ static void pc_init1(ram_addr_t ram_size, }for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { - dinfo =drive_get (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); - hd[i] = dinfo ? dinfo->bdrv :NULL ; + hd[i] =drive_get (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); }if (pci_enabled) {
hw/pcmcia.h +2 -1
@@ -1,6 +1,7 @@/* PCMCIA/Cardbus */ #include "qemu-common.h" +#include "sysemu.h" typedef struct { qemu_irq irq;
@@ -48,4 +49,4 @@ struct PCMCIACardState {#define CISTPL_ENDMARK 0xff/* dscm1xxxx.c */ -PCMCIACardState *dscm1xxxx_init (BlockDriverState *bdrv); +PCMCIACardState *dscm1xxxx_init (DriveInfo *bdrv);
hw/ppc_newworld.c +2 -4
@@ -107,8 +107,7 @@ static void ppc_core99_init (ram_addr_t ram_size,qemu_irq *dummy_irq;int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index;int ppc_boot_device; -DriveInfo *dinfo; -BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; +DriveInfo *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];void *fw_cfg;void *dbdma;uint8_t *vga_bios_ptr;
@@ -316,8 +315,7 @@ static void ppc_core99_init (ram_addr_t ram_size,exit (1 ); }for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { - dinfo =drive_get (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); - hd[i] = dinfo ? dinfo->bdrv :NULL ; + hd[i] =drive_get (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); } dbdma =DBDMA_init (&dbdma_mem_index);pci_cmd646_ide_init (pci_bus, hd,0 );
hw/ppc_oldworld.c +5 -10
@@ -137,8 +137,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,int pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index;int escc_mem_index, ide_mem_index[2 ];uint16_t ppc_boot_device; -BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; -DriveInfo *dinfo; +DriveInfo *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];void *fw_cfg;void *dbdma;uint8_t *vga_bios_ptr;
@@ -331,19 +330,15 @@ static void ppc_heathrow_init (ram_addr_t ram_size, }/* First IDE channel is a MAC IDE on the MacIO bus */ - dinfo =drive_get (IF_IDE ,0 ,0 ); - hd[0 ] = dinfo ? dinfo->bdrv :NULL ; - dinfo =drive_get (IF_IDE ,0 ,1 ); - hd[1 ] = dinfo ? dinfo->bdrv :NULL ; + hd[0 ] =drive_get (IF_IDE ,0 ,0 ); + hd[1 ] =drive_get (IF_IDE ,0 ,1 ); dbdma =DBDMA_init (&dbdma_mem_index); ide_mem_index[0 ] =-1 ; ide_mem_index[1 ] =pmac_ide_init (hd, pic[0x0D ], dbdma,0x16 , pic[0x02 ]);/* Second IDE channel is a CMD646 on the PCI bus */ - dinfo =drive_get (IF_IDE ,1 ,0 ); - hd[0 ] = dinfo ? dinfo->bdrv :NULL ; - dinfo =drive_get (IF_IDE ,1 ,1 ); - hd[1 ] = dinfo ? dinfo->bdrv :NULL ; + hd[0 ] =drive_get (IF_IDE ,1 ,0 ); + hd[1 ] =drive_get (IF_IDE ,1 ,1 ); hd[3 ] = hd[2 ] =NULL ;pci_cmd646_ide_init (pci_bus, hd,0 );
hw/ppc_prep.c +2 -3
@@ -563,7 +563,7 @@ static void ppc_prep_init (ram_addr_t ram_size,qemu_irq *i8259;int ppc_boot_device;DriveInfo *dinfo; -BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; +DriveInfo *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];BlockDriverState *fd[MAX_FD ]; sysctrl =qemu_mallocz (sizeof (sysctrl_t));
@@ -703,8 +703,7 @@ static void ppc_prep_init (ram_addr_t ram_size, }for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { - dinfo =drive_get (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); - hd[i] = dinfo ? dinfo->bdrv :NULL ; + hd[i] =drive_get (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); }for (i =0 ; i <MAX_IDE_BUS ; i++) {
hw/r2d.c +1 -1
@@ -229,7 +229,7 @@ static void r2d_init(ram_addr_t ram_size,/* onboard CF (True IDE mode, Master only). */ if ((dinfo =drive_get (IF_IDE ,0 ,0 )) !=NULL )mmio_ide_init (0x14001000 ,0x1400080c , irq[CF_IDE ],1 , - dinfo->bdrv,NULL ); + dinfo,NULL );/* NIC: rtl8139 on-board, and 2 slots. */ for (i =0 ; i < nb_nics; i++)
hw/spitz.c +1 -1
@@ -752,7 +752,7 @@ static void spitz_microdrive_attach(PXA2xxState *cpu, int slot)return ; bs = dinfo->bdrv;if (bdrv_is_inserted (bs) && !bdrv_is_removable (bs)) { - md =dscm1xxxx_init (bs); + md =dscm1xxxx_init (dinfo);pxa2xx_pcmcia_attach (cpu->pcmcia[slot], md); } }
hw/sun4u.c +2 -3
@@ -555,7 +555,7 @@ static void sun4uv_init(ram_addr_t RAM_size,long initrd_size, kernel_size;PCIBus *pci_bus, *pci_bus2, *pci_bus3;qemu_irq *irq; -BlockDriverState *hd[MAX_IDE_BUS *MAX_IDE_DEVS ]; +DriveInfo *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];BlockDriverState *fd[MAX_FD ];void *fw_cfg;DriveInfo *dinfo;
@@ -606,9 +606,8 @@ static void sun4uv_init(ram_addr_t RAM_size,exit (1 ); }for (i =0 ; i <MAX_IDE_BUS *MAX_IDE_DEVS ; i++) { - dinfo =drive_get (IF_IDE , i /MAX_IDE_DEVS , + hd[i] =drive_get (IF_IDE , i /MAX_IDE_DEVS , i %MAX_IDE_DEVS ); - hd[i] = dinfo ? dinfo->bdrv :NULL ; }pci_cmd646_ide_init (pci_bus, hd,1 );
hw/tosa.c +1 -1
@@ -57,7 +57,7 @@ static void tosa_microdrive_attach(PXA2xxState *cpu)return ; bs = dinfo->bdrv;if (bdrv_is_inserted (bs) && !bdrv_is_removable (bs)) { - md =dscm1xxxx_init (bs); + md =dscm1xxxx_init (dinfo);pxa2xx_pcmcia_attach (cpu->pcmcia[0 ], md); } }
Signature · 1 line
1.6.2.5
PATCH 7/11 ide: split away ide-microdrive.c
In reply to Gerd Hoffmanncreate ide-microdrive.c and place microdrive support there. only build ide-microdrive support for platforms using it.
--- Makefile.target | 2 +- hw/ide-microdrive.c | 574 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/ide.c | 541 ------------------------------------------------ 3 files changed, 575 insertions(+), 542 deletions(-) create mode 100644 hw/ide-microdrive.c
Makefile.target +1 -1
@@ -267,7 +267,7 @@ obj-arm-y += arm-semi.o obj-arm-y += pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o obj-arm-y += pflash_cfi01.o gumstix.o -obj-arm-y += zaurus.o ide.o serial.o spitz.o tosa.o tc6393xb.o +obj-arm-y += zaurus.o ide.o ide-microdrive.o serial.o spitz.o tosa.o tc6393xb.o obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o obj-arm-y += omap2.o omap_dss.o soc_dma.o obj-arm-y += omap_sx1.o palm.o tsc210x.o
hw/ide-microdrive.c new file +574 -0
574 lines not on this page · raw message
hw/ide.c +0 -541
550 lines not on this page · raw message
Signature · 1 line
1.6.2.5
Re: [Qemu-devel] [PATCH 01/11] ide: add IDEBus struct, cleanups
In reply to Gerd HoffmannQuoted 4 lines · Gerd Hoffmann
The current IDE code uses an array of two IDEState structs to maintain the IDE bus. This patch adds a IDEBus to be used instead and does a bunch of cleanups:
Quoted 8 lines
* move ide bus state from IDEState to IDEBus.
* drop a bunch of ugly pointer arithmetics to figure the active interface, explicitly save the interface number instead.
* add helper functions to save/restore idebus state.It also fixes a save/restore bug: loadvm allways stores the command in the master's IDEState, even when it was saved from the slave.
Can you prepare a patch for stable that just fixes this bug? This sounds like something we want there.
Quoted 1 line
Signed-off-by Gerd Hoffmann <[email protected]>
Regards,
Anthony Liguori
Quoted 7 lines · Gerd Hoffmann
Hi,
This is a respin of the ide split and cleanup patches. Rebased to master as of today, solved conflicts (smart support + mmio constify). It got a new patch (#11) which switches the ide init functions from BlockDriverState to DriveInfo. Otherwise unmodified.
Can you pull out #11 and submit that separately? I'd like to push the earlier version I had in stable which is 1-10. By the time you see this, they should be in master already.
Regards,
Anthony Liguori
Quoted 5 lines
cheers,
Gerd