All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com, pkrempa@redhat.com,
	qemu-devel@nongnu.org, mreitz@redhat.com,
	John Snow <jsnow@redhat.com>
Subject: [Qemu-devel] [PATCH v2 4/6] libqos/ahci: Add ATAPI tray macros
Date: Mon,  7 Nov 2016 16:13:32 -0500	[thread overview]
Message-ID: <1478553214-497-5-git-send-email-jsnow@redhat.com> (raw)
In-Reply-To: <1478553214-497-1-git-send-email-jsnow@redhat.com>

(1) Add START_STOP_UNIT command to ahci-test suite
(2) Add eject/start macro commands; this is not a data transfer
    command so it is not well-served by the existing generic pipeline.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/libqos/ahci.c | 30 ++++++++++++++++++++++++++++++
 tests/libqos/ahci.h |  7 +++++--
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c
index 77f9bed..603ecb6 100644
--- a/tests/libqos/ahci.c
+++ b/tests/libqos/ahci.c
@@ -882,6 +882,30 @@ AHCICommand *ahci_atapi_command_create(uint8_t scsi_cmd, uint16_t bcl)
     return cmd;
 }
 
+void ahci_atapi_eject(AHCIQState *ahci, uint8_t port)
+{
+    AHCICommand *cmd = ahci_atapi_command_create(CMD_ATAPI_START_STOP_UNIT, 0);
+    ahci_command_set_size(cmd, 0);
+
+    cmd->atapi_cmd[4] = 0x02; /* loej = true */
+    ahci_command_commit(ahci, cmd, port);
+    ahci_command_issue(ahci, cmd);
+    ahci_command_verify(ahci, cmd);
+    ahci_command_free(cmd);
+}
+
+void ahci_atapi_load(AHCIQState *ahci, uint8_t port)
+{
+    AHCICommand *cmd = ahci_atapi_command_create(CMD_ATAPI_START_STOP_UNIT, 0);
+    ahci_command_set_size(cmd, 0);
+
+    cmd->atapi_cmd[4] = 0x03; /* loej,start = true */
+    ahci_command_commit(ahci, cmd, port);
+    ahci_command_issue(ahci, cmd);
+    ahci_command_verify(ahci, cmd);
+    ahci_command_free(cmd);
+}
+
 void ahci_command_free(AHCICommand *cmd)
 {
     g_free(cmd->atapi_cmd);
@@ -910,6 +934,9 @@ static void ahci_atapi_command_set_offset(AHCICommand *cmd, uint64_t lba)
         g_assert_cmpuint(lba, <=, UINT32_MAX);
         stl_be_p(&cbd[2], lba);
         break;
+    case CMD_ATAPI_START_STOP_UNIT:
+        g_assert_cmpuint(lba, ==, 0x00);
+        break;
     default:
         /* SCSI doesn't have uniform packet formats,
          * so you have to add support for it manually. Sorry! */
@@ -976,6 +1003,9 @@ static void ahci_atapi_set_size(AHCICommand *cmd, uint64_t xbytes)
         cbd[7] = (tmp & 0xFF00) >> 8;
         cbd[8] = (tmp & 0xFF);
         break;
+    case CMD_ATAPI_START_STOP_UNIT:
+        g_assert_cmpuint(xbytes, ==, 0);
+        break;
     default:
         /* SCSI doesn't have uniform packet formats,
          * so you have to add support for it manually. Sorry! */
diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h
index bbe04f8..05ce3de 100644
--- a/tests/libqos/ahci.h
+++ b/tests/libqos/ahci.h
@@ -287,8 +287,9 @@ enum {
 
 /* ATAPI Commands */
 enum {
-    CMD_ATAPI_READ_10 = 0x28,
-    CMD_ATAPI_READ_CD = 0xbe,
+    CMD_ATAPI_START_STOP_UNIT = 0x1b,
+    CMD_ATAPI_READ_10         = 0x28,
+    CMD_ATAPI_READ_CD         = 0xbe,
 };
 
 /* AHCI Command Header Flags & Masks*/
@@ -600,6 +601,8 @@ void ahci_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd,
              void *buffer, size_t bufsize, uint64_t sector);
 void ahci_exec(AHCIQState *ahci, uint8_t port,
                uint8_t op, const AHCIOpts *opts);
+void ahci_atapi_eject(AHCIQState *ahci, uint8_t port);
+void ahci_atapi_load(AHCIQState *ahci, uint8_t port);
 
 /* Command: Fine-grained lifecycle */
 AHCICommand *ahci_command_create(uint8_t command_name);
-- 
2.7.4

  parent reply	other threads:[~2016-11-07 21:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-07 21:13 [Qemu-devel] [PATCH v2 0/6] block-backend: Always notify on blk_eject John Snow
2016-11-07 21:13 ` [Qemu-devel] [PATCH v2 1/6] " John Snow
2016-11-07 22:01   ` Eric Blake
2016-11-07 21:13 ` [Qemu-devel] [PATCH v2 2/6] libqtest: add qmp_eventwait_ref John Snow
2016-11-07 22:25   ` Eric Blake
2016-11-07 21:13 ` [Qemu-devel] [PATCH v2 3/6] libqos/ahci: Support expected errors John Snow
2016-11-07 21:13 ` John Snow [this message]
2016-11-07 21:13 ` [Qemu-devel] [PATCH v2 5/6] libqos/ahci: Add get_sense and test_ready John Snow
2016-11-07 21:13 ` [Qemu-devel] [PATCH v2 6/6] ahci-test: add QMP tray test for ATAPI John Snow
2016-11-10 16:34 ` [Qemu-devel] [PATCH v2 0/6] block-backend: Always notify on blk_eject John Snow
2016-11-11 14:01 ` Kevin Wolf
2016-11-11 15:12   ` John Snow

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=1478553214-497-5-git-send-email-jsnow@redhat.com \
    --to=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.