socsvn commit: r257502 - soc2013/zcore/head/usr.sbin/bhyve
zcore at FreeBSD.org
zcore at FreeBSD.org
Thu Sep 19 16:28:03 UTC 2013
Author: zcore
Date: Thu Sep 19 16:28:02 2013
New Revision: 257502
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257502
Log:
support MODE_SENSE_10
Modified:
soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c
Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c
==============================================================================
--- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Sep 19 16:27:34 2013 (r257501)
+++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Sep 19 16:28:02 2013 (r257502)
@@ -88,6 +88,12 @@
#define READ_CD 0xBE
/*
+ * SCSI mode page codes
+ */
+#define MODEPAGE_RW_ERROR_RECOVERY 0x01
+#define MODEPAGE_CD_CAPABILITIES 0x2A
+
+/*
* Debug printf
*/
#ifdef AHCI_DEBUG
@@ -931,6 +937,78 @@
}
static void
+atapi_mode_sense(struct ahci_port *p, int slot, uint8_t *cfis)
+{
+ int len;
+ uint32_t tfd;
+ uint8_t pc, code, *acmd = cfis + 0x40;
+
+ len = be16dec(acmd + 7);
+ pc = acmd[2] >> 6;
+ code = acmd[2] & 0x3f;
+ switch (pc) {
+ case 0:
+ switch (code) {
+ case MODEPAGE_RW_ERROR_RECOVERY:
+ {
+ uint8_t buf[16];
+
+ if (len > sizeof(buf))
+ len = sizeof(buf);
+
+ memset(buf, 0, sizeof(buf));
+ be16enc(buf, 16 - 2);
+ buf[2] = 0x70;
+ buf[8] = 0x01;
+ buf[9] = 16 - 10;
+ buf[11] = 0x05;
+ write_prdt(p, slot, cfis, buf, len);
+ tfd = ATA_S_READY | ATA_S_DSC;
+ break;
+ }
+ case MODEPAGE_CD_CAPABILITIES:
+ {
+ uint8_t buf[30];
+
+ if (len > sizeof(buf))
+ len = sizeof(buf);
+
+ memset(buf, 0, sizeof(buf));
+ be16enc(buf, 30 - 2);
+ buf[2] = 0x70;
+ buf[8] = 0x2A;
+ buf[9] = 30 - 10;
+ buf[10] = 0x08;
+ buf[12] = 0x71;
+ be16enc(&buf[18], 2);
+ be16enc(&buf[20], 512);
+ write_prdt(p, slot, cfis, buf, len);
+ tfd = ATA_S_READY | ATA_S_DSC;
+ break;
+ }
+ default:
+ goto error;
+ break;
+ }
+ break;
+ case 3:
+ p->sense_key = ATA_SENSE_ILLEGAL_REQUEST;
+ p->asc = 0x39;
+ tfd = (p->sense_key << 12) | ATA_S_READY | ATA_S_ERROR;
+ break;
+error:
+ case 1:
+ case 2:
+ p->sense_key = ATA_SENSE_ILLEGAL_REQUEST;
+ p->asc = 0x24;
+ tfd = (p->sense_key << 12) | ATA_S_READY | ATA_S_ERROR;
+ break;
+ }
+ cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN;
+ ahci_write_fis_d2h(p, slot, cfis, tfd);
+}
+
+static void
handle_packet_cmd(struct ahci_port *p, int slot, uint8_t *cfis)
{
uint8_t *acmd = cfis + 0x40;
@@ -972,6 +1050,9 @@
case START_STOP_UNIT:
atapi_start_stop_unit(p, slot, cfis);
break;
+ case MODE_SENSE_10:
+ atapi_mode_sense(p, slot, cfis);
+ break;
default:
break;
}
More information about the svn-soc-all
mailing list