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

zcore at FreeBSD.org zcore at FreeBSD.org
Sat Sep 14 16:00:57 UTC 2013


Author: zcore
Date: Sat Sep 14 16:00:57 2013
New Revision: 257334
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257334

Log:
  support ATAPI_READ_CAPACITY

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	Sat Sep 14 16:00:27 2013	(r257333)
+++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c	Sat Sep 14 16:00:57 2013	(r257334)
@@ -163,6 +163,14 @@
 };
 #define	ahci_ctx(sc)	((sc)->asc_pi->pi_vmctx)
 
+static inline uint32_t cpu_to_be32(uint32_t val)
+{
+	return ((val & 0xff) << 24) |
+		((val & 0xff00) << 8) |
+		((val & 0xff0000) >> 8) |
+		((val & 0xff000000) >> 24);
+}
+
 /*
  * generate HBA intr depending on whether or not ports within
  * the controller have an interrupt pending.
@@ -602,6 +610,20 @@
 }
 
 static void
+atapi_read_capacity(struct ahci_port *p, int slot, uint8_t *cfis)
+{
+	uint8_t buf[8];
+	uint64_t sectors;
+	uint32_t *ptr = (uint32_t *)buf;
+
+	sectors = blockif_size(p->bctx) / blockif_sectsz(p->bctx);
+	ptr[0] = cpu_to_be32(sectors - 1);
+	ptr[1] = cpu_to_be32(2048);
+	write_prdt(p, slot, cfis, buf, sizeof(buf));
+	ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC);
+}
+
+static void
 handle_packet_cmd(struct ahci_port *p, int slot, uint8_t *cfis)
 {
 	uint8_t *acmd = cfis + 0x40;
@@ -619,8 +641,13 @@
 		ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC);
 		break;
 	case ATAPI_INQUIRY:
+		cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN;
 		atapi_inquiry(p, slot, cfis);
 		break;
+	case ATAPI_READ_CAPACITY:
+		cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN;
+		atapi_read_capacity(p, slot, cfis);
+		break;
 	default:
 		break;
 	}


More information about the svn-soc-all mailing list