Revision 751c6a17
b/hw/device-hotplug.c | ||
---|---|---|
28 | 28 |
#include "block_int.h" |
29 | 29 |
#include "sysemu.h" |
30 | 30 |
|
31 |
int add_init_drive(const char *opts)
|
|
31 |
DriveInfo *add_init_drive(const char *opts)
|
|
32 | 32 |
{ |
33 |
int drive_opt_idx, drive_idx; |
|
34 |
int ret = -1; |
|
33 |
int drive_opt_idx; |
|
34 |
int fatal_error; |
|
35 |
DriveInfo *dinfo; |
|
35 | 36 |
|
36 | 37 |
drive_opt_idx = drive_add(NULL, "%s", opts); |
37 | 38 |
if (!drive_opt_idx) |
38 |
return ret;
|
|
39 |
return NULL;
|
|
39 | 40 |
|
40 |
drive_idx = drive_init(&drives_opt[drive_opt_idx], 0, current_machine);
|
|
41 |
if (drive_idx == -1) {
|
|
41 |
dinfo = drive_init(&drives_opt[drive_opt_idx], 0, current_machine, &fatal_error);
|
|
42 |
if (!dinfo) {
|
|
42 | 43 |
drive_remove(drive_opt_idx); |
43 |
return ret;
|
|
44 |
return NULL;
|
|
44 | 45 |
} |
45 | 46 |
|
46 |
return drive_idx;
|
|
47 |
return dinfo;
|
|
47 | 48 |
} |
48 | 49 |
|
49 | 50 |
void destroy_nic(dev_match_fn *match_fn, void *arg) |
... | ... | |
64 | 65 |
|
65 | 66 |
void destroy_bdrvs(dev_match_fn *match_fn, void *arg) |
66 | 67 |
{ |
67 |
int i;
|
|
68 |
DriveInfo *dinfo;
|
|
68 | 69 |
struct BlockDriverState *bs; |
69 | 70 |
|
70 |
for (i = 0; i <= MAX_DRIVES; i++) {
|
|
71 |
bs = drives_table[i].bdrv;
|
|
71 |
TAILQ_FOREACH(dinfo, &drives, next) {
|
|
72 |
bs = dinfo->bdrv;
|
|
72 | 73 |
if (bs) { |
73 | 74 |
if (bs->private && match_fn(bs->private, arg)) { |
74 | 75 |
drive_uninit(bs); |
b/hw/etraxfs.c | ||
---|---|---|
55 | 55 |
void *etraxfs_dmac; |
56 | 56 |
struct etraxfs_dma_client *eth[2] = {NULL, NULL}; |
57 | 57 |
int kernel_size; |
58 |
DriveInfo *dinfo; |
|
58 | 59 |
int i; |
59 | 60 |
ram_addr_t phys_ram; |
60 | 61 |
ram_addr_t phys_flash; |
... | ... | |
79 | 80 |
|
80 | 81 |
|
81 | 82 |
phys_flash = qemu_ram_alloc(FLASH_SIZE); |
82 |
i = drive_get_index(IF_PFLASH, 0, 0);
|
|
83 |
dinfo = drive_get(IF_PFLASH, 0, 0);
|
|
83 | 84 |
pflash_cfi02_register(0x0, phys_flash, |
84 |
i != -1 ? drives_table[i].bdrv : NULL, (64 * 1024),
|
|
85 |
dinfo ? dinfo->bdrv : NULL, (64 * 1024),
|
|
85 | 86 |
FLASH_SIZE >> 16, |
86 | 87 |
1, 2, 0x0000, 0x0000, 0x0000, 0x0000, |
87 | 88 |
0x555, 0x2aa); |
b/hw/gumstix.c | ||
---|---|---|
47 | 47 |
const char *initrd_filename, const char *cpu_model) |
48 | 48 |
{ |
49 | 49 |
PXA2xxState *cpu; |
50 |
int index;
|
|
50 |
DriveInfo *dinfo;
|
|
51 | 51 |
|
52 | 52 |
uint32_t connex_rom = 0x01000000; |
53 | 53 |
uint32_t connex_ram = 0x04000000; |
54 | 54 |
|
55 | 55 |
cpu = pxa255_init(connex_ram); |
56 | 56 |
|
57 |
index = drive_get_index(IF_PFLASH, 0, 0);
|
|
58 |
if (index == -1) {
|
|
57 |
dinfo = drive_get(IF_PFLASH, 0, 0);
|
|
58 |
if (!dinfo) {
|
|
59 | 59 |
fprintf(stderr, "A flash image must be given with the " |
60 | 60 |
"'pflash' parameter\n"); |
61 | 61 |
exit(1); |
62 | 62 |
} |
63 | 63 |
|
64 | 64 |
if (!pflash_cfi01_register(0x00000000, qemu_ram_alloc(connex_rom), |
65 |
drives_table[index].bdrv, sector_len, connex_rom / sector_len,
|
|
65 |
dinfo->bdrv, sector_len, connex_rom / sector_len,
|
|
66 | 66 |
2, 0, 0, 0, 0)) { |
67 | 67 |
fprintf(stderr, "qemu: Error registering flash memory.\n"); |
68 | 68 |
exit(1); |
... | ... | |
81 | 81 |
const char *initrd_filename, const char *cpu_model) |
82 | 82 |
{ |
83 | 83 |
PXA2xxState *cpu; |
84 |
int index;
|
|
84 |
DriveInfo *dinfo;
|
|
85 | 85 |
|
86 | 86 |
uint32_t verdex_rom = 0x02000000; |
87 | 87 |
uint32_t verdex_ram = 0x10000000; |
88 | 88 |
|
89 | 89 |
cpu = pxa270_init(verdex_ram, cpu_model ?: "pxa270-c0"); |
90 | 90 |
|
91 |
index = drive_get_index(IF_PFLASH, 0, 0);
|
|
92 |
if (index == -1) {
|
|
91 |
dinfo = drive_get(IF_PFLASH, 0, 0);
|
|
92 |
if (!dinfo) {
|
|
93 | 93 |
fprintf(stderr, "A flash image must be given with the " |
94 | 94 |
"'pflash' parameter\n"); |
95 | 95 |
exit(1); |
96 | 96 |
} |
97 | 97 |
|
98 | 98 |
if (!pflash_cfi01_register(0x00000000, qemu_ram_alloc(verdex_rom), |
99 |
drives_table[index].bdrv, sector_len, verdex_rom / sector_len,
|
|
99 |
dinfo->bdrv, sector_len, verdex_rom / sector_len,
|
|
100 | 100 |
2, 0, 0, 0, 0)) { |
101 | 101 |
fprintf(stderr, "qemu: Error registering flash memory.\n"); |
102 | 102 |
exit(1); |
b/hw/mainstone.c | ||
---|---|---|
77 | 77 |
target_phys_addr_t mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 }; |
78 | 78 |
PXA2xxState *cpu; |
79 | 79 |
qemu_irq *mst_irq; |
80 |
int i, index; |
|
80 |
DriveInfo *dinfo; |
|
81 |
int i; |
|
81 | 82 |
|
82 | 83 |
if (!cpu_model) |
83 | 84 |
cpu_model = "pxa270-c5"; |
... | ... | |
92 | 93 |
|
93 | 94 |
/* There are two 32MiB flash devices on the board */ |
94 | 95 |
for (i = 0; i < 2; i ++) { |
95 |
index = drive_get_index(IF_PFLASH, 0, i);
|
|
96 |
if (index == -1) {
|
|
96 |
dinfo = drive_get(IF_PFLASH, 0, i);
|
|
97 |
if (!dinfo) {
|
|
97 | 98 |
fprintf(stderr, "Two flash images must be given with the " |
98 | 99 |
"'pflash' parameter\n"); |
99 | 100 |
exit(1); |
... | ... | |
101 | 102 |
|
102 | 103 |
if (!pflash_cfi01_register(mainstone_flash_base[i], |
103 | 104 |
qemu_ram_alloc(MAINSTONE_FLASH), |
104 |
drives_table[index].bdrv, sector_len,
|
|
105 |
dinfo->bdrv, sector_len,
|
|
105 | 106 |
MAINSTONE_FLASH / sector_len, 4, 0, 0, 0, 0)) { |
106 | 107 |
fprintf(stderr, "qemu: Error registering flash memory.\n"); |
107 | 108 |
exit(1); |
b/hw/mips_jazz.c | ||
---|---|---|
235 | 235 |
exit(1); |
236 | 236 |
} |
237 | 237 |
for (n = 0; n < MAX_FD; n++) { |
238 |
int fd = drive_get_index(IF_FLOPPY, 0, n); |
|
239 |
if (fd != -1) |
|
240 |
fds[n] = drives_table[fd].bdrv; |
|
241 |
else |
|
242 |
fds[n] = NULL; |
|
238 |
DriveInfo *dinfo = drive_get(IF_FLOPPY, 0, n); |
|
239 |
fds[n] = dinfo ? dinfo->bdrv : NULL; |
|
243 | 240 |
} |
244 | 241 |
fdctrl_init(rc4030[1], 0, 1, 0x80003000, fds); |
245 | 242 |
|
b/hw/mips_malta.c | ||
---|---|---|
773 | 773 |
uint8_t *eeprom_buf; |
774 | 774 |
i2c_bus *smbus; |
775 | 775 |
int i; |
776 |
int index;
|
|
776 |
DriveInfo *dinfo;
|
|
777 | 777 |
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
778 | 778 |
BlockDriverState *fd[MAX_FD]; |
779 | 779 |
int fl_idx = 0; |
... | ... | |
827 | 827 |
env->CP0_Status &= ~((1 << CP0St_BEV) | (1 << CP0St_ERL)); |
828 | 828 |
write_bootloader(env, qemu_get_ram_ptr(bios_offset), kernel_entry); |
829 | 829 |
} else { |
830 |
index = drive_get_index(IF_PFLASH, 0, fl_idx);
|
|
831 |
if (index != -1) {
|
|
830 |
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
|
831 |
if (dinfo) {
|
|
832 | 832 |
/* Load firmware from flash. */ |
833 | 833 |
bios_size = 0x400000; |
834 | 834 |
fl_sectors = bios_size >> 16; |
... | ... | |
836 | 836 |
printf("Register parallel flash %d size " TARGET_FMT_lx " at " |
837 | 837 |
"offset %08lx addr %08llx '%s' %x\n", |
838 | 838 |
fl_idx, bios_size, bios_offset, 0x1e000000LL, |
839 |
bdrv_get_device_name(drives_table[index].bdrv), fl_sectors);
|
|
839 |
bdrv_get_device_name(dinfo->bdrv), fl_sectors);
|
|
840 | 840 |
#endif |
841 | 841 |
pflash_cfi01_register(0x1e000000LL, bios_offset, |
842 |
drives_table[index].bdrv, 65536, fl_sectors,
|
|
842 |
dinfo->bdrv, 65536, fl_sectors,
|
|
843 | 843 |
4, 0x0000, 0x0000, 0x0000, 0x0000); |
844 | 844 |
fl_idx++; |
845 | 845 |
} else { |
... | ... | |
898 | 898 |
} |
899 | 899 |
|
900 | 900 |
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { |
901 |
index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
|
902 |
if (index != -1) |
|
903 |
hd[i] = drives_table[index].bdrv; |
|
904 |
else |
|
905 |
hd[i] = NULL; |
|
901 |
dinfo = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
|
902 |
hd[i] = dinfo ? dinfo->bdrv : NULL; |
|
906 | 903 |
} |
907 | 904 |
|
908 | 905 |
piix4_devfn = piix4_init(pci_bus, 80); |
... | ... | |
929 | 926 |
if (parallel_hds[0]) |
930 | 927 |
parallel_init(0x378, i8259[7], parallel_hds[0]); |
931 | 928 |
for(i = 0; i < MAX_FD; i++) { |
932 |
index = drive_get_index(IF_FLOPPY, 0, i); |
|
933 |
if (index != -1) |
|
934 |
fd[i] = drives_table[index].bdrv; |
|
935 |
else |
|
936 |
fd[i] = NULL; |
|
929 |
dinfo = drive_get(IF_FLOPPY, 0, i); |
|
930 |
fd[i] = dinfo ? dinfo->bdrv : NULL; |
|
937 | 931 |
} |
938 | 932 |
floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd); |
939 | 933 |
|
b/hw/mips_r4k.c | ||
---|---|---|
155 | 155 |
RTCState *rtc_state; |
156 | 156 |
int i; |
157 | 157 |
qemu_irq *i8259; |
158 |
int index; |
|
159 | 158 |
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
159 |
DriveInfo *dinfo; |
|
160 | 160 |
|
161 | 161 |
/* init CPUs */ |
162 | 162 |
if (cpu_model == NULL) { |
... | ... | |
208 | 208 |
bios_offset | IO_MEM_ROM); |
209 | 209 |
|
210 | 210 |
load_image_targphys(filename, 0x1fc00000, BIOS_SIZE); |
211 |
} else if ((index = drive_get_index(IF_PFLASH, 0, 0)) > -1) {
|
|
211 |
} else if ((dinfo = drive_get(IF_PFLASH, 0, 0)) != NULL) {
|
|
212 | 212 |
uint32_t mips_rom = 0x00400000; |
213 | 213 |
bios_offset = qemu_ram_alloc(mips_rom); |
214 | 214 |
if (!pflash_cfi01_register(0x1fc00000, bios_offset, |
215 |
drives_table[index].bdrv, sector_len, mips_rom / sector_len,
|
|
215 |
dinfo->bdrv, sector_len, mips_rom / sector_len,
|
|
216 | 216 |
4, 0, 0, 0, 0)) { |
217 | 217 |
fprintf(stderr, "qemu: Error registering flash memory.\n"); |
218 | 218 |
} |
... | ... | |
267 | 267 |
} |
268 | 268 |
|
269 | 269 |
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { |
270 |
index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
|
271 |
if (index != -1) |
|
272 |
hd[i] = drives_table[index].bdrv; |
|
273 |
else |
|
274 |
hd[i] = NULL; |
|
270 |
dinfo = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
|
271 |
hd[i] = dinfo ? dinfo->bdrv : NULL; |
|
275 | 272 |
} |
276 | 273 |
|
277 | 274 |
for(i = 0; i < MAX_IDE_BUS; i++) |
b/hw/musicpal.c | ||
---|---|---|
1512 | 1512 |
qemu_irq pic[32]; |
1513 | 1513 |
DeviceState *dev; |
1514 | 1514 |
int i; |
1515 |
int index; |
|
1516 | 1515 |
unsigned long flash_size; |
1516 |
DriveInfo *dinfo; |
|
1517 | 1517 |
|
1518 | 1518 |
if (!cpu_model) |
1519 | 1519 |
cpu_model = "arm926"; |
... | ... | |
1549 | 1549 |
serial_hds[1], 1); |
1550 | 1550 |
|
1551 | 1551 |
/* Register flash */ |
1552 |
index = drive_get_index(IF_PFLASH, 0, 0);
|
|
1553 |
if (index != -1) {
|
|
1554 |
flash_size = bdrv_getlength(drives_table[index].bdrv);
|
|
1552 |
dinfo = drive_get(IF_PFLASH, 0, 0);
|
|
1553 |
if (dinfo) {
|
|
1554 |
flash_size = bdrv_getlength(dinfo->bdrv);
|
|
1555 | 1555 |
if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 && |
1556 | 1556 |
flash_size != 32*1024*1024) { |
1557 | 1557 |
fprintf(stderr, "Invalid flash image size\n"); |
... | ... | |
1564 | 1564 |
* image is smaller than 32 MB. |
1565 | 1565 |
*/ |
1566 | 1566 |
pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(flash_size), |
1567 |
drives_table[index].bdrv, 0x10000,
|
|
1567 |
dinfo->bdrv, 0x10000,
|
|
1568 | 1568 |
(flash_size + 0xffff) >> 16, |
1569 | 1569 |
MP_FLASH_SIZE_MAX / flash_size, |
1570 | 1570 |
2, 0x00BF, 0x236D, 0x0000, 0x0000, |
b/hw/nand.c | ||
---|---|---|
442 | 442 |
{ |
443 | 443 |
int pagesize; |
444 | 444 |
NANDFlashState *s; |
445 |
int index;
|
|
445 |
DriveInfo *dinfo;
|
|
446 | 446 |
|
447 | 447 |
if (nand_flash_ids[chip_id].size == 0) { |
448 | 448 |
hw_error("%s: Unsupported NAND chip ID.\n", __FUNCTION__); |
449 | 449 |
} |
450 | 450 |
|
451 | 451 |
s = (NANDFlashState *) qemu_mallocz(sizeof(NANDFlashState)); |
452 |
index = drive_get_index(IF_MTD, 0, 0);
|
|
453 |
if (index != -1)
|
|
454 |
s->bdrv = drives_table[index].bdrv;
|
|
452 |
dinfo = drive_get(IF_MTD, 0, 0);
|
|
453 |
if (dinfo)
|
|
454 |
s->bdrv = dinfo->bdrv;
|
|
455 | 455 |
s->manf_id = manf_id; |
456 | 456 |
s->chip_id = chip_id; |
457 | 457 |
s->size = nand_flash_ids[s->chip_id].size << 20; |
b/hw/omap1.c | ||
---|---|---|
4628 | 4628 |
ram_addr_t imif_base, emiff_base; |
4629 | 4629 |
qemu_irq *cpu_irq; |
4630 | 4630 |
qemu_irq dma_irqs[6]; |
4631 |
int sdindex;
|
|
4631 |
DriveInfo *dinfo;
|
|
4632 | 4632 |
|
4633 | 4633 |
if (!core) |
4634 | 4634 |
core = "ti925t"; |
... | ... | |
4740 | 4740 |
omap_dpll_init(&s->dpll[1], 0xfffed000, omap_findclk(s, "dpll2")); |
4741 | 4741 |
omap_dpll_init(&s->dpll[2], 0xfffed100, omap_findclk(s, "dpll3")); |
4742 | 4742 |
|
4743 |
sdindex = drive_get_index(IF_SD, 0, 0);
|
|
4744 |
if (sdindex == -1) {
|
|
4743 |
dinfo = drive_get(IF_SD, 0, 0);
|
|
4744 |
if (!dinfo) {
|
|
4745 | 4745 |
fprintf(stderr, "qemu: missing SecureDigital device\n"); |
4746 | 4746 |
exit(1); |
4747 | 4747 |
} |
4748 |
s->mmc = omap_mmc_init(0xfffb7800, drives_table[sdindex].bdrv,
|
|
4748 |
s->mmc = omap_mmc_init(0xfffb7800, dinfo->bdrv,
|
|
4749 | 4749 |
s->irq[1][OMAP_INT_OQN], &s->drq[OMAP_DMA_MMC_TX], |
4750 | 4750 |
omap_findclk(s, "mmc_ck")); |
4751 | 4751 |
|
b/hw/omap2.c | ||
---|---|---|
4496 | 4496 |
qemu_irq *cpu_irq; |
4497 | 4497 |
qemu_irq dma_irqs[4]; |
4498 | 4498 |
omap_clk gpio_clks[4]; |
4499 |
int sdindex;
|
|
4499 |
DriveInfo *dinfo;
|
|
4500 | 4500 |
int i; |
4501 | 4501 |
|
4502 | 4502 |
/* Core */ |
... | ... | |
4645 | 4645 |
s->sdrc = omap_sdrc_init(0x68009000); |
4646 | 4646 |
s->gpmc = omap_gpmc_init(0x6800a000, s->irq[0][OMAP_INT_24XX_GPMC_IRQ]); |
4647 | 4647 |
|
4648 |
sdindex = drive_get_index(IF_SD, 0, 0);
|
|
4649 |
if (sdindex == -1) {
|
|
4648 |
dinfo = drive_get(IF_SD, 0, 0);
|
|
4649 |
if (!dinfo) {
|
|
4650 | 4650 |
fprintf(stderr, "qemu: missing SecureDigital device\n"); |
4651 | 4651 |
exit(1); |
4652 | 4652 |
} |
4653 |
s->mmc = omap2_mmc_init(omap_l4tao(s->l4, 9), drives_table[sdindex].bdrv,
|
|
4653 |
s->mmc = omap2_mmc_init(omap_l4tao(s->l4, 9), dinfo->bdrv,
|
|
4654 | 4654 |
s->irq[0][OMAP_INT_24XX_MMC_IRQ], |
4655 | 4655 |
&s->drq[OMAP24XX_DMA_MMC1_TX], |
4656 | 4656 |
omap_findclk(s, "mmc_fclk"), omap_findclk(s, "mmc_iclk")); |
b/hw/omap_sx1.c | ||
---|---|---|
127 | 127 |
static uint32_t cs2val = 0x00001139; |
128 | 128 |
static uint32_t cs3val = 0x00001139; |
129 | 129 |
ram_addr_t phys_flash; |
130 |
int index;
|
|
130 |
DriveInfo *dinfo;
|
|
131 | 131 |
int fl_idx; |
132 | 132 |
uint32_t flash_size = flash0_size; |
133 | 133 |
|
... | ... | |
151 | 151 |
|
152 | 152 |
fl_idx = 0; |
153 | 153 |
|
154 |
if ((index = drive_get_index(IF_PFLASH, 0, fl_idx)) > -1) {
|
|
154 |
if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
|
|
155 | 155 |
if (!pflash_cfi01_register(OMAP_CS0_BASE, qemu_ram_alloc(flash_size), |
156 |
drives_table[index].bdrv, sector_size, flash_size / sector_size,
|
|
156 |
dinfo->bdrv, sector_size, flash_size / sector_size,
|
|
157 | 157 |
4, 0, 0, 0, 0)) { |
158 | 158 |
fprintf(stderr, "qemu: Error registering flash memory %d.\n", |
159 | 159 |
fl_idx); |
... | ... | |
162 | 162 |
} |
163 | 163 |
|
164 | 164 |
if ((version == 1) && |
165 |
(index = drive_get_index(IF_PFLASH, 0, fl_idx)) > -1) {
|
|
165 |
(dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
|
|
166 | 166 |
cpu_register_physical_memory(OMAP_CS1_BASE, flash1_size, |
167 | 167 |
(phys_flash = qemu_ram_alloc(flash1_size)) | |
168 | 168 |
IO_MEM_ROM); |
... | ... | |
171 | 171 |
OMAP_CS1_SIZE - flash1_size, io); |
172 | 172 |
|
173 | 173 |
if (!pflash_cfi01_register(OMAP_CS1_BASE, qemu_ram_alloc(flash1_size), |
174 |
drives_table[index].bdrv, sector_size, flash1_size / sector_size,
|
|
174 |
dinfo->bdrv, sector_size, flash1_size / sector_size,
|
|
175 | 175 |
4, 0, 0, 0, 0)) { |
176 | 176 |
fprintf(stderr, "qemu: Error registering flash memory %d.\n", |
177 | 177 |
fl_idx); |
b/hw/onenand.c | ||
---|---|---|
618 | 618 |
void *onenand_init(uint32_t id, int regshift, qemu_irq irq) |
619 | 619 |
{ |
620 | 620 |
OneNANDState *s = (OneNANDState *) qemu_mallocz(sizeof(*s)); |
621 |
int bdrv_index = drive_get_index(IF_MTD, 0, 0);
|
|
621 |
DriveInfo *dinfo = drive_get(IF_MTD, 0, 0);
|
|
622 | 622 |
uint32_t size = 1 << (24 + ((id >> 12) & 7)); |
623 | 623 |
void *ram; |
624 | 624 |
|
... | ... | |
632 | 632 |
s->density_mask = (id & (1 << 11)) ? (1 << (6 + ((id >> 12) & 7))) : 0; |
633 | 633 |
s->iomemtype = cpu_register_io_memory(onenand_readfn, |
634 | 634 |
onenand_writefn, s); |
635 |
if (bdrv_index == -1)
|
|
635 |
if (!dinfo)
|
|
636 | 636 |
s->image = memset(qemu_malloc(size + (size >> 5)), |
637 | 637 |
0xff, size + (size >> 5)); |
638 | 638 |
else |
639 |
s->bdrv = drives_table[bdrv_index].bdrv;
|
|
639 |
s->bdrv = dinfo->bdrv;
|
|
640 | 640 |
s->otp = memset(qemu_malloc((64 + 2) << PAGE_SHIFT), |
641 | 641 |
0xff, (64 + 2) << PAGE_SHIFT); |
642 | 642 |
s->ram = qemu_ram_alloc(0xc000 << s->shift); |
b/hw/pc.c | ||
---|---|---|
1126 | 1126 |
CPUState *env; |
1127 | 1127 |
qemu_irq *cpu_irq; |
1128 | 1128 |
qemu_irq *i8259; |
1129 |
int index;
|
|
1129 |
DriveInfo *dinfo;
|
|
1130 | 1130 |
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
1131 | 1131 |
BlockDriverState *fd[MAX_FD]; |
1132 | 1132 |
int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled; |
... | ... | |
1356 | 1356 |
} |
1357 | 1357 |
|
1358 | 1358 |
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { |
1359 |
index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
|
1360 |
if (index != -1) |
|
1361 |
hd[i] = drives_table[index].bdrv; |
|
1362 |
else |
|
1363 |
hd[i] = NULL; |
|
1359 |
dinfo = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
|
1360 |
hd[i] = dinfo ? dinfo->bdrv : NULL; |
|
1364 | 1361 |
} |
1365 | 1362 |
|
1366 | 1363 |
if (pci_enabled) { |
... | ... | |
1379 | 1376 |
#endif |
1380 | 1377 |
|
1381 | 1378 |
for(i = 0; i < MAX_FD; i++) { |
1382 |
index = drive_get_index(IF_FLOPPY, 0, i); |
|
1383 |
if (index != -1) |
|
1384 |
fd[i] = drives_table[index].bdrv; |
|
1385 |
else |
|
1386 |
fd[i] = NULL; |
|
1379 |
dinfo = drive_get(IF_FLOPPY, 0, i); |
|
1380 |
fd[i] = dinfo ? dinfo->bdrv : NULL; |
|
1387 | 1381 |
} |
1388 | 1382 |
floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd); |
1389 | 1383 |
|
... | ... | |
1437 | 1431 |
|
1438 | 1432 |
/* Add virtio block devices */ |
1439 | 1433 |
if (pci_enabled) { |
1440 |
int index; |
|
1441 | 1434 |
int unit_id = 0; |
1442 | 1435 |
|
1443 |
while ((index = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
|
|
1436 |
while ((dinfo = drive_get(IF_VIRTIO, 0, unit_id)) != NULL) {
|
|
1444 | 1437 |
pci_dev = pci_create(virtio_blk_name, |
1445 |
drives_table[index].devaddr);
|
|
1438 |
dinfo->devaddr);
|
|
1446 | 1439 |
qdev_init(&pci_dev->qdev); |
1447 | 1440 |
unit_id++; |
1448 | 1441 |
} |
b/hw/pci-hotplug.c | ||
---|---|---|
52 | 52 |
{ |
53 | 53 |
int dom, pci_bus; |
54 | 54 |
unsigned slot; |
55 |
int drive_idx, type, bus;
|
|
55 |
int type, bus; |
|
56 | 56 |
int success = 0; |
57 | 57 |
PCIDevice *dev; |
58 |
DriveInfo *dinfo; |
|
58 | 59 |
|
59 | 60 |
if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) { |
60 | 61 |
return; |
... | ... | |
66 | 67 |
return; |
67 | 68 |
} |
68 | 69 |
|
69 |
drive_idx = add_init_drive(opts);
|
|
70 |
if (drive_idx < 0)
|
|
70 |
dinfo = add_init_drive(opts);
|
|
71 |
if (!dinfo)
|
|
71 | 72 |
return; |
72 |
if (drives_table[drive_idx].devaddr) {
|
|
73 |
if (dinfo->devaddr) {
|
|
73 | 74 |
monitor_printf(mon, "Parameter addr not supported\n"); |
74 | 75 |
return; |
75 | 76 |
} |
76 |
type = drives_table[drive_idx].type;
|
|
77 |
type = dinfo->type;
|
|
77 | 78 |
bus = drive_get_max_bus (type); |
78 | 79 |
|
79 | 80 |
switch (type) { |
80 | 81 |
case IF_SCSI: |
81 | 82 |
success = 1; |
82 |
lsi_scsi_attach(&dev->qdev, drives_table[drive_idx].bdrv,
|
|
83 |
drives_table[drive_idx].unit);
|
|
83 |
lsi_scsi_attach(&dev->qdev, dinfo->bdrv,
|
|
84 |
dinfo->unit);
|
|
84 | 85 |
break; |
85 | 86 |
default: |
86 | 87 |
monitor_printf(mon, "Can't hot-add drive to type %d\n", type); |
... | ... | |
88 | 89 |
|
89 | 90 |
if (success) |
90 | 91 |
monitor_printf(mon, "OK bus %d, unit %d\n", |
91 |
drives_table[drive_idx].bus,
|
|
92 |
drives_table[drive_idx].unit);
|
|
92 |
dinfo->bus,
|
|
93 |
dinfo->unit);
|
|
93 | 94 |
return; |
94 | 95 |
} |
95 | 96 |
|
... | ... | |
98 | 99 |
const char *opts) |
99 | 100 |
{ |
100 | 101 |
PCIDevice *dev; |
101 |
int type = -1, drive_idx = -1; |
|
102 |
DriveInfo *dinfo; |
|
103 |
int type = -1; |
|
102 | 104 |
char buf[128]; |
103 | 105 |
|
104 | 106 |
if (get_param_value(buf, sizeof(buf), "if", opts)) { |
... | ... | |
116 | 118 |
} |
117 | 119 |
|
118 | 120 |
if (get_param_value(buf, sizeof(buf), "file", opts)) { |
119 |
drive_idx = add_init_drive(opts);
|
|
120 |
if (drive_idx < 0)
|
|
121 |
dinfo = add_init_drive(opts);
|
|
122 |
if (!dinfo)
|
|
121 | 123 |
return NULL; |
122 |
if (drives_table[drive_idx].devaddr) {
|
|
124 |
if (dinfo->devaddr) {
|
|
123 | 125 |
monitor_printf(mon, "Parameter addr not supported\n"); |
124 | 126 |
return NULL; |
125 | 127 |
} |
b/hw/petalogix_s3adsp1800_mmu.c | ||
---|---|---|
106 | 106 |
DeviceState *dev; |
107 | 107 |
CPUState *env; |
108 | 108 |
int kernel_size; |
109 |
DriveInfo *dinfo; |
|
109 | 110 |
int i; |
110 | 111 |
target_phys_addr_t ddr_base = 0x90000000; |
111 | 112 |
ram_addr_t phys_lmb_bram; |
... | ... | |
131 | 132 |
cpu_register_physical_memory(ddr_base, ram_size, phys_ram | IO_MEM_RAM); |
132 | 133 |
|
133 | 134 |
phys_flash = qemu_ram_alloc(FLASH_SIZE); |
134 |
i = drive_get_index(IF_PFLASH, 0, 0);
|
|
135 |
dinfo = drive_get(IF_PFLASH, 0, 0);
|
|
135 | 136 |
pflash_cfi02_register(0xa0000000, phys_flash, |
136 |
i != -1 ? drives_table[i].bdrv : NULL, (64 * 1024),
|
|
137 |
dinfo ? dinfo->bdrv : NULL, (64 * 1024),
|
|
137 | 138 |
FLASH_SIZE >> 16, |
138 | 139 |
1, 1, 0x0000, 0x0000, 0x0000, 0x0000, |
139 | 140 |
0x555, 0x2aa); |
b/hw/ppc405_boards.c | ||
---|---|---|
188 | 188 |
int linux_boot; |
189 | 189 |
int fl_idx, fl_sectors, len; |
190 | 190 |
int ppc_boot_device = boot_device[0]; |
191 |
int index;
|
|
191 |
DriveInfo *dinfo;
|
|
192 | 192 |
|
193 | 193 |
/* XXX: fix this */ |
194 | 194 |
ram_bases[0] = qemu_ram_alloc(0x08000000); |
... | ... | |
215 | 215 |
#endif |
216 | 216 |
fl_idx = 0; |
217 | 217 |
#ifdef USE_FLASH_BIOS |
218 |
index = drive_get_index(IF_PFLASH, 0, fl_idx);
|
|
219 |
if (index != -1) {
|
|
220 |
bios_size = bdrv_getlength(drives_table[index].bdrv);
|
|
218 |
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
|
219 |
if (dinfo) {
|
|
220 |
bios_size = bdrv_getlength(dinfo->bdrv);
|
|
221 | 221 |
bios_offset = qemu_ram_alloc(bios_size); |
222 | 222 |
fl_sectors = (bios_size + 65535) >> 16; |
223 | 223 |
#ifdef DEBUG_BOARD_INIT |
224 | 224 |
printf("Register parallel flash %d size " ADDRX " at offset %08lx " |
225 | 225 |
" addr " ADDRX " '%s' %d\n", |
226 | 226 |
fl_idx, bios_size, bios_offset, -bios_size, |
227 |
bdrv_get_device_name(drives_table[index].bdrv), fl_sectors);
|
|
227 |
bdrv_get_device_name(dinfo->bdrv), fl_sectors);
|
|
228 | 228 |
#endif |
229 | 229 |
pflash_cfi02_register((uint32_t)(-bios_size), bios_offset, |
230 |
drives_table[index].bdrv, 65536, fl_sectors, 1,
|
|
230 |
dinfo->bdrv, 65536, fl_sectors, 1,
|
|
231 | 231 |
2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA); |
232 | 232 |
fl_idx++; |
233 | 233 |
} else |
... | ... | |
509 | 509 |
int linux_boot; |
510 | 510 |
int fl_idx, fl_sectors; |
511 | 511 |
int ppc_boot_device = boot_device[0]; |
512 |
int index;
|
|
512 |
DriveInfo *dinfo;
|
|
513 | 513 |
|
514 | 514 |
/* RAM is soldered to the board so the size cannot be changed */ |
515 | 515 |
ram_bases[0] = qemu_ram_alloc(0x04000000); |
... | ... | |
528 | 528 |
#endif |
529 | 529 |
fl_idx = 0; |
530 | 530 |
#if defined(USE_FLASH_BIOS) |
531 |
index = drive_get_index(IF_PFLASH, 0, fl_idx);
|
|
532 |
if (index != -1) {
|
|
533 |
bios_size = bdrv_getlength(drives_table[index].bdrv);
|
|
531 |
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
|
532 |
if (dinfo) {
|
|
533 |
bios_size = bdrv_getlength(dinfo->bdrv);
|
|
534 | 534 |
/* XXX: should check that size is 2MB */ |
535 | 535 |
// bios_size = 2 * 1024 * 1024; |
536 | 536 |
fl_sectors = (bios_size + 65535) >> 16; |
... | ... | |
539 | 539 |
printf("Register parallel flash %d size " ADDRX " at offset %08lx " |
540 | 540 |
" addr " ADDRX " '%s' %d\n", |
541 | 541 |
fl_idx, bios_size, bios_offset, -bios_size, |
542 |
bdrv_get_device_name(drives_table[index].bdrv), fl_sectors);
|
|
542 |
bdrv_get_device_name(dinfo->bdrv), fl_sectors);
|
|
543 | 543 |
#endif |
544 | 544 |
pflash_cfi02_register((uint32_t)(-bios_size), bios_offset, |
545 |
drives_table[index].bdrv, 65536, fl_sectors, 1,
|
|
545 |
dinfo->bdrv, 65536, fl_sectors, 1,
|
|
546 | 546 |
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA); |
547 | 547 |
fl_idx++; |
548 | 548 |
} else |
... | ... | |
570 | 570 |
bios_size, bios_offset | IO_MEM_ROM); |
571 | 571 |
} |
572 | 572 |
/* Register Linux flash */ |
573 |
index = drive_get_index(IF_PFLASH, 0, fl_idx);
|
|
574 |
if (index != -1) {
|
|
575 |
bios_size = bdrv_getlength(drives_table[index].bdrv);
|
|
573 |
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
|
574 |
if (dinfo) {
|
|
575 |
bios_size = bdrv_getlength(dinfo->bdrv);
|
|
576 | 576 |
/* XXX: should check that size is 32MB */ |
577 | 577 |
bios_size = 32 * 1024 * 1024; |
578 | 578 |
fl_sectors = (bios_size + 65535) >> 16; |
... | ... | |
580 | 580 |
printf("Register parallel flash %d size " ADDRX " at offset %08lx " |
581 | 581 |
" addr " ADDRX " '%s'\n", |
582 | 582 |
fl_idx, bios_size, bios_offset, (target_ulong)0xfc000000, |
583 |
bdrv_get_device_name(drives_table[index].bdrv));
|
|
583 |
bdrv_get_device_name(dinfo->bdrv));
|
|
584 | 584 |
#endif |
585 | 585 |
bios_offset = qemu_ram_alloc(bios_size); |
586 | 586 |
pflash_cfi02_register(0xfc000000, bios_offset, |
587 |
drives_table[index].bdrv, 65536, fl_sectors, 1,
|
|
587 |
dinfo->bdrv, 65536, fl_sectors, 1,
|
|
588 | 588 |
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA); |
589 | 589 |
fl_idx++; |
590 | 590 |
} |
b/hw/ppc440_bamboo.c | ||
---|---|---|
102 | 102 |
target_ulong dt_base = 0; |
103 | 103 |
void *fdt; |
104 | 104 |
int i; |
105 |
DriveInfo *dinfo; |
|
105 | 106 |
|
106 | 107 |
/* Setup CPU. */ |
107 | 108 |
env = ppc440ep_init(&ram_size, &pcibus, pci_irq_nrs, 1, cpu_model); |
... | ... | |
110 | 111 |
int unit_id = 0; |
111 | 112 |
|
112 | 113 |
/* Add virtio block devices. */ |
113 |
while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
|
|
114 |
pci_dev = pci_create("virtio-blk-pci", drives_table[i].devaddr);
|
|
114 |
while ((dinfo = drive_get(IF_VIRTIO, 0, unit_id)) != NULL) {
|
|
115 |
pci_dev = pci_create("virtio-blk-pci", dinfo->devaddr);
|
|
115 | 116 |
qdev_init(&pci_dev->qdev); |
116 | 117 |
unit_id++; |
117 | 118 |
} |
b/hw/ppc_newworld.c | ||
---|---|---|
106 | 106 |
qemu_irq *dummy_irq; |
107 | 107 |
int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index; |
108 | 108 |
int ppc_boot_device; |
109 |
int index;
|
|
109 |
DriveInfo *dinfo;
|
|
110 | 110 |
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
111 | 111 |
void *fw_cfg; |
112 | 112 |
void *dbdma; |
... | ... | |
315 | 315 |
exit(1); |
316 | 316 |
} |
317 | 317 |
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { |
318 |
index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
|
319 |
if (index != -1) |
|
320 |
hd[i] = drives_table[index].bdrv; |
|
321 |
else |
|
322 |
hd[i] = NULL; |
|
318 |
dinfo = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
|
319 |
hd[i] = dinfo ? dinfo->bdrv : NULL; |
|
323 | 320 |
} |
324 | 321 |
dbdma = DBDMA_init(&dbdma_mem_index); |
325 | 322 |
pci_cmd646_ide_init(pci_bus, hd, 0); |
b/hw/ppc_oldworld.c | ||
---|---|---|
135 | 135 |
int escc_mem_index, ide_mem_index[2]; |
136 | 136 |
uint16_t ppc_boot_device; |
137 | 137 |
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
138 |
int index;
|
|
138 |
DriveInfo *dinfo;
|
|
139 | 139 |
void *fw_cfg; |
140 | 140 |
void *dbdma; |
141 | 141 |
uint8_t *vga_bios_ptr; |
... | ... | |
328 | 328 |
} |
329 | 329 |
|
330 | 330 |
/* First IDE channel is a MAC IDE on the MacIO bus */ |
331 |
index = drive_get_index(IF_IDE, 0, 0); |
|
332 |
if (index == -1) |
|
333 |
hd[0] = NULL; |
|
334 |
else |
|
335 |
hd[0] = drives_table[index].bdrv; |
|
336 |
index = drive_get_index(IF_IDE, 0, 1); |
|
337 |
if (index == -1) |
|
338 |
hd[1] = NULL; |
|
339 |
else |
|
340 |
hd[1] = drives_table[index].bdrv; |
|
331 |
dinfo = drive_get(IF_IDE, 0, 0); |
|
332 |
hd[0] = dinfo ? dinfo->bdrv : NULL; |
|
333 |
dinfo = drive_get(IF_IDE, 0, 1); |
|
334 |
hd[1] = dinfo ? dinfo->bdrv : NULL; |
|
341 | 335 |
dbdma = DBDMA_init(&dbdma_mem_index); |
342 | 336 |
ide_mem_index[0] = -1; |
343 | 337 |
ide_mem_index[1] = pmac_ide_init(hd, pic[0x0D], dbdma, 0x16, pic[0x02]); |
344 | 338 |
|
345 | 339 |
/* Second IDE channel is a CMD646 on the PCI bus */ |
346 |
index = drive_get_index(IF_IDE, 1, 0); |
|
347 |
if (index == -1) |
|
348 |
hd[0] = NULL; |
|
349 |
else |
|
350 |
hd[0] = drives_table[index].bdrv; |
|
351 |
index = drive_get_index(IF_IDE, 1, 1); |
|
352 |
if (index == -1) |
|
353 |
hd[1] = NULL; |
|
354 |
else |
|
355 |
hd[1] = drives_table[index].bdrv; |
|
340 |
dinfo = drive_get(IF_IDE, 1, 0); |
|
341 |
hd[0] = dinfo ? dinfo->bdrv : NULL; |
|
342 |
dinfo = drive_get(IF_IDE, 1, 1); |
|
343 |
hd[1] = dinfo ? dinfo->bdrv : NULL; |
|
356 | 344 |
hd[3] = hd[2] = NULL; |
357 | 345 |
pci_cmd646_ide_init(pci_bus, hd, 0); |
358 | 346 |
|
b/hw/ppc_prep.c | ||
---|---|---|
550 | 550 |
PCIBus *pci_bus; |
551 | 551 |
qemu_irq *i8259; |
552 | 552 |
int ppc_boot_device; |
553 |
int index;
|
|
553 |
DriveInfo *dinfo;
|
|
554 | 554 |
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
555 | 555 |
BlockDriverState *fd[MAX_FD]; |
556 | 556 |
|
... | ... | |
691 | 691 |
} |
692 | 692 |
|
693 | 693 |
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { |
694 |
index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
|
695 |
if (index != -1) |
|
696 |
hd[i] = drives_table[index].bdrv; |
|
697 |
else |
|
698 |
hd[i] = NULL; |
|
694 |
dinfo = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
|
695 |
hd[i] = dinfo ? dinfo->bdrv : NULL; |
|
699 | 696 |
} |
700 | 697 |
|
701 | 698 |
for(i = 0; i < MAX_IDE_BUS; i++) { |
... | ... | |
708 | 705 |
// SB16_init(); |
709 | 706 |
|
710 | 707 |
for(i = 0; i < MAX_FD; i++) { |
711 |
index = drive_get_index(IF_FLOPPY, 0, i); |
|
712 |
if (index != -1) |
|
713 |
fd[i] = drives_table[index].bdrv; |
|
714 |
else |
|
715 |
fd[i] = NULL; |
|
708 |
dinfo = drive_get(IF_FLOPPY, 0, i); |
|
709 |
fd[i] = dinfo ? dinfo->bdrv : NULL; |
|
716 | 710 |
} |
717 | 711 |
fdctrl_init(i8259[6], 2, 0, 0x3f0, fd); |
718 | 712 |
|
b/hw/ppce500_mpc8544ds.c | ||
---|---|---|
172 | 172 |
unsigned int pci_irq_nrs[4] = {1, 2, 3, 4}; |
173 | 173 |
qemu_irq *irqs, *mpic, *pci_irqs; |
174 | 174 |
SerialState * serial[2]; |
175 |
DriveInfo *dinfo; |
|
175 | 176 |
|
176 | 177 |
/* Setup CPU */ |
177 | 178 |
env = cpu_ppc_init("e500v2_v30"); |
... | ... | |
219 | 220 |
int unit_id = 0; |
220 | 221 |
|
221 | 222 |
/* Add virtio block devices. */ |
222 |
while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
|
|
223 |
pci_dev = pci_create("virtio-blk-pci", drives_table[i].devaddr);
|
|
223 |
while ((dinfo = drive_get(IF_VIRTIO, 0, unit_id)) != NULL) {
|
|
224 |
pci_dev = pci_create("virtio-blk-pci", dinfo->devaddr);
|
|
224 | 225 |
qdev_init(&pci_dev->qdev); |
225 | 226 |
unit_id++; |
226 | 227 |
} |
b/hw/pxa2xx.c | ||
---|---|---|
2034 | 2034 |
{ |
2035 | 2035 |
PXA2xxState *s; |
2036 | 2036 |
int iomemtype, i; |
2037 |
int index;
|
|
2037 |
DriveInfo *dinfo;
|
|
2038 | 2038 |
s = (PXA2xxState *) qemu_mallocz(sizeof(PXA2xxState)); |
2039 | 2039 |
|
2040 | 2040 |
if (revision && strncmp(revision, "pxa27", 5)) { |
... | ... | |
2066 | 2066 |
|
2067 | 2067 |
s->gpio = pxa2xx_gpio_init(0x40e00000, s->env, s->pic, 121); |
2068 | 2068 |
|
2069 |
index = drive_get_index(IF_SD, 0, 0);
|
|
2070 |
if (index == -1) {
|
|
2069 |
dinfo = drive_get(IF_SD, 0, 0);
|
|
2070 |
if (!dinfo) {
|
|
2071 | 2071 |
fprintf(stderr, "qemu: missing SecureDigital device\n"); |
2072 | 2072 |
exit(1); |
2073 | 2073 |
} |
2074 |
s->mmc = pxa2xx_mmci_init(0x41100000, drives_table[index].bdrv,
|
|
2074 |
s->mmc = pxa2xx_mmci_init(0x41100000, dinfo->bdrv,
|
|
2075 | 2075 |
s->pic[PXA2XX_PIC_MMC], s->dma); |
2076 | 2076 |
|
2077 | 2077 |
for (i = 0; pxa270_serial[i].io_base; i ++) |
... | ... | |
2153 | 2153 |
{ |
2154 | 2154 |
PXA2xxState *s; |
2155 | 2155 |
int iomemtype, i; |
2156 |
int index;
|
|
2156 |
DriveInfo *dinfo;
|
|
2157 | 2157 |
|
2158 | 2158 |
s = (PXA2xxState *) qemu_mallocz(sizeof(PXA2xxState)); |
2159 | 2159 |
|
... | ... | |
2178 | 2178 |
|
2179 | 2179 |
s->gpio = pxa2xx_gpio_init(0x40e00000, s->env, s->pic, 85); |
2180 | 2180 |
|
2181 |
index = drive_get_index(IF_SD, 0, 0);
|
|
2182 |
if (index == -1) {
|
|
2181 |
dinfo = drive_get(IF_SD, 0, 0);
|
|
2182 |
if (!dinfo) {
|
|
2183 | 2183 |
fprintf(stderr, "qemu: missing SecureDigital device\n"); |
2184 | 2184 |
exit(1); |
2185 | 2185 |
} |
2186 |
s->mmc = pxa2xx_mmci_init(0x41100000, drives_table[index].bdrv,
|
|
2186 |
s->mmc = pxa2xx_mmci_init(0x41100000, dinfo->bdrv,
|
|
2187 | 2187 |
s->pic[PXA2XX_PIC_MMC], s->dma); |
2188 | 2188 |
|
2189 | 2189 |
for (i = 0; pxa255_serial[i].io_base; i ++) |
b/hw/qdev.c | ||
---|---|---|
267 | 267 |
BlockDriverState *qdev_init_bdrv(DeviceState *dev, BlockInterfaceType type) |
268 | 268 |
{ |
269 | 269 |
int unit = next_block_unit[type]++; |
270 |
int index;
|
|
270 |
DriveInfo *dinfo;
|
|
271 | 271 |
|
272 |
index = drive_get_index(type, 0, unit); |
|
273 |
if (index == -1) { |
|
274 |
return NULL; |
|
275 |
} |
|
276 |
return drives_table[index].bdrv; |
|
272 |
dinfo = drive_get(type, 0, unit); |
|
273 |
return dinfo ? dinfo->bdrv : NULL; |
|
277 | 274 |
} |
278 | 275 |
|
279 | 276 |
BusState *qdev_get_child_bus(DeviceState *dev, const char *name) |
... | ... | |
296 | 293 |
{ |
297 | 294 |
int bus = next_scsi_bus++; |
298 | 295 |
int unit; |
299 |
int index;
|
|
296 |
DriveInfo *dinfo;
|
|
300 | 297 |
|
301 | 298 |
for (unit = 0; unit < MAX_SCSI_DEVS; unit++) { |
302 |
index = drive_get_index(IF_SCSI, bus, unit);
|
|
303 |
if (index == -1) {
|
|
299 |
dinfo = drive_get(IF_SCSI, bus, unit);
|
|
300 |
if (!dinfo) {
|
|
304 | 301 |
continue; |
305 | 302 |
} |
306 |
attach(host, drives_table[index].bdrv, unit);
|
|
303 |
attach(host, dinfo->bdrv, unit);
|
|
307 | 304 |
} |
308 | 305 |
} |
309 | 306 |
|
b/hw/r2d.c | ||
---|---|---|
203 | 203 |
ram_addr_t sdram_addr; |
204 | 204 |
qemu_irq *irq; |
205 | 205 |
PCIBus *pci; |
206 |
DriveInfo *dinfo; |
|
206 | 207 |
int i; |
207 | 208 |
|
208 | 209 |
if (!cpu_model) |
... | ... | |
225 | 226 |
sm501_init(0x10000000, SM501_VRAM_SIZE, irq[SM501], serial_hds[2]); |
226 | 227 |
|
227 | 228 |
/* onboard CF (True IDE mode, Master only). */ |
228 |
if ((i = drive_get_index(IF_IDE, 0, 0)) != -1)
|
|
229 |
if ((dinfo = drive_get(IF_IDE, 0, 0)) != NULL)
|
|
229 | 230 |
mmio_ide_init(0x14001000, 0x1400080c, irq[CF_IDE], 1, |
230 |
drives_table[i].bdrv, NULL);
|
|
231 |
dinfo->bdrv, NULL);
|
|
231 | 232 |
|
232 | 233 |
/* NIC: rtl8139 on-board, and 2 slots. */ |
233 | 234 |
for (i = 0; i < nb_nics; i++) |
b/hw/spitz.c | ||
---|---|---|
744 | 744 |
static void spitz_microdrive_attach(PXA2xxState *cpu, int slot) |
745 | 745 |
{ |
746 | 746 |
PCMCIACardState *md; |
747 |
int index; |
|
748 | 747 |
BlockDriverState *bs; |
748 |
DriveInfo *dinfo; |
|
749 | 749 |
|
750 |
index = drive_get_index(IF_IDE, 0, 0);
|
|
751 |
if (index == -1)
|
|
750 |
dinfo = drive_get(IF_IDE, 0, 0);
|
|
751 |
if (!dinfo)
|
|
752 | 752 |
return; |
753 |
bs = drives_table[index].bdrv;
|
|
753 |
bs = dinfo->bdrv;
|
|
754 | 754 |
if (bdrv_is_inserted(bs) && !bdrv_is_removable(bs)) { |
755 | 755 |
md = dscm1xxxx_init(bs); |
756 | 756 |
pxa2xx_pcmcia_attach(cpu->pcmcia[slot], md); |
b/hw/sun4m.c | ||
---|---|---|
581 | 581 |
qemu_irq *cpu_halt; |
582 | 582 |
unsigned long kernel_size; |
583 | 583 |
BlockDriverState *fd[MAX_FD]; |
584 |
int drive_index; |
|
585 | 584 |
void *fw_cfg; |
586 | 585 |
DeviceState *dev; |
586 |
DriveInfo *dinfo; |
|
587 | 587 |
|
588 | 588 |
/* init CPUs */ |
589 | 589 |
if (!cpu_model) |
... | ... | |
662 | 662 |
if (hwdef->fd_base) { |
663 | 663 |
/* there is zero or one floppy drive */ |
664 | 664 |
memset(fd, 0, sizeof(fd)); |
665 |
drive_index = drive_get_index(IF_FLOPPY, 0, 0);
|
|
666 |
if (drive_index != -1)
|
|
667 |
fd[0] = drives_table[drive_index].bdrv;
|
|
665 |
dinfo = drive_get(IF_FLOPPY, 0, 0);
|
|
666 |
if (dinfo)
|
|
667 |
fd[0] = dinfo->bdrv;
|
|
668 | 668 |
|
669 | 669 |
sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd, |
670 | 670 |
&fdc_tc); |
... | ... | |
1507 | 1507 |
qemu_irq fdc_tc; |
1508 | 1508 |
unsigned long kernel_size; |
1509 | 1509 |
BlockDriverState *fd[MAX_FD]; |
1510 |
int drive_index; |
|
1511 | 1510 |
void *fw_cfg; |
1512 | 1511 |
DeviceState *dev; |
1513 | 1512 |
unsigned int i; |
1513 |
DriveInfo *dinfo; |
|
1514 | 1514 |
|
1515 | 1515 |
/* init CPU */ |
1516 | 1516 |
if (!cpu_model) |
... | ... | |
1565 | 1565 |
if (hwdef->fd_base != (target_phys_addr_t)-1) { |
1566 | 1566 |
/* there is zero or one floppy drive */ |
1567 | 1567 |
memset(fd, 0, sizeof(fd)); |
1568 |
drive_index = drive_get_index(IF_FLOPPY, 0, 0);
|
|
1569 |
if (drive_index != -1)
|
|
1570 |
fd[0] = drives_table[drive_index].bdrv;
|
|
1568 |
dinfo = drive_get(IF_FLOPPY, 0, 0);
|
|
1569 |
if (dinfo)
|
|
1570 |
fd[0] = dinfo->bdrv;
|
|
1571 | 1571 |
|
1572 | 1572 |
sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd, |
1573 | 1573 |
&fdc_tc); |
b/hw/sun4u.c | ||
---|---|---|
557 | 557 |
long initrd_size, kernel_size; |
558 | 558 |
PCIBus *pci_bus, *pci_bus2, *pci_bus3; |
559 | 559 |
qemu_irq *irq; |
560 |
int drive_index; |
|
561 | 560 |
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
562 | 561 |
BlockDriverState *fd[MAX_FD]; |
563 | 562 |
void *fw_cfg; |
563 |
DriveInfo *dinfo; |
|
564 | 564 |
|
565 | 565 |
/* init CPUs */ |
566 | 566 |
env = cpu_devinit(cpu_model, hwdef); |
... | ... | |
608 | 608 |
exit(1); |
609 | 609 |
} |
610 | 610 |
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { |
611 |
drive_index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, |
|
612 |
i % MAX_IDE_DEVS); |
|
613 |
if (drive_index != -1) |
|
614 |
hd[i] = drives_table[drive_index].bdrv; |
|
615 |
else |
|
616 |
hd[i] = NULL; |
|
611 |
dinfo = drive_get(IF_IDE, i / MAX_IDE_DEVS, |
|
612 |
i % MAX_IDE_DEVS); |
|
613 |
hd[i] = dinfo ? dinfo->bdrv : NULL; |
|
617 | 614 |
} |
618 | 615 |
|
619 | 616 |
pci_cmd646_ide_init(pci_bus, hd, 1); |
... | ... | |
621 | 618 |
/* FIXME: wire up interrupts. */ |
622 | 619 |
i8042_init(NULL/*1*/, NULL/*12*/, 0x60); |
623 | 620 |
for(i = 0; i < MAX_FD; i++) { |
624 |
drive_index = drive_get_index(IF_FLOPPY, 0, i); |
|
625 |
if (drive_index != -1) |
|
626 |
fd[i] = drives_table[drive_index].bdrv; |
|
627 |
else |
|
628 |
fd[i] = NULL; |
|
621 |
dinfo = drive_get(IF_FLOPPY, 0, i); |
|
622 |
fd[i] = dinfo ? dinfo->bdrv : NULL; |
|
629 | 623 |
} |
630 | 624 |
floppy_controller = fdctrl_init(NULL/*6*/, 2, 0, 0x3f0, fd); |
631 | 625 |
nvram = m48t59_init(NULL/*8*/, 0, 0x0074, NVRAM_SIZE, 59); |
b/hw/tosa.c | ||
---|---|---|
49 | 49 |
static void tosa_microdrive_attach(PXA2xxState *cpu) |
50 | 50 |
{ |
51 | 51 |
PCMCIACardState *md; |
52 |
int index; |
|
53 | 52 |
BlockDriverState *bs; |
53 |
DriveInfo *dinfo; |
|
54 | 54 |
|
55 |
index = drive_get_index(IF_IDE, 0, 0);
|
|
56 |
if (index == -1)
|
|
55 |
dinfo = drive_get(IF_IDE, 0, 0);
|
|
56 |
if (!dinfo)
|
|
57 | 57 |
return; |
58 |
bs = drives_table[index].bdrv;
|
|
58 |
bs = dinfo->bdrv;
|
|
59 | 59 |
if (bdrv_is_inserted(bs) && !bdrv_is_removable(bs)) { |
60 | 60 |
md = dscm1xxxx_init(bs); |
61 | 61 |
pxa2xx_pcmcia_attach(cpu->pcmcia[0], md); |
b/hw/xen_disk.c | ||
---|---|---|
107 | 107 |
int requests_finished; |
108 | 108 |
|
109 | 109 |
/* qemu block driver */ |
110 |
int index;
|
|
110 |
DriveInfo *dinfo;
|
|
111 | 111 |
BlockDriverState *bs; |
112 | 112 |
QEMUBH *bh; |
113 | 113 |
}; |
... | ... | |
575 | 575 |
static int blk_init(struct XenDevice *xendev) |
576 | 576 |
{ |
577 | 577 |
struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); |
578 |
int mode, qflags, have_barriers, info = 0; |
|
578 |
int index, mode, qflags, have_barriers, info = 0;
|
|
579 | 579 |
char *h; |
580 | 580 |
|
581 | 581 |
/* read xenstore entries */ |
... | ... | |
622 | 622 |
info |= VDISK_CDROM; |
623 | 623 |
|
624 | 624 |
/* init qemu block driver */ |
625 |
blkdev->index = (blkdev->xendev.dev - 202 * 256) / 16;
|
|
626 |
blkdev->index = drive_get_index(IF_XEN, 0, blkdev->index);
|
|
627 |
if (blkdev->index == -1) {
|
|
625 |
index = (blkdev->xendev.dev - 202 * 256) / 16; |
|
626 |
blkdev->dinfo = drive_get(IF_XEN, 0, index);
|
|
627 |
if (!blkdev->dinfo) {
|
|
628 | 628 |
/* setup via xenbus -> create new block driver instance */ |
629 | 629 |
xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n"); |
630 | 630 |
blkdev->bs = bdrv_new(blkdev->dev); |
... | ... | |
640 | 640 |
} else { |
641 | 641 |
/* setup via qemu cmdline -> already setup for us */ |
642 | 642 |
xen_be_printf(&blkdev->xendev, 2, "get configured bdrv (cmdline setup)\n"); |
643 |
blkdev->bs = drives_table[blkdev->index].bdrv;
|
|
643 |
blkdev->bs = blkdev->dinfo->bdrv;
|
|
644 | 644 |
} |
645 | 645 |
blkdev->file_blk = BLOCK_SIZE; |
646 | 646 |
blkdev->file_size = bdrv_getlength(blkdev->bs); |
... | ... | |
729 | 729 |
struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); |
730 | 730 |
|
731 | 731 |
if (blkdev->bs) { |
732 |
if (blkdev->index == -1) {
|
|
732 |
if (!blkdev->dinfo) {
|
|
733 | 733 |
/* close/delete only if we created it ourself */ |
734 | 734 |
bdrv_close(blkdev->bs); |
735 | 735 |
bdrv_delete(blkdev->bs); |
b/hw/xen_machine_pv.c | ||
---|---|---|
40 | 40 |
const char *cpu_model) |
41 | 41 |
{ |
42 | 42 |
CPUState *env; |
43 |
int i, index; |
|
43 |
DriveInfo *dinfo; |
|
44 |
int i; |
|
44 | 45 |
|
45 | 46 |
/* Initialize a dummy CPU */ |
46 | 47 |
if (cpu_model == NULL) { |
... | ... | |
90 | 91 |
|
91 | 92 |
/* configure disks */ |
92 | 93 |
for (i = 0; i < 16; i++) { |
93 |
index = drive_get_index(IF_XEN, 0, i);
|
|
94 |
if (index == -1)
|
|
94 |
dinfo = drive_get(IF_XEN, 0, i);
|
|
95 |
if (!dinfo)
|
|
95 | 96 |
continue; |
96 |
xen_config_dev_blk(drives_table + index);
|
|
97 |
xen_config_dev_blk(dinfo);
|
|
97 | 98 |
} |
98 | 99 |
|
99 | 100 |
/* configure nics */ |
b/monitor.c | ||
---|---|---|
253 | 253 |
|
254 | 254 |
static void do_commit(Monitor *mon, const char *device) |
255 | 255 |
{ |
256 |
int i, all_devices; |
|
256 |
int all_devices; |
|
257 |
DriveInfo *dinfo; |
|
257 | 258 |
|
258 | 259 |
all_devices = !strcmp(device, "all"); |
259 |
for (i = 0; i < nb_drives; i++) { |
|
260 |
if (all_devices || |
|
261 |
!strcmp(bdrv_get_device_name(drives_table[i].bdrv), device)) |
|
262 |
bdrv_commit(drives_table[i].bdrv); |
|
260 |
TAILQ_FOREACH(dinfo, &drives, next) { |
|
261 |
if (!all_devices) |
|
262 |
if (!strcmp(bdrv_get_device_name(dinfo->bdrv), device)) |
|
263 |
continue; |
|
264 |
bdrv_commit(dinfo->bdrv); |
|
263 | 265 |
} |
264 | 266 |
} |
265 | 267 |
|
b/qemu-char.c | ||
---|---|---|
350 | 350 |
} |
351 | 351 |
case 's': |
352 | 352 |
{ |
353 |
int i;
|
|
354 |
for (i = 0; i < nb_drives; i++) {
|
|
355 |
bdrv_commit(drives_table[i].bdrv);
|
|
353 |
DriveInfo *dinfo;
|
|
354 |
TAILQ_FOREACH(dinfo, &drives, next) {
|
|
355 |
bdrv_commit(dinfo->bdrv);
|
|
356 | 356 |
} |
357 | 357 |
} |
358 | 358 |
break; |
b/savevm.c | ||
---|---|---|
1011 | 1011 |
static BlockDriverState *get_bs_snapshots(void) |
1012 | 1012 |
{ |
1013 | 1013 |
BlockDriverState *bs; |
1014 |
int i;
|
|
1014 |
DriveInfo *dinfo;
|
|
1015 | 1015 |
|
1016 | 1016 |
if (bs_snapshots) |
1017 | 1017 |
return bs_snapshots; |
1018 |
for(i = 0; i <= nb_drives; i++) {
|
|
1019 |
bs = drives_table[i].bdrv;
|
|
1018 |
TAILQ_FOREACH(dinfo, &drives, next) {
|
|
1019 |
bs = dinfo->bdrv;
|
|
1020 | 1020 |
if (bdrv_can_snapshot(bs)) |
1021 | 1021 |
goto ok; |
1022 | 1022 |
} |
... | ... | |
1050 | 1050 |
|
1051 | 1051 |
void do_savevm(Monitor *mon, const char *name) |
1052 | 1052 |
{ |
1053 |
DriveInfo *dinfo; |
|
1053 | 1054 |
BlockDriverState *bs, *bs1; |
1054 | 1055 |
QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1; |
1055 |
int must_delete, ret, i;
|
|
1056 |
int must_delete, ret; |
|
1056 | 1057 |
QEMUFile *f; |
1057 | 1058 |
int saved_vm_running; |
1058 | 1059 |
uint32_t vm_state_size; |
... | ... | |
1118 | 1119 |
|
1119 | 1120 |
/* create the snapshots */ |
1120 | 1121 |
|
1121 |
for(i = 0; i < nb_drives; i++) {
|
|
1122 |
bs1 = drives_table[i].bdrv;
|
|
1122 |
TAILQ_FOREACH(dinfo, &drives, next) {
|
|
1123 |
bs1 = dinfo->bdrv;
|
|
1123 | 1124 |
if (bdrv_has_snapshot(bs1)) { |
1124 | 1125 |
if (must_delete) { |
1125 | 1126 |
ret = bdrv_snapshot_delete(bs1, old_sn->id_str); |
... | ... | |
1146 | 1147 |
|
1147 | 1148 |
void do_loadvm(Monitor *mon, const char *name) |
1148 | 1149 |
{ |
1150 |
DriveInfo *dinfo; |
|
1149 | 1151 |
BlockDriverState *bs, *bs1; |
1150 | 1152 |
QEMUSnapshotInfo sn; |
1151 | 1153 |
QEMUFile *f; |
1152 |
int i, ret;
|
|
1154 |
int ret; |
|
1153 | 1155 |
int saved_vm_running; |
1154 | 1156 |
|
1155 | 1157 |
bs = get_bs_snapshots(); |
... | ... | |
1164 | 1166 |
saved_vm_running = vm_running; |
1165 | 1167 |
vm_stop(0); |
1166 | 1168 |
|
1167 |
for(i = 0; i <= nb_drives; i++) {
|
|
1168 |
bs1 = drives_table[i].bdrv;
|
|
1169 |
TAILQ_FOREACH(dinfo, &drives, next) {
|
|
1170 |
bs1 = dinfo->bdrv;
|
|
1169 | 1171 |
if (bdrv_has_snapshot(bs1)) { |
1170 | 1172 |
ret = bdrv_snapshot_goto(bs1, name); |
1171 | 1173 |
if (ret < 0) { |
... | ... | |
1217 | 1219 |
|
1218 | 1220 |
void do_delvm(Monitor *mon, const char *name) |
1219 | 1221 |
{ |
1222 |
DriveInfo *dinfo; |
|
1220 | 1223 |
BlockDriverState *bs, *bs1; |
1221 |
int i, ret;
|
|
1224 |
int ret; |
|
1222 | 1225 |
|
1223 | 1226 |
bs = get_bs_snapshots(); |
1224 | 1227 |
if (!bs) { |
... | ... | |
1226 | 1229 |
return; |
1227 | 1230 |
} |
1228 | 1231 |
|
1229 |
for(i = 0; i <= nb_drives; i++) {
|
|
1230 |
bs1 = drives_table[i].bdrv;
|
|
1232 |
TAILQ_FOREACH(dinfo, &drives, next) {
|
|
1233 |
bs1 = dinfo->bdrv;
|
|
1231 | 1234 |
if (bdrv_has_snapshot(bs1)) { |
1232 | 1235 |
ret = bdrv_snapshot_delete(bs1, name); |
1233 | 1236 |
if (ret < 0) { |
... | ... | |
1245 | 1248 |
|
1246 | 1249 |
void do_info_snapshots(Monitor *mon) |
1247 | 1250 |
{ |
1251 |
DriveInfo *dinfo; |
|
1248 | 1252 |
BlockDriverState *bs, *bs1; |
1249 | 1253 |
QEMUSnapshotInfo *sn_tab, *sn; |
1250 | 1254 |
int nb_sns, i; |
... | ... | |
1256 | 1260 |
return; |
1257 | 1261 |
} |
1258 | 1262 |
monitor_printf(mon, "Snapshot devices:"); |
1259 |
for(i = 0; i <= nb_drives; i++) {
|
|
1260 |
bs1 = drives_table[i].bdrv;
|
|
1263 |
TAILQ_FOREACH(dinfo, &drives, next) {
|
|
1264 |
bs1 = dinfo->bdrv;
|
|
1261 | 1265 |
if (bdrv_has_snapshot(bs1)) { |
1262 | 1266 |
if (bs == bs1) |
1263 | 1267 |
monitor_printf(mon, " %s", bdrv_get_device_name(bs1)); |
b/sysemu.h | ||
---|---|---|
3 | 3 |
/* Misc. things related to the system emulator. */ |
4 | 4 |
|
5 | 5 |
#include "qemu-common.h" |
6 |
#include "sys-queue.h" |
|
6 | 7 |
|
7 | 8 |
#ifdef _WIN32 |
8 | 9 |
#include <windows.h> |
... | ... | |
164 | 165 |
BlockInterfaceType type; |
165 | 166 |
int bus; |
166 | 167 |
int unit; |
167 |
int used; |
|
168 | 168 |
int drive_opt_idx; |
169 | 169 |
BlockInterfaceErrorAction onerror; |
170 | 170 |
char serial[BLOCK_SERIAL_STRLEN + 1]; |
171 |
TAILQ_ENTRY(DriveInfo) next; |
|
171 | 172 |
} DriveInfo; |
172 | 173 |
|
173 | 174 |
#define MAX_IDE_DEVS 2 |
174 | 175 |
#define MAX_SCSI_DEVS 7 |
175 | 176 |
#define MAX_DRIVES 32 |
176 | 177 |
|
177 |
extern int nb_drives; |
|
178 |
extern DriveInfo drives_table[MAX_DRIVES+1]; |
|
178 |
extern TAILQ_HEAD(drivelist, DriveInfo) drives; |
|
179 | 179 |
|
180 |
extern int drive_get_index(BlockInterfaceType type, int bus, int unit);
|
|
180 |
extern DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
|
|
181 | 181 |
extern int drive_get_max_bus(BlockInterfaceType type); |
182 | 182 |
extern void drive_uninit(BlockDriverState *bdrv); |
183 | 183 |
extern void drive_remove(int index); |
... | ... | |
196 | 196 |
extern int nb_drives_opt; |
197 | 197 |
|
198 | 198 |
extern int drive_add(const char *file, const char *fmt, ...); |
199 |
extern int drive_init(struct drive_opt *arg, int snapshot, void *machine); |
|
199 |
extern DriveInfo *drive_init(struct drive_opt *arg, int snapshot, void *machine, |
|
200 |
int *fatal_error); |
|
200 | 201 |
|
201 | 202 |
/* acpi */ |
202 | 203 |
typedef void (*qemu_system_device_hot_add_t)(int pcibus, int slot, int state); |
... | ... | |
207 | 208 |
|
208 | 209 |
typedef int (dev_match_fn)(void *dev_private, void *arg); |
209 | 210 |
|
210 |
int add_init_drive(const char *opts);
|
|
211 |
DriveInfo *add_init_drive(const char *opts);
|
|
211 | 212 |
void destroy_nic(dev_match_fn *match_fn, void *arg); |
212 | 213 |
void destroy_bdrvs(dev_match_fn *match_fn, void *arg); |
213 | 214 |
|
b/vl.c | ||
---|---|---|
180 | 180 |
const char *bios_name = NULL; |
181 | 181 |
/* Note: drives_table[MAX_DRIVES] is a dummy block driver if none available |
182 | 182 |
to store the VM snapshots */ |
183 |
DriveInfo drives_table[MAX_DRIVES+1]; |
|
184 |
int nb_drives; |
|
183 |
struct drivelist drives = TAILQ_HEAD_INITIALIZER(drives); |
|
185 | 184 |
enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; |
186 | 185 |
static DisplayState *display_state; |
187 | 186 |
DisplayType display_type = DT_DEFAULT; |
... | ... | |
1879 | 1878 |
return -1; |
1880 | 1879 |
} |
1881 | 1880 |
|
1882 |
static int drive_get_free_idx(void) |
|
1883 |
{ |
|
1884 |
int index; |
|
1885 |
|
|
1886 |
for (index = 0; index < MAX_DRIVES; index++) |
|
1887 |
if (!drives_table[index].used) { |
|
1888 |
drives_table[index].used = 1; |
|
1889 |
return index; |
|
1890 |
} |
|
1891 |
|
|
1892 |
return -1; |
Also available in: Unified diff