From owner-svn-soc-all@FreeBSD.ORG Sat Sep 14 15:57:50 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 2B8A37D5 for ; Sat, 14 Sep 2013 15:57:50 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id F13D72D3C for ; Sat, 14 Sep 2013 15:57:49 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8EFvnlW092066 for ; Sat, 14 Sep 2013 15:57:49 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8EFvniq092060 for svn-soc-all@FreeBSD.org; Sat, 14 Sep 2013 15:57:49 GMT (envelope-from zcore@FreeBSD.org) Date: Sat, 14 Sep 2013 15:57:49 GMT Message-Id: <201309141557.r8EFvniq092060@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257329 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Sep 2013 15:57:50 -0000 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);