[hatari-devel] Patch for adding REPORT LUNS command

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

The attached patch adds the REPORT LUNS command, which for some scenarios is
quite convenient.

Best regards

Uwe
diff --git a/src/hdc.c b/src/hdc.c
index e6f3488c..6e1dff4c 100644
--- a/src/hdc.c
+++ b/src/hdc.c
@@ -422,6 +422,31 @@ static void HDC_Cmd_FormatDrive(SCSI_CTRLR *ctr)
 }
 
 
+/**
+ * Report LUNs.
+ */
+static void HDC_Cmd_ReportLuns(SCSI_CTRLR *ctr)
+{
+        SCSI_DEV *dev = &ctr->devs[ctr->target];
+	Uint8 *buf;
+
+        LOG_TRACE(TRACE_SCSI_CMD, "HDC: REPORT LUNS (%s).\n", HDC_CmdInfoStr(ctr));
+
+        buf = HDC_PrepRespBuf(ctr, 16);
+
+	// LUN list length, 8 bytes per LUN
+	buf[0] = 0;
+	buf[1] = 0;
+	buf[2] = 0;
+	buf[3] = 8;
+	memset(&buf[4], 0, 12);
+
+        ctr->status = HD_STATUS_OK;
+        dev->nLastError = HD_REQSENS_OK;
+        dev->bSetLastBlockAddr = false;
+}
+
+
 /**
  * Read capacity of our disk.
  */
@@ -608,6 +633,10 @@ static void HDC_EmulateCommandPacket(SCSI_CTRLR *ctr)
 		HDC_Cmd_FormatDrive(ctr);
 		break;
 
+	case HD_REPORT_LUNS:
+		HDC_Cmd_ReportLuns(ctr);
+		break;
+
 	 /* as of yet unsupported commands */
 	 case HD_VERIFY_TRACK:
 	 case HD_FORMAT_TRACK:
@@ -960,7 +989,8 @@ bool HDC_WriteCommandPacket(SCSI_CTRLR *ctr, Uint8 b)
 
 	/* have we received a complete 6-byte class 0 or 10-byte class 1 packet yet? */
 	if ((ctr->opcode < 0x20 && ctr->byteCount == 6) ||
-	    (ctr->opcode >= 0x20 && ctr->opcode < 0x60 && ctr->byteCount == 10))
+	    (ctr->opcode >= 0x20 && ctr->opcode < 0x60 && ctr->byteCount == 10) ||
+	    (ctr->opcode == 0xa0 && ctr->byteCount == 12))
 	{
 		/* We currently only support LUN 0, however INQUIRY must
 		 * always be handled, see SCSI standard */
diff --git a/src/includes/hdc.h b/src/includes/hdc.h
index 201aa380..da9f56d9 100644
--- a/src/includes/hdc.h
+++ b/src/includes/hdc.h
@@ -33,6 +33,7 @@
 #define HD_REQ_SENSE       0x03               /* Request sense */
 #define HD_SHIP            0x1B               /* Ship drive */
 #define HD_READ_CAPACITY1  0x25               /* Read capacity (class 1) */
+#define HD_REPORT_LUNS     0xa0	              /* Report Luns */
 
 /* Status codes */
 #define HD_STATUS_OK       0x00


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/