Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Jun 2009 11:53:07 GMT
From:      Alexander Motin <mav@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 165151 for review
Message-ID:  <200906251153.n5PBr7uL079489@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=165151

Change 165151 by mav@mav_mavbook on 2009/06/25 11:52:53

	Implement kernel dumping to ada.

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_da.c#13 edit

Differences ...

==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_da.c#13 (text+ko) ====

@@ -136,7 +136,7 @@
 //};
 
 static	disk_strategy_t	adastrategy;
-//static	dumper_t	adadump;
+static	dumper_t	adadump;
 static	periph_init_t	adainit;
 static	void		adaasync(void *callback_arg, u_int32_t code,
 				struct cam_path *path, void *arg);
@@ -333,15 +333,17 @@
 
 	return;
 }
-#if 0
+
 static int
 adadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t length)
 {
 	struct	    cam_periph *periph;
 	struct	    ada_softc *softc;
 	u_int	    secsize;
-	struct	    ccb_scsiio csio;
+	struct	    ccb_ataio ataio;
 	struct	    disk *dp;
+	uint64_t    lba;
+	uint16_t    count;
 
 	dp = arg;
 	periph = dp->d_drv1;
@@ -350,6 +352,8 @@
 	softc = (struct ada_softc *)periph->softc;
 	cam_periph_lock(periph);
 	secsize = softc->params.secsize;
+	lba = offset / secsize;
+	count = length / secsize;
 	
 	if ((softc->flags & ADA_FLAG_PACK_INVALID) != 0) {
 		cam_periph_unlock(periph);
@@ -358,43 +362,39 @@
 
 	if (length > 0) {
 		periph->flags |= CAM_PERIPH_POLLED;
-		xpt_setup_ccb(&csio.ccb_h, periph->path, /*priority*/1);
-		csio.ccb_h.ccb_state = ADA_CCB_DUMP;
-		scsi_read_write(&csio,
-				/*retries*/1,
-				adadone,
-				0,//MSG_ORDERED_Q_TAG,
-				/*read*/FALSE,
-				/*byte2*/0,
-				/*minimum_cmd_size*/ softc->minimum_cmd_size,
-				offset / secsize,
-				length / secsize,
-				/*data_ptr*/(u_int8_t *) virtual,
-				/*dxfer_len*/length,
-				/*sense_len*/SSD_FULL_SIZE,
-				ADA_DEFAULT_TIMEOUT * 1000);		
-		xpt_polled_action((union ccb *)&csio);
+		xpt_setup_ccb(&ataio.ccb_h, periph->path, /*priority*/1);
+		ataio.ccb_h.ccb_state = ADA_CCB_DUMP;
+		cam_fill_ataio(&ataio,
+		    0,
+		    adadone,
+		    CAM_DIR_OUT,
+		    0,
+		    (u_int8_t *) virtual,
+		    length,
+		    ada_default_timeout*1000);
+		if ((softc->flags & ADA_FLAG_CAN_48BIT) &&
+		    (lba + count >= ATA_MAX_28BIT_LBA ||
+		    count >= 256)) {
+			ata_48bit_cmd(&ataio, ATA_WRITE_DMA48,
+			    0, lba, count);
+		} else {
+			ata_36bit_cmd(&ataio, ATA_WRITE_DMA,
+			    0, lba, count);
+		}
+		xpt_polled_action((union ccb *)&ataio);
 
-		if ((csio.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
+		if ((ataio.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
 			printf("Aborting dump due to I/O error.\n");
-			if ((csio.ccb_h.status & CAM_STATUS_MASK) ==
-			     CAM_SCSI_STATUS_ERROR)
-				scsi_sense_print(&csio);
-			else
-				printf("status == 0x%x, scsi status == 0x%x\n",
-				       csio.ccb_h.status, csio.scsi_status);
-			periph->flags |= CAM_PERIPH_POLLED;
+			cam_periph_unlock(periph);
 			return(EIO);
 		}
 		cam_periph_unlock(periph);
 		return(0);
 	}
-		
 	periph->flags &= ~CAM_PERIPH_POLLED;
 	cam_periph_unlock(periph);
 	return (0);
 }
-#endif
 
 static void
 adainit(void)
@@ -639,7 +639,7 @@
 	softc->disk->d_open = adaopen;
 	softc->disk->d_close = adaclose;
 	softc->disk->d_strategy = adastrategy;
-//	softc->disk->d_dump = adadump;
+	softc->disk->d_dump = adadump;
 	softc->disk->d_name = "ada";
 	softc->disk->d_drv1 = periph;
 	if (cgd->ident_data.support.command2 & ATA_SUPPORT_ADDRESS48)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906251153.n5PBr7uL079489>