mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
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>
This commit is contained in:
committed by
Anthony Liguori
parent
8a14daa5a1
commit
751c6a1704
+12
-11
@@ -28,22 +28,23 @@
|
||||
#include "block_int.h"
|
||||
#include "sysemu.h"
|
||||
|
||||
int add_init_drive(const char *opts)
|
||||
DriveInfo *add_init_drive(const char *opts)
|
||||
{
|
||||
int drive_opt_idx, drive_idx;
|
||||
int ret = -1;
|
||||
int drive_opt_idx;
|
||||
int fatal_error;
|
||||
DriveInfo *dinfo;
|
||||
|
||||
drive_opt_idx = drive_add(NULL, "%s", opts);
|
||||
if (!drive_opt_idx)
|
||||
return ret;
|
||||
return NULL;
|
||||
|
||||
drive_idx = drive_init(&drives_opt[drive_opt_idx], 0, current_machine);
|
||||
if (drive_idx == -1) {
|
||||
dinfo = drive_init(&drives_opt[drive_opt_idx], 0, current_machine, &fatal_error);
|
||||
if (!dinfo) {
|
||||
drive_remove(drive_opt_idx);
|
||||
return ret;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return drive_idx;
|
||||
return dinfo;
|
||||
}
|
||||
|
||||
void destroy_nic(dev_match_fn *match_fn, void *arg)
|
||||
@@ -64,11 +65,11 @@ void destroy_nic(dev_match_fn *match_fn, void *arg)
|
||||
|
||||
void destroy_bdrvs(dev_match_fn *match_fn, void *arg)
|
||||
{
|
||||
int i;
|
||||
DriveInfo *dinfo;
|
||||
struct BlockDriverState *bs;
|
||||
|
||||
for (i = 0; i <= MAX_DRIVES; i++) {
|
||||
bs = drives_table[i].bdrv;
|
||||
TAILQ_FOREACH(dinfo, &drives, next) {
|
||||
bs = dinfo->bdrv;
|
||||
if (bs) {
|
||||
if (bs->private && match_fn(bs->private, arg)) {
|
||||
drive_uninit(bs);
|
||||
|
||||
+3
-2
@@ -55,6 +55,7 @@ void bareetraxfs_init (ram_addr_t ram_size,
|
||||
void *etraxfs_dmac;
|
||||
struct etraxfs_dma_client *eth[2] = {NULL, NULL};
|
||||
int kernel_size;
|
||||
DriveInfo *dinfo;
|
||||
int i;
|
||||
ram_addr_t phys_ram;
|
||||
ram_addr_t phys_flash;
|
||||
@@ -79,9 +80,9 @@ void bareetraxfs_init (ram_addr_t ram_size,
|
||||
|
||||
|
||||
phys_flash = qemu_ram_alloc(FLASH_SIZE);
|
||||
i = drive_get_index(IF_PFLASH, 0, 0);
|
||||
dinfo = drive_get(IF_PFLASH, 0, 0);
|
||||
pflash_cfi02_register(0x0, phys_flash,
|
||||
i != -1 ? drives_table[i].bdrv : NULL, (64 * 1024),
|
||||
dinfo ? dinfo->bdrv : NULL, (64 * 1024),
|
||||
FLASH_SIZE >> 16,
|
||||
1, 2, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x555, 0x2aa);
|
||||
|
||||
+8
-8
@@ -47,22 +47,22 @@ static void connex_init(ram_addr_t ram_size,
|
||||
const char *initrd_filename, const char *cpu_model)
|
||||
{
|
||||
PXA2xxState *cpu;
|
||||
int index;
|
||||
DriveInfo *dinfo;
|
||||
|
||||
uint32_t connex_rom = 0x01000000;
|
||||
uint32_t connex_ram = 0x04000000;
|
||||
|
||||
cpu = pxa255_init(connex_ram);
|
||||
|
||||
index = drive_get_index(IF_PFLASH, 0, 0);
|
||||
if (index == -1) {
|
||||
dinfo = drive_get(IF_PFLASH, 0, 0);
|
||||
if (!dinfo) {
|
||||
fprintf(stderr, "A flash image must be given with the "
|
||||
"'pflash' parameter\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!pflash_cfi01_register(0x00000000, qemu_ram_alloc(connex_rom),
|
||||
drives_table[index].bdrv, sector_len, connex_rom / sector_len,
|
||||
dinfo->bdrv, sector_len, connex_rom / sector_len,
|
||||
2, 0, 0, 0, 0)) {
|
||||
fprintf(stderr, "qemu: Error registering flash memory.\n");
|
||||
exit(1);
|
||||
@@ -81,22 +81,22 @@ static void verdex_init(ram_addr_t ram_size,
|
||||
const char *initrd_filename, const char *cpu_model)
|
||||
{
|
||||
PXA2xxState *cpu;
|
||||
int index;
|
||||
DriveInfo *dinfo;
|
||||
|
||||
uint32_t verdex_rom = 0x02000000;
|
||||
uint32_t verdex_ram = 0x10000000;
|
||||
|
||||
cpu = pxa270_init(verdex_ram, cpu_model ?: "pxa270-c0");
|
||||
|
||||
index = drive_get_index(IF_PFLASH, 0, 0);
|
||||
if (index == -1) {
|
||||
dinfo = drive_get(IF_PFLASH, 0, 0);
|
||||
if (!dinfo) {
|
||||
fprintf(stderr, "A flash image must be given with the "
|
||||
"'pflash' parameter\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!pflash_cfi01_register(0x00000000, qemu_ram_alloc(verdex_rom),
|
||||
drives_table[index].bdrv, sector_len, verdex_rom / sector_len,
|
||||
dinfo->bdrv, sector_len, verdex_rom / sector_len,
|
||||
2, 0, 0, 0, 0)) {
|
||||
fprintf(stderr, "qemu: Error registering flash memory.\n");
|
||||
exit(1);
|
||||
|
||||
+5
-4
@@ -77,7 +77,8 @@ static void mainstone_common_init(ram_addr_t ram_size,
|
||||
target_phys_addr_t mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
|
||||
PXA2xxState *cpu;
|
||||
qemu_irq *mst_irq;
|
||||
int i, index;
|
||||
DriveInfo *dinfo;
|
||||
int i;
|
||||
|
||||
if (!cpu_model)
|
||||
cpu_model = "pxa270-c5";
|
||||
@@ -92,8 +93,8 @@ static void mainstone_common_init(ram_addr_t ram_size,
|
||||
|
||||
/* There are two 32MiB flash devices on the board */
|
||||
for (i = 0; i < 2; i ++) {
|
||||
index = drive_get_index(IF_PFLASH, 0, i);
|
||||
if (index == -1) {
|
||||
dinfo = drive_get(IF_PFLASH, 0, i);
|
||||
if (!dinfo) {
|
||||
fprintf(stderr, "Two flash images must be given with the "
|
||||
"'pflash' parameter\n");
|
||||
exit(1);
|
||||
@@ -101,7 +102,7 @@ static void mainstone_common_init(ram_addr_t ram_size,
|
||||
|
||||
if (!pflash_cfi01_register(mainstone_flash_base[i],
|
||||
qemu_ram_alloc(MAINSTONE_FLASH),
|
||||
drives_table[index].bdrv, sector_len,
|
||||
dinfo->bdrv, sector_len,
|
||||
MAINSTONE_FLASH / sector_len, 4, 0, 0, 0, 0)) {
|
||||
fprintf(stderr, "qemu: Error registering flash memory.\n");
|
||||
exit(1);
|
||||
|
||||
+2
-5
@@ -235,11 +235,8 @@ void mips_jazz_init (ram_addr_t ram_size,
|
||||
exit(1);
|
||||
}
|
||||
for (n = 0; n < MAX_FD; n++) {
|
||||
int fd = drive_get_index(IF_FLOPPY, 0, n);
|
||||
if (fd != -1)
|
||||
fds[n] = drives_table[fd].bdrv;
|
||||
else
|
||||
fds[n] = NULL;
|
||||
DriveInfo *dinfo = drive_get(IF_FLOPPY, 0, n);
|
||||
fds[n] = dinfo ? dinfo->bdrv : NULL;
|
||||
}
|
||||
fdctrl_init(rc4030[1], 0, 1, 0x80003000, fds);
|
||||
|
||||
|
||||
+9
-15
@@ -773,7 +773,7 @@ void mips_malta_init (ram_addr_t ram_size,
|
||||
uint8_t *eeprom_buf;
|
||||
i2c_bus *smbus;
|
||||
int i;
|
||||
int index;
|
||||
DriveInfo *dinfo;
|
||||
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
|
||||
BlockDriverState *fd[MAX_FD];
|
||||
int fl_idx = 0;
|
||||
@@ -827,8 +827,8 @@ void mips_malta_init (ram_addr_t ram_size,
|
||||
env->CP0_Status &= ~((1 << CP0St_BEV) | (1 << CP0St_ERL));
|
||||
write_bootloader(env, qemu_get_ram_ptr(bios_offset), kernel_entry);
|
||||
} else {
|
||||
index = drive_get_index(IF_PFLASH, 0, fl_idx);
|
||||
if (index != -1) {
|
||||
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
||||
if (dinfo) {
|
||||
/* Load firmware from flash. */
|
||||
bios_size = 0x400000;
|
||||
fl_sectors = bios_size >> 16;
|
||||
@@ -836,10 +836,10 @@ void mips_malta_init (ram_addr_t ram_size,
|
||||
printf("Register parallel flash %d size " TARGET_FMT_lx " at "
|
||||
"offset %08lx addr %08llx '%s' %x\n",
|
||||
fl_idx, bios_size, bios_offset, 0x1e000000LL,
|
||||
bdrv_get_device_name(drives_table[index].bdrv), fl_sectors);
|
||||
bdrv_get_device_name(dinfo->bdrv), fl_sectors);
|
||||
#endif
|
||||
pflash_cfi01_register(0x1e000000LL, bios_offset,
|
||||
drives_table[index].bdrv, 65536, fl_sectors,
|
||||
dinfo->bdrv, 65536, fl_sectors,
|
||||
4, 0x0000, 0x0000, 0x0000, 0x0000);
|
||||
fl_idx++;
|
||||
} else {
|
||||
@@ -898,11 +898,8 @@ void mips_malta_init (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;
|
||||
}
|
||||
|
||||
piix4_devfn = piix4_init(pci_bus, 80);
|
||||
@@ -929,11 +926,8 @@ void mips_malta_init (ram_addr_t ram_size,
|
||||
if (parallel_hds[0])
|
||||
parallel_init(0x378, i8259[7], parallel_hds[0]);
|
||||
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);
|
||||
|
||||
|
||||
+5
-8
@@ -155,8 +155,8 @@ void mips_r4k_init (ram_addr_t ram_size,
|
||||
RTCState *rtc_state;
|
||||
int i;
|
||||
qemu_irq *i8259;
|
||||
int index;
|
||||
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
|
||||
DriveInfo *dinfo;
|
||||
|
||||
/* init CPUs */
|
||||
if (cpu_model == NULL) {
|
||||
@@ -208,11 +208,11 @@ void mips_r4k_init (ram_addr_t ram_size,
|
||||
bios_offset | IO_MEM_ROM);
|
||||
|
||||
load_image_targphys(filename, 0x1fc00000, BIOS_SIZE);
|
||||
} else if ((index = drive_get_index(IF_PFLASH, 0, 0)) > -1) {
|
||||
} else if ((dinfo = drive_get(IF_PFLASH, 0, 0)) != NULL) {
|
||||
uint32_t mips_rom = 0x00400000;
|
||||
bios_offset = qemu_ram_alloc(mips_rom);
|
||||
if (!pflash_cfi01_register(0x1fc00000, bios_offset,
|
||||
drives_table[index].bdrv, sector_len, mips_rom / sector_len,
|
||||
dinfo->bdrv, sector_len, mips_rom / sector_len,
|
||||
4, 0, 0, 0, 0)) {
|
||||
fprintf(stderr, "qemu: Error registering flash memory.\n");
|
||||
}
|
||||
@@ -267,11 +267,8 @@ void mips_r4k_init (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;
|
||||
}
|
||||
|
||||
for(i = 0; i < MAX_IDE_BUS; i++)
|
||||
|
||||
+5
-5
@@ -1512,8 +1512,8 @@ static void musicpal_init(ram_addr_t ram_size,
|
||||
qemu_irq pic[32];
|
||||
DeviceState *dev;
|
||||
int i;
|
||||
int index;
|
||||
unsigned long flash_size;
|
||||
DriveInfo *dinfo;
|
||||
|
||||
if (!cpu_model)
|
||||
cpu_model = "arm926";
|
||||
@@ -1549,9 +1549,9 @@ static void musicpal_init(ram_addr_t ram_size,
|
||||
serial_hds[1], 1);
|
||||
|
||||
/* Register flash */
|
||||
index = drive_get_index(IF_PFLASH, 0, 0);
|
||||
if (index != -1) {
|
||||
flash_size = bdrv_getlength(drives_table[index].bdrv);
|
||||
dinfo = drive_get(IF_PFLASH, 0, 0);
|
||||
if (dinfo) {
|
||||
flash_size = bdrv_getlength(dinfo->bdrv);
|
||||
if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 &&
|
||||
flash_size != 32*1024*1024) {
|
||||
fprintf(stderr, "Invalid flash image size\n");
|
||||
@@ -1564,7 +1564,7 @@ static void musicpal_init(ram_addr_t ram_size,
|
||||
* image is smaller than 32 MB.
|
||||
*/
|
||||
pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(flash_size),
|
||||
drives_table[index].bdrv, 0x10000,
|
||||
dinfo->bdrv, 0x10000,
|
||||
(flash_size + 0xffff) >> 16,
|
||||
MP_FLASH_SIZE_MAX / flash_size,
|
||||
2, 0x00BF, 0x236D, 0x0000, 0x0000,
|
||||
|
||||
@@ -442,16 +442,16 @@ NANDFlashState *nand_init(int manf_id, int chip_id)
|
||||
{
|
||||
int pagesize;
|
||||
NANDFlashState *s;
|
||||
int index;
|
||||
DriveInfo *dinfo;
|
||||
|
||||
if (nand_flash_ids[chip_id].size == 0) {
|
||||
hw_error("%s: Unsupported NAND chip ID.\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
s = (NANDFlashState *) qemu_mallocz(sizeof(NANDFlashState));
|
||||
index = drive_get_index(IF_MTD, 0, 0);
|
||||
if (index != -1)
|
||||
s->bdrv = drives_table[index].bdrv;
|
||||
dinfo = drive_get(IF_MTD, 0, 0);
|
||||
if (dinfo)
|
||||
s->bdrv = dinfo->bdrv;
|
||||
s->manf_id = manf_id;
|
||||
s->chip_id = chip_id;
|
||||
s->size = nand_flash_ids[s->chip_id].size << 20;
|
||||
|
||||
+4
-4
@@ -4628,7 +4628,7 @@ struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size,
|
||||
ram_addr_t imif_base, emiff_base;
|
||||
qemu_irq *cpu_irq;
|
||||
qemu_irq dma_irqs[6];
|
||||
int sdindex;
|
||||
DriveInfo *dinfo;
|
||||
|
||||
if (!core)
|
||||
core = "ti925t";
|
||||
@@ -4740,12 +4740,12 @@ struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size,
|
||||
omap_dpll_init(&s->dpll[1], 0xfffed000, omap_findclk(s, "dpll2"));
|
||||
omap_dpll_init(&s->dpll[2], 0xfffed100, omap_findclk(s, "dpll3"));
|
||||
|
||||
sdindex = drive_get_index(IF_SD, 0, 0);
|
||||
if (sdindex == -1) {
|
||||
dinfo = drive_get(IF_SD, 0, 0);
|
||||
if (!dinfo) {
|
||||
fprintf(stderr, "qemu: missing SecureDigital device\n");
|
||||
exit(1);
|
||||
}
|
||||
s->mmc = omap_mmc_init(0xfffb7800, drives_table[sdindex].bdrv,
|
||||
s->mmc = omap_mmc_init(0xfffb7800, dinfo->bdrv,
|
||||
s->irq[1][OMAP_INT_OQN], &s->drq[OMAP_DMA_MMC_TX],
|
||||
omap_findclk(s, "mmc_ck"));
|
||||
|
||||
|
||||
+4
-4
@@ -4496,7 +4496,7 @@ struct omap_mpu_state_s *omap2420_mpu_init(unsigned long sdram_size,
|
||||
qemu_irq *cpu_irq;
|
||||
qemu_irq dma_irqs[4];
|
||||
omap_clk gpio_clks[4];
|
||||
int sdindex;
|
||||
DriveInfo *dinfo;
|
||||
int i;
|
||||
|
||||
/* Core */
|
||||
@@ -4645,12 +4645,12 @@ struct omap_mpu_state_s *omap2420_mpu_init(unsigned long sdram_size,
|
||||
s->sdrc = omap_sdrc_init(0x68009000);
|
||||
s->gpmc = omap_gpmc_init(0x6800a000, s->irq[0][OMAP_INT_24XX_GPMC_IRQ]);
|
||||
|
||||
sdindex = drive_get_index(IF_SD, 0, 0);
|
||||
if (sdindex == -1) {
|
||||
dinfo = drive_get(IF_SD, 0, 0);
|
||||
if (!dinfo) {
|
||||
fprintf(stderr, "qemu: missing SecureDigital device\n");
|
||||
exit(1);
|
||||
}
|
||||
s->mmc = omap2_mmc_init(omap_l4tao(s->l4, 9), drives_table[sdindex].bdrv,
|
||||
s->mmc = omap2_mmc_init(omap_l4tao(s->l4, 9), dinfo->bdrv,
|
||||
s->irq[0][OMAP_INT_24XX_MMC_IRQ],
|
||||
&s->drq[OMAP24XX_DMA_MMC1_TX],
|
||||
omap_findclk(s, "mmc_fclk"), omap_findclk(s, "mmc_iclk"));
|
||||
|
||||
+5
-5
@@ -127,7 +127,7 @@ static void sx1_init(ram_addr_t ram_size,
|
||||
static uint32_t cs2val = 0x00001139;
|
||||
static uint32_t cs3val = 0x00001139;
|
||||
ram_addr_t phys_flash;
|
||||
int index;
|
||||
DriveInfo *dinfo;
|
||||
int fl_idx;
|
||||
uint32_t flash_size = flash0_size;
|
||||
|
||||
@@ -151,9 +151,9 @@ static void sx1_init(ram_addr_t ram_size,
|
||||
|
||||
fl_idx = 0;
|
||||
|
||||
if ((index = drive_get_index(IF_PFLASH, 0, fl_idx)) > -1) {
|
||||
if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
|
||||
if (!pflash_cfi01_register(OMAP_CS0_BASE, qemu_ram_alloc(flash_size),
|
||||
drives_table[index].bdrv, sector_size, flash_size / sector_size,
|
||||
dinfo->bdrv, sector_size, flash_size / sector_size,
|
||||
4, 0, 0, 0, 0)) {
|
||||
fprintf(stderr, "qemu: Error registering flash memory %d.\n",
|
||||
fl_idx);
|
||||
@@ -162,7 +162,7 @@ static void sx1_init(ram_addr_t ram_size,
|
||||
}
|
||||
|
||||
if ((version == 1) &&
|
||||
(index = drive_get_index(IF_PFLASH, 0, fl_idx)) > -1) {
|
||||
(dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
|
||||
cpu_register_physical_memory(OMAP_CS1_BASE, flash1_size,
|
||||
(phys_flash = qemu_ram_alloc(flash1_size)) |
|
||||
IO_MEM_ROM);
|
||||
@@ -171,7 +171,7 @@ static void sx1_init(ram_addr_t ram_size,
|
||||
OMAP_CS1_SIZE - flash1_size, io);
|
||||
|
||||
if (!pflash_cfi01_register(OMAP_CS1_BASE, qemu_ram_alloc(flash1_size),
|
||||
drives_table[index].bdrv, sector_size, flash1_size / sector_size,
|
||||
dinfo->bdrv, sector_size, flash1_size / sector_size,
|
||||
4, 0, 0, 0, 0)) {
|
||||
fprintf(stderr, "qemu: Error registering flash memory %d.\n",
|
||||
fl_idx);
|
||||
|
||||
+3
-3
@@ -618,7 +618,7 @@ static CPUWriteMemoryFunc *onenand_writefn[] = {
|
||||
void *onenand_init(uint32_t id, int regshift, qemu_irq irq)
|
||||
{
|
||||
OneNANDState *s = (OneNANDState *) qemu_mallocz(sizeof(*s));
|
||||
int bdrv_index = drive_get_index(IF_MTD, 0, 0);
|
||||
DriveInfo *dinfo = drive_get(IF_MTD, 0, 0);
|
||||
uint32_t size = 1 << (24 + ((id >> 12) & 7));
|
||||
void *ram;
|
||||
|
||||
@@ -632,11 +632,11 @@ void *onenand_init(uint32_t id, int regshift, qemu_irq irq)
|
||||
s->density_mask = (id & (1 << 11)) ? (1 << (6 + ((id >> 12) & 7))) : 0;
|
||||
s->iomemtype = cpu_register_io_memory(onenand_readfn,
|
||||
onenand_writefn, s);
|
||||
if (bdrv_index == -1)
|
||||
if (!dinfo)
|
||||
s->image = memset(qemu_malloc(size + (size >> 5)),
|
||||
0xff, size + (size >> 5));
|
||||
else
|
||||
s->bdrv = drives_table[bdrv_index].bdrv;
|
||||
s->bdrv = dinfo->bdrv;
|
||||
s->otp = memset(qemu_malloc((64 + 2) << PAGE_SHIFT),
|
||||
0xff, (64 + 2) << PAGE_SHIFT);
|
||||
s->ram = qemu_ram_alloc(0xc000 << s->shift);
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
+15
-13
@@ -52,9 +52,10 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts)
|
||||
{
|
||||
int dom, pci_bus;
|
||||
unsigned slot;
|
||||
int drive_idx, type, bus;
|
||||
int type, bus;
|
||||
int success = 0;
|
||||
PCIDevice *dev;
|
||||
DriveInfo *dinfo;
|
||||
|
||||
if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
|
||||
return;
|
||||
@@ -66,21 +67,21 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts)
|
||||
return;
|
||||
}
|
||||
|
||||
drive_idx = add_init_drive(opts);
|
||||
if (drive_idx < 0)
|
||||
dinfo = add_init_drive(opts);
|
||||
if (!dinfo)
|
||||
return;
|
||||
if (drives_table[drive_idx].devaddr) {
|
||||
if (dinfo->devaddr) {
|
||||
monitor_printf(mon, "Parameter addr not supported\n");
|
||||
return;
|
||||
}
|
||||
type = drives_table[drive_idx].type;
|
||||
type = dinfo->type;
|
||||
bus = drive_get_max_bus (type);
|
||||
|
||||
switch (type) {
|
||||
case IF_SCSI:
|
||||
success = 1;
|
||||
lsi_scsi_attach(&dev->qdev, drives_table[drive_idx].bdrv,
|
||||
drives_table[drive_idx].unit);
|
||||
lsi_scsi_attach(&dev->qdev, dinfo->bdrv,
|
||||
dinfo->unit);
|
||||
break;
|
||||
default:
|
||||
monitor_printf(mon, "Can't hot-add drive to type %d\n", type);
|
||||
@@ -88,8 +89,8 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts)
|
||||
|
||||
if (success)
|
||||
monitor_printf(mon, "OK bus %d, unit %d\n",
|
||||
drives_table[drive_idx].bus,
|
||||
drives_table[drive_idx].unit);
|
||||
dinfo->bus,
|
||||
dinfo->unit);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -98,7 +99,8 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
|
||||
const char *opts)
|
||||
{
|
||||
PCIDevice *dev;
|
||||
int type = -1, drive_idx = -1;
|
||||
DriveInfo *dinfo;
|
||||
int type = -1;
|
||||
char buf[128];
|
||||
|
||||
if (get_param_value(buf, sizeof(buf), "if", opts)) {
|
||||
@@ -116,10 +118,10 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
|
||||
}
|
||||
|
||||
if (get_param_value(buf, sizeof(buf), "file", opts)) {
|
||||
drive_idx = add_init_drive(opts);
|
||||
if (drive_idx < 0)
|
||||
dinfo = add_init_drive(opts);
|
||||
if (!dinfo)
|
||||
return NULL;
|
||||
if (drives_table[drive_idx].devaddr) {
|
||||
if (dinfo->devaddr) {
|
||||
monitor_printf(mon, "Parameter addr not supported\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ petalogix_s3adsp1800_init(ram_addr_t ram_size,
|
||||
DeviceState *dev;
|
||||
CPUState *env;
|
||||
int kernel_size;
|
||||
DriveInfo *dinfo;
|
||||
int i;
|
||||
target_phys_addr_t ddr_base = 0x90000000;
|
||||
ram_addr_t phys_lmb_bram;
|
||||
@@ -131,9 +132,9 @@ petalogix_s3adsp1800_init(ram_addr_t ram_size,
|
||||
cpu_register_physical_memory(ddr_base, ram_size, phys_ram | IO_MEM_RAM);
|
||||
|
||||
phys_flash = qemu_ram_alloc(FLASH_SIZE);
|
||||
i = drive_get_index(IF_PFLASH, 0, 0);
|
||||
dinfo = drive_get(IF_PFLASH, 0, 0);
|
||||
pflash_cfi02_register(0xa0000000, phys_flash,
|
||||
i != -1 ? drives_table[i].bdrv : NULL, (64 * 1024),
|
||||
dinfo ? dinfo->bdrv : NULL, (64 * 1024),
|
||||
FLASH_SIZE >> 16,
|
||||
1, 1, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x555, 0x2aa);
|
||||
|
||||
+17
-17
@@ -188,7 +188,7 @@ static void ref405ep_init (ram_addr_t ram_size,
|
||||
int linux_boot;
|
||||
int fl_idx, fl_sectors, len;
|
||||
int ppc_boot_device = boot_device[0];
|
||||
int index;
|
||||
DriveInfo *dinfo;
|
||||
|
||||
/* XXX: fix this */
|
||||
ram_bases[0] = qemu_ram_alloc(0x08000000);
|
||||
@@ -215,19 +215,19 @@ static void ref405ep_init (ram_addr_t ram_size,
|
||||
#endif
|
||||
fl_idx = 0;
|
||||
#ifdef USE_FLASH_BIOS
|
||||
index = drive_get_index(IF_PFLASH, 0, fl_idx);
|
||||
if (index != -1) {
|
||||
bios_size = bdrv_getlength(drives_table[index].bdrv);
|
||||
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
||||
if (dinfo) {
|
||||
bios_size = bdrv_getlength(dinfo->bdrv);
|
||||
bios_offset = qemu_ram_alloc(bios_size);
|
||||
fl_sectors = (bios_size + 65535) >> 16;
|
||||
#ifdef DEBUG_BOARD_INIT
|
||||
printf("Register parallel flash %d size " ADDRX " at offset %08lx "
|
||||
" addr " ADDRX " '%s' %d\n",
|
||||
fl_idx, bios_size, bios_offset, -bios_size,
|
||||
bdrv_get_device_name(drives_table[index].bdrv), fl_sectors);
|
||||
bdrv_get_device_name(dinfo->bdrv), fl_sectors);
|
||||
#endif
|
||||
pflash_cfi02_register((uint32_t)(-bios_size), bios_offset,
|
||||
drives_table[index].bdrv, 65536, fl_sectors, 1,
|
||||
dinfo->bdrv, 65536, fl_sectors, 1,
|
||||
2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA);
|
||||
fl_idx++;
|
||||
} else
|
||||
@@ -509,7 +509,7 @@ static void taihu_405ep_init(ram_addr_t ram_size,
|
||||
int linux_boot;
|
||||
int fl_idx, fl_sectors;
|
||||
int ppc_boot_device = boot_device[0];
|
||||
int index;
|
||||
DriveInfo *dinfo;
|
||||
|
||||
/* RAM is soldered to the board so the size cannot be changed */
|
||||
ram_bases[0] = qemu_ram_alloc(0x04000000);
|
||||
@@ -528,9 +528,9 @@ static void taihu_405ep_init(ram_addr_t ram_size,
|
||||
#endif
|
||||
fl_idx = 0;
|
||||
#if defined(USE_FLASH_BIOS)
|
||||
index = drive_get_index(IF_PFLASH, 0, fl_idx);
|
||||
if (index != -1) {
|
||||
bios_size = bdrv_getlength(drives_table[index].bdrv);
|
||||
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
||||
if (dinfo) {
|
||||
bios_size = bdrv_getlength(dinfo->bdrv);
|
||||
/* XXX: should check that size is 2MB */
|
||||
// bios_size = 2 * 1024 * 1024;
|
||||
fl_sectors = (bios_size + 65535) >> 16;
|
||||
@@ -539,10 +539,10 @@ static void taihu_405ep_init(ram_addr_t ram_size,
|
||||
printf("Register parallel flash %d size " ADDRX " at offset %08lx "
|
||||
" addr " ADDRX " '%s' %d\n",
|
||||
fl_idx, bios_size, bios_offset, -bios_size,
|
||||
bdrv_get_device_name(drives_table[index].bdrv), fl_sectors);
|
||||
bdrv_get_device_name(dinfo->bdrv), fl_sectors);
|
||||
#endif
|
||||
pflash_cfi02_register((uint32_t)(-bios_size), bios_offset,
|
||||
drives_table[index].bdrv, 65536, fl_sectors, 1,
|
||||
dinfo->bdrv, 65536, fl_sectors, 1,
|
||||
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA);
|
||||
fl_idx++;
|
||||
} else
|
||||
@@ -570,9 +570,9 @@ static void taihu_405ep_init(ram_addr_t ram_size,
|
||||
bios_size, bios_offset | IO_MEM_ROM);
|
||||
}
|
||||
/* Register Linux flash */
|
||||
index = drive_get_index(IF_PFLASH, 0, fl_idx);
|
||||
if (index != -1) {
|
||||
bios_size = bdrv_getlength(drives_table[index].bdrv);
|
||||
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
||||
if (dinfo) {
|
||||
bios_size = bdrv_getlength(dinfo->bdrv);
|
||||
/* XXX: should check that size is 32MB */
|
||||
bios_size = 32 * 1024 * 1024;
|
||||
fl_sectors = (bios_size + 65535) >> 16;
|
||||
@@ -580,11 +580,11 @@ static void taihu_405ep_init(ram_addr_t ram_size,
|
||||
printf("Register parallel flash %d size " ADDRX " at offset %08lx "
|
||||
" addr " ADDRX " '%s'\n",
|
||||
fl_idx, bios_size, bios_offset, (target_ulong)0xfc000000,
|
||||
bdrv_get_device_name(drives_table[index].bdrv));
|
||||
bdrv_get_device_name(dinfo->bdrv));
|
||||
#endif
|
||||
bios_offset = qemu_ram_alloc(bios_size);
|
||||
pflash_cfi02_register(0xfc000000, bios_offset,
|
||||
drives_table[index].bdrv, 65536, fl_sectors, 1,
|
||||
dinfo->bdrv, 65536, fl_sectors, 1,
|
||||
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA);
|
||||
fl_idx++;
|
||||
}
|
||||
|
||||
+3
-2
@@ -102,6 +102,7 @@ static void bamboo_init(ram_addr_t ram_size,
|
||||
target_ulong dt_base = 0;
|
||||
void *fdt;
|
||||
int i;
|
||||
DriveInfo *dinfo;
|
||||
|
||||
/* Setup CPU. */
|
||||
env = ppc440ep_init(&ram_size, &pcibus, pci_irq_nrs, 1, cpu_model);
|
||||
@@ -110,8 +111,8 @@ static void bamboo_init(ram_addr_t ram_size,
|
||||
int unit_id = 0;
|
||||
|
||||
/* Add virtio block devices. */
|
||||
while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
|
||||
pci_dev = pci_create("virtio-blk-pci", drives_table[i].devaddr);
|
||||
while ((dinfo = drive_get(IF_VIRTIO, 0, unit_id)) != NULL) {
|
||||
pci_dev = pci_create("virtio-blk-pci", dinfo->devaddr);
|
||||
qdev_init(&pci_dev->qdev);
|
||||
unit_id++;
|
||||
}
|
||||
|
||||
+3
-6
@@ -106,7 +106,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
|
||||
qemu_irq *dummy_irq;
|
||||
int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index;
|
||||
int ppc_boot_device;
|
||||
int index;
|
||||
DriveInfo *dinfo;
|
||||
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
|
||||
void *fw_cfg;
|
||||
void *dbdma;
|
||||
@@ -315,11 +315,8 @@ static void ppc_core99_init (ram_addr_t ram_size,
|
||||
exit(1);
|
||||
}
|
||||
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;
|
||||
}
|
||||
dbdma = DBDMA_init(&dbdma_mem_index);
|
||||
pci_cmd646_ide_init(pci_bus, hd, 0);
|
||||
|
||||
+9
-21
@@ -135,7 +135,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
|
||||
int escc_mem_index, ide_mem_index[2];
|
||||
uint16_t ppc_boot_device;
|
||||
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
|
||||
int index;
|
||||
DriveInfo *dinfo;
|
||||
void *fw_cfg;
|
||||
void *dbdma;
|
||||
uint8_t *vga_bios_ptr;
|
||||
@@ -328,31 +328,19 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
|
||||
}
|
||||
|
||||
/* First IDE channel is a MAC IDE on the MacIO bus */
|
||||
index = drive_get_index(IF_IDE, 0, 0);
|
||||
if (index == -1)
|
||||
hd[0] = NULL;
|
||||
else
|
||||
hd[0] = drives_table[index].bdrv;
|
||||
index = drive_get_index(IF_IDE, 0, 1);
|
||||
if (index == -1)
|
||||
hd[1] = NULL;
|
||||
else
|
||||
hd[1] = drives_table[index].bdrv;
|
||||
dinfo = drive_get(IF_IDE, 0, 0);
|
||||
hd[0] = dinfo ? dinfo->bdrv : NULL;
|
||||
dinfo = drive_get(IF_IDE, 0, 1);
|
||||
hd[1] = dinfo ? dinfo->bdrv : NULL;
|
||||
dbdma = DBDMA_init(&dbdma_mem_index);
|
||||
ide_mem_index[0] = -1;
|
||||
ide_mem_index[1] = pmac_ide_init(hd, pic[0x0D], dbdma, 0x16, pic[0x02]);
|
||||
|
||||
/* Second IDE channel is a CMD646 on the PCI bus */
|
||||
index = drive_get_index(IF_IDE, 1, 0);
|
||||
if (index == -1)
|
||||
hd[0] = NULL;
|
||||
else
|
||||
hd[0] = drives_table[index].bdrv;
|
||||
index = drive_get_index(IF_IDE, 1, 1);
|
||||
if (index == -1)
|
||||
hd[1] = NULL;
|
||||
else
|
||||
hd[1] = drives_table[index].bdrv;
|
||||
dinfo = drive_get(IF_IDE, 1, 0);
|
||||
hd[0] = dinfo ? dinfo->bdrv : NULL;
|
||||
dinfo = drive_get(IF_IDE, 1, 1);
|
||||
hd[1] = dinfo ? dinfo->bdrv : NULL;
|
||||
hd[3] = hd[2] = NULL;
|
||||
pci_cmd646_ide_init(pci_bus, hd, 0);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user