From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KR7U7-0003Zd-CZ for mharc-grub-devel@gnu.org; Thu, 07 Aug 2008 11:33:03 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KR7U4-0003WI-SG for grub-devel@gnu.org; Thu, 07 Aug 2008 11:33:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KR7U1-0003T0-Fc for grub-devel@gnu.org; Thu, 07 Aug 2008 11:33:00 -0400 Received: from [199.232.76.173] (port=52355 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KR7U1-0003Sr-8E for grub-devel@gnu.org; Thu, 07 Aug 2008 11:32:57 -0400 Received: from mailout04.t-online.de ([194.25.134.18]:59233) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KR7U0-0001QE-Qm for grub-devel@gnu.org; Thu, 07 Aug 2008 11:32:57 -0400 Received: from fwd33.aul.t-online.de by mailout04.sul.t-online.de with smtp id 1KR7Tz-0001Hl-03; Thu, 07 Aug 2008 17:32:55 +0200 Received: from [10.3.2.2] (XYESz0ZSwhobww5Wazq9M2HcW4ktsAHg+a+O4LEbg3l9UYyGnQY9q8hbNMKMxiTwIm@[217.235.235.41]) by fwd33.aul.t-online.de with esmtp id 1KR7Tn-04TSLY0; Thu, 7 Aug 2008 17:32:43 +0200 Message-ID: <489B159A.2000106@t-online.de> Date: Thu, 07 Aug 2008 17:32:42 +0200 From: Christian Franke User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 SeaMonkey/1.1.11 MIME-Version: 1.0 To: The development of GRUB 2 Content-Type: multipart/mixed; boundary="------------010606020906090409000404" X-ID: XYESz0ZSwhobww5Wazq9M2HcW4ktsAHg+a+O4LEbg3l9UYyGnQY9q8hbNMKMxiTwIm X-TOI-MSGID: 0bed326a-39ce-4ac5-b775-0484abfc2bca X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Subject: [PATCH] Fix infinite loop in grub_pit_wait() X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2008 15:33:01 -0000 This is a multi-part message in MIME format. --------------010606020906090409000404 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit grub2 from current SVN hangs if run in VirtualPC, the problem was introduced with 'svn diff -r 1779:1780'. Here is a proposed fix. Christian 2008-08-07 Christian Franke * kern/i386/pit.c (TIMER2_SPEAKER): New define. (TIMER2_GATE): Likewise. (grub_pit_wait): Add enable/disable of the timer2 gate bit of port 0x61. This fixes a possible infinite loop. --------------010606020906090409000404 Content-Type: text/x-diff; name="grub2-pit-gate.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="grub2-pit-gate.patch" diff --git a/kern/i386/pit.c b/kern/i386/pit.c index d0a6eda..a3fab26 100644 --- a/kern/i386/pit.c +++ b/kern/i386/pit.c @@ -28,13 +28,26 @@ #define TIMER_ENABLE_LSB 0x20 #define TIMER_ENABLE_MSB 0x10 #define TIMER2_LATCH 0x20 +#define TIMER2_SPEAKER 0x02 +#define TIMER2_GATE 0x01 void grub_pit_wait (grub_uint16_t tics) { + /* Disable timer2 gate and speaker. */ + grub_outb (grub_inb (TIMER2_REG_LATCH) & ~ (TIMER2_SPEAKER | TIMER2_GATE), TIMER2_REG_LATCH); + + /* Set tics. */ grub_outb (TIMER2_SELECT | TIMER_ENABLE_LSB | TIMER_ENABLE_MSB, TIMER_REG_COMMAND); grub_outb (tics & 0xff, TIMER2_REG_CONTROL); grub_outb (tics >> 8, TIMER2_REG_CONTROL); + /* Enable timer2 gate, keep speaker disabled. */ + grub_outb ((grub_inb (TIMER2_REG_LATCH) & ~ TIMER2_SPEAKER) | TIMER2_GATE, TIMER2_REG_LATCH); + + /* Wait. */ while ((grub_inb (TIMER2_REG_LATCH) & TIMER2_LATCH) == 0x00); + + /* Disable timer2 gate and speaker. */ + grub_outb (grub_inb (TIMER2_REG_LATCH) & ~ (TIMER2_SPEAKER | TIMER2_GATE), TIMER2_REG_LATCH); } --------------010606020906090409000404--