提交 7d8406be 编写于 作者: P pbrook

PCI SCSI HBA emulation.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1946 c046a42c-6fe2-441c-8c8c-71466251a162
上级 0fc5c15a
...@@ -307,7 +307,7 @@ SOUND_HW += fmopl.o adlib.o ...@@ -307,7 +307,7 @@ SOUND_HW += fmopl.o adlib.o
endif endif
# SCSI layer # SCSI layer
VL_OBJS+= scsi-disk.o cdrom.o VL_OBJS+= scsi-disk.o cdrom.o lsi53c895a.o
# USB layer # USB layer
VL_OBJS+= usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o VL_OBJS+= usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o
......
此差异已折叠。
...@@ -838,6 +838,24 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device, ...@@ -838,6 +838,24 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
if (pci_enabled && acpi_enabled) { if (pci_enabled && acpi_enabled) {
piix4_pm_init(pci_bus, piix3_devfn + 3); piix4_pm_init(pci_bus, piix3_devfn + 3);
} }
#if 0
/* ??? Need to figure out some way for the user to
specify SCSI devices. */
if (pci_enabled) {
void *scsi;
BlockDriverState *bdrv;
scsi = lsi_scsi_init(pci_bus, -1);
bdrv = bdrv_new("scsidisk");
bdrv_open(bdrv, "scsi_disk.img", 0);
lsi_scsi_attach(scsi, bdrv, -1);
bdrv = bdrv_new("scsicd");
bdrv_open(bdrv, "scsi_cd.iso", 0);
bdrv_set_type_hint(bdrv, BDRV_TYPE_CDROM);
lsi_scsi_attach(scsi, bdrv, -1);
}
#endif
/* must be done after all PCI devices are instanciated */ /* must be done after all PCI devices are instanciated */
/* XXX: should be done in the Bochs BIOS */ /* XXX: should be done in the Bochs BIOS */
if (pci_enabled) { if (pci_enabled) {
......
...@@ -245,7 +245,7 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun) ...@@ -245,7 +245,7 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun)
s->buf_len = 4; s->buf_len = 4;
break; break;
case 0x12: case 0x12:
DPRINTF("Inquiry (len %d)\n", len); DPRINTF("Inquiry (len %d)\n", len);
if (len < 36) { if (len < 36) {
BADF("Inquiry buffer too small (%d)\n", len); BADF("Inquiry buffer too small (%d)\n", len);
} }
...@@ -253,12 +253,13 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun) ...@@ -253,12 +253,13 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun)
if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) { if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) {
s->buf[0] = 5; s->buf[0] = 5;
s->buf[1] = 0x80; s->buf[1] = 0x80;
memcpy(&s->buf[16], "QEMU CDROM ", 16); memcpy(&s->buf[16], "QEMU CD-ROM ", 16);
} else { } else {
s->buf[0] = 0; s->buf[0] = 0;
memcpy(&s->buf[16], "QEMU HARDDISK ", 16); memcpy(&s->buf[16], "QEMU HARDDISK ", 16);
} }
memcpy(&s->buf[8], "QEMU ", 8); memcpy(&s->buf[8], "QEMU ", 8);
memcpy(&s->buf[32], QEMU_VERSION, 4);
s->buf[2] = 3; /* SCSI-3 */ s->buf[2] = 3; /* SCSI-3 */
s->buf[3] = 2; /* Format 2 */ s->buf[3] = 2; /* Format 2 */
s->buf[4] = 32; s->buf[4] = 32;
...@@ -275,18 +276,27 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun) ...@@ -275,18 +276,27 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun)
goto fail; goto fail;
break; break;
case 0x1a: case 0x1a:
DPRINTF("Mode Sense(6) (page %d, len %d)\n", buf[2], len); case 0x5a:
memset(s->buf, 0, 4); DPRINTF("Mode Sense (page %d, len %d)\n", buf[2], len);
s->buf[0] = 0x16; /* Mode data length (4 + 0x12). */ if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) {
s->buf[1] = 0; /* Default media type. */ memset(s->buf, 0, 4);
s->buf[2] = 0; /* Write enabled. */ s->buf[0] = 4; /* Mode data length. */
s->buf[3] = 0; /* Block descriptor length. */ s->buf[1] = 0; /* Default media type. */
/* Caching page. */ s->buf[2] = 0x80; /* Readonly. */
s->buf[4 + 0] = 8; s->buf[3] = 0; /* Block descriptor length. */
s->buf[4 + 1] = 0x12; } else {
s->buf[4 + 2] = 4; /* WCE */ memset(s->buf, 0, 0x16);
if (len > 0x16) s->buf[0] = 0x16; /* Mode data length (4 + 0x12). */
len = 0x16; s->buf[1] = 0; /* Default media type. */
s->buf[2] = 0; /* Write enabled. */
s->buf[3] = 0; /* Block descriptor length. */
/* Caching page. */
s->buf[4 + 0] = 8;
s->buf[4 + 1] = 0x12;
s->buf[4 + 2] = 4; /* WCE */
if (len > 0x16)
len = 0x16;
}
s->buf_len = len; s->buf_len = len;
break; break;
case 0x25: case 0x25:
...@@ -317,6 +327,10 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun) ...@@ -317,6 +327,10 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun)
s->sector_count = len * s->cluster_size; s->sector_count = len * s->cluster_size;
is_write = 1; is_write = 1;
break; break;
case 0x35:
DPRINTF("Syncronise cache (sector %d, count %d)\n", lba, len);
/* ??? Extend block layer and use fsync to implement this. */
break;
case 0x43: case 0x43:
{ {
int start_track, format, msf, toclen; int start_track, format, msf, toclen;
......
...@@ -343,6 +343,7 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device, ...@@ -343,6 +343,7 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
CPUState *env; CPUState *env;
void *pic; void *pic;
void *sic; void *sic;
void *scsi_hba;
PCIBus *pci_bus; PCIBus *pci_bus;
NICInfo *nd; NICInfo *nd;
int n; int n;
...@@ -377,6 +378,12 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device, ...@@ -377,6 +378,12 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
if (usb_enabled) { if (usb_enabled) {
usb_ohci_init(pci_bus, 3, -1); usb_ohci_init(pci_bus, 3, -1);
} }
scsi_hba = lsi_scsi_init(pci_bus, -1);
for (n = 0; n < MAX_DISKS; n++) {
if (bs_table[n]) {
lsi_scsi_attach(scsi_hba, bs_table[n], n);
}
}
pl011_init(0x101f1000, pic, 12, serial_hds[0]); pl011_init(0x101f1000, pic, 12, serial_hds[0]);
pl011_init(0x101f2000, pic, 13, serial_hds[1]); pl011_init(0x101f2000, pic, 13, serial_hds[1]);
......
...@@ -1048,6 +1048,10 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun); ...@@ -1048,6 +1048,10 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun);
int scsi_read_data(SCSIDevice *s, uint8_t *data, uint32_t len); int scsi_read_data(SCSIDevice *s, uint8_t *data, uint32_t len);
int scsi_write_data(SCSIDevice *s, uint8_t *data, uint32_t len); int scsi_write_data(SCSIDevice *s, uint8_t *data, uint32_t len);
/* lsi53c895a.c */
void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id);
void *lsi_scsi_init(PCIBus *bus, int devfn);
/* integratorcp.c */ /* integratorcp.c */
extern QEMUMachine integratorcp926_machine; extern QEMUMachine integratorcp926_machine;
extern QEMUMachine integratorcp1026_machine; extern QEMUMachine integratorcp1026_machine;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册