From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BkTxh-0004yd-SR for qemu-devel@nongnu.org; Tue, 13 Jul 2004 16:33:13 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BkTxf-0004xi-VY for qemu-devel@nongnu.org; Tue, 13 Jul 2004 16:33:13 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BkTxf-0004xf-Sq for qemu-devel@nongnu.org; Tue, 13 Jul 2004 16:33:11 -0400 Received: from [80.91.224.249] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BkTur-0007ee-UC for qemu-devel@nongnu.org; Tue, 13 Jul 2004 16:30:18 -0400 Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1BkTuq-00040K-00 for ; Tue, 13 Jul 2004 22:30:16 +0200 Received: from c-24-6-66-193.client.comcast.net ([24.6.66.193]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 13 Jul 2004 22:30:16 +0200 Received: from blp by c-24-6-66-193.client.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 13 Jul 2004 22:30:16 +0200 From: Ben Pfaff Date: Tue, 13 Jul 2004 13:20:09 -0700 Message-ID: <87n023lkw6.fsf@benpfaff.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: news Subject: [Qemu-devel] [patch] Support Windows NT 4 Reply-To: blp@cs.stanford.edu, 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 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 */ -- "A computer is a state machine. Threads are for people who cant [sic] program state machines." --Alan Cox