[hatari-devel] Patch for adding REPORT LUNS command |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: [hatari-devel] Patch for adding REPORT LUNS command
- From: Uwe Seimet <Uwe.Seimet@xxxxxxxxx>
- Date: Fri, 25 Feb 2022 18:35:54 +0100
- Authentication-results: strato.com; dkim=none
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1645810554; s=strato-dkim-0002; d=seimet.de; h=Message-ID:Subject:To:From:Date:Cc:Date:From:Subject:Sender; bh=G/RaNK9oct5ev5oisvd8ZZ+XowRWZEK2W4f4CkwYNbg=; b=GGFv6mR4FlJGtd12xo47RTzJ7uIs3jCW9vxFNpnDtsNxS81v3/dGR+HEMHP4+TzzoV IKcVWxop0IYOKlhrYi0xXC7IO7+mLnb4/ejPlZ3GC/11Ttr8n8jqdqeQZweFT0B5RDUk rOu3ifGqyLVLlH/Z9VqcDimCurzBZr0Jq/3VfU1KAOOBIXrEnk7YCOSHHojI8fLEsDVH ZRUyypZV5/R0lY4bun3bmfdgiT+bF8ogs0ERtsFvqZhRqDGaTrWqqfg/J1BRKRTFhaHa K0JtsWpKdRBXVChYJ3vT+VCgJLek+EAKfbVZj2bGpDhZjoIbYI40frjql7UE9+GVmZ80 WLRQ==
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