Date: Fri, 27 Mar 2015 08:50:27 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r280741 - stable/10/usr.sbin/bhyve Message-ID: <201503270850.t2R8oRSb022421@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Fri Mar 27 08:50:26 2015 New Revision: 280741 URL: https://svnweb.freebsd.org/changeset/base/280741 Log: MFC r279987: Add checksums to identify data and NCQ command error log. Modified: stable/10/usr.sbin/bhyve/pci_ahci.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- stable/10/usr.sbin/bhyve/pci_ahci.c Fri Mar 27 08:49:33 2015 (r280740) +++ stable/10/usr.sbin/bhyve/pci_ahci.c Fri Mar 27 08:50:26 2015 (r280741) @@ -794,6 +794,17 @@ write_prdt(struct ahci_port *p, int slot } static void +ahci_checksum(uint8_t *buf, int size) +{ + int i; + uint8_t sum = 0; + + for (i = 0; i < size - 1; i++) + sum += buf[i]; + buf[size - 1] = 0x100 - sum; +} + +static void ahci_handle_read_log(struct ahci_port *p, int slot, uint8_t *cfis) { struct ahci_cmd_hdr *hdr; @@ -809,6 +820,7 @@ ahci_handle_read_log(struct ahci_port *p memset(buf, 0, sizeof(buf)); memcpy(buf, p->err_cfis, sizeof(p->err_cfis)); + ahci_checksum(buf, sizeof(buf)); if (cfis[2] == ATA_READ_LOG_EXT) ahci_write_fis_piosetup(p); @@ -915,6 +927,8 @@ handle_identify(struct ahci_port *p, int buf[119] = (ATA_SUPPORT_RWLOGDMAEXT | 1 << 14); buf[120] = (ATA_SUPPORT_RWLOGDMAEXT | 1 << 14); buf[222] = 0x1020; + buf[255] = 0x00a5; + ahci_checksum((uint8_t *)buf, sizeof(buf)); ahci_write_fis_piosetup(p); write_prdt(p, slot, cfis, (void *)buf, sizeof(buf)); ahci_write_fis_d2h(p, slot, cfis, ATA_S_DSC | ATA_S_READY); @@ -963,6 +977,8 @@ handle_atapi_identify(struct ahci_port * if (p->xfermode & ATA_UDMA0) buf[88] |= (1 << ((p->xfermode & 7) + 8)); buf[222] = 0x1020; + buf[255] = 0x00a5; + ahci_checksum((uint8_t *)buf, sizeof(buf)); ahci_write_fis_piosetup(p); write_prdt(p, slot, cfis, (void *)buf, sizeof(buf)); ahci_write_fis_d2h(p, slot, cfis, ATA_S_DSC | ATA_S_READY);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503270850.t2R8oRSb022421>