From patchwork Tue Oct 25 10:40:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 121630 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EEBF1B6F98 for ; Tue, 25 Oct 2011 23:11:32 +1100 (EST) Received: from localhost ([::1]:44871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIeS9-0000xe-GV for incoming@patchwork.ozlabs.org; Tue, 25 Oct 2011 06:41:53 -0400 Received: from eggs.gnu.org ([140.186.70.92]:59565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIeRJ-0008Jl-LH for qemu-devel@nongnu.org; Tue, 25 Oct 2011 06:41:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RIeRG-0006IA-I5 for qemu-devel@nongnu.org; Tue, 25 Oct 2011 06:41:01 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:49684) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIeRG-0006FG-4T for qemu-devel@nongnu.org; Tue, 25 Oct 2011 06:40:58 -0400 Received: by mail-wy0-f173.google.com with SMTP id 15so379083wyh.4 for ; Tue, 25 Oct 2011 03:40:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=/vNDvUu9LL+m529+q+yuKya8/nGsNbND93TDTUSP5R0=; b=wnZNioquZ/KCUfk1AenH15iOJHYmHT5DXZ9/xet/xDARP25RCGO6M0EU9/4SwvGbSJ 1x/suvtyXXgN+A0qMsZzaGH+uUyVw3sCJiRNzjxUZEC62UdaT4oOlsrE/leC8qlj6Q8X 919TCo7FPX6Bn6XG9bve0aZtqmSmky/yuLSvE= Received: by 10.227.204.141 with SMTP id fm13mr2848161wbb.12.1319539257602; Tue, 25 Oct 2011 03:40:57 -0700 (PDT) Received: from localhost.localdomain (93-34-199-98.ip51.fastwebnet.it. [93.34.199.98]) by mx.google.com with ESMTPS id fr4sm15677349wbb.0.2011.10.25.03.40.56 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 25 Oct 2011 03:40:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 25 Oct 2011 12:40:16 +0200 Message-Id: <1319539241-26436-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1319539241-26436-1-git-send-email-pbonzini@redhat.com> References: <1319539241-26436-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.173 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH v2 08/33] scsi-disk: add stubs for more MMC commands 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 patch adds a few stub implementations for MMC commands to scsi-disk, to be filled in later in the series. It also adds to scsi-defs.h constants for commands implemented by ide/atapi.c, when missing. Signed-off-by: Paolo Bonzini --- v1->v2: coding style (braces) hw/scsi-defs.h | 3 ++ hw/scsi-disk.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/hw/scsi-defs.h b/hw/scsi-defs.h index 5e6c9b7..d0a467a 100644 --- a/hw/scsi-defs.h +++ b/hw/scsi-defs.h @@ -113,6 +113,7 @@ #define READ_12 0xa8 #define WRITE_12 0xaa #define SERVICE_ACTION_IN_12 0xab +#define READ_DVD_STRUCTURE 0xad #define WRITE_VERIFY_12 0xae #define VERIFY_12 0xaf #define SEARCH_HIGH_12 0xb0 @@ -122,6 +123,8 @@ #define SEND_VOLUME_TAG 0xb6 #define READ_DEFECT_DATA_12 0xb7 #define SET_CD_SPEED 0xbb +#define MECHANISM_STATUS 0xbd +#define READ_CD 0xbe /* * SERVICE ACTION IN subcodes diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 3a08848..0557ede 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -567,6 +567,43 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) return buflen; } +static int scsi_read_dvd_structure(SCSIDiskState *s, SCSIDiskReq *r, + uint8_t *outbuf) +{ + scsi_check_condition(r, SENSE_CODE(INVALID_OPCODE)); + return -1; +} + +static int scsi_get_event_status_notification(SCSIDiskState *s, + SCSIDiskReq *r, uint8_t *outbuf) +{ + scsi_check_condition(r, SENSE_CODE(INVALID_OPCODE)); + return -1; +} + +static int scsi_get_configuration(SCSIDiskState *s, SCSIDiskReq *r, + uint8_t *outbuf) +{ + if (s->qdev.type != TYPE_ROM) { + return -1; + } + memset(outbuf, 0, 8); + /* ??? This should probably return much more information. For now + just return the basic header indicating the CD-ROM profile. */ + outbuf[7] = 8; /* CD-ROM */ + return 8; +} + +static int scsi_emulate_mechanism_status(SCSIDiskState *s, uint8_t *outbuf) +{ + if (s->qdev.type != TYPE_ROM) { + return -1; + } + memset(outbuf, 0, 8); + outbuf[5] = 1; /* CD-ROM */ + return 8; +} + static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf, int page_control) { @@ -964,12 +1001,29 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r) outbuf[7] = 0; buflen = 8; break; + case MECHANISM_STATUS: + buflen = scsi_emulate_mechanism_status(s, outbuf); + if (buflen < 0) { + goto illegal_request; + } + break; case GET_CONFIGURATION: - memset(outbuf, 0, 8); - /* ??? This should probably return much more information. For now - just return the basic header indicating the CD-ROM profile. */ - outbuf[7] = 8; // CD-ROM - buflen = 8; + buflen = scsi_get_configuration(s, r, outbuf); + if (buflen < 0) { + goto illegal_request; + } + break; + case GET_EVENT_STATUS_NOTIFICATION: + buflen = scsi_get_event_status_notification(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) { + goto illegal_request; + } break; case SERVICE_ACTION_IN_16: /* Service Action In subcommands. */ @@ -1073,7 +1127,10 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf) case ALLOW_MEDIUM_REMOVAL: case READ_CAPACITY_10: case READ_TOC: + case READ_DVD_STRUCTURE: case GET_CONFIGURATION: + case GET_EVENT_STATUS_NOTIFICATION: + case MECHANISM_STATUS: case SERVICE_ACTION_IN_16: case VERIFY_10: rc = scsi_disk_emulate_command(r);