[PATCH] Added header to mode pages, updated command byte counts |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- Subject: [PATCH] Added header to mode pages, updated command byte counts
- From: Uwe Seimet <Uwe.Seimet@xxxxxxxxx>
- Date: Thu, 17 Mar 2022 22:41:52 +0100
The mode pages were missing the header required by the SCSI specification.
Replaces magic constants (opcodes) by existing definitions.
Updated comments
---
src/hdc.c | 42 ++++++++++++++++++++----------------------
src/includes/hdc.h | 3 ---
2 files changed, 20 insertions(+), 25 deletions(-)
diff --git a/src/hdc.c b/src/hdc.c
index 895fbef2..48054f1f 100644
--- a/src/hdc.c
+++ b/src/hdc.c
@@ -58,12 +58,12 @@ static SCSI_CTRLR AcsiBus;
int nAcsiPartitions;
bool bAcsiEmuOn;
-/* Our dummy INQUIRY response data */
+/* Our INQUIRY response data */
static unsigned char inquiry_bytes[] =
{
0, /* device type 0 = direct access device */
0, /* device type qualifier (nonremovable) */
- 1, /* ACSI/SCSI version */
+ 1, /* SCSI-1 CCS */
0, /* reserved */
31, /* length of the following data */
0, 0, 0, /* Vendor specific data */
@@ -102,14 +102,10 @@ static unsigned long HDC_GetLBA(SCSI_CTRLR *ctr)
*/
static int HDC_GetCommandByteCount(SCSI_CTRLR *ctr)
{
- if (ctr->opcode == 0x88 || ctr->opcode == 0x8a || ctr->opcode == 0x8f ||
- ctr->opcode == 0x91 || ctr->opcode == 0x9e || ctr->opcode == 0x9f) {
- return 16;
- }
- else if (ctr->opcode == 0xa0) {
+ if (ctr->opcode == HD_REPORT_LUNS) {
return 12;
}
- else if (ctr->opcode == 0x05 || (ctr->opcode >= 0x20 && ctr->opcode <= 0x7d)) {
+ else if (ctr->opcode >= 0x20 && ctr->opcode <= 0x7d) {
return 10;
} else {
return 6;
@@ -375,8 +371,8 @@ static void HDC_CmdModeSense0x04(SCSI_DEV *dev, SCSI_CTRLR *ctr, Uint8 *buf)
buf[19] = 0;
- buf[20] = 0;
- buf[21] = 0;
+ buf[20] = 0x1c; // Medium rotation rate 7200
+ buf[21] = 0x20;
buf[22] = 0;
buf[23] = 0;
@@ -403,21 +399,28 @@ static void HDC_Cmd_ModeSense(SCSI_CTRLR *ctr)
}
case 0x04: {
- Uint8 *buf = HDC_PrepRespBuf(ctr, 24);
- HDC_CmdModeSense0x04(dev, ctr, buf);
+ Uint8 *buf = HDC_PrepRespBuf(ctr, 28);
+ HDC_CmdModeSense0x04(dev, ctr, buf + 4);
+ buf[0] = 24;
+ buf[1] = 0;
+ buf[2] = 0;
+ buf[3] = 0;
break;
}
case 0x3f: {
Uint8 *buf = HDC_PrepRespBuf(ctr, 44);
- buf[0] = 44;
HDC_CmdModeSense0x04(dev, ctr, buf + 4);
HDC_CmdModeSense0x00(dev, ctr, buf + 28);
+ buf[0] = 44;
+ buf[1] = 0;
+ buf[2] = 0;
+ buf[3] = 0;
break;
}
default:
- Log_Printf(LOG_TODO, "HDC: Unsupported MODE SENSE command\n");
+ Log_Printf(LOG_TODO, "HDC: Unsupported MODE SENSE mode page\n");
ctr->status = HD_STATUS_ERROR;
dev->nLastError = HD_REQSENS_INVARG;
return;
@@ -660,11 +663,6 @@ static void HDC_EmulateCommandPacket(SCSI_CTRLR *ctr)
HDC_Cmd_ReportLuns(ctr);
break;
- /* as of yet unsupported commands */
- case HD_VERIFY_TRACK:
- case HD_FORMAT_TRACK:
- case HD_CORRECTION:
-
default:
LOG_TRACE(TRACE_SCSI_CMD, "HDC: Unsupported command (%s)!\n", HDC_CmdInfoStr(ctr));
ctr->status = HD_STATUS_ERROR;
@@ -1010,10 +1008,10 @@ bool HDC_WriteCommandPacket(SCSI_CTRLR *ctr, Uint8 b)
ctr->command[ctr->byteCount] = b;
++ctr->byteCount;
- /* have we received a complete 6-byte class 0 or 10-byte class 1 packet yet? */
+ /* have we received a complete command packet yet? */
if ((ctr->opcode < 0x20 && ctr->byteCount == 6) ||
(ctr->opcode >= 0x20 && ctr->opcode < 0x60 && ctr->byteCount == 10) ||
- (ctr->opcode == 0xa0 && ctr->byteCount == 12))
+ (ctr->opcode == HD_REPORT_LUNS && ctr->byteCount == 12))
{
/* We currently only support LUN 0, however INQUIRY must
* always be handled, see SCSI standard */
@@ -1039,7 +1037,7 @@ bool HDC_WriteCommandPacket(SCSI_CTRLR *ctr, Uint8 b)
}
}
}
- else if (ctr->opcode >= 0x60)
+ else if (ctr->opcode >= 0x60 && ctr->opcode != HD_REPORT_LUNS)
{
/* Commands >= 0x60 are not supported right now */
ctr->status = HD_STATUS_ERROR;
diff --git a/src/includes/hdc.h b/src/includes/hdc.h
index a2b006ed..becdb451 100644
--- a/src/includes/hdc.h
+++ b/src/includes/hdc.h
@@ -15,8 +15,6 @@
/* Opcodes */
/* The following are multi-sector transfers with seek implied */
-#define HD_VERIFY_TRACK 0x05 /* Verify track */
-#define HD_FORMAT_TRACK 0x06 /* Format track */
#define HD_READ_SECTOR 0x08 /* Read sector */
#define HD_READ_SECTOR1 0x28 /* Read sector (class 1) */
#define HD_WRITE_SECTOR 0x0A /* Write sector */
@@ -26,7 +24,6 @@
#define HD_TEST_UNIT_RDY 0x00 /* Test unit ready */
#define HD_FORMAT_DRIVE 0x04 /* Format the whole drive */
#define HD_SEEK 0x0B /* Seek */
-#define HD_CORRECTION 0x0D /* Correction */
#define HD_INQUIRY 0x12 /* Inquiry */
#define HD_MODESELECT 0x15 /* Mode select */
#define HD_MODESENSE 0x1A /* Mode sense */
--
2.34.1
--3XDgeq4Vt4i8fs9F--