socsvn commit: r257366 - soc2013/zcore/head/usr.sbin/bhyve

zcore at FreeBSD.org zcore at FreeBSD.org
Sun Sep 15 09:51:32 UTC 2013


Author: zcore
Date: Sun Sep 15 09:51:31 2013
New Revision: 257366
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257366

Log:
  support START_STOP_UNIT

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	Sun Sep 15 09:51:04 2013	(r257365)
+++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c	Sun Sep 15 09:51:31 2013	(r257366)
@@ -258,7 +258,7 @@
 	fis[0] = error;
 	fis[2] = tfd & 0x77;
 	*(uint32_t *)(fis + 4) = (1 << slot);
-	if (error & ATA_S_ERROR)
+	if (fis[2] & ATA_S_ERROR)
 		p->is |= AHCI_P_IX_TFE;
 	p->tfd = tfd;
 	p->ci &= ~(1 << slot);
@@ -287,7 +287,7 @@
 	fis[11] = cfis[11];
 	fis[12] = cfis[12];
 	fis[13] = cfis[13];
-	if (error & ATA_S_ERROR)
+	if (fis[2] & ATA_S_ERROR)
 		p->is |= AHCI_P_IX_TFE;
 	p->tfd = tfd;
 	p->ci &= ~(1 << slot);
@@ -900,6 +900,30 @@
 }
 
 static void
+atapi_start_stop_unit(struct ahci_port *p, int slot, uint8_t *cfis)
+{
+	uint32_t tfd;
+	uint8_t *acmd = cfis + 0x40;
+
+	switch (acmd[4] & 3) {
+	case 0:
+	case 1:
+	case 3:
+		cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN;
+		tfd = ATA_S_READY | ATA_S_DSC;
+		break;
+	case 2:
+		/* TODO eject media */
+		cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN;
+		p->sense_key = ATA_SENSE_ILLEGAL_REQUEST;
+		p->asc = 0x53;
+		tfd = (p->sense_key << 12) | ATA_S_READY | ATA_S_ERROR;
+		break;
+	}
+	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;
@@ -938,6 +962,9 @@
 	case REQUEST_SENSE:
 		atapi_request_sense(p, slot, cfis);
 		break;
+	case START_STOP_UNIT:
+		atapi_start_stop_unit(p, slot, cfis);
+		break;
 	default:
 		break;
 	}


More information about the svn-soc-all mailing list