[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 10/33] atapi/scsi-disk: make mode page values coh
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH v2 10/33] atapi/scsi-disk: make mode page values coherent between the two |
Date: |
Tue, 25 Oct 2011 12:40:18 +0200 |
This patch adds to scsi-disk the missing mode page 0x01 for both disk
and CD-ROM drives, and mode page 0x0e for CD drives only.
A few offsets were wrong in atapi.c. Also change the 2Ah mode page to
expose DVD media read capabilities in the IDE cdrom. This lets you run
dvd+rw-mediainfo on the virtual DVD drives.
Signed-off-by: Paolo Bonzini <address@hidden>
---
v1->v2: use symbolic names and expressions for ATAPI
buf[8] and buf[9], write high byte of 2 as "2 >> 8".
hw/ide/atapi.c | 14 +++++++-------
hw/scsi-disk.c | 33 ++++++++++++++++++++++++---------
2 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index e898da2..90b6729 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -751,7 +751,7 @@ static void cmd_mode_sense(IDEState *s, uint8_t *buf)
buf[8] = MODE_PAGE_CAPABILITIES;
buf[9] = 28 - 10;
- buf[10] = 0x00;
+ buf[10] = 0x3b; /* read CDR/CDRW/DVDROM/DVDR/DVDRAM */
buf[11] = 0x00;
/* Claim PLAY_AUDIO capability (0x01) since some Linux
@@ -760,14 +760,14 @@ static void cmd_mode_sense(IDEState *s, uint8_t *buf)
buf[13] = 3 << 5;
buf[14] = (1 << 0) | (1 << 3) | (1 << 5);
if (s->tray_locked) {
- buf[6] |= 1 << 1;
+ buf[14] |= 1 << 1;
}
- buf[15] = 0x00;
- cpu_to_ube16(&buf[16], 706);
- buf[18] = 0;
+ buf[15] = 0x00; /* No volume & mute control, no changer */
+ cpu_to_ube16(&buf[16], 704); /* 4x read speed */
+ buf[18] = 0; /* Two volume levels */
buf[19] = 2;
- cpu_to_ube16(&buf[20], 512);
- cpu_to_ube16(&buf[22], 706);
+ cpu_to_ube16(&buf[20], 512); /* 512k buffer */
+ cpu_to_ube16(&buf[22], 704); /* 4x read speed current */
buf[24] = 0;
buf[25] = 0;
buf[26] = 0;
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index bcce076..8f25e29 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -611,6 +611,8 @@ static int mode_sense_page(SCSIDiskState *s, int page,
uint8_t **p_outbuf,
[MODE_PAGE_HD_GEOMETRY] = (1 << TYPE_DISK),
[MODE_PAGE_FLEXIBLE_DISK_GEOMETRY] = (1 << TYPE_DISK),
[MODE_PAGE_CACHING] = (1 << TYPE_DISK) | (1 <<
TYPE_ROM),
+ [MODE_PAGE_R_W_ERROR] = (1 << TYPE_DISK) | (1 <<
TYPE_ROM),
+ [MODE_PAGE_AUDIO_CTL] = (1 << TYPE_ROM),
[MODE_PAGE_CAPABILITIES] = (1 << TYPE_ROM),
};
@@ -711,13 +713,26 @@ static int mode_sense_page(SCSIDiskState *s, int page,
uint8_t **p_outbuf,
}
break;
+ case MODE_PAGE_R_W_ERROR:
+ p[1] = 10;
+ p[2] = 0x80; /* Automatic Write Reallocation Enabled */
+ if (s->qdev.type == TYPE_ROM) {
+ p[3] = 0x20; /* Read Retry Count */
+ }
+ break;
+
+ case MODE_PAGE_AUDIO_CTL:
+ p[1] = 14;
+ break;
+
case MODE_PAGE_CAPABILITIES:
p[1] = 0x14;
if (page_control == 1) { /* Changeable Values */
break;
}
- p[2] = 3; // CD-R & CD-RW read
- p[3] = 0; // Writing not supported
+
+ p[2] = 0x3b; /* CD-R & CD-RW read */
+ p[3] = 0; /* Writing not supported */
p[4] = 0x7f; /* Audio, composite, digital out,
mode 2 form 1&2, multi session */
p[5] = 0xff; /* CD DA, DA accurate, RW supported,
@@ -727,17 +742,17 @@ static int mode_sense_page(SCSIDiskState *s, int page,
uint8_t **p_outbuf,
/* Locking supported, jumper present, eject, tray */
p[7] = 0; /* no volume & mute control, no
changer */
- p[8] = (50 * 176) >> 8; // 50x read speed
+ p[8] = (50 * 176) >> 8; /* 50x read speed */
p[9] = (50 * 176) & 0xff;
- p[10] = 0 >> 8; // No volume
- p[11] = 0 & 0xff;
- p[12] = 2048 >> 8; // 2M buffer
+ p[10] = 2 >> 8; /* Two volume levels */
+ p[11] = 2 & 0xff;
+ p[12] = 2048 >> 8; /* 2M buffer */
p[13] = 2048 & 0xff;
- p[14] = (16 * 176) >> 8; // 16x read speed current
+ p[14] = (16 * 176) >> 8; /* 16x read speed current */
p[15] = (16 * 176) & 0xff;
- p[18] = (16 * 176) >> 8; // 16x write speed
+ p[18] = (16 * 176) >> 8; /* 16x write speed */
p[19] = (16 * 176) & 0xff;
- p[20] = (16 * 176) >> 8; // 16x write speed current
+ p[20] = (16 * 176) >> 8; /* 16x write speed current */
p[21] = (16 * 176) & 0xff;
break;
--
1.7.6
- [Qemu-devel] [PATCH v2 02/33] atapi/scsi: unify definitions for MMC, (continued)
- [Qemu-devel] [PATCH v2 02/33] atapi/scsi: unify definitions for MMC, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 04/33] atapi: cleanup/fix mode sense results, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 05/33] scsi: notify the device when unit attention is reported, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 06/33] scsi-disk: report media changed via unit attention sense codes, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 09/33] scsi-disk: store valid mode pages in a table, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 08/33] scsi-disk: add stubs for more MMC commands, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 07/33] scsi-disk: fix coding style issues (braces), Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 17/33] scsi: implement REPORT LUNS for arbitrary LUNs, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 13/33] scsi-disk: report media changed via GET EVENT STATUS NOTIFICATION, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 12/33] scsi-disk: support READ DVD STRUCTURE, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 10/33] atapi/scsi-disk: make mode page values coherent between the two,
Paolo Bonzini <=
- [Qemu-devel] [PATCH v2 32/33] scsi: export scsi_generic_reqops, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 24/33] scsi-generic: check ioctl statuses when SG_IO succeeds, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 30/33] scsi: move max_lba to SCSIDevice, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 22/33] scsi-generic: drop SCSIGenericState, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 11/33] scsi-disk: support DVD profile in GET CONFIGURATION, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 19/33] scsi: add channel to addressing, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 31/33] scsi: make reqops const, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 28/33] scsi-disk: remove cluster_size, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 29/33] scsi-disk: small clean up to INQUIRY, Paolo Bonzini, 2011/10/25
- [Qemu-devel] [PATCH v2 20/33] scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0, Paolo Bonzini, 2011/10/25