qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Partial IDE DVD emulation
@ 2007-09-08 19:21 Filip Navara
  2007-09-08 19:58 ` Alex Beregszaszi
  0 siblings, 1 reply; 3+ messages in thread
From: Filip Navara @ 2007-09-08 19:21 UTC (permalink / raw)
  To: qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 224 bytes --]

Attached patch implements enough of the MMC-6 specification so that certain
guest operating systems (Darwin/x86) recognize the emulated CD-ROM drive as
DVD one. Specific DVD behavior is enabled for images larger than 700Mb.

[-- Attachment #1.2: Type: text/html, Size: 229 bytes --]

[-- Attachment #2: qemu-ide-dvd.patch --]
[-- Type: application/octet-stream, Size: 4232 bytes --]

Index: hw/ide.c
===================================================================
RCS file: /sources/qemu/qemu/hw/ide.c,v
retrieving revision 1.65
diff -u -r1.65 ide.c
--- hw/ide.c	26 Aug 2007 17:42:20 -0000	1.65
+++ hw/ide.c	8 Sep 2007 16:05:27 -0000
@@ -261,6 +261,7 @@
  * older drives only.
  */
 #define GPCMD_GET_MEDIA_STATUS		    0xda
+#define GPCMD_MODE_SENSE_6		    0x1a
 
 /* Mode page codes for mode sense/set */
 #define GPMODE_R_W_ERROR_PAGE		0x01
@@ -1329,10 +1330,14 @@
                                 ASC_MEDIUM_NOT_PRESENT);
         }
         break;
+    case GPCMD_MODE_SENSE_6:
     case GPCMD_MODE_SENSE_10:
         {
             int action, code;
-            max_len = ube16_to_cpu(packet + 7);
+            if (packet[0] == GPCMD_MODE_SENSE_10)
+                max_len = ube16_to_cpu(packet + 7);
+            else
+                max_len = packet[4];
             action = packet[2] >> 6;
             code = packet[2] & 0x3f;
             switch(action) {
@@ -1368,7 +1373,7 @@
 
                     buf[8] = 0x2a;
                     buf[9] = 0x12;
-                    buf[10] = 0x00;
+                    buf[10] = 0x08;
                     buf[11] = 0x00;
                     
                     buf[12] = 0x70;
@@ -1582,6 +1587,50 @@
             ide_atapi_cmd_reply(s, 8, 8);
         }
         break;
+    case GPCMD_READ_DVD_STRUCTURE:
+        {
+            int media = packet[1];
+            int layer = packet[6];
+            int format = packet[2];
+            int64_t total_sectors;
+
+            if (media != 0 || layer != 0)
+            {
+                ide_atapi_cmd_error(s, SENSE_ILLEGAL_REQUEST, 
+                                    ASC_INV_FIELD_IN_CMD_PACKET);
+            }
+
+            switch (format) {
+                case 0:
+                    bdrv_get_geometry(s->bs, &total_sectors);
+                    total_sectors >>= 2;
+
+                    memset(buf, 0, 2052);
+
+                    buf[4] = 1;   // DVD-ROM, part version 1
+                    buf[5] = 0xf; // 120mm disc, maximum rate unspecified
+                    buf[6] = 0;   // one layer, embossed data
+                    buf[7] = 0;
+
+                    cpu_to_ube32(buf + 8, 0);
+                    cpu_to_ube32(buf + 12, total_sectors - 1);
+                    cpu_to_ube32(buf + 16, total_sectors - 1);
+
+                    cpu_to_be16wu((uint16_t *)buf, 2048 + 4);
+
+                    ide_atapi_cmd_reply(s, 2048 + 3, 2048 + 4);
+                    break;
+
+                default:
+                    ide_atapi_cmd_error(s, SENSE_ILLEGAL_REQUEST, 
+                                        ASC_INV_FIELD_IN_CMD_PACKET);
+                    break;
+            }
+        }
+        break;
+    case GPCMD_SET_SPEED:
+        ide_atapi_cmd_ok(s);
+        break;
     case GPCMD_INQUIRY:
         max_len = packet[4];
         buf[0] = 0x05; /* CD-ROM */
@@ -1597,6 +1646,29 @@
         padstr8(buf + 32, 4, QEMU_VERSION);
         ide_atapi_cmd_reply(s, 36, max_len);
         break;
+    case GPCMD_GET_CONFIGURATION:
+        {
+            int64_t total_sectors;
+
+            /* only feature 0 is supported */
+            if (packet[2] != 0 || packet[3] != 0) {
+                ide_atapi_cmd_error(s, SENSE_ILLEGAL_REQUEST, 
+                                    ASC_INV_FIELD_IN_CMD_PACKET);
+                break;
+            }
+            memset(buf, 0, 32);
+            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 */
+            buf[13] = 0x10; /* DVD-ROM profile */
+            buf[14] = buf[7] == 0x10; /* (in)active */
+            buf[17] = 0x08; /* CD-ROM profile */
+            buf[18] = buf[7] == 0x08; /* (in)active */
+            ide_atapi_cmd_reply(s, 32, 32);
+            break;
+        }
     default:
         ide_atapi_cmd_error(s, SENSE_ILLEGAL_REQUEST, 
                             ASC_ILLEGAL_OPCODE);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] Partial IDE DVD emulation
  2007-09-08 19:21 [Qemu-devel] [PATCH] Partial IDE DVD emulation Filip Navara
@ 2007-09-08 19:58 ` Alex Beregszaszi
  2007-09-20  7:34   ` Filip Navara
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Beregszaszi @ 2007-09-08 19:58 UTC (permalink / raw)
  To: qemu-devel

Hi,

On Sat, 2007-09-08 at 21:21 +0200, Filip Navara wrote:
> Attached patch implements enough of the MMC-6 specification so that
> certain guest operating systems (Darwin/x86) recognize the emulated
> CD-ROM drive as DVD one. Specific DVD behavior is enabled for images
> larger than 700Mb. 

Are there any changes required to the Bochs BIOS to support this?

--
Alex

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] Partial IDE DVD emulation
  2007-09-08 19:58 ` Alex Beregszaszi
@ 2007-09-20  7:34   ` Filip Navara
  0 siblings, 0 replies; 3+ messages in thread
From: Filip Navara @ 2007-09-20  7:34 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 585 bytes --]

No changes are required for Bochs BIOS. Sorry for late reply, the message
was discarded by spam filter :-/

Best regards,
Filip Navara

On 9/8/07, Alex Beregszaszi <alex@rtfs.hu> wrote:
>
> Hi,
>
> On Sat, 2007-09-08 at 21:21 +0200, Filip Navara wrote:
> > Attached patch implements enough of the MMC-6 specification so that
> > certain guest operating systems (Darwin/x86) recognize the emulated
> > CD-ROM drive as DVD one. Specific DVD behavior is enabled for images
> > larger than 700Mb.
>
> Are there any changes required to the Bochs BIOS to support this?
>
> --
> Alex
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 894 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-09-20  7:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-08 19:21 [Qemu-devel] [PATCH] Partial IDE DVD emulation Filip Navara
2007-09-08 19:58 ` Alex Beregszaszi
2007-09-20  7:34   ` Filip Navara

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).