[hatari-devel] MODE_SENSE diff |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: [hatari-devel] MODE_SENSE diff
- From: Uwe Seimet <Uwe.Seimet@xxxxxxxxx>
- Date: Mon, 8 Oct 2018 19:03:59 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1539018239; s=strato-dkim-0002; d=seimet.de; h=Message-ID:Subject:To:From:Date:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=mvJQvemBZWkKjKDWzVN3uRQDwGsxYIBCdszqRXcUwuI=; b=Rh9yTmsVzt2+TgkmitfCiRws4ALXmiuoJ9JjqxBilvlWpoT4c8FQYukoSHiwP9lewR tGtLsW6zsF5S4MREKdO/lk5SIU0UHioUrs3nE7Lsq3hXm8HQSXnNcSeL828PSHLaEUX/ T6bnt7x/25nWoHouLPvuJOu+Yh0YV1W4Wuw5q0DndzsMigO41iK6wi54f2dzqRwVMC7D 9q4b1ym/1gOuPmuWHf/c2+DXUBNQ15cLu8z6Uftasg8IlsXOGwgy+yU7Y+HKUpPKOta5 0PHT9w8bkZWUnVGy0mEggqh4m2yKbMpgNzrW39jdbarQmuqaCsXvLY1wg7Er1Qehmi6D +S/g==
Hi,
The attached diff modifies the MODE_SENSE implementation and adds the
rigid geometry page requested by ASV. I verified that the proprietary page
0 still works fine for HDX. Maybe you can check in these changes.
The geometry calculation may not be perfect, but is most likely
irrelevant anyway, because it has no meaning for simply reading and writing
sectors.
Best regards
Uwe
diff -r 3659d537914f src/hdc.c
--- a/src/hdc.c Mon Oct 08 15:19:45 2018 +0200
+++ b/src/hdc.c Mon Oct 08 18:58:32 2018 +0200
@@ -295,30 +295,15 @@
/**
- * Mode sense - Get parameters from disk.
+ * Mode sense - Vendor specific page 00h.
* (Just enough to make the HDX tool from AHDI 5.0 happy)
*/
-static void HDC_Cmd_ModeSense(SCSI_CTRLR *ctr)
+static void HDC_CmdModeSense0x00(SCSI_DEV *dev, SCSI_CTRLR *ctr)
{
- SCSI_DEV *dev = &ctr->devs[ctr->target];
- Uint8 *buf;
-
- LOG_TRACE(TRACE_SCSI_CMD, "HDC: MODE SENSE (%s).\n", HDC_CmdInfoStr(ctr));
-
- dev->bSetLastBlockAddr = false;
-
- if (ctr->command[2] != 0 || HDC_GetCount(ctr) != 0x10)
- {
- Log_Printf(LOG_TODO, "HDC: Unsupported MODE SENSE command\n");
- ctr->status = HD_STATUS_ERROR;
- dev->nLastError = HD_REQSENS_INVARG;
- return;
- }
-
- buf = HDC_PrepRespBuf(ctr, 16);
+ Uint8 *buf = HDC_PrepRespBuf(ctr, 16);
buf[0] = 0;
- buf[1] = 0;
+ buf[1] = 14;
buf[2] = 0;
buf[3] = 8;
buf[4] = 0;
@@ -337,6 +322,81 @@
buf[13] = 0;
buf[14] = 0;
buf[15] = 0;
+}
+
+
+/**
+ * Mode sense - Rigid disk geometry page (requested by ASV).
+ */
+static void HDC_CmdModeSense0x04(SCSI_DEV *dev, SCSI_CTRLR *ctr)
+{
+ Uint8 *buf = HDC_PrepRespBuf(ctr, 24);
+
+ buf[0] = 4;
+ buf[1] = 22;
+
+ buf[2] = dev->hdSize >> 23; // Number of cylinders, high
+ buf[3] = dev->hdSize >> 15; // Number of cylinders, med
+ buf[4] = dev->hdSize >> 7; // Number of cylinders, low
+
+ buf[5] = 128; // Number of heads
+
+ buf[6] = 0;
+ buf[7] = 0;
+ buf[8] = 0;
+
+ buf[9] = 0;
+ buf[10] = 0;
+ buf[11] = 0;
+
+ buf[12] = 0;
+ buf[13] = 0;
+
+ buf[14] = 0;
+ buf[15] = 0;
+ buf[16] = 0;
+
+ buf[17] = 0;
+
+ buf[18] = 0;
+
+ buf[19] = 0;
+
+ buf[20] = 0;
+ buf[21] = 0;
+
+ buf[22] = 0;
+ buf[23] = 0;
+}
+
+
+/**
+ * Mode sense - Get parameters from disk.
+ */
+static void HDC_Cmd_ModeSense(SCSI_CTRLR *ctr)
+{
+ SCSI_DEV *dev = &ctr->devs[ctr->target];
+
+ LOG_TRACE(TRACE_SCSI_CMD, "HDC: MODE SENSE (%s).\n", HDC_CmdInfoStr(ctr));
+
+ dev->bSetLastBlockAddr = false;
+
+ switch(ctr->command[2])
+ {
+ case 0x00:
+ HDC_CmdModeSense0x00(dev, ctr);
+ break;
+
+ case 0x04:
+ HDC_CmdModeSense0x04(dev, ctr);
+ break;
+
+ default:
+ Log_Printf(LOG_TODO, "HDC: Unsupported MODE SENSE command\n");
+ ctr->status = HD_STATUS_ERROR;
+ dev->nLastError = HD_REQSENS_INVARG;
+ return;
+ }
ctr->status = HD_STATUS_OK;
dev->nLastError = HD_REQSENS_OK;