[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/35] scsi-disk: store valid mode pages in a table
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 08/35] scsi-disk: store valid mode pages in a table |
Date: |
Thu, 13 Oct 2011 13:03:38 +0200 |
A small refactoring of the MODE SENSE implementation in scsi-disk.
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi-disk.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 95a6b77..a4aadf2 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -603,10 +603,23 @@ static int scsi_emulate_mechanism_status(SCSIDiskState
*s, uint8_t *outbuf)
static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf,
int page_control)
{
+ static const int mode_sense_valid[0x3f] = {
+ [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_CAPABILITIES] = (1 << TYPE_ROM),
+ };
+
BlockDriverState *bdrv = s->bs;
int cylinders, heads, secs;
uint8_t *p = *p_outbuf;
+ if ((mode_sense_valid[page] & (1 << s->qdev.type)) == 0) {
+ return -1;
+ }
+
+ p[0] = page;
+
/*
* If Changeable Values are requested, a mask denoting those mode
parameters
* that are changeable shall be returned. As we currently don't support
@@ -615,10 +628,6 @@ static int mode_sense_page(SCSIDiskState *s, int page,
uint8_t **p_outbuf,
*/
switch (page) {
case MODE_PAGE_HD_GEOMETRY:
- if (s->qdev.type == TYPE_ROM) {
- return -1;
- }
- p[0] = 4;
p[1] = 0x16;
if (page_control == 1) { /* Changeable Values */
break;
@@ -650,10 +659,6 @@ static int mode_sense_page(SCSIDiskState *s, int page,
uint8_t **p_outbuf,
break;
case MODE_PAGE_FLEXIBLE_DISK_GEOMETRY:
- if (s->qdev.type == TYPE_ROM) {
- return -1;
- }
- p[0] = 5;
p[1] = 0x1e;
if (page_control == 1) { /* Changeable Values */
break;
@@ -703,10 +708,6 @@ static int mode_sense_page(SCSIDiskState *s, int page,
uint8_t **p_outbuf,
break;
case MODE_PAGE_CAPABILITIES:
- if (s->qdev.type != TYPE_ROM) {
- return -1;
- }
- p[0] = 0x2a;
p[1] = 0x14;
if (page_control == 1) { /* Changeable Values */
break;
--
1.7.6
- Re: [Qemu-devel] [PATCH 04/35] atapi: fill in AUDIO_CTL page correctly, (continued)
- [Qemu-devel] [PATCH 03/35] atapi: move GESN definitions to scsi-defs.h, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 02/35] atapi/scsi: unify definitions for MMC, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 06/35] scsi-disk: report media changed via unit attention sense codes, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 05/35] scsi: notify the device when unit attention is reported, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 09/35] atapi/scsi-disk: make mode page values coherent between the two, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 08/35] scsi-disk: store valid mode pages in a table,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 07/35] scsi-disk: add stubs for more MMC commands, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 10/35] scsi-disk: support DVD profile in GET CONFIGURATION, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 14/35] qdev: switch children device list to QTAILQ, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 13/35] scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo), Paolo Bonzini, 2011/10/13