Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Mar 2015 14:06:38 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r279987 - head/usr.sbin/bhyve
Message-ID:  <201503141406.t2EE6cDF088053@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat Mar 14 14:06:37 2015
New Revision: 279987
URL: https://svnweb.freebsd.org/changeset/base/279987

Log:
  Add checksums to identify data and NCQ command error log.
  
  MFC after:	2 weeks

Modified:
  head/usr.sbin/bhyve/pci_ahci.c

Modified: head/usr.sbin/bhyve/pci_ahci.c
==============================================================================
--- head/usr.sbin/bhyve/pci_ahci.c	Sat Mar 14 13:45:43 2015	(r279986)
+++ head/usr.sbin/bhyve/pci_ahci.c	Sat Mar 14 14:06:37 2015	(r279987)
@@ -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);
@@ -914,6 +926,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);
@@ -962,6 +976,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?201503141406.t2EE6cDF088053>