Revision 679f4f8b
b/hw/ide.h | ||
---|---|---|
13 | 13 |
/* ide-pci.c */ |
14 | 14 |
void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table, |
15 | 15 |
int secondary_ide_enabled); |
16 |
PCIDevice *pci_piix3_xen_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn); |
|
16 | 17 |
PCIDevice *pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn); |
17 | 18 |
PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn); |
18 | 19 |
void vt82c686b_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn); |
b/hw/ide/piix.c | ||
---|---|---|
149 | 149 |
return 0; |
150 | 150 |
} |
151 | 151 |
|
152 |
static int pci_piix3_xen_ide_unplug(DeviceState *dev) |
|
153 |
{ |
|
154 |
PCIDevice *pci_dev; |
|
155 |
PCIIDEState *pci_ide; |
|
156 |
DriveInfo *di; |
|
157 |
int i = 0; |
|
158 |
|
|
159 |
pci_dev = DO_UPCAST(PCIDevice, qdev, dev); |
|
160 |
pci_ide = DO_UPCAST(PCIIDEState, dev, pci_dev); |
|
161 |
|
|
162 |
for (; i < 3; i++) { |
|
163 |
di = drive_get_by_index(IF_IDE, i); |
|
164 |
if (di != NULL && di->bdrv != NULL && !di->bdrv->removable) { |
|
165 |
DeviceState *ds = bdrv_get_attached(di->bdrv); |
|
166 |
if (ds) { |
|
167 |
bdrv_detach(di->bdrv, ds); |
|
168 |
} |
|
169 |
bdrv_close(di->bdrv); |
|
170 |
pci_ide->bus[di->bus].ifs[di->unit].bs = NULL; |
|
171 |
drive_put_ref(di); |
|
172 |
} |
|
173 |
} |
|
174 |
qdev_reset_all(&(pci_ide->dev.qdev)); |
|
175 |
return 0; |
|
176 |
} |
|
177 |
|
|
178 |
PCIDevice *pci_piix3_xen_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn) |
|
179 |
{ |
|
180 |
PCIDevice *dev; |
|
181 |
|
|
182 |
dev = pci_create_simple(bus, devfn, "piix3-ide-xen"); |
|
183 |
dev->qdev.info->unplug = pci_piix3_xen_ide_unplug; |
|
184 |
pci_ide_create_devs(dev, hd_table); |
|
185 |
return dev; |
|
186 |
} |
|
187 |
|
|
152 | 188 |
/* hd_table must contain 4 block drivers */ |
153 | 189 |
/* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */ |
154 | 190 |
PCIDevice *pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn) |
... | ... | |
182 | 218 |
.device_id = PCI_DEVICE_ID_INTEL_82371SB_1, |
183 | 219 |
.class_id = PCI_CLASS_STORAGE_IDE, |
184 | 220 |
},{ |
221 |
.qdev.name = "piix3-ide-xen", |
|
222 |
.qdev.size = sizeof(PCIIDEState), |
|
223 |
.qdev.no_user = 1, |
|
224 |
.init = pci_piix_ide_initfn, |
|
225 |
.vendor_id = PCI_VENDOR_ID_INTEL, |
|
226 |
.device_id = PCI_DEVICE_ID_INTEL_82371SB_1, |
|
227 |
.class_id = PCI_CLASS_STORAGE_IDE, |
|
228 |
},{ |
|
185 | 229 |
.qdev.name = "piix4-ide", |
186 | 230 |
.qdev.size = sizeof(PCIIDEState), |
187 | 231 |
.qdev.no_user = 1, |
b/hw/pc_piix.c | ||
---|---|---|
155 | 155 |
ide_drive_get(hd, MAX_IDE_BUS); |
156 | 156 |
if (pci_enabled) { |
157 | 157 |
PCIDevice *dev; |
158 |
dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1); |
|
158 |
if (xen_enabled()) { |
|
159 |
dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1); |
|
160 |
} else { |
|
161 |
dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1); |
|
162 |
} |
|
159 | 163 |
idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); |
160 | 164 |
idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); |
161 | 165 |
} else { |
b/hw/xen_platform.c | ||
---|---|---|
76 | 76 |
} |
77 | 77 |
|
78 | 78 |
/* Xen Platform, Fixed IOPort */ |
79 |
#define UNPLUG_ALL_IDE_DISKS 1 |
|
80 |
#define UNPLUG_ALL_NICS 2 |
|
81 |
#define UNPLUG_AUX_IDE_DISKS 4 |
|
82 |
|
|
83 |
static void unplug_nic(PCIBus *b, PCIDevice *d) |
|
84 |
{ |
|
85 |
if (pci_get_word(d->config + PCI_CLASS_DEVICE) == |
|
86 |
PCI_CLASS_NETWORK_ETHERNET) { |
|
87 |
qdev_unplug(&(d->qdev)); |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
static void pci_unplug_nics(PCIBus *bus) |
|
92 |
{ |
|
93 |
pci_for_each_device(bus, 0, unplug_nic); |
|
94 |
} |
|
95 |
|
|
96 |
static void unplug_disks(PCIBus *b, PCIDevice *d) |
|
97 |
{ |
|
98 |
if (pci_get_word(d->config + PCI_CLASS_DEVICE) == |
|
99 |
PCI_CLASS_STORAGE_IDE) { |
|
100 |
qdev_unplug(&(d->qdev)); |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
static void pci_unplug_disks(PCIBus *bus) |
|
105 |
{ |
|
106 |
pci_for_each_device(bus, 0, unplug_disks); |
|
107 |
} |
|
79 | 108 |
|
80 | 109 |
static void platform_fixed_ioport_writew(void *opaque, uint32_t addr, uint32_t val) |
81 | 110 |
{ |
... | ... | |
83 | 112 |
|
84 | 113 |
switch (addr - XEN_PLATFORM_IOPORT) { |
85 | 114 |
case 0: |
86 |
/* TODO: */ |
|
87 | 115 |
/* Unplug devices. Value is a bitmask of which devices to |
88 | 116 |
unplug, with bit 0 the IDE devices, bit 1 the network |
89 | 117 |
devices, and bit 2 the non-primary-master IDE devices. */ |
118 |
if (val & UNPLUG_ALL_IDE_DISKS) { |
|
119 |
DPRINTF("unplug disks\n"); |
|
120 |
qemu_aio_flush(); |
|
121 |
bdrv_flush_all(); |
|
122 |
pci_unplug_disks(s->pci_dev.bus); |
|
123 |
} |
|
124 |
if (val & UNPLUG_ALL_NICS) { |
|
125 |
DPRINTF("unplug nics\n"); |
|
126 |
pci_unplug_nics(s->pci_dev.bus); |
|
127 |
} |
|
128 |
if (val & UNPLUG_AUX_IDE_DISKS) { |
|
129 |
DPRINTF("unplug auxiliary disks not supported\n"); |
|
130 |
} |
|
90 | 131 |
break; |
91 | 132 |
case 2: |
92 | 133 |
switch (val) { |
Also available in: Unified diff