From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 03/12] atapi: move GESN definitions to scsi-defs.h
Date: Tue, 20 Sep 2011 17:26:37 +0200 [thread overview]
Message-ID: <1316532406-25340-4-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1316532406-25340-1-git-send-email-pbonzini@redhat.com>
As a complement to the previous patch, move definitions for GET EVENT
STATUS NOTIFICATION from the two functions to scsi-defs.h.
The NCR_* constants are just bit values corresponding to the ENC_*
values, with no offsets even, so keep just one copy.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/ide/atapi.c | 43 ++++++-------------------------------------
hw/scsi-defs.h | 21 +++++++++++++++++++++
2 files changed, 27 insertions(+), 37 deletions(-)
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index be3b728..347c38d 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -505,19 +505,6 @@ static int ide_dvd_read_structure(IDEState *s, int format,
static unsigned int event_status_media(IDEState *s,
uint8_t *buf)
{
- enum media_event_code {
- MEC_NO_CHANGE = 0, /* Status unchanged */
- MEC_EJECT_REQUESTED, /* received a request from user to eject */
- MEC_NEW_MEDIA, /* new media inserted and ready for access */
- MEC_MEDIA_REMOVAL, /* only for media changers */
- MEC_MEDIA_CHANGED, /* only for media changers */
- MEC_BG_FORMAT_COMPLETED, /* MRW or DVD+RW b/g format completed */
- MEC_BG_FORMAT_RESTARTED, /* MRW or DVD+RW b/g format restarted */
- };
- enum media_status {
- MS_TRAY_OPEN = 1,
- MS_MEDIA_PRESENT = 2,
- };
uint8_t event_code, media_status;
media_status = 0;
@@ -564,27 +551,6 @@ static void cmd_get_event_status_notification(IDEState *s,
uint8_t notification_class;
uint8_t supported_events;
} QEMU_PACKED *gesn_event_header;
-
- enum notification_class_request_type {
- NCR_RESERVED1 = 1 << 0,
- NCR_OPERATIONAL_CHANGE = 1 << 1,
- NCR_POWER_MANAGEMENT = 1 << 2,
- NCR_EXTERNAL_REQUEST = 1 << 3,
- NCR_MEDIA = 1 << 4,
- NCR_MULTI_HOST = 1 << 5,
- NCR_DEVICE_BUSY = 1 << 6,
- NCR_RESERVED2 = 1 << 7,
- };
- enum event_notification_class_field {
- ENC_NO_EVENTS = 0,
- ENC_OPERATIONAL_CHANGE,
- ENC_POWER_MANAGEMENT,
- ENC_EXTERNAL_REQUEST,
- ENC_MEDIA,
- ENC_MULTIPLE_HOSTS,
- ENC_DEVICE_BUSY,
- ENC_RESERVED,
- };
unsigned int max_len, used_len;
gesn_cdb = (void *)packet;
@@ -606,8 +572,11 @@ static void cmd_get_event_status_notification(IDEState *s,
* These are the supported events.
*
* We currently only support requests of the 'media' type.
+ * Notification class requests and supported event classes are bitmasks,
+ * but they are build from the same values as the "notification class"
+ * field.
*/
- gesn_event_header->supported_events = NCR_MEDIA;
+ gesn_event_header->supported_events = 1 << GESN_MEDIA;
/*
* We use |= below to set the class field; other bits in this byte
@@ -621,8 +590,8 @@ static void cmd_get_event_status_notification(IDEState *s,
* notification_class_request_type enum above specifies the
* priority: upper elements are higher prio than lower ones.
*/
- if (gesn_cdb->class & NCR_MEDIA) {
- gesn_event_header->notification_class |= ENC_MEDIA;
+ if (gesn_cdb->class & (1 << GESN_MEDIA)) {
+ gesn_event_header->notification_class |= GESN_MEDIA;
used_len = event_status_media(s, buf);
} else {
gesn_event_header->notification_class = 0x80; /* No event available */
diff --git a/hw/scsi-defs.h b/hw/scsi-defs.h
index dfa3095..8094698 100644
--- a/hw/scsi-defs.h
+++ b/hw/scsi-defs.h
@@ -203,6 +203,27 @@
* of MODE_PAGE_SENSE_POWER */
#define MODE_PAGE_CDROM 0x0d
+/* Event notification classes for GET EVENT STATUS NOTIFICATION */
+#define GESN_NO_EVENTS 0
+#define GESN_OPERATIONAL_CHANGE 1
+#define GESN_POWER_MANAGEMENT 2
+#define GESN_EXTERNAL_REQUEST 3
+#define GESN_MEDIA 4
+#define GESN_MULTIPLE_HOSTS 5
+#define GESN_DEVICE_BUSY 6
+
+/* Event codes for MEDIA event status notification */
+#define MEC_NO_CHANGE 0
+#define MEC_EJECT_REQUESTED 1
+#define MEC_NEW_MEDIA 2
+#define MEC_MEDIA_REMOVAL 3 /* only for media changers */
+#define MEC_MEDIA_CHANGED 4 /* only for media changers */
+#define MEC_BG_FORMAT_COMPLETED 5 /* MRW or DVD+RW b/g format completed */
+#define MEC_BG_FORMAT_RESTARTED 6 /* MRW or DVD+RW b/g format restarted */
+
+#define MS_TRAY_OPEN 1
+#define MS_MEDIA_PRESENT 2
+
/*
* Based on values from <linux/cdrom.h> but extending CD_MINS
* to the maximum common size allowed by the Orange's Book ATIP
--
1.7.6
next prev parent reply other threads:[~2011-09-20 15:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-20 15:26 [Qemu-devel] [PATCH 00/12] scsi-disk: Add DVD-ROM support and media change + atapi: nitpicking Paolo Bonzini
2011-09-20 15:26 ` [Qemu-devel] [PATCH 01/12] scsi: pass correct sense code for ENOMEDIUM Paolo Bonzini
2011-09-20 15:26 ` [Qemu-devel] [PATCH 02/12] atapi/scsi: unify definitions for MMC Paolo Bonzini
2011-09-20 15:26 ` Paolo Bonzini [this message]
2011-09-20 15:26 ` [Qemu-devel] [PATCH 04/12] atapi: fill in AUDIO_CTL page correctly Paolo Bonzini
2011-09-20 15:26 ` [Qemu-devel] [PATCH 05/12] scsi: notify the device when unit attention is reported Paolo Bonzini
2011-09-20 15:26 ` [Qemu-devel] [PATCH 06/12] scsi-disk: report media changed via unit attention sense codes Paolo Bonzini
2011-09-20 15:26 ` [Qemu-devel] [PATCH 07/12] scsi-disk: add stubs for more MMC commands Paolo Bonzini
2011-09-20 15:26 ` [Qemu-devel] [PATCH 08/12] scsi-disk: store valid mode pages in a table Paolo Bonzini
2011-09-20 15:26 ` [Qemu-devel] [PATCH 09/12] atapi/scsi-disk: make mode page values coherent between the two Paolo Bonzini
2011-09-20 15:26 ` [Qemu-devel] [PATCH 10/12] scsi-disk: support DVD profile in GET CONFIGURATION Paolo Bonzini
2011-09-20 15:26 ` [Qemu-devel] [PATCH 11/12] scsi-disk: support READ DVD STRUCTURE Paolo Bonzini
2011-09-20 15:26 ` [Qemu-devel] [PATCH 12/12] scsi-disk: report media changed via GET EVENT STATUS NOTIFICATION Paolo Bonzini
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=1316532406-25340-4-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--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 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).