@@ -183,14 +183,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
@@ -211,7 +211,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
new file mode 100644
@@ -0,0 +1,97 @@
+#ifndef HW_IDE_INTERNAL_H
+#define HW_IDE_INTERNAL_H
+
+#include "ide.h"
+
+typedef struct IDEBus IDEBus;
+typedef struct IDEState IDEState;
+typedef struct BMDMAState BMDMAState;
+
+typedef void EndTransferFunc(IDEState *);
+
+/* 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;
+};
+
+struct IDEBus {
+ BusState qbus;
+ BMDMAState *bmdma;
+ IDEState ifs[2];
+ uint8_t unit;
+};
+
+static inline IDEState *idebus_active_if(IDEBus *bus)
+{
+ return bus->ifs + bus->unit;
+}
+
+/* ide.c */
+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 */
new file mode 100644
@@ -0,0 +1,45 @@
+/*
+ * QEMU IDE disk and CD/DVD-ROM Emulator
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2006 Openedhand Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "hw.h"
+#include "pc.h"
+#include "block.h"
+#include "block_int.h"
+#include "sysemu.h"
+#include "dma.h"
+#include "ide-internal.h"
+
+/***********************************************************/
+/* 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);
+}
@@ -35,11 +35,7 @@
#include "mac_dbdma.h"
#include "sh.h"
#include "dma.h"
-#include "ide.h"
-
-typedef struct IDEBus IDEBus;
-typedef struct IDEState IDEState;
-typedef struct BMDMAState BMDMAState;
+#include "ide-internal.h"
/* debug IDE devices */
//#define DEBUG_IDE
@@ -377,83 +373,6 @@ typedef struct BMDMAState BMDMAState;
#define SENSE_ILLEGAL_REQUEST 5
#define SENSE_UNIT_ATTENTION 6
-typedef void EndTransferFunc(IDEState *);
-
-/* 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;
-};
-
-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)
{
@@ -527,11 +446,6 @@ static inline IDEState *bmdma_active_if(BMDMAState *bmdma)
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);
@@ -2829,9 +2743,8 @@ static void ide_reset(IDEState *s)
s->media_changed = 0;
}
-static void ide_init2(IDEBus *bus,
- BlockDriverState *hd0, BlockDriverState *hd1,
- qemu_irq irq)
+void ide_init2(IDEBus *bus, BlockDriverState *hd0, BlockDriverState *hd1,
+ qemu_irq irq)
{
IDEState *s;
static int drive_serial = 1;
@@ -2870,7 +2783,7 @@ static void ide_init2(IDEBus *bus,
}
}
-static void ide_init_ioport(IDEBus *bus, int iobase, int iobase2)
+void ide_init_ioport(IDEBus *bus, int iobase, int iobase2)
{
register_ioport_write(iobase, 8, 1, ide_ioport_write, bus);
register_ioport_read(iobase, 8, 1, ide_ioport_read, bus);
@@ -2969,20 +2882,6 @@ static 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);
new file mode 100644
@@ -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 */
@@ -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)
@@ -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
@@ -152,8 +152,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,
@@ -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
create ide.h and ide-internal header files. ide-internal.h is supposed to be used by ide*.c only. create ide-isa.c and place isa bus support there. only build ide-isa support for platforms using it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- Makefile.target | 7 ++- hw/ide-internal.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++ hw/ide-isa.c | 45 ++++++++++++++++++++++ hw/ide.c | 109 ++--------------------------------------------------- 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, 163 insertions(+), 110 deletions(-) create mode 100644 hw/ide-internal.h create mode 100644 hw/ide-isa.c create mode 100644 hw/ide.h