qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [patch] Support Windows NT 4
@ 2004-07-13 20:20 Ben Pfaff
  2004-07-14 23:41 ` [Qemu-devel] " Ben Pfaff
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ben Pfaff @ 2004-07-13 20:20 UTC (permalink / raw)
  To: qemu-devel

The following patch allows the CVS version of qemu to install and
boot Windows NT 4, as long as the `-isa' flag is used.  Without
the patch, trying to install NT 4 will fail because no hard disk
will be detected.  Almost unbelievably, NT 4 won't detect a hard
drive unless the CMOS RAM says that it is there.

Even with this fix, WNT4 can't see the hard drives if PCI support
is turned on.  There must be something else to track down too.

Index: hw/ide.c
===================================================================
RCS file: /cvsroot/qemu/qemu/hw/ide.c,v
retrieving revision 1.26
diff -u -p -u -r1.26 ide.c
--- hw/ide.c	25 Jun 2004 14:54:19 -0000	1.26
+++ hw/ide.c	13 Jul 2004 20:13:33 -0000
@@ -1875,6 +1875,7 @@ static void ide_init2(IDEState *ide_stat
                     s->heads = 16;
                     s->sectors = 63;
                 }
+                bdrv_set_geometry_hint(s->bs, s->cylinders, s->heads, s->sectors);
             }
             if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) {
                 s->is_cdrom = 1;
Index: hw/pc.c
===================================================================
RCS file: /cvsroot/qemu/qemu/hw/pc.c,v
retrieving revision 1.25
diff -u -p -u -r1.25 pc.c
--- hw/pc.c	26 Jun 2004 15:53:17 -0000	1.25
+++ hw/pc.c	13 Jul 2004 20:13:33 -0000
@@ -101,13 +101,32 @@ static int cmos_get_fd_drive_type(int fd
     return val;
 }
 
-static void cmos_init(int ram_size, int boot_device)
+static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd) 
+{
+    RTCState *s = rtc_state;
+    int cylinders, heads, sectors;
+    bdrv_get_geometry_hint(hd, &cylinders, &heads, &sectors);
+    rtc_set_memory(s, type_ofs, 47);
+    rtc_set_memory(s, info_ofs, cylinders);
+    rtc_set_memory(s, info_ofs + 1, cylinders >> 8);
+    rtc_set_memory(s, info_ofs + 2, heads);
+    rtc_set_memory(s, info_ofs + 3, 0xff);
+    rtc_set_memory(s, info_ofs + 4, 0xff);
+    rtc_set_memory(s, info_ofs + 5, 0xc0 | ((heads > 8) << 3));
+    rtc_set_memory(s, info_ofs + 6, cylinders);
+    rtc_set_memory(s, info_ofs + 7, cylinders >> 8);
+    rtc_set_memory(s, info_ofs + 8, sectors);
+}
+
+/* hd_table must contain 4 block drivers */
+static void cmos_init(int ram_size, int boot_device, BlockDriverState **hd_table)
 {
     RTCState *s = rtc_state;
     int val;
     int fd0, fd1, nb;
     time_t ti;
     struct tm *tm;
+    int i;
 
     /* set the CMOS date */
     time(&ti);
@@ -187,6 +206,35 @@ static void cmos_init(int ram_size, int 
     val |= 0x04; /* PS/2 mouse installed */
     rtc_set_memory(s, REG_EQUIPMENT_BYTE, val);
 
+    /* hard drives */
+
+    rtc_set_memory(s, 0x12, (hd_table[0] ? 0xf0 : 0) | (hd_table[1] ? 0x0f : 0));
+    if (hd_table[0])
+        cmos_init_hd(0x19, 0x1b, hd_table[0]);
+    if (hd_table[1]) 
+        cmos_init_hd(0x1a, 0x24, hd_table[1]);
+
+    val = 0;
+    for (i = 0; i < 4; i++)
+        if (hd_table[i]) {
+            int cylinders, heads, sectors;
+            uint8_t translation;
+            
+            bdrv_get_geometry_hint(hd_table[i], &cylinders, &heads, &sectors);
+            if (cylinders <= 1024 && cylinders <= 16 && sectors <= 63) {
+                /* No translation. */
+                translation = 0;
+            } else if (cylinders * heads > 131072) {
+                /* LBA translation. */
+                translation = 1;
+            } else {
+                /* LARGE translation. */
+                translation = 2;
+            }
+
+            val |= translation << (i * 2);
+        }
+    rtc_set_memory(s, 0x39, val);
 }
 
 static void speaker_ioport_write(void *opaque, uint32_t addr, uint32_t val)
@@ -506,7 +554,7 @@ void pc_init(int ram_size, int vga_ram_s
 
     floppy_controller = fdctrl_init(6, 2, 0, 0x3f0, fd_table);
 
-    cmos_init(ram_size, boot_device);
+    cmos_init(ram_size, boot_device, bs_table);
 
     /* must be done after all PCI devices are instanciated */
     /* XXX: should be done in the Bochs BIOS */


-- 
"A computer is a state machine.
 Threads are for people who cant [sic] program state machines."
--Alan Cox

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

end of thread, other threads:[~2004-10-09 16:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-13 20:20 [Qemu-devel] [patch] Support Windows NT 4 Ben Pfaff
2004-07-14 23:41 ` [Qemu-devel] " Ben Pfaff
2004-07-17 20:17 ` [Qemu-devel] " Sylvain Petreolle
2004-07-17 21:22   ` [Qemu-devel] " Ben Pfaff
2004-07-19 14:40   ` [Qemu-devel] " Paul Jakma
2004-10-09 16:50 ` Fabrice Bellard

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