From patchwork Tue Jun 12 16:42:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 164450 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D5FA2B6FA8 for ; Wed, 13 Jun 2012 02:43:37 +1000 (EST) Received: from localhost ([::1]:55673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeUBr-0003fi-NN for incoming@patchwork.ozlabs.org; Tue, 12 Jun 2012 12:43:35 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeUBU-00039c-3n for qemu-devel@nongnu.org; Tue, 12 Jun 2012 12:43:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SeUBN-0006FG-PH for qemu-devel@nongnu.org; Tue, 12 Jun 2012 12:43:11 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:57794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeUBN-0006A5-GQ for qemu-devel@nongnu.org; Tue, 12 Jun 2012 12:43:05 -0400 Received: by mail-pb0-f45.google.com with SMTP id ro12so1095823pbb.4 for ; Tue, 12 Jun 2012 09:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=zIGNtw5rt6680BnTmqQbdDPB1lGzJZ8l7tJMRbKI12k=; b=flJyTAY1AUnafvCK2goM3quGlzJND3Ds4xAsE2oAShvKH6O9rlWOymUFeGlcDivSeJ X4FBOjhfcLF4A80PXkf6HUcINEnyUPQCCnOaKPPfPHoiF2pKBfRVhKEMiY986Gjs0ySE PzYqVm9xP3QM1PZMlg43Obr/g2k5XcR4O14JYuWfqbnQaXMp4GRXVEhpR5BJJPSi0qSr yRoRgrzCb/BalKtls+Sip8OVzcF8OzFTKiHbFfS/sb4qOGVKf7gM/XvyRwav/uoLxYp2 5XXWIzLq5sTW4M3PvFtwOfnIAadcPqRNPh2+eRgYgpPJnKyh/oWsC5CZMU1ASGQt9mw5 wpHg== Received: by 10.68.134.163 with SMTP id pl3mr2902961pbb.167.1339519384283; Tue, 12 Jun 2012 09:43:04 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-204-25.ip51.fastwebnet.it. [93.34.204.25]) by mx.google.com with ESMTPS id z2sm2533527pbv.34.2012.06.12.09.43.00 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jun 2012 09:43:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 12 Jun 2012 18:42:36 +0200 Message-Id: <1339519362-18852-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.10.2 In-Reply-To: <1339519362-18852-1-git-send-email-pbonzini@redhat.com> References: <1339519362-18852-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Kevin Wolf , Markus Armbruster Subject: [Qemu-devel] [PATCH 04/10] scsi-disk: implement READ DISC INFORMATION X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This command is not necessary for CD-ROM and DVD-ROM, but some versions of udev trip on its absence. Cc: Kevin Wolf Cc: Markus Armbruster Signed-off-by: Paolo Bonzini --- hw/scsi-defs.h | 1 + hw/scsi-disk.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/hw/scsi-defs.h b/hw/scsi-defs.h index 219c84d..3c9f1b5 100644 --- a/hw/scsi-defs.h +++ b/hw/scsi-defs.h @@ -82,6 +82,7 @@ #define GET_EVENT_STATUS_NOTIFICATION 0x4a #define LOG_SELECT 0x4c #define LOG_SENSE 0x4d +#define READ_DISC_INFORMATION 0x51 #define RESERVE_TRACK 0x53 #define MODE_SELECT_10 0x55 #define RESERVE_10 0x56 diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 8882f69..c4ad2ba 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -713,6 +713,39 @@ static inline bool media_is_cd(SCSIDiskState *s) return nb_sectors <= CD_MAX_SECTORS; } +static int scsi_read_disc_information(SCSIDiskState *s, SCSIDiskReq *r, + uint8_t *outbuf) +{ + uint8_t type = r->req.cmd.buf[1] & 7; + + if (s->qdev.type != TYPE_ROM) { + return -1; + } + + /* Types 1/2 are only defined for Blu-Ray. */ + if (type != 0) { + scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); + return -1; + } + + memset(outbuf, 0, 34); + outbuf[1] = 32; + outbuf[2] = 0xe; /* last session complete, disc finalized */ + outbuf[3] = 1; /* first track on disc */ + outbuf[4] = 1; /* # of sessions */ + outbuf[5] = 1; /* first track of last session */ + outbuf[6] = 1; /* last track of last session */ + outbuf[7] = 0x20; /* unrestricted use */ + outbuf[8] = 0x00; /* CD-ROM or DVD-ROM */ + /* 9-10-11: most significant byte corresponding bytes 4-5-6 */ + /* 12-23: not meaningful for CD-ROM or DVD-ROM */ + /* 24-31: disc bar code */ + /* 32: disc application code */ + /* 33: number of OPC tables */ + + return 34; +} + static int scsi_read_dvd_structure(SCSIDiskState *s, SCSIDiskReq *r, uint8_t *outbuf) { @@ -1352,6 +1385,12 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r) goto illegal_request; } break; + case READ_DISC_INFORMATION: + buflen = scsi_read_disc_information(s, r, outbuf); + if (buflen < 0) { + goto illegal_request; + } + break; case READ_DVD_STRUCTURE: buflen = scsi_read_dvd_structure(s, r, outbuf); if (buflen < 0) { @@ -1479,6 +1518,7 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf) case ALLOW_MEDIUM_REMOVAL: case READ_CAPACITY_10: case READ_TOC: + case READ_DISC_INFORMATION: case READ_DVD_STRUCTURE: case GET_CONFIGURATION: case GET_EVENT_STATUS_NOTIFICATION: