[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 28/55] scsi-disk: support DVD profile in GET CONFIGU
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 28/55] scsi-disk: support DVD profile in GET CONFIGURATION |
Date: |
Mon, 31 Oct 2011 14:30:03 +0100 |
From: Paolo Bonzini <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
hw/scsi-disk.c | 50 ++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 116e562..38b196b 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -567,6 +567,19 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req,
uint8_t *outbuf)
return buflen;
}
+static inline bool media_is_dvd(SCSIDiskState *s)
+{
+ uint64_t nb_sectors;
+ if (s->qdev.type != TYPE_ROM) {
+ return false;
+ }
+ if (!bdrv_is_inserted(s->bs)) {
+ return false;
+ }
+ bdrv_get_geometry(s->bs, &nb_sectors);
+ return nb_sectors > CD_MAX_SECTORS;
+}
+
static int scsi_read_dvd_structure(SCSIDiskState *s, SCSIDiskReq *r,
uint8_t *outbuf)
{
@@ -581,17 +594,38 @@ static int
scsi_get_event_status_notification(SCSIDiskState *s,
return -1;
}
-static int scsi_get_configuration(SCSIDiskState *s, SCSIDiskReq *r,
- uint8_t *outbuf)
+static int scsi_get_configuration(SCSIDiskState *s, uint8_t *outbuf)
{
+ int current;
+
if (s->qdev.type != TYPE_ROM) {
return -1;
}
- memset(outbuf, 0, 8);
- /* ??? This should probably return much more information. For now
- just return the basic header indicating the CD-ROM profile. */
- outbuf[7] = 8; /* CD-ROM */
- return 8;
+ current = media_is_dvd(s) ? MMC_PROFILE_DVD_ROM : MMC_PROFILE_CD_ROM;
+ memset(outbuf, 0, 40);
+ stl_be_p(&outbuf[0], 36); /* Bytes after the data length field */
+ stw_be_p(&outbuf[6], current);
+ /* outbuf[8] - outbuf[19]: Feature 0 - Profile list */
+ outbuf[10] = 0x03; /* persistent, current */
+ outbuf[11] = 8; /* two profiles */
+ stw_be_p(&outbuf[12], MMC_PROFILE_DVD_ROM);
+ outbuf[14] = (current == MMC_PROFILE_DVD_ROM);
+ stw_be_p(&outbuf[16], MMC_PROFILE_CD_ROM);
+ outbuf[18] = (current == MMC_PROFILE_CD_ROM);
+ /* outbuf[20] - outbuf[31]: Feature 1 - Core feature */
+ stw_be_p(&outbuf[20], 1);
+ outbuf[22] = 0x08 | 0x03; /* version 2, persistent, current */
+ outbuf[23] = 8;
+ stl_be_p(&outbuf[24], 1); /* SCSI */
+ outbuf[28] = 1; /* DBE = 1, mandatory */
+ /* outbuf[32] - outbuf[39]: Feature 3 - Removable media feature */
+ stw_be_p(&outbuf[32], 3);
+ outbuf[34] = 0x08 | 0x03; /* version 2, persistent, current */
+ outbuf[35] = 4;
+ outbuf[36] = 0x39; /* tray, load=1, eject=1, unlocked at powerup, lock=1 */
+ /* TODO: Random readable, CD read, DVD read, drive serial number,
+ power management */
+ return 40;
}
static int scsi_emulate_mechanism_status(SCSIDiskState *s, uint8_t *outbuf)
@@ -1024,7 +1058,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r)
}
break;
case GET_CONFIGURATION:
- buflen = scsi_get_configuration(s, r, outbuf);
+ buflen = scsi_get_configuration(s, outbuf);
if (buflen < 0) {
goto illegal_request;
}
--
1.7.6.4
- [Qemu-devel] [PATCH 51/55] scsi: do not call transfer_data after canceling a request, (continued)
- [Qemu-devel] [PATCH 51/55] scsi: do not call transfer_data after canceling a request, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 36/55] scsi: add channel to addressing, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 21/55] atapi: cleanup/fix mode sense results, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 20/55] atapi: move GESN definitions to scsi-defs.h, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 30/55] scsi-disk: report media changed via GET EVENT STATUS NOTIFICATION, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 23/55] scsi-disk: report media changed via unit attention sense codes, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 42/55] scsi-generic: look at host status, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 48/55] scsi: make reqops const, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 53/55] scsi-generic: bump SCSIRequest reference count until aio completion runs, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 27/55] atapi/scsi-disk: make mode page values coherent between the two, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 28/55] scsi-disk: support DVD profile in GET CONFIGURATION,
Kevin Wolf <=
- [Qemu-devel] [PATCH 54/55] scsi: push request restart to SCSIDevice, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 29/55] scsi-disk: support READ DVD STRUCTURE, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 25/55] scsi-disk: add stubs for more MMC commands, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 43/55] scsi-generic: snoop READ CAPACITY commands to get block size, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 32/55] qdev: switch children device list to QTAILQ, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 19/55] atapi/scsi: unify definitions for MMC, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 26/55] scsi-disk: store valid mode pages in a table, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 39/55] scsi-generic: drop SCSIGenericState, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 24/55] scsi-disk: fix coding style issues (braces), Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 31/55] scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo), Kevin Wolf, 2011/10/31