summaryrefslogtreecommitdiff
path: root/hw/pc.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-07-22 16:42:57 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-07-27 14:08:23 -0500
commit751c6a17042b5d011013d6963c0505d671cf708e (patch)
tree61a769ed1a1c16ebdfc1397ce9d775222dfa8e57 /hw/pc.c
parent8a14daa5a1ae22fcfc317f4727a88d6c15c39aae (diff)
downloadqemu-751c6a17042b5d011013d6963c0505d671cf708e.zip
kill drives_table
First step cleaning up the drives handling. This one does nothing but removing drives_table[], still it became seriously big. drive_get_index() is gone and is replaced by drives_get() which hands out DriveInfo pointers instead of a table index. This needs adaption in *tons* of places all over. The drives are now maintained as linked list. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/pc.c')
-rw-r--r--hw/pc.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/hw/pc.c b/hw/pc.c
index c55c303bc1..46ff8cf7ca 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1126,7 +1126,7 @@ static void pc_init1(ram_addr_t ram_size,
CPUState *env;
qemu_irq *cpu_irq;
qemu_irq *i8259;
- int index;
+ DriveInfo *dinfo;
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
BlockDriverState *fd[MAX_FD];
int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled;
@@ -1356,11 +1356,8 @@ static void pc_init1(ram_addr_t ram_size,
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
- index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
- if (index != -1)
- hd[i] = drives_table[index].bdrv;
- else
- hd[i] = NULL;
+ dinfo = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
+ hd[i] = dinfo ? dinfo->bdrv : NULL;
}
if (pci_enabled) {
@@ -1379,11 +1376,8 @@ static void pc_init1(ram_addr_t ram_size,
#endif
for(i = 0; i < MAX_FD; i++) {
- index = drive_get_index(IF_FLOPPY, 0, i);
- if (index != -1)
- fd[i] = drives_table[index].bdrv;
- else
- fd[i] = NULL;
+ dinfo = drive_get(IF_FLOPPY, 0, i);
+ fd[i] = dinfo ? dinfo->bdrv : NULL;
}
floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd);
@@ -1437,12 +1431,11 @@ static void pc_init1(ram_addr_t ram_size,
/* Add virtio block devices */
if (pci_enabled) {
- int index;
int unit_id = 0;
- while ((index = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
+ while ((dinfo = drive_get(IF_VIRTIO, 0, unit_id)) != NULL) {
pci_dev = pci_create(virtio_blk_name,
- drives_table[index].devaddr);
+ dinfo->devaddr);
qdev_init(&pci_dev->qdev);
unit_id++;
}