提交 75717903 编写于 作者: I Isaku Yamahata 提交者: Kevin Wolf

ide: consolidate drive_get(IF_IDE)

factor out ide initialization to call drive_get(IF_IDE)
Signed-off-by: NIsaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 e2982c3a
...@@ -28,4 +28,7 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2, ...@@ -28,4 +28,7 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2,
void ide_get_bs(BlockDriverState *bs[], BusState *qbus); void ide_get_bs(BlockDriverState *bs[], BusState *qbus);
/* ide/core.c */
void ide_drive_get(DriveInfo **hd, int max_bus);
#endif /* HW_IDE_H */ #endif /* HW_IDE_H */
...@@ -2826,3 +2826,17 @@ const VMStateDescription vmstate_ide_bus = { ...@@ -2826,3 +2826,17 @@ const VMStateDescription vmstate_ide_bus = {
VMSTATE_END_OF_LIST() VMSTATE_END_OF_LIST()
} }
}; };
void ide_drive_get(DriveInfo **hd, int max_bus)
{
int i;
if (drive_get_max_bus(IF_IDE) >= max_bus) {
fprintf(stderr, "qemu: too many IDE bus: %d\n", max_bus);
exit(1);
}
for(i = 0; i < max_bus * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
}
}
...@@ -338,14 +338,7 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device, ...@@ -338,14 +338,7 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,
pci_bus = bonito_init((qemu_irq *)&(env->irq[2])); pci_bus = bonito_init((qemu_irq *)&(env->irq[2]));
/* South bridge */ /* South bridge */
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { ide_drive_get(hd, MAX_IDE_BUS);
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
}
via_devfn = vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 0)); via_devfn = vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 0));
if (via_devfn < 0) { if (via_devfn < 0) {
......
...@@ -905,15 +905,7 @@ void mips_malta_init (ram_addr_t ram_size, ...@@ -905,15 +905,7 @@ void mips_malta_init (ram_addr_t ram_size,
pci_bus = gt64120_register(i8259); pci_bus = gt64120_register(i8259);
/* Southbridge */ /* Southbridge */
ide_drive_get(hd, MAX_IDE_BUS);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
}
piix4_devfn = piix4_init(pci_bus, 80); piix4_devfn = piix4_init(pci_bus, 80);
isa_bus_irqs(i8259); isa_bus_irqs(i8259);
......
...@@ -287,15 +287,7 @@ void mips_r4k_init (ram_addr_t ram_size, ...@@ -287,15 +287,7 @@ void mips_r4k_init (ram_addr_t ram_size,
if (nd_table[0].vlan) if (nd_table[0].vlan)
isa_ne2000_init(0x300, 9, &nd_table[0]); isa_ne2000_init(0x300, 9, &nd_table[0]);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { ide_drive_get(hd, MAX_IDE_BUS);
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
}
for(i = 0; i < MAX_IDE_BUS; i++) for(i = 0; i < MAX_IDE_BUS; i++)
isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i], isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i],
......
...@@ -129,15 +129,7 @@ static void pc_init1(ram_addr_t ram_size, ...@@ -129,15 +129,7 @@ static void pc_init1(ram_addr_t ram_size,
pci_nic_init_nofail(nd, "e1000", NULL); pci_nic_init_nofail(nd, "e1000", NULL);
} }
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { ide_drive_get(hd, MAX_IDE_BUS);
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
}
if (pci_enabled) { if (pci_enabled) {
PCIDevice *dev; PCIDevice *dev;
dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1); dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
......
...@@ -325,20 +325,13 @@ static void ppc_core99_init (ram_addr_t ram_size, ...@@ -325,20 +325,13 @@ static void ppc_core99_init (ram_addr_t ram_size,
for(i = 0; i < nb_nics; i++) for(i = 0; i < nb_nics; i++)
pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { ide_drive_get(hd, MAX_IDE_BUS);
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
dbdma = DBDMA_init(&dbdma_mem_index); dbdma = DBDMA_init(&dbdma_mem_index);
/* We only emulate 2 out of 3 IDE controllers for now */ /* We only emulate 2 out of 3 IDE controllers for now */
ide_mem_index[0] = -1; ide_mem_index[0] = -1;
hd[0] = drive_get(IF_IDE, 0, 0);
hd[1] = drive_get(IF_IDE, 0, 1);
ide_mem_index[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]); ide_mem_index[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
hd[0] = drive_get(IF_IDE, 1, 0); ide_mem_index[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, pic[0x02]);
hd[1] = drive_get(IF_IDE, 1, 1);
ide_mem_index[2] = pmac_ide_init(hd, pic[0x0e], dbdma, 0x1a, pic[0x02]);
/* cuda also initialize ADB */ /* cuda also initialize ADB */
if (machine_arch == ARCH_MAC99_U3) { if (machine_arch == ARCH_MAC99_U3) {
......
...@@ -236,21 +236,16 @@ static void ppc_heathrow_init (ram_addr_t ram_size, ...@@ -236,21 +236,16 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { ide_drive_get(hd, MAX_IDE_BUS);
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
/* First IDE channel is a MAC IDE on the MacIO bus */ /* First IDE channel is a MAC IDE on the MacIO bus */
hd[0] = drive_get(IF_IDE, 0, 0);
hd[1] = drive_get(IF_IDE, 0, 1);
dbdma = DBDMA_init(&dbdma_mem_index); dbdma = DBDMA_init(&dbdma_mem_index);
ide_mem_index[0] = -1; ide_mem_index[0] = -1;
ide_mem_index[1] = pmac_ide_init(hd, pic[0x0D], dbdma, 0x16, pic[0x02]); ide_mem_index[1] = pmac_ide_init(hd, pic[0x0D], dbdma, 0x16, pic[0x02]);
/* Second IDE channel is a CMD646 on the PCI bus */ /* Second IDE channel is a CMD646 on the PCI bus */
hd[0] = drive_get(IF_IDE, 1, 0); hd[0] = hd[MAX_IDE_DEVS];
hd[1] = drive_get(IF_IDE, 1, 1); hd[1] = hd[MAX_IDE_DEVS + 1];
hd[3] = hd[2] = NULL; hd[3] = hd[2] = NULL;
pci_cmd646_ide_init(pci_bus, hd, 0); pci_cmd646_ide_init(pci_bus, hd, 0);
......
...@@ -681,15 +681,7 @@ static void ppc_prep_init (ram_addr_t ram_size, ...@@ -681,15 +681,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
} }
} }
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { ide_drive_get(hd, MAX_IDE_BUS);
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
}
for(i = 0; i < MAX_IDE_BUS; i++) { for(i = 0; i < MAX_IDE_BUS; i++) {
isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i], isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
hd[2 * i], hd[2 * i],
......
...@@ -793,14 +793,7 @@ static void sun4uv_init(ram_addr_t RAM_size, ...@@ -793,14 +793,7 @@ static void sun4uv_init(ram_addr_t RAM_size,
for(i = 0; i < nb_nics; i++) for(i = 0; i < nb_nics; i++)
pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { ide_drive_get(hd, MAX_IDE_BUS);
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS,
i % MAX_IDE_DEVS);
}
pci_cmd646_ide_init(pci_bus, hd, 1); pci_cmd646_ide_init(pci_bus, hd, 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册