Debian Codegraph @

i386/i386at/rtc.h

raw
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or [email protected]
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 Copyright 1988, 1989 by Intel Corporation, Santa Clara, California.
28
29 All Rights Reserved
30
31 Permission to use, copy, modify, and distribute this software and
32 its documentation for any purpose and without fee is hereby
33 granted, provided that the above copyright notice appears in all
34 copies and that both the copyright notice and this permission notice
35 appear in supporting documentation, and that the name of Intel
36 not be used in advertising or publicity pertaining to distribution
37 of the software without specific, written prior permission.
38
39 INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
40 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
41 IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
42 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
43 LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
44 NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
45 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
46 */
47
48 #ifndef _RTC_H_
49 #define _RTC_H_
50
51 #define RTC_ADDR 0x70 /* I/O port address for register select */
52 #define RTC_DATA 0x71 /* I/O port address for data read/write */
53
54 /*
55 * Register A definitions
56 */
57 #define RTC_A 0x0a /* register A address */
58 #define RTC_UIP 0x80 /* Update in progress bit */
59 #define RTC_DIV0 0x00 /* Time base of 4.194304 MHz */
60 #define RTC_DIV1 0x10 /* Time base of 1.048576 MHz */
61 #define RTC_DIV2 0x20 /* Time base of 32.768 KHz */
62 #define RTC_RATE6 0x06 /* interrupt rate of 976.562 */
63
64 /*
65 * Register B definitions
66 */
67 #define RTC_B 0x0b /* register B address */
68 #define RTC_SET 0x80 /* stop updates for time set */
69 #define RTC_PIE 0x40 /* Periodic interrupt enable */
70 #define RTC_AIE 0x20 /* Alarm interrupt enable */
71 #define RTC_UIE 0x10 /* Update ended interrupt enable */
72 #define RTC_SQWE 0x08 /* Square wave enable */
73 #define RTC_DM 0x04 /* Date mode, 1 = binary, 0 = BCD */
74 #define RTC_HM 0x02 /* hour mode, 1 = 24 hour, 0 = 12 hour */
75 #define RTC_DSE 0x01 /* Daylight savings enable */
76
77 /*
78 * Register C definitions
79 */
80 #define RTC_C 0x0c /* register C address */
81 #define RTC_IRQF 0x80 /* IRQ flag */
82 #define RTC_PF 0x40 /* PF flag bit */
83 #define RTC_AF 0x20 /* AF flag bit */
84 #define RTC_UF 0x10 /* UF flag bit */
85
86 /*
87 * Register D definitions
88 */
89 #define RTC_D 0x0d /* register D address */
90 #define RTC_VRT 0x80 /* Valid RAM and time bit */
91
92 #define RTC_NREG 0x0e /* number of RTC registers */
93 #define RTC_NREGP 0x0a /* number of RTC registers to set time */
94
95 #define RTCRTIME _IOR('c', 0x01, struct rtc_st) /* Read time from RTC */
96 #define RTCSTIME _IOW('c', 0x02, struct rtc_st) /* Set time into RTC */
97
98 struct rtc_st {
99 char rtc_sec;
100 char rtc_asec;
101 char rtc_min;
102 char rtc_amin;
103 char rtc_hr;
104 char rtc_ahr;
105 char rtc_dow;
106 char rtc_dom;
107 char rtc_mon;
108 char rtc_yr;
109 char rtc_statusa;
110 char rtc_statusb;
111 char rtc_statusc;
112 char rtc_statusd;
113 };
114
115 /*
116 * this macro reads contents of real time clock to specified buffer
117 */
118 #define load_rtc(regs) \
119 MACRO_BEGIN \
120 int i; \
121 \
122 for (i = 0; i < RTC_NREG; i++) { \
123 outb(RTC_ADDR, i); \
124 regs[i] = inb(RTC_DATA); \
125 } \
126 MACRO_END
127
128 /*
129 * this macro writes contents of specified buffer to real time clock
130 */
131 #define save_rtc(regs) \
132 MACRO_BEGIN \
133 int i; \
134 for (i = 0; i < RTC_NREGP; i++) { \
135 outb(RTC_ADDR, i); \
136 outb(RTC_DATA, regs[i]);\
137 } \
138 MACRO_END
139
140 extern int readtodc(uint64_t *tp);
141 extern int writetodc(void);
142
143 #endif /* _RTC_H_ */