[hatari-devel] MODE SENSE update patch |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: [hatari-devel] MODE SENSE update patch
- From: Uwe Seimet <Uwe.Seimet@xxxxxxxxx>
- Date: Fri, 11 Mar 2022 10:40:11 +0100
- Authentication-results: strato.com; dkim=none
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1646991612; s=strato-dkim-0002; d=seimet.de; h=Message-ID:Subject:To:From:Date:Cc:Date:From:Subject:Sender; bh=fR+a2O8d3ycexZotrT/41VHP+bYI1MbU+qT8ZArhcy0=; b=EyTivGM2VWBsjAYDL0/zR2ZZB8b2cB1jfwXf2XuO3OztNuVLjvP+1nOjyd81lnC8G0 0qcQ/vLmovpLPNkekIqR33MXlHf/cw3KSDqeQMy2GFvtuRIYHm33S9M4mIhiJcUfUoIy V2NUBzqaoO/sbbsmq0juOKvQM3DNEg5Gpuq+a203PuLr10zXoAUOP8DsqZN7hBFdA44i Wj3K5DDm6yU7xdz7S26TOsFxboSKMLIY143Ks+3FgFj7PLd3kpC4PJPf2v5qhq7pcZyj TJabQf1Cq/zOez1Nl4v93d8V+2eqBYRiQaLX3JKmEDTftIuNfIm4tOtl+AY5V1qbPoIV px9w==
Hi,
This patch updates mode page 0x3f to return all available pages in the order
requested by the SCSI specification (i.e. page 0 last).
IMO the implementation of mode page 0x04 is wrong. It is definitely incomplete
because it ignores some CDB data. In particular it does not check the DBD bit:
A disable block descriptors (DBD) bit of zero indicates that the target
may return zero or more block descriptors in the returned MODE SENSE data
(see 8.3.3), at the target's discretion. A DBD bit of one specifies that
the target shall not return any block descriptors in the returned MODE
SENSE data.
It also does not check the PC field:
The page control (PC) field defines the type of mode parameter values to
be returned in the mode pages. The page control field is defined in
table 55.
Table 55 - Page control field
+=======-=====================-============+
| Code | Type of parameter | Subclause |
|-------+---------------------+------------|
| 00b | Current values | 8.2.10.1 |
| 01b | Changeable values | 8.2.10.2 |
| 10b | Default values | 8.2.10.3 |
| 11b | Saved values | 8.2.10.4 |
+==========================================+
The header of mode page 0x04 also appears to be wrong, because it is missing
data:
Table 91 - Mode parameter header(6)
+=====-========-========-========-========-========-========-========-========+
| Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|Byte | | | | | | | | |
|=====+=======================================================================|
| 0 | Mode data length |
|-----+-----------------------------------------------------------------------|
| 1 | Medium type |
|-----+-----------------------------------------------------------------------|
| 2 | Device-specific parameter |
|-----+-----------------------------------------------------------------------|
| 3 | Block descriptor length |
+=============================================================================+
If there are no objections I might fix some of these issues with a
subsequent patch. For now the attached patch fixes page code 0x3f, which is
a fix I needed right now while running some tests.
Best regards
Uwe
diff --git a/src/hdc.c b/src/hdc.c
index 6a235679..815489fd 100644
--- a/src/hdc.c
+++ b/src/hdc.c
@@ -300,10 +300,8 @@ static void HDC_Cmd_RequestSense(SCSI_CTRLR *ctr)
* Mode sense - Vendor specific page 00h.
* (Just enough to make the HDX tool from AHDI 5.0 happy)
*/
-static void HDC_CmdModeSense0x00(SCSI_DEV *dev, SCSI_CTRLR *ctr)
+static void HDC_CmdModeSense0x00(SCSI_DEV *dev, SCSI_CTRLR *ctr, Uint8 *buf)
{
- Uint8 *buf = HDC_PrepRespBuf(ctr, 16);
-
buf[0] = 0;
buf[1] = 14;
buf[2] = 0;
@@ -330,10 +328,8 @@ static void HDC_CmdModeSense0x00(SCSI_DEV *dev, SCSI_CTRLR *ctr)
/**
* Mode sense - Rigid disk geometry page (requested by ASV).
*/
-static void HDC_CmdModeSense0x04(SCSI_DEV *dev, SCSI_CTRLR *ctr)
+static void HDC_CmdModeSense0x04(SCSI_DEV *dev, SCSI_CTRLR *ctr, Uint8 *buf)
{
- Uint8 *buf = HDC_PrepRespBuf(ctr, 24);
-
buf[0] = 4;
buf[1] = 22;
@@ -385,16 +381,27 @@ static void HDC_Cmd_ModeSense(SCSI_CTRLR *ctr)
switch(ctr->command[2])
{
- case 0x00:
- HDC_CmdModeSense0x00(dev, ctr);
+ case 0x00: {
+ Uint8 *buf = HDC_PrepRespBuf(ctr, 16);
+ HDC_CmdModeSense0x00(dev, ctr, buf);
+ break;
+ }
+
+ case 0x04: {
+ Uint8 *buf = HDC_PrepRespBuf(ctr, 24);
+ HDC_CmdModeSense0x04(dev, ctr, buf);
break;
+ }
- case 0x04:
- case 0x3f:
- HDC_CmdModeSense0x04(dev, ctr);
+ case 0x3f: {
+ Uint8 *buf = HDC_PrepRespBuf(ctr, 44);
+ buf[0] = 44;
+ HDC_CmdModeSense0x04(dev, ctr, buf + 4);
+ HDC_CmdModeSense0x00(dev, ctr, buf + 28);
break;
+ }
- default:
+ default:
Log_Printf(LOG_TODO, "HDC: Unsupported MODE SENSE command\n");
ctr->status = HD_STATUS_ERROR;
dev->nLastError = HD_REQSENS_INVARG;