]> git.proxmox.com Git - grub2.git/commitdiff
2008-08-07 Christian Franke <franke@computer.org>
authorchrfranke <chrfranke@localhost>
Thu, 7 Aug 2008 19:43:36 +0000 (19:43 +0000)
committerchrfranke <chrfranke@localhost>
Thu, 7 Aug 2008 19:43:36 +0000 (19:43 +0000)
* 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.

ChangeLog
kern/i386/pit.c

index 334b1d8c449209729c93c84337c4a16e959765a2..1237565be3089638470348365069827f648fe53f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-08-07  Christian Franke  <franke@computer.org>
+
+       * 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  <bean123ch@gmail.com>
 
        * conf/x86_64-efi.rmk (kernel_mod_SOURCES): Add kern/time.c,
index fad521b1ace6ca42d27ba95477115ac8119aeee6..82a17d3e0b0f09ed218ad5999182f70e3aa92873 100644 (file)
 #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);
 }