PERFORCE change 163707 for review

Alexander Motin mav at FreeBSD.org
Sun Jun 7 12:43:04 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=163707

Change 163707 by mav at mav_mavbook on 2009/06/07 12:42:52

	Teach ATA commands to resurn result.
	
	Remove PM control functions from driver. Soft reset will be the next.
	That functions will be implemented on SATA XPT layer.

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.c#16 edit

Differences ...

==== //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.c#16 (text+ko) ====

@@ -68,8 +68,6 @@
 static void ahci_execute_command(struct ahci_slot *slot);
 static void ahci_timeout(struct ahci_slot *slot);
 static void ahci_end_transaction(struct ahci_slot *slot, enum ahci_err_type et);
-//static int ahci_pm_read(device_t dev, int port, int reg, u_int32_t *result);
-//static int ahci_pm_write(device_t dev, int port, int reg, u_int32_t result);
 static int ahci_hardreset(device_t dev, int port, uint32_t *signature);
 static u_int32_t ahci_softreset(device_t dev, int port);
 static int ahci_setup_fis(struct ahci_cmd_tab *ctp, union ccb *ccb, int tag);
@@ -937,7 +935,7 @@
 {
 	device_t dev = slot->dev;
 	struct ahci_channel *ch = device_get_softc(dev);
-	struct ahci_cmd_list *clp;
+//	struct ahci_cmd_list *clp;
 	u_int32_t tf_data;
 
 //device_printf(dev, "%s slot %d\n", __func__, slot->slot);
@@ -954,27 +952,29 @@
 			request->error = tf_data >> 8;
 	}
 #endif
-	/* on control commands read back registers to the request struct */
-/*	if (request->flags & ATA_R_CONTROL) {
-		struct ata_device *atadev = device_get_softc(request->dev);
+	/* Read registers to the result struct */
+	if (slot->ccb->ccb_h.func_code == XPT_ATA_IO) {
+		struct ata_res *res = &slot->ccb->ataio.res;
 		u_int8_t *fis = ch->dma.work + AHCI_FB_OFFSET + 0x40;
 
-		request->u.ata.count = fis[12] | ((u_int16_t)fis[13] << 8);
-		request->u.ata.lba = fis[4] | ((u_int64_t)fis[5] << 8) |
-			((u_int64_t)fis[6] << 16);
-		if (atadev->flags & ATA_D_48BIT_ACTIVE)
-			request->u.ata.lba |= ((u_int64_t)fis[8] << 24) |
-				  ((u_int64_t)fis[9] << 32) |
-				  ((u_int64_t)fis[10] << 40);
-		else
-			request->u.ata.lba |= ((u_int64_t)(fis[7] & 0x0f) << 24);
+		res->status = fis[2];
+		res->error = fis[3];
+		res->lba_low = fis[4];
+		res->lba_mid = fis[5];
+		res->lba_high = fis[6];
+		res->device = fis[7];
+		res->lba_low_exp = fis[8];
+		res->lba_mid_exp = fis[9];
+		res->lba_high_exp = fis[10];
+		res->sector_count = fis[12];
+		res->sector_count_exp = fis[13];
 	}
-*/
+#if 0
 	/* record how much data we actually moved */
 	clp = (struct ahci_cmd_list *)
 	    (ch->dma.work + AHCI_CL_OFFSET + (AHCI_CL_SIZE * slot->slot));
-//	request->donecount = clp->bytecount;
-
+	request->donecount = clp->bytecount;
+#endif
 	if ((slot->ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
 		bus_dmamap_sync(slot->dma.sg_tag, slot->dma.sg_map,
 		    BUS_DMASYNC_POSTWRITE);
@@ -1061,60 +1061,6 @@
 	return (0);
 }
 
-#if 0
-static int
-ahci_pm_read(device_t dev, int port, int reg, u_int32_t *result)
-{
-    struct ahci_channel *ch = device_get_softc(dev);
-    struct ahci_cmd_tab *ctp =
-	(struct ahci_cmd_tab *)(ch->dma.work + AHCI_CT_OFFSET);
-    u_int8_t *fis = ch->dma.work + AHCI_FB_OFFSET + 0x40;
-
-    bzero(ctp->cfis, 64);
-    ctp->cfis[0] = 0x27;	/* host to device */
-    ctp->cfis[1] = 0x8f;	/* command FIS to PM port */
-    ctp->cfis[2] = ATA_READ_PM;
-    ctp->cfis[3] = reg;
-    ctp->cfis[7] = port | ATA_D_LBA;
-    ctp->cfis[15] = ATA_A_4BIT;
-
-    if (ahci_issue_cmd(dev, 0, 10)) {
-	device_printf(dev, "error reading PM port\n");
-	return EIO;
-    }
-
-    *result = fis[12] | (fis[4] << 8) | (fis[5] << 16) | (fis[6] << 24);
-    return 0;
-}
-
-static int
-ahci_pm_write(device_t dev, int port, int reg, u_int32_t value)
-{
-    struct ahci_channel *ch = device_get_softc(dev);
-    struct ahci_cmd_tab *ctp =
-	(struct ahci_cmd_tab *)(ch->dma.work + AHCI_CT_OFFSET);
-
-    bzero(ctp->cfis, 64);
-    ctp->cfis[0] = 0x27;	/* host to device */
-    ctp->cfis[1] = 0x8f;	/* command FIS to PM port */
-    ctp->cfis[2] = ATA_WRITE_PM;
-    ctp->cfis[3] = reg;
-    ctp->cfis[7] = port | ATA_D_LBA;
-    ctp->cfis[12] = value & 0xff;
-    ctp->cfis[4] = (value >> 8) & 0xff;;
-    ctp->cfis[5] = (value >> 16) & 0xff;;
-    ctp->cfis[6] = (value >> 24) & 0xff;;
-    ctp->cfis[15] = ATA_A_4BIT;
-
-    if (ahci_issue_cmd(dev, 0, 100)) {
-	device_printf(dev, "error writing PM port\n");
-	return ATA_E_ABORT;
-    }
-
-    return (ATA_INL(ch->r_mem, AHCI_P_TFD) >> 8) & 0xff;
-}
-#endif
-
 static void
 ahci_start(device_t dev)
 {
@@ -1352,8 +1298,6 @@
 		break;
 	case 0x9669:
 		ch->devices = ATA_PORTMULTIPLIER | 0x0003; /* Temporary hack. */
-//		ch->devices = ATA_PORTMULTIPLIER;
-//		ata_pm_identify(dev);
 		break;
 	case 0xeb14:
 		ch->devices = ATA_ATAPI_MASTER;


More information about the p4-projects mailing list