From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CGKW9-0003QP-Hc for qemu-devel@nongnu.org; Sat, 09 Oct 2004 12:56:25 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CGKW9-0003PU-0a for qemu-devel@nongnu.org; Sat, 09 Oct 2004 12:56:25 -0400 Received: from [129.104.30.34] (helo=a.mx.polytechnique.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CGKPB-0004KF-VL for qemu-devel@nongnu.org; Sat, 09 Oct 2004 12:49:14 -0400 Message-ID: <416816BD.6040508@bellard.org> Date: Sat, 09 Oct 2004 18:50:05 +0200 From: Fabrice Bellard MIME-Version: 1.0 Subject: Re: [Qemu-devel] [patch] Support Windows NT 4 References: <87n023lkw6.fsf@benpfaff.org> In-Reply-To: <87n023lkw6.fsf@benpfaff.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: blp@cs.stanford.edu, qemu-devel@nongnu.org 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, §ors); > + 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, §ors); > + 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 */ > >