mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-28 05:50:37 +00:00
ide: port pci ide to vmstate
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
44bfa33281
commit
407a4f3073
@ -233,7 +233,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)
|
||||
ide_init2(&d->bus[0], NULL, NULL, irq[0]);
|
||||
ide_init2(&d->bus[1], NULL, NULL, irq[1]);
|
||||
|
||||
register_savevm("ide", 0, 3, pci_ide_save, pci_ide_load, d);
|
||||
vmstate_register(0, &vmstate_ide_pci, d);
|
||||
qemu_register_reset(cmd646_reset, d);
|
||||
cmd646_reset(d);
|
||||
return 0;
|
||||
|
@ -517,6 +517,9 @@ extern const VMStateDescription vmstate_ide_bus;
|
||||
#define VMSTATE_IDE_BUS(_field, _state) \
|
||||
VMSTATE_STRUCT(_field, _state, 1, vmstate_ide_bus, IDEBus)
|
||||
|
||||
#define VMSTATE_IDE_BUS_ARRAY(_field, _state, _num) \
|
||||
VMSTATE_STRUCT_ARRAY(_field, _state, _num, 1, vmstate_ide_bus, IDEBus)
|
||||
|
||||
extern const VMStateDescription vmstate_ide_drive;
|
||||
|
||||
#define VMSTATE_IDE_DRIVES(_field, _state) \
|
||||
|
97
hw/ide/pci.c
97
hw/ide/pci.c
@ -121,75 +121,52 @@ void bmdma_addr_writel(void *opaque, uint32_t addr, uint32_t val)
|
||||
bm->cur_addr = bm->addr;
|
||||
}
|
||||
|
||||
void pci_ide_save(QEMUFile* f, void *opaque)
|
||||
static const VMStateDescription vmstate_bmdma = {
|
||||
.name = "ide bmdma",
|
||||
.version_id = 3,
|
||||
.minimum_version_id = 0,
|
||||
.minimum_version_id_old = 0,
|
||||
.fields = (VMStateField []) {
|
||||
VMSTATE_UINT8(cmd, BMDMAState),
|
||||
VMSTATE_UINT8(status, BMDMAState),
|
||||
VMSTATE_UINT32(addr, BMDMAState),
|
||||
VMSTATE_INT64(sector_num, BMDMAState),
|
||||
VMSTATE_UINT32(nsector, BMDMAState),
|
||||
VMSTATE_UINT8(unit, BMDMAState),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
static int ide_pci_post_load(void *opaque, int version_id)
|
||||
{
|
||||
PCIIDEState *d = opaque;
|
||||
int i;
|
||||
|
||||
pci_device_save(&d->dev, f);
|
||||
|
||||
for(i = 0; i < 2; i++) {
|
||||
BMDMAState *bm = &d->bmdma[i];
|
||||
uint8_t ifidx;
|
||||
qemu_put_8s(f, &bm->cmd);
|
||||
qemu_put_8s(f, &bm->status);
|
||||
qemu_put_be32s(f, &bm->addr);
|
||||
qemu_put_sbe64s(f, &bm->sector_num);
|
||||
qemu_put_be32s(f, &bm->nsector);
|
||||
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++) {
|
||||
idebus_save(f, d->bus+i);
|
||||
}
|
||||
|
||||
/* per IDE drive data */
|
||||
for(i = 0; i < 2; i++) {
|
||||
ide_save(f, &d->bus[i].ifs[0]);
|
||||
ide_save(f, &d->bus[i].ifs[1]);
|
||||
}
|
||||
}
|
||||
|
||||
int pci_ide_load(QEMUFile* f, void *opaque, int version_id)
|
||||
{
|
||||
PCIIDEState *d = opaque;
|
||||
int ret, i;
|
||||
|
||||
if (version_id != 2 && version_id != 3)
|
||||
return -EINVAL;
|
||||
ret = pci_device_load(&d->dev, f);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
for(i = 0; i < 2; i++) {
|
||||
BMDMAState *bm = &d->bmdma[i];
|
||||
uint8_t ifidx;
|
||||
qemu_get_8s(f, &bm->cmd);
|
||||
qemu_get_8s(f, &bm->status);
|
||||
qemu_get_be32s(f, &bm->addr);
|
||||
qemu_get_sbe64s(f, &bm->sector_num);
|
||||
qemu_get_be32s(f, &bm->nsector);
|
||||
qemu_get_8s(f, &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++) {
|
||||
idebus_load(f, d->bus+i, version_id);
|
||||
}
|
||||
|
||||
/* per IDE drive data */
|
||||
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);
|
||||
/* current versions always store 0/1, but older version
|
||||
stored bigger values. We only need last bit */
|
||||
d->bmdma[i].unit &= 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const VMStateDescription vmstate_ide_pci = {
|
||||
.name = "ide",
|
||||
.version_id = 3,
|
||||
.minimum_version_id = 0,
|
||||
.minimum_version_id_old = 0,
|
||||
.post_load = ide_pci_post_load,
|
||||
.fields = (VMStateField []) {
|
||||
VMSTATE_PCI_DEVICE(dev, PCIIDEState),
|
||||
VMSTATE_STRUCT_ARRAY(bmdma, PCIIDEState, 2, 0,
|
||||
vmstate_bmdma, BMDMAState),
|
||||
VMSTATE_IDE_BUS_ARRAY(bus, PCIIDEState, 2),
|
||||
VMSTATE_IDE_DRIVES(bus[0].ifs, PCIIDEState),
|
||||
VMSTATE_IDE_DRIVES(bus[1].ifs, PCIIDEState),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
void pci_ide_create_devs(PCIDevice *dev, DriveInfo **hd_table)
|
||||
{
|
||||
PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev);
|
||||
|
@ -17,7 +17,7 @@ uint32_t bmdma_addr_readw(void *opaque, uint32_t addr);
|
||||
void bmdma_addr_writew(void *opaque, uint32_t addr, uint32_t val);
|
||||
uint32_t bmdma_addr_readl(void *opaque, uint32_t addr);
|
||||
void bmdma_addr_writel(void *opaque, uint32_t addr, uint32_t val);
|
||||
void pci_ide_save(QEMUFile* f, void *opaque);
|
||||
int pci_ide_load(QEMUFile* f, void *opaque, int version_id);
|
||||
void pci_ide_create_devs(PCIDevice *dev, DriveInfo **hd_table);
|
||||
|
||||
extern const VMStateDescription vmstate_ide_pci;
|
||||
#endif
|
||||
|
@ -124,7 +124,7 @@ static int pci_piix_ide_initfn(PCIIDEState *d)
|
||||
|
||||
pci_register_bar(&d->dev, 4, 0x10, PCI_ADDRESS_SPACE_IO, bmdma_map);
|
||||
|
||||
register_savevm("ide", 0, 3, pci_ide_save, pci_ide_load, d);
|
||||
vmstate_register(0, &vmstate_ide_pci, d);
|
||||
|
||||
ide_bus_new(&d->bus[0], &d->dev.qdev);
|
||||
ide_bus_new(&d->bus[1], &d->dev.qdev);
|
||||
|
Loading…
Reference in New Issue
Block a user