~ubuntu-branches/debian/sid/grub2/sid-200907171837

« back to all changes in this revision

Viewing changes to kern/i386/pit.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Millan
  • Date: 2009-07-02 13:23:51 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702132351-tanpn0ryyijp93gu
Tags: 1.96+20090702-1
* New SVN snapshot.
* rules: Remove duplicated files in sparc64-ieee1275 port.
* rules: Comment out -DGRUB_ASSUME_LINUX_HAS_FB_SUPPORT=1 setting.  We'll
  re-evaluate using it when it's more mature.  (Closes: #535026).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  GRUB  --  GRand Unified Bootloader
 
3
 *  Copyright (C) 2008  Free Software Foundation, Inc.
 
4
 *
 
5
 *  GRUB is free software: you can redistribute it and/or modify
 
6
 *  it under the terms of the GNU General Public License as published by
 
7
 *  the Free Software Foundation, either version 3 of the License, or
 
8
 *  (at your option) any later version.
 
9
 *
 
10
 *  GRUB is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
#include <grub/types.h>
 
20
#include <grub/i386/io.h>
 
21
#include <grub/i386/pit.h>
 
22
 
 
23
#define TIMER2_REG_CONTROL      0x42
 
24
#define TIMER_REG_COMMAND       0x43
 
25
#define TIMER2_REG_LATCH        0x61
 
26
 
 
27
#define TIMER2_SELECT           0x80
 
28
#define TIMER_ENABLE_LSB        0x20
 
29
#define TIMER_ENABLE_MSB        0x10
 
30
#define TIMER2_LATCH            0x20
 
31
#define TIMER2_SPEAKER          0x02
 
32
#define TIMER2_GATE             0x01
 
33
 
 
34
void
 
35
grub_pit_wait (grub_uint16_t tics)
 
36
{
 
37
  /* Disable timer2 gate and speaker.  */
 
38
  grub_outb (grub_inb (TIMER2_REG_LATCH) & ~ (TIMER2_SPEAKER | TIMER2_GATE),
 
39
             TIMER2_REG_LATCH);
 
40
 
 
41
  /* Set tics.  */
 
42
  grub_outb (TIMER2_SELECT | TIMER_ENABLE_LSB | TIMER_ENABLE_MSB, TIMER_REG_COMMAND);
 
43
  grub_outb (tics & 0xff, TIMER2_REG_CONTROL);
 
44
  grub_outb (tics >> 8, TIMER2_REG_CONTROL);
 
45
 
 
46
  /* Enable timer2 gate, keep speaker disabled.  */
 
47
  grub_outb ((grub_inb (TIMER2_REG_LATCH) & ~ TIMER2_SPEAKER) | TIMER2_GATE,
 
48
             TIMER2_REG_LATCH);
 
49
 
 
50
  /* Wait.  */
 
51
  while ((grub_inb (TIMER2_REG_LATCH) & TIMER2_LATCH) == 0x00);
 
52
 
 
53
  /* Disable timer2 gate and speaker.  */
 
54
  grub_outb (grub_inb (TIMER2_REG_LATCH) & ~ (TIMER2_SPEAKER | TIMER2_GATE),
 
55
             TIMER2_REG_LATCH);
 
56
}