qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cong Meng <mc@linux.vnet.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: zwanp@cn.ibm.com, Cong Meng <mc@linux.vnet.ibm.com>,
	linuxram@us.ibm.com, stefanha@linux.vnet.ibm.com,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2] add suport for ATA_PASSTHROUGH_xx scsi command
Date: Wed,  1 Aug 2012 17:05:43 +0800	[thread overview]
Message-ID: <1343811943-3972-1-git-send-email-mc@linux.vnet.ibm.com> (raw)

Correct the command names of opcode 0x85 and 0xa1, and calculate
their xfer size from CDB.

ChangeLog:
v2: For opcode 0xa1 on TYPE_ROM device, do not calc the xfer size

Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com>
---
 hw/scsi-bus.c  |   19 ++++++++++++++++---
 hw/scsi-defs.h |    4 ++--
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index e4ec19e..8af1e86 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -867,6 +867,18 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
             cmd->xfer = buf[9] | (buf[8] << 8);
         }
         break;
+    case ATA_PASSTHROUGH_12:
+        if (dev->type != TYPE_ROM) {
+            if ((buf[2] & 0x3) == 2) {
+                cmd->xfer = buf[4] * dev->blocksize;
+            }
+        }
+        break;
+    case ATA_PASSTHROUGH_16:
+        if ((buf[2] & 0x3) == 2) {
+            cmd->xfer = ((buf[5] << 8) | buf[6]) * dev->blocksize;
+        }
+        break;
     }
     return 0;
 }
@@ -996,7 +1008,8 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd)
     case SEND_DVD_STRUCTURE:
     case PERSISTENT_RESERVE_OUT:
     case MAINTENANCE_OUT:
-    case ATA_PASSTHROUGH:
+    case ATA_PASSTHROUGH_12:
+    case ATA_PASSTHROUGH_16:
         cmd->mode = SCSI_XFER_TO_DEV;
         break;
     default:
@@ -1335,7 +1348,7 @@ static const char *scsi_command_name(uint8_t cmd)
         [ PERSISTENT_RESERVE_OUT   ] = "PERSISTENT_RESERVE_OUT",
         [ WRITE_FILEMARKS_16       ] = "WRITE_FILEMARKS_16",
         [ EXTENDED_COPY            ] = "EXTENDED_COPY",
-        [ ATA_PASSTHROUGH          ] = "ATA_PASSTHROUGH",
+        [ ATA_PASSTHROUGH_16       ] = "ATA_PASSTHROUGH_16",
         [ ACCESS_CONTROL_IN        ] = "ACCESS_CONTROL_IN",
         [ ACCESS_CONTROL_OUT       ] = "ACCESS_CONTROL_OUT",
         [ READ_16                  ] = "READ_16",
@@ -1352,7 +1365,7 @@ static const char *scsi_command_name(uint8_t cmd)
         [ SERVICE_ACTION_IN_16     ] = "SERVICE_ACTION_IN_16",
         [ WRITE_LONG_16            ] = "WRITE_LONG_16",
         [ REPORT_LUNS              ] = "REPORT_LUNS",
-        [ BLANK                    ] = "BLANK",
+        [ ATA_PASSTHROUGH_12       ] = "ATA_PASSTHROUGH_12",
         [ MOVE_MEDIUM              ] = "MOVE_MEDIUM",
         [ EXCHANGE_MEDIUM          ] = "EXCHANGE MEDIUM",
         [ LOAD_UNLOAD              ] = "LOAD_UNLOAD",
diff --git a/hw/scsi-defs.h b/hw/scsi-defs.h
index 8a73f74..d7a4019 100644
--- a/hw/scsi-defs.h
+++ b/hw/scsi-defs.h
@@ -100,7 +100,7 @@
 #define READ_REVERSE_16       0x81
 #define ALLOW_OVERWRITE       0x82
 #define EXTENDED_COPY         0x83
-#define ATA_PASSTHROUGH       0x85
+#define ATA_PASSTHROUGH_16    0x85
 #define ACCESS_CONTROL_IN     0x86
 #define ACCESS_CONTROL_OUT    0x87
 #define READ_16               0x88
@@ -117,7 +117,7 @@
 #define SERVICE_ACTION_IN_16  0x9e
 #define WRITE_LONG_16         0x9f
 #define REPORT_LUNS           0xa0
-#define BLANK                 0xa1
+#define ATA_PASSTHROUGH_12    0xa1
 #define MAINTENANCE_IN        0xa3
 #define MAINTENANCE_OUT       0xa4
 #define MOVE_MEDIUM           0xa5
-- 
1.7.7.6

             reply	other threads:[~2012-08-01  9:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-01  9:05 Cong Meng [this message]
2012-08-01  9:42 ` [Qemu-devel] [PATCH v2] add suport for ATA_PASSTHROUGH_xx scsi command Paolo Bonzini
2012-08-01 10:08   ` Cong Meng
2012-08-01 10:17     ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343811943-3972-1-git-send-email-mc@linux.vnet.ibm.com \
    --to=mc@linux.vnet.ibm.com \
    --cc=linuxram@us.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    --cc=zwanp@cn.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).