From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Iy9Yz-0003Bc-Jc for qemu-devel@nongnu.org; Fri, 30 Nov 2007 12:22:05 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Iy9Yy-0003AL-Lw for qemu-devel@nongnu.org; Fri, 30 Nov 2007 12:22:04 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iy9Yy-00039p-GX for qemu-devel@nongnu.org; Fri, 30 Nov 2007 12:22:04 -0500 Received: from tapir.sajinet.com.pe ([66.139.79.212]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Iy9Yx-0002iU-MH for qemu-devel@nongnu.org; Fri, 30 Nov 2007 12:22:04 -0500 Date: Fri, 30 Nov 2007 11:28:21 -0600 From: Carlo Marcelo Arenas Belon Message-ID: <20071130172821.GA32198@tapir> References: <20071130171809.GH28369@tapir> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20071130171809.GH28369@tapir> Subject: [Qemu-devel] [PATCH 1/2] ide: fix GPCMD_GET_CONFIGURATION for OpenSolaris guests Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org The following patch implements the following changes to the implementation of "GET CONFIGURATION" as part of the initial MMC-6 support added to ide.c so it would emulate a multi profile device with DVD-ROM capabilities : * recognize and honor "Allocation Length" command parameter * corrected flags for response to match bits for persistent and current as requested by the standard * only set "current profile" for the response if a profile is current (either CD or DVD loaded) * calculate "data length" including all headers * refactor code and add comments to help document references to all partially implemented standards (ATAPI-4, SPC-3 and MMC-6) Carlo --- Index: hw/ide.c =================================================================== RCS file: /sources/qemu/qemu/hw/ide.c,v retrieving revision 1.72 diff -u -p -r1.72 ide.c --- hw/ide.c 18 Nov 2007 01:44:37 -0000 1.72 +++ hw/ide.c 30 Nov 2007 16:29:49 -0000 @@ -1636,6 +1636,7 @@ static void ide_atapi_cmd(IDEState *s) break; case GPCMD_GET_CONFIGURATION: { + uint32_t len; int64_t total_sectors; /* only feature 0 is supported */ @@ -1644,17 +1645,27 @@ static void ide_atapi_cmd(IDEState *s) ASC_INV_FIELD_IN_CMD_PACKET); break; } - memset(buf, 0, 32); + max_len = ube16_to_cpu(packet + 7); bdrv_get_geometry(s->bs, &total_sectors); - buf[3] = 16; - buf[7] = total_sectors <= 1433600 ? 0x08 : 0x10; /* current profile */ - buf[10] = 0x10 | 0x1; - buf[11] = 0x08; /* size of profile list */ + memset(buf, 0, 32); + if (total_sectors) { + if (total_sectors > 1433600) { + buf[7] = 0x10; /* DVD-ROM */ + } else { + buf[7] = 0x08; /* CD-ROM */ + } + } else { + buf[7] = 0x00; /* no current profile */ + } + buf[10] = 0x02 | 0x01; /* persistent and current */ + buf[11] = 0x08; /* size of profile list = 4 bytes per profile */ buf[13] = 0x10; /* DVD-ROM profile */ - buf[14] = buf[7] == 0x10; /* (in)active */ + buf[14] = buf[13] == buf[7]; /* (in)active */ buf[17] = 0x08; /* CD-ROM profile */ - buf[18] = buf[7] == 0x08; /* (in)active */ - ide_atapi_cmd_reply(s, 32, 32); + buf[18] = buf[17] == buf[7]; /* (in)active */ + len = 8 + 4 + buf[11]; /* headers + size of profile list */ + cpu_to_ube32(buf, len - 4); /* data length */ + ide_atapi_cmd_reply(s, len, max_len); break; } default: