From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JBL0l-0002kL-I0 for qemu-devel@nongnu.org; Sat, 05 Jan 2008 21:13:15 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JBL0k-0002k9-5z for qemu-devel@nongnu.org; Sat, 05 Jan 2008 21:13:14 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JBL0j-0002k6-W8 for qemu-devel@nongnu.org; Sat, 05 Jan 2008 21:13:14 -0500 Received: from tapir.sajinet.com.pe ([66.139.79.212]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JBL0j-0007DZ-HL for qemu-devel@nongnu.org; Sat, 05 Jan 2008 21:13:13 -0500 Date: Sat, 5 Jan 2008 20:22:33 -0600 From: Carlo Marcelo Arenas Belon Subject: Re: [Qemu-devel] [RESEND] [PATCH] ide: fix GET_CONFIGURATION DVD-ROM support Message-ID: <20080106022233.GB27577@tapir> References: <20071226073615.GB25052@tapir> <200801041825.26304.rob@landley.net> <20080105010230.GA2230@miranda.arrow> <200801042153.09808.rob@landley.net> <20080105102834.GA3379@miranda.arrow> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Kj7319i9nmIyA2yE" Content-Disposition: inline In-Reply-To: <20080105102834.GA3379@miranda.arrow> 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 --Kj7319i9nmIyA2yE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Jan 05, 2008 at 10:28:34AM +0000, Stuart Brady wrote: > On Fri, Jan 04, 2008 at 09:53:09PM -0600, Rob Landley wrote: > > Except that according to http://en.wikipedia.org/wiki/CD-ROM it's actually 703 > > and 1/8 binary megabytes (360,000 sectors *2048 bytes), which would be > > 1440000. > > Apparently that value comes from 75 sectors per second * 80 minutes... > 75*80*60 = 360000, and of course, 360000*2048/512 = 1440000, although > it actually seems that it should be one sector less than 80 minutes, > which is 359999 2048-byte sectors or 1439996 512-byte chunks. > > BTW, there are/were also 90 and 99 minute 'CD-Rs' -- Wikipedia's page on > CD-Rs describes them, but they were never very popular, and a lot of > drives can't read the discs. the exact number of sectors is really not that relevant, as the whole point here is to try to detect if it is a CD (700MB) or a DVD (4.7GB) and the logic is just assuming that if it has more sectors than you should normally expect in a CD, then it is a DVD. attached the program I used in the guests (only works on Linux) to poke the emulated drive (or a physical drive if you feel like) and compare the responses (you will need to take a look at the SPEC tables to interpret the data though) for my own tests (using a linux guest with -cdrom /dev/cdrom in my linux host that has a DVD-+RW drive) : 700MB CD-R = 1374880 (with FreeSBIE 2.0.1) 4.7GB DVD-R = 6939520 (with SXDE 9/07) feel free to report back with the value to use then if you happen to have a CD that is completely full but I had already enough problems trying to get this merged without trying to change the code that much to try to guess a better magic number than the one was originally used (I like 1440000 though) Carlo --Kj7319i9nmIyA2yE Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ide-atapi.c" /* ide-atapi Copyright (c) 2007 Carlo Marcelo Arenas Belon ide-atapi is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include #include #include #include int main (int argc, char *argv[]) { struct cdrom_generic_command cgc; struct request_sense sense; unsigned char buf[250]; int i; if (argc < 2) { printf("Usage: %s \n", argv[0]); printf("\n"); printf(" device: where the commands are send\n"); printf("\n"); return 1; } memset (&cgc, 0, sizeof(struct cdrom_generic_command)); memset (&sense, 0, sizeof(struct request_sense)); memset (&buf, 0, sizeof(buf)); int fd = open (argv[1], O_RDONLY | O_NONBLOCK); if (fd < 0) { printf("couldn't open device %s\n", argv[1]); return 1; } cgc.cmd[0] = GPCMD_GET_CONFIGURATION; cgc.cmd[1] = 0x00; cgc.cmd[8] = sizeof(buf); cgc.timeout = 100; cgc.buffer = buf; cgc.buflen = sizeof(buf); cgc.data_direction = CGC_DATA_READ; cgc.sense = &sense; cgc.quiet = 0; i = ioctl (fd, CDROM_SEND_PACKET, &cgc); if (i < 0) { printf("command failed\n"); close (fd); return 1; } printf("Response raw dump:\n"); for (i = 0; i