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

* [Qemu-devel] Re: [patch] Support Windows NT 4
  2004-07-13 20:20 [Qemu-devel] [patch] Support Windows NT 4 Ben Pfaff
@ 2004-07-14 23:41 ` Ben Pfaff
  2004-07-17 20:17 ` [Qemu-devel] " Sylvain Petreolle
  2004-10-09 16:50 ` Fabrice Bellard
  2 siblings, 0 replies; 6+ messages in thread
From: Ben Pfaff @ 2004-07-14 23:41 UTC (permalink / raw)
  To: qemu-devel

Ben Pfaff <blp@cs.stanford.edu> writes:

> +            if (cylinders <= 1024 && cylinders <= 16 && sectors <= 63) {

The second comparison against cylinders should actually be
against heads.
-- 
"Unix... is not so much a product
 as it is a painstakingly compiled oral history
 of the hacker subculture."
--Neal Stephenson

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

* Re: [Qemu-devel] [patch] Support Windows NT 4
  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 ` 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
  2 siblings, 2 replies; 6+ messages in thread
From: Sylvain Petreolle @ 2004-07-17 20:17 UTC (permalink / raw)
  To: qemu-devel

It appears Windows NT 4 Workstation wants 122 Mb to install,
but fails unless you give a 124 Mb image to qemu.
I tried successively 122 and 123 Mb and got everytime an error message 
saying the disk was too small.
(though the disk size was computed correctly)

--- Ben Pfaff <blp@cs.stanford.edu> a écrit : 
> 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.


=====
Sylvain Petreolle (spetreolle_at_users_dot_sourceforge_dot_net)
Say NO to software patents
Dites NON aux brevets logiciels

"You believe it's the year 1984, when in fact, its closer to 2184"1984 / Matrix


	

	
		
Créez gratuitement votre Yahoo! Mail avec 100 Mo de stockage !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com

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

* [Qemu-devel] Re: [patch] Support Windows NT 4
  2004-07-17 20:17 ` [Qemu-devel] " Sylvain Petreolle
@ 2004-07-17 21:22   ` Ben Pfaff
  2004-07-19 14:40   ` [Qemu-devel] " Paul Jakma
  1 sibling, 0 replies; 6+ messages in thread
From: Ben Pfaff @ 2004-07-17 21:22 UTC (permalink / raw)
  To: qemu-devel

Sylvain Petreolle <spetreolle@yahoo.fr> writes:

> It appears Windows NT 4 Workstation wants 122 Mb to install,
> but fails unless you give a 124 Mb image to qemu.
> I tried successively 122 and 123 Mb and got everytime an error message 
> saying the disk was too small.
> (though the disk size was computed correctly)

At the other end of the size spectrum, I can't get disks bigger
than 504 MB to work.  It is undoubtedly some kind of CHS<->LBA
translation issue, but I couldn't figure out what kind.
-- 
"Debian for hackers, Red Hat for suits, Slackware for loons."
--CmdrTaco <URL:http://slashdot.org/articles/99/03/22/0928207.shtml>

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

* Re: [Qemu-devel] [patch] Support Windows NT 4
  2004-07-17 20:17 ` [Qemu-devel] " Sylvain Petreolle
  2004-07-17 21:22   ` [Qemu-devel] " Ben Pfaff
@ 2004-07-19 14:40   ` Paul Jakma
  1 sibling, 0 replies; 6+ messages in thread
From: Paul Jakma @ 2004-07-19 14:40 UTC (permalink / raw)
  To: spetreolle, qemu-devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 713 bytes --]

On Sat, 17 Jul 2004, [iso-8859-1] Sylvain Petreolle wrote:

> --- Ben Pfaff <blp@cs.stanford.edu> a écrit :

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

Interesting, Solaris has problems too if it tries to use its pci-ide 
driver to access the disks. Disk access times out and returns error 
code 0x03. Using the Solaris isa 'ata' driver works fine though.

regardsm
-- 
Paul Jakma	paul@clubi.ie	paul@jakma.org	Key ID: 64A2FF6A
 	warning: do not ever send email to spam@dishone.st
Fortune:
"The value of marriage is not that adults produce children, but that children 
produce adults."
-- Peter De Vries

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

* Re: [Qemu-devel] [patch] Support Windows NT 4
  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-10-09 16:50 ` Fabrice Bellard
  2 siblings, 0 replies; 6+ messages in thread
From: Fabrice Bellard @ 2004-10-09 16:50 UTC (permalink / raw)
  To: blp, qemu-devel

Applied.

Fabrice.

Ben Pfaff wrote:
> 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 */
> 
> 

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