direct-io.hg
changeset 14285:fdbd9b91a030
[HVM] Save/restore: back-port IDE controller save routine from current qemu.
Also, send an interrupt and an error code to the guest on restore if we
dropped an active request when we saved.
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
Also, send an interrupt and an error code to the guest on restore if we
dropped an active request when we saved.
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author | Tim Deegan <Tim.Deegan@xensource.com> |
---|---|
date | Thu Mar 08 14:37:21 2007 +0000 (2007-03-08) |
parents | 18cf0c56226d |
children | 90e8d8169afd |
files | tools/ioemu/hw/ide.c |
line diff
1.1 --- a/tools/ioemu/hw/ide.c Thu Mar 08 14:29:09 2007 +0000 1.2 +++ b/tools/ioemu/hw/ide.c Thu Mar 08 14:37:21 2007 +0000 1.3 @@ -2602,6 +2602,120 @@ void pci_cmd646_ide_init(PCIBus *bus, Bl 1.4 #endif /* DMA_MULTI_THREAD */ 1.5 } 1.6 1.7 +static void pci_ide_save(QEMUFile* f, void *opaque) 1.8 +{ 1.9 + PCIIDEState *d = opaque; 1.10 + int i; 1.11 + 1.12 + for(i = 0; i < 2; i++) { 1.13 + BMDMAState *bm = &d->bmdma[i]; 1.14 + qemu_put_8s(f, &bm->cmd); 1.15 + qemu_put_8s(f, &bm->status); 1.16 + qemu_put_be32s(f, &bm->addr); 1.17 + /* XXX: if a transfer is pending, we do not save it yet */ 1.18 + } 1.19 + 1.20 + /* per IDE interface data */ 1.21 + for(i = 0; i < 2; i++) { 1.22 + IDEState *s = &d->ide_if[i * 2]; 1.23 + uint8_t drive1_selected; 1.24 + qemu_put_8s(f, &s->cmd); 1.25 + drive1_selected = (s->cur_drive != s); 1.26 + qemu_put_8s(f, &drive1_selected); 1.27 + } 1.28 + 1.29 + /* per IDE drive data */ 1.30 + for(i = 0; i < 4; i++) { 1.31 + IDEState *s = &d->ide_if[i]; 1.32 + qemu_put_be32s(f, &s->mult_sectors); 1.33 + qemu_put_be32s(f, &s->identify_set); 1.34 + if (s->identify_set) { 1.35 + qemu_put_buffer(f, (const uint8_t *)s->identify_data, 512); 1.36 + } 1.37 + qemu_put_8s(f, &s->write_cache); 1.38 + qemu_put_8s(f, &s->feature); 1.39 + qemu_put_8s(f, &s->error); 1.40 + qemu_put_be32s(f, &s->nsector); 1.41 + qemu_put_8s(f, &s->sector); 1.42 + qemu_put_8s(f, &s->lcyl); 1.43 + qemu_put_8s(f, &s->hcyl); 1.44 + qemu_put_8s(f, &s->hob_feature); 1.45 + qemu_put_8s(f, &s->hob_nsector); 1.46 + qemu_put_8s(f, &s->hob_sector); 1.47 + qemu_put_8s(f, &s->hob_lcyl); 1.48 + qemu_put_8s(f, &s->hob_hcyl); 1.49 + qemu_put_8s(f, &s->select); 1.50 + qemu_put_8s(f, &s->status); 1.51 + qemu_put_8s(f, &s->lba48); 1.52 + 1.53 + qemu_put_8s(f, &s->sense_key); 1.54 + qemu_put_8s(f, &s->asc); 1.55 + /* XXX: if a transfer is pending, we do not save it yet */ 1.56 + } 1.57 +} 1.58 + 1.59 +static int pci_ide_load(QEMUFile* f, void *opaque, int version_id) 1.60 +{ 1.61 + PCIIDEState *d = opaque; 1.62 + int ret, i; 1.63 + 1.64 + if (version_id != 1) 1.65 + return -EINVAL; 1.66 + 1.67 + for(i = 0; i < 2; i++) { 1.68 + BMDMAState *bm = &d->bmdma[i]; 1.69 + qemu_get_8s(f, &bm->cmd); 1.70 + qemu_get_8s(f, &bm->status); 1.71 + qemu_get_be32s(f, &bm->addr); 1.72 + /* XXX: if a transfer is pending, we do not save it yet */ 1.73 + } 1.74 + 1.75 + /* per IDE interface data */ 1.76 + for(i = 0; i < 2; i++) { 1.77 + IDEState *s = &d->ide_if[i * 2]; 1.78 + uint8_t drive1_selected; 1.79 + qemu_get_8s(f, &s->cmd); 1.80 + qemu_get_8s(f, &drive1_selected); 1.81 + s->cur_drive = &d->ide_if[i * 2 + (drive1_selected != 0)]; 1.82 + } 1.83 + 1.84 + /* per IDE drive data */ 1.85 + for(i = 0; i < 4; i++) { 1.86 + IDEState *s = &d->ide_if[i]; 1.87 + qemu_get_be32s(f, &s->mult_sectors); 1.88 + qemu_get_be32s(f, &s->identify_set); 1.89 + if (s->identify_set) { 1.90 + qemu_get_buffer(f, (uint8_t *)s->identify_data, 512); 1.91 + } 1.92 + qemu_get_8s(f, &s->write_cache); 1.93 + qemu_get_8s(f, &s->feature); 1.94 + qemu_get_8s(f, &s->error); 1.95 + qemu_get_be32s(f, &s->nsector); 1.96 + qemu_get_8s(f, &s->sector); 1.97 + qemu_get_8s(f, &s->lcyl); 1.98 + qemu_get_8s(f, &s->hcyl); 1.99 + qemu_get_8s(f, &s->hob_feature); 1.100 + qemu_get_8s(f, &s->hob_nsector); 1.101 + qemu_get_8s(f, &s->hob_sector); 1.102 + qemu_get_8s(f, &s->hob_lcyl); 1.103 + qemu_get_8s(f, &s->hob_hcyl); 1.104 + qemu_get_8s(f, &s->select); 1.105 + qemu_get_8s(f, &s->status); 1.106 + qemu_get_8s(f, &s->lba48); 1.107 + 1.108 + qemu_get_8s(f, &s->sense_key); 1.109 + qemu_get_8s(f, &s->asc); 1.110 + /* XXX: if a transfer is pending, we do not save it yet */ 1.111 + if (s->status & (DRQ_STAT|BUSY_STAT)) { 1.112 + /* Tell the guest that its transfer has gone away */ 1.113 + ide_abort_command(s); 1.114 + ide_set_irq(s); 1.115 + } 1.116 + } 1.117 + return 0; 1.118 +} 1.119 + 1.120 + 1.121 /* hd_table must contain 4 block drivers */ 1.122 /* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */ 1.123 void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn) 1.124 @@ -2643,6 +2757,7 @@ void pci_piix3_ide_init(PCIBus *bus, Blo 1.125 buffered_pio_init(); 1.126 1.127 register_savevm("ide_pci", 0, 1, generic_pci_save, generic_pci_load, d); 1.128 + register_savevm("ide", 0, 1, pci_ide_save, pci_ide_load, d); 1.129 1.130 #ifdef DMA_MULTI_THREAD 1.131 dma_create_thread();