Commit e4bcb14c authored by ths's avatar ths

Add -drive parameter, by Laurent Vivier.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3759 c046a42c-6fe2-441c-8c8c-71466251a162
parent 7233b355
...@@ -50,14 +50,11 @@ do { printf("ESP: " fmt , ##args); } while (0) ...@@ -50,14 +50,11 @@ do { printf("ESP: " fmt , ##args); } while (0)
#define ESP_REGS 16 #define ESP_REGS 16
#define ESP_SIZE (ESP_REGS * 4) #define ESP_SIZE (ESP_REGS * 4)
#define TI_BUFSZ 32 #define TI_BUFSZ 32
/* The HBA is ID 7, so for simplicitly limit to 7 devices. */
#define ESP_MAX_DEVS 7
typedef struct ESPState ESPState; typedef struct ESPState ESPState;
struct ESPState { struct ESPState {
qemu_irq irq; qemu_irq irq;
BlockDriverState **bd;
uint8_t rregs[ESP_REGS]; uint8_t rregs[ESP_REGS];
uint8_t wregs[ESP_REGS]; uint8_t wregs[ESP_REGS];
int32_t ti_size; int32_t ti_size;
...@@ -65,7 +62,7 @@ struct ESPState { ...@@ -65,7 +62,7 @@ struct ESPState {
uint8_t ti_buf[TI_BUFSZ]; uint8_t ti_buf[TI_BUFSZ];
int sense; int sense;
int dma; int dma;
SCSIDevice *scsi_dev[MAX_DISKS]; SCSIDevice *scsi_dev[ESP_MAX_DEVS];
SCSIDevice *current_dev; SCSIDevice *current_dev;
uint8_t cmdbuf[TI_BUFSZ]; uint8_t cmdbuf[TI_BUFSZ];
int cmdlen; int cmdlen;
...@@ -172,7 +169,7 @@ static int get_cmd(ESPState *s, uint8_t *buf) ...@@ -172,7 +169,7 @@ static int get_cmd(ESPState *s, uint8_t *buf)
s->async_len = 0; s->async_len = 0;
} }
if (target >= MAX_DISKS || !s->scsi_dev[target]) { if (target >= ESP_MAX_DEVS || !s->scsi_dev[target]) {
// No such drive // No such drive
s->rregs[ESP_RSTAT] = STAT_IN; s->rregs[ESP_RSTAT] = STAT_IN;
s->rregs[ESP_RINTR] = INTR_DC; s->rregs[ESP_RINTR] = INTR_DC;
...@@ -621,7 +618,7 @@ void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id) ...@@ -621,7 +618,7 @@ void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id)
s->scsi_dev[id] = scsi_disk_init(bd, 0, esp_command_complete, s); s->scsi_dev[id] = scsi_disk_init(bd, 0, esp_command_complete, s);
} }
void *esp_init(BlockDriverState **bd, target_phys_addr_t espaddr, void *esp_init(target_phys_addr_t espaddr,
void *dma_opaque, qemu_irq irq, qemu_irq *reset) void *dma_opaque, qemu_irq irq, qemu_irq *reset)
{ {
ESPState *s; ESPState *s;
...@@ -631,7 +628,6 @@ void *esp_init(BlockDriverState **bd, target_phys_addr_t espaddr, ...@@ -631,7 +628,6 @@ void *esp_init(BlockDriverState **bd, target_phys_addr_t espaddr,
if (!s) if (!s)
return NULL; return NULL;
s->bd = bd;
s->irq = irq; s->irq = irq;
s->dma_opaque = dma_opaque; s->dma_opaque = dma_opaque;
......
...@@ -47,6 +47,7 @@ static void connex_init(int ram_size, int vga_ram_size, ...@@ -47,6 +47,7 @@ static void connex_init(int ram_size, int vga_ram_size,
const char *initrd_filename, const char *cpu_model) const char *initrd_filename, const char *cpu_model)
{ {
struct pxa2xx_state_s *cpu; struct pxa2xx_state_s *cpu;
int index;
uint32_t connex_rom = 0x01000000; uint32_t connex_rom = 0x01000000;
uint32_t connex_ram = 0x04000000; uint32_t connex_ram = 0x04000000;
...@@ -59,14 +60,15 @@ static void connex_init(int ram_size, int vga_ram_size, ...@@ -59,14 +60,15 @@ static void connex_init(int ram_size, int vga_ram_size,
cpu = pxa255_init(connex_ram, ds); cpu = pxa255_init(connex_ram, ds);
if (pflash_table[0] == NULL) { index = drive_get_index(IF_PFLASH, 0, 0);
if (index == -1) {
fprintf(stderr, "A flash image must be given with the " fprintf(stderr, "A flash image must be given with the "
"'pflash' parameter\n"); "'pflash' parameter\n");
exit(1); exit(1);
} }
if (!pflash_register(0x00000000, qemu_ram_alloc(connex_rom), if (!pflash_register(0x00000000, qemu_ram_alloc(connex_rom),
pflash_table[0], sector_len, connex_rom / sector_len, drives_table[index].bdrv, sector_len, connex_rom / sector_len,
2, 0, 0, 0, 0)) { 2, 0, 0, 0, 0)) {
fprintf(stderr, "qemu: Error registering flash memory.\n"); fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1); exit(1);
...@@ -85,6 +87,7 @@ static void verdex_init(int ram_size, int vga_ram_size, ...@@ -85,6 +87,7 @@ static void verdex_init(int ram_size, int vga_ram_size,
const char *initrd_filename, const char *cpu_model) const char *initrd_filename, const char *cpu_model)
{ {
struct pxa2xx_state_s *cpu; struct pxa2xx_state_s *cpu;
int index;
uint32_t verdex_rom = 0x02000000; uint32_t verdex_rom = 0x02000000;
uint32_t verdex_ram = 0x10000000; uint32_t verdex_ram = 0x10000000;
...@@ -97,14 +100,15 @@ static void verdex_init(int ram_size, int vga_ram_size, ...@@ -97,14 +100,15 @@ static void verdex_init(int ram_size, int vga_ram_size,
cpu = pxa270_init(verdex_ram, ds, cpu_model ?: "pxa270-c0"); cpu = pxa270_init(verdex_ram, ds, cpu_model ?: "pxa270-c0");
if (pflash_table[0] == NULL) { index = drive_get_index(IF_PFLASH, 0, 0);
if (index == -1) {
fprintf(stderr, "A flash image must be given with the " fprintf(stderr, "A flash image must be given with the "
"'pflash' parameter\n"); "'pflash' parameter\n");
exit(1); exit(1);
} }
if (!pflash_register(0x00000000, qemu_ram_alloc(verdex_rom), if (!pflash_register(0x00000000, qemu_ram_alloc(verdex_rom),
pflash_table[0], sector_len, verdex_rom / sector_len, drives_table[index].bdrv, sector_len, verdex_rom / sector_len,
2, 0, 0, 0, 0)) { 2, 0, 0, 0, 0)) {
fprintf(stderr, "qemu: Error registering flash memory.\n"); fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1); exit(1);
......
...@@ -478,6 +478,7 @@ static void integratorcp_init(int ram_size, int vga_ram_size, ...@@ -478,6 +478,7 @@ static void integratorcp_init(int ram_size, int vga_ram_size,
uint32_t bios_offset; uint32_t bios_offset;
qemu_irq *pic; qemu_irq *pic;
qemu_irq *cpu_pic; qemu_irq *cpu_pic;
int sd;
if (!cpu_model) if (!cpu_model)
cpu_model = "arm926"; cpu_model = "arm926";
...@@ -506,7 +507,12 @@ static void integratorcp_init(int ram_size, int vga_ram_size, ...@@ -506,7 +507,12 @@ static void integratorcp_init(int ram_size, int vga_ram_size,
icp_control_init(0xcb000000); icp_control_init(0xcb000000);
pl050_init(0x18000000, pic[3], 0); pl050_init(0x18000000, pic[3], 0);
pl050_init(0x19000000, pic[4], 1); pl050_init(0x19000000, pic[4], 1);
pl181_init(0x1c000000, sd_bdrv, pic[23], pic[24]); sd = drive_get_index(IF_SD, 0, 0);
if (sd == -1) {
fprintf(stderr, "qemu: missing SecureDigital card\n");
exit(1);
}
pl181_init(0x1c000000, drives_table[sd].bdrv, pic[23], pic[24]);
if (nd_table[0].vlan) { if (nd_table[0].vlan) {
if (nd_table[0].model == NULL if (nd_table[0].model == NULL
|| strcmp(nd_table[0].model, "smc91c111") == 0) { || strcmp(nd_table[0].model, "smc91c111") == 0) {
......
...@@ -151,9 +151,6 @@ do { fprintf(stderr, "lsi_scsi: error: " fmt , ##args);} while (0) ...@@ -151,9 +151,6 @@ do { fprintf(stderr, "lsi_scsi: error: " fmt , ##args);} while (0)
#define PHASE_MI 7 #define PHASE_MI 7
#define PHASE_MASK 7 #define PHASE_MASK 7
/* The HBA is ID 7, so for simplicitly limit to 7 devices. */
#define LSI_MAX_DEVS 7
/* Maximum length of MSG IN data. */ /* Maximum length of MSG IN data. */
#define LSI_MAX_MSGIN_LEN 8 #define LSI_MAX_MSGIN_LEN 8
......
...@@ -29,6 +29,7 @@ static void mainstone_common_init(int ram_size, int vga_ram_size, ...@@ -29,6 +29,7 @@ static void mainstone_common_init(int ram_size, int vga_ram_size,
uint32_t mainstone_rom = 0x00800000; uint32_t mainstone_rom = 0x00800000;
struct pxa2xx_state_s *cpu; struct pxa2xx_state_s *cpu;
qemu_irq *mst_irq; qemu_irq *mst_irq;
int index;
if (!cpu_model) if (!cpu_model)
cpu_model = "pxa270-c5"; cpu_model = "pxa270-c5";
...@@ -47,18 +48,32 @@ static void mainstone_common_init(int ram_size, int vga_ram_size, ...@@ -47,18 +48,32 @@ static void mainstone_common_init(int ram_size, int vga_ram_size,
/* Setup initial (reset) machine state */ /* Setup initial (reset) machine state */
cpu->env->regs[15] = PXA2XX_SDRAM_BASE; cpu->env->regs[15] = PXA2XX_SDRAM_BASE;
/* There are two 32MiB flash devices on the board */ /* There are two 32MiB flash devices on the board */
if (!pflash_register(MST_FLASH_0, mainstone_ram + PXA2XX_INTERNAL_SIZE, index = drive_get_index(IF_PFLASH, 0, 0);
pflash_table[0], 256 * 1024, 128, 4, 0, 0, 0, 0)) { if (index == -1) {
fprintf(stderr, "qemu: Error register flash memory.\n"); fprintf(stderr, "Two flash images must be given with the "
exit(1); "'pflash' parameter\n");
} exit(1);
}
if (!pflash_register(MST_FLASH_0, mainstone_ram + PXA2XX_INTERNAL_SIZE,
drives_table[index].bdrv,
256 * 1024, 128, 4, 0, 0, 0, 0)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
if (!pflash_register(MST_FLASH_1, mainstone_ram + PXA2XX_INTERNAL_SIZE, index = drive_get_index(IF_PFLASH, 0, 1);
pflash_table[1], 256 * 1024, 128, 4, 0, 0, 0, 0)) { if (index == -1) {
fprintf(stderr, "qemu: Error register flash memory.\n"); fprintf(stderr, "Two flash images must be given with the "
exit(1); "'pflash' parameter\n");
} exit(1);
}
if (!pflash_register(MST_FLASH_1, mainstone_ram + PXA2XX_INTERNAL_SIZE,
drives_table[index].bdrv,
256 * 1024, 128, 4, 0, 0, 0, 0)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
mst_irq = mst_irq_init(cpu, MST_FPGA_PHYS, PXA2XX_PIC_GPIO_0); mst_irq = mst_irq_init(cpu, MST_FPGA_PHYS, PXA2XX_PIC_GPIO_0);
smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]); smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]);
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
#define ENVP_NB_ENTRIES 16 #define ENVP_NB_ENTRIES 16
#define ENVP_ENTRY_SIZE 256 #define ENVP_ENTRY_SIZE 256
#define MAX_IDE_BUS 2
extern FILE *logfile; extern FILE *logfile;
typedef struct { typedef struct {
...@@ -776,6 +778,9 @@ void mips_malta_init (int ram_size, int vga_ram_size, ...@@ -776,6 +778,9 @@ void mips_malta_init (int ram_size, int vga_ram_size,
uint8_t *eeprom_buf; uint8_t *eeprom_buf;
i2c_bus *smbus; i2c_bus *smbus;
int i; int i;
int index;
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
BlockDriverState *fd[MAX_FD];
/* init CPUs */ /* init CPUs */
if (cpu_model == NULL) { if (cpu_model == NULL) {
...@@ -862,8 +867,22 @@ void mips_malta_init (int ram_size, int vga_ram_size, ...@@ -862,8 +867,22 @@ void mips_malta_init (int ram_size, int vga_ram_size,
pci_bus = pci_gt64120_init(i8259); pci_bus = pci_gt64120_init(i8259);
/* Southbridge */ /* Southbridge */
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++) {
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;
}
piix4_devfn = piix4_init(pci_bus, 80); piix4_devfn = piix4_init(pci_bus, 80);
pci_piix4_ide_init(pci_bus, bs_table, piix4_devfn + 1, i8259); pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1, i8259);
usb_uhci_piix4_init(pci_bus, piix4_devfn + 2); usb_uhci_piix4_init(pci_bus, piix4_devfn + 2);
smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100); smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100);
eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this persistent */ eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this persistent */
...@@ -883,7 +902,14 @@ void mips_malta_init (int ram_size, int vga_ram_size, ...@@ -883,7 +902,14 @@ void mips_malta_init (int ram_size, int vga_ram_size,
serial_init(0x2f8, i8259[3], serial_hds[1]); serial_init(0x2f8, i8259[3], serial_hds[1]);
if (parallel_hds[0]) if (parallel_hds[0])
parallel_init(0x378, i8259[7], parallel_hds[0]); parallel_init(0x378, i8259[7], parallel_hds[0]);
floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd_table); 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;
}
floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd);
/* Sound card */ /* Sound card */
#ifdef HAS_AUDIO #ifdef HAS_AUDIO
......
...@@ -44,6 +44,9 @@ ...@@ -44,6 +44,9 @@
#define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000)) #define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000))
#define MAX_IDE_BUS 2
#define MAX_FD 2
static const int ide_iobase[2] = { 0x1f0, 0x170 }; static const int ide_iobase[2] = { 0x1f0, 0x170 };
static const int ide_iobase2[2] = { 0x3f6, 0x376 }; static const int ide_iobase2[2] = { 0x3f6, 0x376 };
static const int ide_irq[2] = { 14, 15 }; static const int ide_irq[2] = { 14, 15 };
...@@ -72,6 +75,8 @@ void mips_pica61_init (int ram_size, int vga_ram_size, ...@@ -72,6 +75,8 @@ void mips_pica61_init (int ram_size, int vga_ram_size,
int i; int i;
int available_ram; int available_ram;
qemu_irq *i8259; qemu_irq *i8259;
int index;
BlockDriverState *fd[MAX_FD];
/* init CPUs */ /* init CPUs */
if (cpu_model == NULL) { if (cpu_model == NULL) {
...@@ -141,9 +146,20 @@ void mips_pica61_init (int ram_size, int vga_ram_size, ...@@ -141,9 +146,20 @@ void mips_pica61_init (int ram_size, int vga_ram_size,
i8042_mm_init(i8259[6], i8259[7], 0x80005060, 0); i8042_mm_init(i8259[6], i8259[7], 0x80005060, 0);
/* IDE controller */ /* IDE controller */
for(i = 0; i < 2; i++)
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; i++) {
int hd0, hd1;
hd0 = drive_get_index(IF_IDE, i, 0);
hd1 = drive_get_index(IF_IDE, i, 1);
isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]],
bs_table[2 * i], bs_table[2 * i + 1]); hd0 == -1 ? NULL : drives_table[hd0].bdrv,
hd1 == -1 ? NULL : drives_table[hd1].bdrv);
}
/* Network controller */ /* Network controller */
/* FIXME: missing NS SONIC DP83932 */ /* FIXME: missing NS SONIC DP83932 */
...@@ -152,7 +168,14 @@ void mips_pica61_init (int ram_size, int vga_ram_size, ...@@ -152,7 +168,14 @@ void mips_pica61_init (int ram_size, int vga_ram_size,
/* FIXME: missing NCR 53C94 */ /* FIXME: missing NCR 53C94 */
/* ISA devices (floppy, serial, parallel) */ /* ISA devices (floppy, serial, parallel) */
fdctrl_init(i8259[1], 1, 1, 0x80003000, fd_table);
for (i = 0; i < MAX_FD; i++) {
index = drive_get_index(IF_FLOPPY, 0, i);
if (index == -1)
continue;
fd[i] = drives_table[index].bdrv;
}
fdctrl_init(i8259[1], 1, 1, 0x80003000, fd);
for(i = 0; i < MAX_SERIAL_PORTS; i++) { for(i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) { if (serial_hds[i]) {
serial_mm_init(serial_base[i], 0, i8259[serial_irq[i]], serial_hds[i], 1); serial_mm_init(serial_base[i], 0, i8259[serial_irq[i]], serial_hds[i], 1);
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000)) #define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000))
#define MAX_IDE_BUS 2
static const int ide_iobase[2] = { 0x1f0, 0x170 }; static const int ide_iobase[2] = { 0x1f0, 0x170 };
static const int ide_iobase2[2] = { 0x3f6, 0x376 }; static const int ide_iobase2[2] = { 0x3f6, 0x376 };
static const int ide_irq[2] = { 14, 15 }; static const int ide_irq[2] = { 14, 15 };
...@@ -155,6 +157,8 @@ void mips_r4k_init (int ram_size, int vga_ram_size, ...@@ -155,6 +157,8 @@ void mips_r4k_init (int ram_size, int vga_ram_size,
RTCState *rtc_state; RTCState *rtc_state;
int i; int i;
qemu_irq *i8259; qemu_irq *i8259;
int index;
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
/* init CPUs */ /* init CPUs */
if (cpu_model == NULL) { if (cpu_model == NULL) {
...@@ -245,9 +249,23 @@ void mips_r4k_init (int ram_size, int vga_ram_size, ...@@ -245,9 +249,23 @@ void mips_r4k_init (int ram_size, int vga_ram_size,
} }
} }
for(i = 0; i < 2; i++) 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++) {
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;
}
for(i = 0; i < MAX_IDE_BUS; i++)
isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]],
bs_table[2 * i], bs_table[2 * i + 1]); hd[MAX_IDE_DEVS * i],
hd[MAX_IDE_DEVS * i + 1]);
i8042_init(i8259[1], i8259[12], 0x60); i8042_init(i8259[1], i8259[12], 0x60);
ds1225y_init(0x9000, "nvram"); ds1225y_init(0x9000, "nvram");
......
...@@ -444,14 +444,20 @@ struct nand_flash_s *nand_init(int manf_id, int chip_id) ...@@ -444,14 +444,20 @@ struct nand_flash_s *nand_init(int manf_id, int chip_id)
{ {
int pagesize; int pagesize;
struct nand_flash_s *s; struct nand_flash_s *s;
int index;
if (nand_flash_ids[chip_id].size == 0) { if (nand_flash_ids[chip_id].size == 0) {
cpu_abort(cpu_single_env, "%s: Unsupported NAND chip ID.\n", cpu_abort(cpu_single_env, "%s: Unsupported NAND chip ID.\n",
__FUNCTION__); __FUNCTION__);
} }
index = drive_get_index(IF_MTD, 0, 0);
if (index == -1) {
cpu_abort(cpu_single_env, "%s: missing MTD device\n",
__FUNCTION__);
}
s = (struct nand_flash_s *) qemu_mallocz(sizeof(struct nand_flash_s)); s = (struct nand_flash_s *) qemu_mallocz(sizeof(struct nand_flash_s));
s->bdrv = mtd_bdrv; s->bdrv = drives_table[index].bdrv;
s->manf_id = manf_id; s->manf_id = manf_id;
s->chip_id = chip_id; s->chip_id = chip_id;
s->size = nand_flash_ids[s->chip_id].size << 20; s->size = nand_flash_ids[s->chip_id].size << 20;
......
...@@ -4901,6 +4901,7 @@ struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size, ...@@ -4901,6 +4901,7 @@ struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size,
struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) struct omap_mpu_state_s *s = (struct omap_mpu_state_s *)
qemu_mallocz(sizeof(struct omap_mpu_state_s)); qemu_mallocz(sizeof(struct omap_mpu_state_s));
ram_addr_t imif_base, emiff_base; ram_addr_t imif_base, emiff_base;
int index;
if (!core) if (!core)
core = "ti925t"; core = "ti925t";
...@@ -4997,7 +4998,13 @@ struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size, ...@@ -4997,7 +4998,13 @@ 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[1], 0xfffed000, omap_findclk(s, "dpll2"));
omap_dpll_init(&s->dpll[2], 0xfffed100, omap_findclk(s, "dpll3")); omap_dpll_init(&s->dpll[2], 0xfffed100, omap_findclk(s, "dpll3"));
s->mmc = omap_mmc_init(0xfffb7800, sd_bdrv, s->irq[1][OMAP_INT_OQN], index = drive_get_index(IF_SD, 0, 0);
if (index == -1) {
fprintf(stderr, "qemu: missing SecureDigital device\n");
exit(1);
}
s->mmc = omap_mmc_init(0xfffb7800, drives_table[index].bdrv,
s->irq[1][OMAP_INT_OQN],
&s->drq[OMAP_DMA_MMC_TX], omap_findclk(s, "mmc_ck")); &s->drq[OMAP_DMA_MMC_TX], omap_findclk(s, "mmc_ck"));
s->mpuio = omap_mpuio_init(0xfffb5000, s->mpuio = omap_mpuio_init(0xfffb5000,
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
/* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables. */ /* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables. */
#define ACPI_DATA_SIZE 0x10000 #define ACPI_DATA_SIZE 0x10000
#define MAX_IDE_BUS 2
static fdctrl_t *floppy_controller; static fdctrl_t *floppy_controller;
static RTCState *rtc_state; static RTCState *rtc_state;
static PITState *pit; static PITState *pit;
...@@ -381,8 +383,10 @@ static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip) ...@@ -381,8 +383,10 @@ static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip)
{ {
uint8_t bootsect[512], *p; uint8_t bootsect[512], *p;
int i; int i;
int hda;
if (bs_table[0] == NULL) { hda = drive_get_index(IF_IDE, 0, 0);
if (hda == -1) {
fprintf(stderr, "A disk image must be given for 'hda' when booting " fprintf(stderr, "A disk image must be given for 'hda' when booting "
"a Linux kernel\n"); "a Linux kernel\n");
exit(1); exit(1);
...@@ -391,7 +395,7 @@ static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip) ...@@ -391,7 +395,7 @@ static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip)
memset(bootsect, 0, sizeof(bootsect)); memset(bootsect, 0, sizeof(bootsect));
/* Copy the MSDOS partition table if possible */ /* Copy the MSDOS partition table if possible */
bdrv_read(bs_table[0], 0, bootsect, 1); bdrv_read(drives_table[hda].bdrv, 0, bootsect, 1);
/* Make sure we have a partition signature */ /* Make sure we have a partition signature */
bootsect[510] = 0x55; bootsect[510] = 0x55;
...@@ -428,7 +432,7 @@ static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip) ...@@ -428,7 +432,7 @@ static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip)
*p++ = segs[1]; /* CS */ *p++ = segs[1]; /* CS */
*p++ = segs[1] >> 8; *p++ = segs[1] >> 8;
bdrv_set_boot_sector(bs_table[0], bootsect, sizeof(bootsect)); bdrv_set_boot_sector(drives_table[hda].bdrv, bootsect, sizeof(bootsect));
} }
static int load_kernel(const char *filename, uint8_t *addr, static int load_kernel(const char *filename, uint8_t *addr,
...@@ -709,6 +713,9 @@ static void pc_init1(int ram_size, int vga_ram_size, ...@@ -709,6 +713,9 @@ static void pc_init1(int ram_size, int vga_ram_size,
NICInfo *nd; NICInfo *nd;
qemu_irq *cpu_irq; qemu_irq *cpu_irq;
qemu_irq *i8259; qemu_irq *i8259;
int index;
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
BlockDriverState *fd[MAX_FD];
linux_boot = (kernel_filename != NULL); linux_boot = (kernel_filename != NULL);