[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 04/14] scsi-disk: add SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD q
From: |
Mark Cave-Ayland |
Subject: |
[PATCH v3 04/14] scsi-disk: add SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD quirk for Macintosh |
Date: |
Wed, 22 Jun 2022 11:53:04 +0100 |
During SCSI bus enumeration A/UX sends a MODE SENSE command to the CDROM with
the DBD bit unset and expects the response to include a block descriptor. As per
the latest SCSI documentation, QEMU currently force-disables the block
descriptor for CDROM devices but the A/UX driver expects the requested block
descriptor to be returned.
If the block descriptor is not returned in the response then A/UX becomes
confused, since the block descriptor returned in the MODE SENSE response is
used to generate a subsequent MODE SELECT command which is then invalid.
Add a new SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD quirk to allow this behaviour
to be enabled as required. Note that an additional workaround is required for
the previous SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR quirk which must never
return a block descriptor even though the DBD bit is left unset.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/scsi/scsi-disk.c | 27 +++++++++++++++++++++++----
include/hw/scsi/scsi.h | 1 +
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 64f9418dc9..41bcf07272 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -1279,10 +1279,27 @@ static int scsi_disk_emulate_mode_sense(SCSIDiskReq *r,
uint8_t *outbuf)
dev_specific_param |= 0x80; /* Readonly. */
}
} else {
- /* MMC prescribes that CD/DVD drives have no block descriptors,
- * and defines no device-specific parameter. */
- dev_specific_param = 0x00;
- dbd = true;
+ if (s->quirks & (1 << SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD)) {
+ /* Use DBD from the request... */
+ dev_specific_param = 0x00;
+
+ /*
+ * ... unless we receive a request for MODE_PAGE_APPLE_VENDOR
+ * which should never return a block descriptor even though DBD is
+ * not set, otherwise CDROM detection fails in MacOS
+ */
+ if (s->quirks & (1 << SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR) &&
+ page == MODE_PAGE_APPLE_VENDOR) {
+ dbd = true;
+ }
+ } else {
+ /*
+ * MMC prescribes that CD/DVD drives have no block descriptors,
+ * and defines no device-specific parameter.
+ */
+ dev_specific_param = 0x00;
+ dbd = true;
+ }
}
if (r->req.cmd.buf[0] == MODE_SENSE) {
@@ -3103,6 +3120,8 @@ static Property scsi_cd_properties[] = {
5),
DEFINE_PROP_BIT("quirk_mode_page_apple_vendor", SCSIDiskState, quirks,
SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR, 0),
+ DEFINE_PROP_BIT("quirk_mode_sense_rom_use_dbd", SCSIDiskState, quirks,
+ SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD, 0),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
index e090ea1b40..845d05722b 100644
--- a/include/hw/scsi/scsi.h
+++ b/include/hw/scsi/scsi.h
@@ -228,5 +228,6 @@ extern const SCSIReqOps scsi_generic_req_ops;
/* scsi-disk.c */
#define SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR 0
+#define SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD 1
#endif
--
2.30.2
- [PATCH v3 00/14] scsi: add quirks and features to support m68k Macs, Mark Cave-Ayland, 2022/06/22
- [PATCH v3 01/14] scsi-disk: add new quirks bitmap to SCSIDiskState, Mark Cave-Ayland, 2022/06/22
- [PATCH v3 02/14] scsi-disk: add MODE_PAGE_APPLE_VENDOR quirk for Macintosh, Mark Cave-Ayland, 2022/06/22
- [PATCH v3 03/14] q800: implement compat_props to enable quirk_mode_page_apple_vendor for scsi-cd devices, Mark Cave-Ayland, 2022/06/22
- [PATCH v3 04/14] scsi-disk: add SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD quirk for Macintosh,
Mark Cave-Ayland <=
- [PATCH v3 05/14] q800: implement compat_props to enable quirk_mode_sense_rom_use_dbd for scsi-cd devices, Mark Cave-Ayland, 2022/06/22
- [PATCH v3 06/14] scsi-disk: add SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE quirk for Macintosh, Mark Cave-Ayland, 2022/06/22
- [PATCH v3 07/14] q800: implement compat_props to enable quirk_mode_page_vendor_specific_apple for scsi devices, Mark Cave-Ayland, 2022/06/22
- [PATCH v3 08/14] scsi-disk: add FORMAT UNIT command, Mark Cave-Ayland, 2022/06/22
- [PATCH v3 09/14] scsi-disk: add SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED quirk for Macintosh, Mark Cave-Ayland, 2022/06/22
- [PATCH v3 10/14] q800: implement compat_props to enable quirk_mode_page_truncated for scsi-cd devices, Mark Cave-Ayland, 2022/06/22
- [PATCH v3 11/14] scsi-disk: allow the MODE_PAGE_R_W_ERROR AWRE bit to be changeable for CDROM drives, Mark Cave-Ayland, 2022/06/22
- [PATCH v3 12/14] scsi-disk: allow MODE SELECT block descriptor to set the block size, Mark Cave-Ayland, 2022/06/22
- [PATCH v3 13/14] q800: add default vendor and product information for scsi-hd devices, Mark Cave-Ayland, 2022/06/22
- [PATCH v3 14/14] q800: add default vendor and product information for scsi-cd devices, Mark Cave-Ayland, 2022/06/22