socsvn commit: r257329 - soc2013/zcore/head/usr.sbin/bhyve
zcore at FreeBSD.org
zcore at FreeBSD.org
Sat Sep 14 15:57:50 UTC 2013
Author: zcore
Date: Sat Sep 14 15:57:49 2013
New Revision: 257329
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257329
Log:
support ATA_ATAPI_IDENTIFY
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 15:53:52 2013 (r257328)
+++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Sep 14 15:57:49 2013 (r257329)
@@ -511,6 +511,65 @@
}
static void
+handle_atapi_identify(struct ahci_port *p, int slot, uint8_t *cfis)
+{
+ struct pci_ahci_softc *sc = p->pr_sc;
+
+ if (!p->atapi) {
+ p->tfd = (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR;
+ p->is |= AHCI_P_IX_TFE;
+ } else {
+ uint16_t buf[256];
+ int i, len;
+ void *from;
+ struct ahci_prdt_entry *prdt;
+ struct ahci_cmd_hdr *hdr;
+
+ memset(buf, 0, sizeof(buf));
+ buf[0] = (2 << 14 | 5 << 8 | 1 << 7 | 2 << 5);
+ /* TODO emulate different serial? */
+ ata_string((uint8_t *)(buf+10), "123456", 20);
+ ata_string((uint8_t *)(buf+23), "001", 8);
+ ata_string((uint8_t *)(buf+27), "BHYVE SATA DVD ROM", 40);
+ buf[49] = (1 << 9 | 1 << 8);
+ buf[50] = (1 << 14 | 1);
+ buf[53] = (1 << 2 | 1 << 1);
+ buf[62] = 0x3f;
+ buf[63] = 7;
+ buf[64] = 3;
+ buf[65] = 100;
+ buf[66] = 100;
+ buf[67] = 100;
+ buf[68] = 100;
+ buf[76] = (1 << 2 | 1 << 1);
+ buf[80] = (0x1f << 4);
+ buf[82] = (1 << 4);
+ buf[83] = (1 << 14);
+ buf[84] = (1 << 14);
+ buf[85] = (1 << 4);
+ buf[87] = (1 << 14);
+ buf[88] = (1 << 14 | 0x7f);
+ len = sizeof(buf);
+ from = buf;
+ prdt = (struct ahci_prdt_entry *)(cfis + 0x80);
+ hdr = p->cmd_lst + slot * AHCI_CL_SIZE;
+ for (i = 0; i < hdr->prdtl && len; i++) {
+ uint8_t *p = paddr_guest2host(ahci_ctx(sc),
+ prdt->dba, prdt->dbc + 1);
+ memcpy(p, from, prdt->dbc + 1);
+ len -= (prdt->dbc + 1);
+ from += (prdt->dbc + 1);
+ prdt++;
+ }
+ hdr->prdbc = sizeof(buf) - len;
+ p->tfd = ATA_S_DSC | ATA_S_READY;
+ p->is |= AHCI_P_IX_DHR;
+ }
+ p->ci &= ~(1 << slot);
+ ahci_generate_intr(sc);
+}
+
+static void
handle_cmd(struct ahci_port *p, int slot, uint8_t *cfis)
{
switch(cfis[2]) {
@@ -583,7 +642,11 @@
case ATA_SLEEP:
ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC);
break;
+ case ATA_ATAPI_IDENTIFY:
+ handle_atapi_identify(p, slot, cfis);
+ break;
default:
+ WPRINTF(("Unsupported cmd:%02x\n", cfis[2]));
p->tfd = (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR;
p->is |= AHCI_P_IX_TFE;
p->ci &= ~(1 << slot);
More information about the svn-soc-all
mailing list