Revision fd8014e1
b/hw/fdc.c | ||
---|---|---|
81 | 81 |
} fdisk_flags_t; |
82 | 82 |
|
83 | 83 |
typedef struct fdrive_t { |
84 |
DriveInfo *dinfo; |
|
84 | 85 |
BlockDriverState *bs; |
85 | 86 |
/* Drive status */ |
86 | 87 |
fdrive_type_t drive; |
... | ... | |
97 | 98 |
uint8_t ro; /* Is read-only */ |
98 | 99 |
} fdrive_t; |
99 | 100 |
|
100 |
static void fd_init (fdrive_t *drv, BlockDriverState *bs)
|
|
101 |
static void fd_init (fdrive_t *drv) |
|
101 | 102 |
{ |
102 | 103 |
/* Drive */ |
103 |
drv->bs = bs;
|
|
104 |
drv->bs = drv->dinfo ? drv->dinfo->bdrv : NULL;
|
|
104 | 105 |
drv->drive = FDRIVE_DRV_NONE; |
105 | 106 |
drv->perpendicular = 0; |
106 | 107 |
/* Disk */ |
... | ... | |
1829 | 1830 |
} |
1830 | 1831 |
|
1831 | 1832 |
/* Init functions */ |
1832 |
static void fdctrl_connect_drives(fdctrl_t *fdctrl, BlockDriverState **fds)
|
|
1833 |
static void fdctrl_connect_drives(fdctrl_t *fdctrl) |
|
1833 | 1834 |
{ |
1834 | 1835 |
unsigned int i; |
1835 | 1836 |
|
1836 | 1837 |
for (i = 0; i < MAX_FD; i++) { |
1837 |
fd_init(&fdctrl->drives[i], fds[i]);
|
|
1838 |
fd_init(&fdctrl->drives[i]); |
|
1838 | 1839 |
fd_revalidate(&fdctrl->drives[i]); |
1839 | 1840 |
} |
1840 | 1841 |
} |
1841 | 1842 |
|
1842 |
fdctrl_t *fdctrl_init_isa(BlockDriverState **fds)
|
|
1843 |
fdctrl_t *fdctrl_init_isa(DriveInfo **fds)
|
|
1843 | 1844 |
{ |
1844 | 1845 |
fdctrl_t *fdctrl; |
1845 | 1846 |
ISADevice *dev; |
1846 | 1847 |
int dma_chann = 2; |
1847 | 1848 |
|
1848 |
dev = isa_create_simple("isa-fdc"); |
|
1849 |
dev = isa_create("isa-fdc"); |
|
1850 |
qdev_prop_set_drive(&dev->qdev, "driveA", fds[0]); |
|
1851 |
qdev_prop_set_drive(&dev->qdev, "driveB", fds[1]); |
|
1852 |
if (qdev_init(&dev->qdev) != 0) |
|
1853 |
return NULL; |
|
1849 | 1854 |
fdctrl = &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state); |
1850 | 1855 |
|
1851 | 1856 |
fdctrl->dma_chann = dma_chann; |
1852 | 1857 |
DMA_register_channel(dma_chann, &fdctrl_transfer_handler, fdctrl); |
1853 | 1858 |
|
1854 |
fdctrl_connect_drives(fdctrl, fds);
|
|
1859 |
fdctrl_connect_drives(fdctrl); |
|
1855 | 1860 |
|
1856 | 1861 |
return fdctrl; |
1857 | 1862 |
} |
1858 | 1863 |
|
1859 | 1864 |
fdctrl_t *fdctrl_init_sysbus(qemu_irq irq, int dma_chann, |
1860 | 1865 |
target_phys_addr_t mmio_base, |
1861 |
BlockDriverState **fds)
|
|
1866 |
DriveInfo **fds)
|
|
1862 | 1867 |
{ |
1863 | 1868 |
fdctrl_t *fdctrl; |
1864 | 1869 |
DeviceState *dev; |
1865 | 1870 |
fdctrl_sysbus_t *sys; |
1866 | 1871 |
|
1867 | 1872 |
dev = qdev_create(NULL, "sysbus-fdc"); |
1868 |
qdev_init(dev); |
|
1873 |
qdev_prop_set_drive(dev, "driveA", fds[0]); |
|
1874 |
qdev_prop_set_drive(dev, "driveB", fds[1]); |
|
1875 |
if (qdev_init(dev) != 0) |
|
1876 |
return NULL; |
|
1869 | 1877 |
sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev); |
1870 | 1878 |
fdctrl = &sys->state; |
1871 | 1879 |
sysbus_connect_irq(&sys->busdev, 0, irq); |
... | ... | |
1873 | 1881 |
|
1874 | 1882 |
fdctrl->dma_chann = dma_chann; |
1875 | 1883 |
DMA_register_channel(dma_chann, &fdctrl_transfer_handler, fdctrl); |
1876 |
fdctrl_connect_drives(fdctrl, fds);
|
|
1884 |
fdctrl_connect_drives(fdctrl); |
|
1877 | 1885 |
|
1878 | 1886 |
return fdctrl; |
1879 | 1887 |
} |
1880 | 1888 |
|
1881 | 1889 |
fdctrl_t *sun4m_fdctrl_init (qemu_irq irq, target_phys_addr_t io_base, |
1882 |
BlockDriverState **fds, qemu_irq *fdc_tc)
|
|
1890 |
DriveInfo **fds, qemu_irq *fdc_tc)
|
|
1883 | 1891 |
{ |
1884 | 1892 |
DeviceState *dev; |
1885 | 1893 |
fdctrl_sysbus_t *sys; |
1886 | 1894 |
fdctrl_t *fdctrl; |
1887 | 1895 |
|
1888 | 1896 |
dev = qdev_create(NULL, "SUNW,fdtwo"); |
1889 |
qdev_init(dev); |
|
1897 |
qdev_prop_set_drive(dev, "drive", fds[0]); |
|
1898 |
if (qdev_init(dev) != 0) |
|
1899 |
return NULL; |
|
1890 | 1900 |
sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev); |
1891 | 1901 |
fdctrl = &sys->state; |
1892 | 1902 |
sysbus_connect_irq(&sys->busdev, 0, irq); |
... | ... | |
1895 | 1905 |
|
1896 | 1906 |
fdctrl->dma_chann = -1; |
1897 | 1907 |
|
1898 |
fdctrl_connect_drives(fdctrl, fds);
|
|
1908 |
fdctrl_connect_drives(fdctrl); |
|
1899 | 1909 |
|
1900 | 1910 |
return fdctrl; |
1901 | 1911 |
} |
... | ... | |
1985 | 1995 |
.init = isabus_fdc_init1, |
1986 | 1996 |
.qdev.name = "isa-fdc", |
1987 | 1997 |
.qdev.size = sizeof(fdctrl_isabus_t), |
1998 |
.qdev.props = (Property[]) { |
|
1999 |
DEFINE_PROP_DRIVE("driveA", fdctrl_isabus_t, state.drives[0].dinfo), |
|
2000 |
DEFINE_PROP_DRIVE("driveB", fdctrl_isabus_t, state.drives[1].dinfo), |
|
2001 |
DEFINE_PROP_END_OF_LIST(), |
|
2002 |
}, |
|
1988 | 2003 |
}; |
1989 | 2004 |
|
1990 | 2005 |
static SysBusDeviceInfo sysbus_fdc_info = { |
1991 | 2006 |
.init = sysbus_fdc_init1, |
1992 | 2007 |
.qdev.name = "sysbus-fdc", |
1993 | 2008 |
.qdev.size = sizeof(fdctrl_sysbus_t), |
2009 |
.qdev.props = (Property[]) { |
|
2010 |
DEFINE_PROP_DRIVE("driveA", fdctrl_sysbus_t, state.drives[0].dinfo), |
|
2011 |
DEFINE_PROP_DRIVE("driveB", fdctrl_sysbus_t, state.drives[1].dinfo), |
|
2012 |
DEFINE_PROP_END_OF_LIST(), |
|
2013 |
}, |
|
1994 | 2014 |
}; |
1995 | 2015 |
|
1996 | 2016 |
static SysBusDeviceInfo sun4m_fdc_info = { |
1997 | 2017 |
.init = sun4m_fdc_init1, |
1998 | 2018 |
.qdev.name = "SUNW,fdtwo", |
1999 | 2019 |
.qdev.size = sizeof(fdctrl_sysbus_t), |
2020 |
.qdev.props = (Property[]) { |
|
2021 |
DEFINE_PROP_DRIVE("drive", fdctrl_sysbus_t, state.drives[0].dinfo), |
|
2022 |
DEFINE_PROP_END_OF_LIST(), |
|
2023 |
}, |
|
2000 | 2024 |
}; |
2001 | 2025 |
|
2002 | 2026 |
static void fdc_register_devices(void) |
b/hw/fdc.h | ||
---|---|---|
1 | 1 |
/* fdc.c */ |
2 |
#include "sysemu.h" |
|
2 | 3 |
#define MAX_FD 2 |
3 | 4 |
|
4 | 5 |
typedef struct fdctrl_t fdctrl_t; |
5 | 6 |
|
6 |
fdctrl_t *fdctrl_init_isa(BlockDriverState **fds);
|
|
7 |
fdctrl_t *fdctrl_init_isa(DriveInfo **fds);
|
|
7 | 8 |
fdctrl_t *fdctrl_init_sysbus(qemu_irq irq, int dma_chann, |
8 | 9 |
target_phys_addr_t mmio_base, |
9 |
BlockDriverState **fds);
|
|
10 |
DriveInfo **fds);
|
|
10 | 11 |
fdctrl_t *sun4m_fdctrl_init (qemu_irq irq, target_phys_addr_t io_base, |
11 |
BlockDriverState **fds, qemu_irq *fdc_tc);
|
|
12 |
DriveInfo **fds, qemu_irq *fdc_tc);
|
|
12 | 13 |
int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num); |
b/hw/mips_jazz.c | ||
---|---|---|
126 | 126 |
int s_rtc, s_dma_dummy; |
127 | 127 |
NICInfo *nd; |
128 | 128 |
PITState *pit; |
129 |
BlockDriverState *fds[MAX_FD];
|
|
129 |
DriveInfo *fds[MAX_FD];
|
|
130 | 130 |
qemu_irq esp_reset; |
131 | 131 |
ram_addr_t ram_offset; |
132 | 132 |
ram_addr_t bios_offset; |
... | ... | |
234 | 234 |
exit(1); |
235 | 235 |
} |
236 | 236 |
for (n = 0; n < MAX_FD; n++) { |
237 |
DriveInfo *dinfo = drive_get(IF_FLOPPY, 0, n); |
|
238 |
fds[n] = dinfo ? dinfo->bdrv : NULL; |
|
237 |
fds[n] = drive_get(IF_FLOPPY, 0, n); |
|
239 | 238 |
} |
240 | 239 |
fdctrl_init_sysbus(rc4030[1], 0, 0x80003000, fds); |
241 | 240 |
|
b/hw/mips_malta.c | ||
---|---|---|
786 | 786 |
int i; |
787 | 787 |
DriveInfo *dinfo; |
788 | 788 |
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
789 |
BlockDriverState *fd[MAX_FD];
|
|
789 |
DriveInfo *fd[MAX_FD];
|
|
790 | 790 |
int fl_idx = 0; |
791 | 791 |
int fl_sectors = 0; |
792 | 792 |
|
... | ... | |
947 | 947 |
if (parallel_hds[0]) |
948 | 948 |
parallel_init(0, parallel_hds[0]); |
949 | 949 |
for(i = 0; i < MAX_FD; i++) { |
950 |
dinfo = drive_get(IF_FLOPPY, 0, i); |
|
951 |
fd[i] = dinfo ? dinfo->bdrv : NULL; |
|
950 |
fd[i] = drive_get(IF_FLOPPY, 0, i); |
|
952 | 951 |
} |
953 | 952 |
floppy_controller = fdctrl_init_isa(fd); |
954 | 953 |
|
b/hw/pc.c | ||
---|---|---|
1133 | 1133 |
qemu_irq *isa_irq; |
1134 | 1134 |
qemu_irq *i8259; |
1135 | 1135 |
IsaIrqState *isa_irq_state; |
1136 |
DriveInfo *dinfo; |
|
1137 | 1136 |
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
1138 |
BlockDriverState *fd[MAX_FD];
|
|
1137 |
DriveInfo *fd[MAX_FD];
|
|
1139 | 1138 |
int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled; |
1140 | 1139 |
void *fw_cfg; |
1141 | 1140 |
|
... | ... | |
1378 | 1377 |
#endif |
1379 | 1378 |
|
1380 | 1379 |
for(i = 0; i < MAX_FD; i++) { |
1381 |
dinfo = drive_get(IF_FLOPPY, 0, i); |
|
1382 |
fd[i] = dinfo ? dinfo->bdrv : NULL; |
|
1380 |
fd[i] = drive_get(IF_FLOPPY, 0, i); |
|
1383 | 1381 |
} |
1384 | 1382 |
floppy_controller = fdctrl_init_isa(fd); |
1385 | 1383 |
|
b/hw/ppc_prep.c | ||
---|---|---|
563 | 563 |
PCIBus *pci_bus; |
564 | 564 |
qemu_irq *i8259; |
565 | 565 |
int ppc_boot_device; |
566 |
DriveInfo *dinfo; |
|
567 | 566 |
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
568 |
BlockDriverState *fd[MAX_FD];
|
|
567 |
DriveInfo *fd[MAX_FD];
|
|
569 | 568 |
|
570 | 569 |
sysctrl = qemu_mallocz(sizeof(sysctrl_t)); |
571 | 570 |
|
... | ... | |
720 | 719 |
// SB16_init(); |
721 | 720 |
|
722 | 721 |
for(i = 0; i < MAX_FD; i++) { |
723 |
dinfo = drive_get(IF_FLOPPY, 0, i); |
|
724 |
fd[i] = dinfo ? dinfo->bdrv : NULL; |
|
722 |
fd[i] = drive_get(IF_FLOPPY, 0, i); |
|
725 | 723 |
} |
726 | 724 |
fdctrl_init_isa(fd); |
727 | 725 |
|
b/hw/sun4m.c | ||
---|---|---|
758 | 758 |
qemu_irq fdc_tc; |
759 | 759 |
qemu_irq *cpu_halt; |
760 | 760 |
unsigned long kernel_size; |
761 |
BlockDriverState *fd[MAX_FD];
|
|
761 |
DriveInfo *fd[MAX_FD];
|
|
762 | 762 |
void *fw_cfg; |
763 |
DriveInfo *dinfo; |
|
764 | 763 |
|
765 | 764 |
/* init CPUs */ |
766 | 765 |
if (!cpu_model) |
... | ... | |
834 | 833 |
if (hwdef->fd_base) { |
835 | 834 |
/* there is zero or one floppy drive */ |
836 | 835 |
memset(fd, 0, sizeof(fd)); |
837 |
dinfo = drive_get(IF_FLOPPY, 0, 0); |
|
838 |
if (dinfo) |
|
839 |
fd[0] = dinfo->bdrv; |
|
840 |
|
|
836 |
fd[0] = drive_get(IF_FLOPPY, 0, 0); |
|
841 | 837 |
sun4m_fdctrl_init(slavio_irq[22], hwdef->fd_base, fd, |
842 | 838 |
&fdc_tc); |
843 | 839 |
} |
... | ... | |
1562 | 1558 |
qemu_irq esp_reset; |
1563 | 1559 |
qemu_irq fdc_tc; |
1564 | 1560 |
unsigned long kernel_size; |
1565 |
BlockDriverState *fd[MAX_FD];
|
|
1561 |
DriveInfo *fd[MAX_FD];
|
|
1566 | 1562 |
void *fw_cfg; |
1567 | 1563 |
DeviceState *dev; |
1568 | 1564 |
unsigned int i; |
1569 |
DriveInfo *dinfo; |
|
1570 | 1565 |
|
1571 | 1566 |
/* init CPU */ |
1572 | 1567 |
if (!cpu_model) |
... | ... | |
1618 | 1613 |
if (hwdef->fd_base != (target_phys_addr_t)-1) { |
1619 | 1614 |
/* there is zero or one floppy drive */ |
1620 | 1615 |
memset(fd, 0, sizeof(fd)); |
1621 |
dinfo = drive_get(IF_FLOPPY, 0, 0); |
|
1622 |
if (dinfo) |
|
1623 |
fd[0] = dinfo->bdrv; |
|
1624 |
|
|
1616 |
fd[0] = drive_get(IF_FLOPPY, 0, 0); |
|
1625 | 1617 |
sun4m_fdctrl_init(slavio_irq[1], hwdef->fd_base, fd, |
1626 | 1618 |
&fdc_tc); |
1627 | 1619 |
} |
b/hw/sun4u.c | ||
---|---|---|
573 | 573 |
PCIBus *pci_bus, *pci_bus2, *pci_bus3; |
574 | 574 |
qemu_irq *irq; |
575 | 575 |
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
576 |
BlockDriverState *fd[MAX_FD];
|
|
576 |
DriveInfo *fd[MAX_FD];
|
|
577 | 577 |
void *fw_cfg; |
578 |
DriveInfo *dinfo; |
|
579 | 578 |
|
580 | 579 |
/* init CPUs */ |
581 | 580 |
env = cpu_devinit(cpu_model, hwdef); |
... | ... | |
630 | 629 |
|
631 | 630 |
isa_create_simple("i8042"); |
632 | 631 |
for(i = 0; i < MAX_FD; i++) { |
633 |
dinfo = drive_get(IF_FLOPPY, 0, i); |
|
634 |
fd[i] = dinfo ? dinfo->bdrv : NULL; |
|
632 |
fd[i] = drive_get(IF_FLOPPY, 0, i); |
|
635 | 633 |
} |
636 | 634 |
fdctrl_init_isa(fd); |
637 | 635 |
nvram = m48t59_init_isa(0x0074, NVRAM_SIZE, 59); |
Also available in: Unified diff