Commit 7d8406be authored by pbrook's avatar pbrook
Browse files

PCI SCSI HBA emulation.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1946 c046a42c-6fe2-441c-8c8c-71466251a162
parent 0fc5c15a
......@@ -307,7 +307,7 @@ SOUND_HW += fmopl.o adlib.o
endif
# SCSI layer
VL_OBJS+= scsi-disk.o cdrom.o
VL_OBJS+= scsi-disk.o cdrom.o lsi53c895a.o
# USB layer
VL_OBJS+= usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o
......
This diff is collapsed.
......@@ -838,6 +838,24 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
if (pci_enabled && acpi_enabled) {
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 */
/* XXX: should be done in the Bochs BIOS */
if (pci_enabled) {
......
......@@ -245,7 +245,7 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun)
s->buf_len = 4;
break;
case 0x12:
DPRINTF("Inquiry (len %d)\n", len);
DPRINTF("Inquiry (len %d)\n", len);
if (len < 36) {
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)
if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) {
s->buf[0] = 5;
s->buf[1] = 0x80;
memcpy(&s->buf[16], "QEMU CDROM ", 16);
memcpy(&s->buf[16], "QEMU CD-ROM ", 16);
} else {
s->buf[0] = 0;
memcpy(&s->buf[16], "QEMU HARDDISK ", 16);
}
memcpy(&s->buf[8], "QEMU ", 8);
memcpy(&s->buf[32], QEMU_VERSION, 4);
s->buf[2] = 3; /* SCSI-3 */
s->buf[3] = 2; /* Format 2 */
s->buf[4] = 32;
......@@ -275,18 +276,27 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun)
goto fail;
break;
case 0x1a:
DPRINTF("Mode Sense(6) (page %d, len %d)\n", buf[2], len);
memset(s->buf, 0, 4);
s->buf[0] = 0x16; /* Mode data length (4 + 0x12). */
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;
case 0x5a:
DPRINTF("Mode Sense (page %d, len %d)\n", buf[2], len);
if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) {
memset(s->buf, 0, 4);
s->buf[0] = 4; /* Mode data length. */
s->buf[1] = 0; /* Default media type. */
s->buf[2] = 0x80; /* Readonly. */
s->buf[3] = 0; /* Block descriptor length. */
} else {
memset(s->buf, 0, 0x16);
s->buf[0] = 0x16; /* Mode data length (4 + 0x12). */
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;
break;
case 0x25:
......@@ -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;
is_write = 1;
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:
{
int start_track, format, msf, toclen;
......
......@@ -343,6 +343,7 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
CPUState *env;
void *pic;
void *sic;
void *scsi_hba;
PCIBus *pci_bus;
NICInfo *nd;
int n;
......@@ -377,6 +378,12 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
if (usb_enabled) {
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(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);
int scsi_read_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 */
extern QEMUMachine integratorcp926_machine;
extern QEMUMachine integratorcp1026_machine;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment