[1792] 2008-08-07 Christian Franke <[email protected]>

Christian Franke <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 1792
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=1792
Author:   chrfranke
Date:     2008-08-07 19:43:36 +0000 (Thu, 07 Aug 2008)

Log Message:
-----------
2008-08-07  Christian Franke  <[email protected]>

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

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/kern/i386/pit.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2008-08-07 19:21:25 UTC (rev 1791)
+++ trunk/grub2/ChangeLog	2008-08-07 19:43:36 UTC (rev 1792)
@@ -1,3 +1,10 @@
+2008-08-07  Christian Franke  <[email protected]>
+
+	* 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.
+
 2008-08-07  Bean  <[email protected]>
 
 	* conf/x86_64-efi.rmk (kernel_mod_SOURCES): Add kern/time.c,

Modified: trunk/grub2/kern/i386/pit.c
===================================================================
--- trunk/grub2/kern/i386/pit.c	2008-08-07 19:21:25 UTC (rev 1791)
+++ trunk/grub2/kern/i386/pit.c	2008-08-07 19:43:36 UTC (rev 1792)
@@ -28,13 +28,29 @@
 #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);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.