2
* GRUB -- GRand Unified Bootloader
3
* Copyright (C) 2008 Free Software Foundation, Inc.
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.
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.
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/>.
19
#include <grub/types.h>
20
#include <grub/i386/io.h>
21
#include <grub/i386/pit.h>
23
#define TIMER2_REG_CONTROL 0x42
24
#define TIMER_REG_COMMAND 0x43
25
#define TIMER2_REG_LATCH 0x61
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
35
grub_pit_wait (grub_uint16_t tics)
37
/* Disable timer2 gate and speaker. */
38
grub_outb (grub_inb (TIMER2_REG_LATCH) & ~ (TIMER2_SPEAKER | TIMER2_GATE),
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);
46
/* Enable timer2 gate, keep speaker disabled. */
47
grub_outb ((grub_inb (TIMER2_REG_LATCH) & ~ TIMER2_SPEAKER) | TIMER2_GATE,
51
while ((grub_inb (TIMER2_REG_LATCH) & TIMER2_LATCH) == 0x00);
53
/* Disable timer2 gate and speaker. */
54
grub_outb (grub_inb (TIMER2_REG_LATCH) & ~ (TIMER2_SPEAKER | TIMER2_GATE),