From owner-svn-soc-all@FreeBSD.ORG Sat Sep 14 16:00:01 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 374B689E for ; Sat, 14 Sep 2013 16:00:01 +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 0A9B72D55 for ; Sat, 14 Sep 2013 16:00:01 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8EG00gq001601 for ; Sat, 14 Sep 2013 16:00:00 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8EG00Ic001596 for svn-soc-all@FreeBSD.org; Sat, 14 Sep 2013 16:00:00 GMT (envelope-from zcore@FreeBSD.org) Date: Sat, 14 Sep 2013 16:00:00 GMT Message-Id: <201309141600.r8EG00Ic001596@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: r257331 - 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 16:00:01 -0000 Author: zcore Date: Sat Sep 14 16:00:00 2013 New Revision: 257331 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257331 Log: support ATAPI_INQUIRY 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:59:26 2013 (r257330) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Sep 14 16:00:00 2013 (r257331) @@ -336,6 +336,19 @@ } static void +atapi_string(uint8_t *dest, const char *src, int len) +{ + int i; + + for (i = 0; i < len; i++) { + if (*src) + dest[i] = *src++; + else + dest[i] = ' '; + } +} + +static void handle_dma(struct ahci_port *p, int slot, uint8_t *cfis) { int i, err, readop = 1; @@ -497,9 +510,9 @@ from = buf; prdt = (struct ahci_prdt_entry *)(cfis + 0x80); for (i = 0; i < hdr->prdtl && len; i++) { - uint8_t *p = paddr_guest2host(ahci_ctx(sc), + uint8_t *ptr = paddr_guest2host(ahci_ctx(sc), prdt->dba, prdt->dbc + 1); - memcpy(p, from, prdt->dbc + 1); + memcpy(ptr, from, prdt->dbc + 1); len -= (prdt->dbc + 1); from += (prdt->dbc + 1); prdt++; @@ -572,6 +585,46 @@ } static void +atapi_inquiry(struct ahci_port *p, int slot, uint8_t *cfis) +{ + uint8_t buf[36]; + uint8_t *acmd = cfis + 0x40; + int i, len; + void *from; + struct ahci_cmd_hdr *hdr; + struct ahci_prdt_entry *prdt; + + buf[0] = 0x05; + buf[1] = 0x80; + buf[2] = 0x00; + buf[3] = 0x21; + buf[4] = 31; + buf[5] = 0; + buf[6] = 0; + buf[7] = 0; + atapi_string(buf + 8, "BHYVE", 8); + atapi_string(buf + 16, "BHYVE DVD-ROM", 16); + atapi_string(buf + 32, "001", 4); + + len = sizeof(buf); + if (len > acmd[4]) + len = acmd[4]; + from = buf; + hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + prdt = (struct ahci_prdt_entry *)(cfis + 0x80); + for (i = 0; i < hdr->prdtl && len; i++) { + uint8_t *ptr = paddr_guest2host(ahci_ctx(p->pr_sc), + prdt->dba, prdt->dbc + 1); + memcpy(ptr, from, prdt->dbc + 1); + len -= (prdt->dbc + 1); + from += (prdt->dbc + 1); + prdt++; + } + hdr->prdbc = sizeof(buf) - len; + 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; @@ -588,6 +641,9 @@ cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC); break; + case ATAPI_INQUIRY: + atapi_inquiry(p, slot, cfis); + break; default: break; }