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

« back to all changes in this revision

Viewing changes to include/grub/i386/cmos.h

  • 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
#ifndef GRUB_CPU_CMOS_H
 
20
#define GRUB_CPU_CMOS_H 1
 
21
 
 
22
#include <grub/types.h>
 
23
#include <grub/i386/io.h>
 
24
 
 
25
#define GRUB_CMOS_ADDR_REG      0x70
 
26
#define GRUB_CMOS_DATA_REG      0x71
 
27
 
 
28
#define GRUB_CMOS_INDEX_SECOND          0
 
29
#define GRUB_CMOS_INDEX_SECOND_ALARM    1
 
30
#define GRUB_CMOS_INDEX_MINUTE          2
 
31
#define GRUB_CMOS_INDEX_MINUTE_ALARM    3
 
32
#define GRUB_CMOS_INDEX_HOUR            4
 
33
#define GRUB_CMOS_INDEX_HOUR_ALARM      5
 
34
#define GRUB_CMOS_INDEX_DAY_OF_WEEK     6
 
35
#define GRUB_CMOS_INDEX_DAY_OF_MONTH    7
 
36
#define GRUB_CMOS_INDEX_MONTH           8
 
37
#define GRUB_CMOS_INDEX_YEAR            9
 
38
 
 
39
#define GRUB_CMOS_INDEX_STATUS_A        0xA
 
40
#define GRUB_CMOS_INDEX_STATUS_B        0xB
 
41
#define GRUB_CMOS_INDEX_STATUS_C        0xC
 
42
#define GRUB_CMOS_INDEX_STATUS_D        0xD
 
43
 
 
44
#define GRUB_CMOS_STATUS_B_DAYLIGHT     1
 
45
#define GRUB_CMOS_STATUS_B_24HOUR       2
 
46
#define GRUB_CMOS_STATUS_B_BINARY       4
 
47
 
 
48
static inline grub_uint8_t
 
49
grub_bcd_to_num (grub_uint8_t a)
 
50
{
 
51
  return ((a >> 4) * 10 + (a & 0xF));
 
52
}
 
53
 
 
54
static inline grub_uint8_t
 
55
grub_num_to_bcd (grub_uint8_t a)
 
56
{
 
57
  return (((a / 10) << 4) + (a % 10));
 
58
}
 
59
 
 
60
static inline grub_uint8_t
 
61
grub_cmos_read (grub_uint8_t index)
 
62
{
 
63
  grub_outb (index, GRUB_CMOS_ADDR_REG);
 
64
  return grub_inb (GRUB_CMOS_DATA_REG);
 
65
}
 
66
 
 
67
static inline void
 
68
grub_cmos_write (grub_uint8_t index, grub_uint8_t value)
 
69
{
 
70
  grub_outb (index, GRUB_CMOS_ADDR_REG);
 
71
  grub_outb (value, GRUB_CMOS_DATA_REG);
 
72
}
 
73
 
 
74
#endif /* GRUB_CPU_CMOS_H */