]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/AT386/rtc.h
30030a2db9b7e03335dc2f88e351b6805887ff5c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
34 * Revision 1.1.1.1 1998/09/22 21:05:39 wsanchez
35 * Import of Mac OS X kernel (~semeria)
37 * Revision 1.1.1.1 1998/03/07 02:25:40 wsanchez
38 * Import of OSF Mach kernel (~mburg)
40 * Revision 1.1.6.1 1994/09/23 01:47:30 ezf
41 * change marker to not FREE
42 * [1994/09/22 21:20:22 ezf]
44 * Revision 1.1.2.3 1993/08/09 19:39:04 dswartz
45 * Add ANSI prototypes - CR#9523
46 * [1993/08/06 17:51:17 dswartz]
48 * Revision 1.1.2.2 1993/06/02 23:21:32 jeffc
49 * Added to OSF/1 R1.3 from NMK15.0.
50 * [1993/06/02 21:03:17 jeffc]
52 * Revision 1.1 1992/09/30 02:27:20 robert
59 * Revision 2.7 91/05/14 16:30:03 mrt
60 * Correcting copyright
62 * Revision 2.6 91/03/16 14:47:03 rpd
63 * Fixed ioctl definitions for ANSI C.
66 * Revision 2.5 91/02/05 17:20:25 mrt
67 * Changed to new Mach copyright
68 * [91/02/01 17:47:16 mrt]
70 * Revision 2.4 90/11/26 14:51:02 rvb
71 * jsb bet me to XMK34, sigh ...
73 * Synched 2.5 & 3.0 at I386q (r1.5.1.3) & XMK35 (r2.4)
76 * Revision 1.5.1.2 90/07/27 11:27:06 rvb
77 * Fix Intel Copyright as per B. Davies authorization.
80 * Revision 2.2 90/05/03 15:46:11 dbg
83 * Revision 1.5.1.1 90/01/08 13:29:46 rvb
84 * Add Intel copyright.
87 * Revision 1.5 89/09/25 12:27:37 rvb
88 * File was provided by Intel 9/18/89.
94 * Mach Operating System
95 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
96 * All Rights Reserved.
98 * Permission to use, copy, modify and distribute this software and its
99 * documentation is hereby granted, provided that both the copyright
100 * notice and this permission notice appear in all copies of the
101 * software, derivative works or modified versions, and any portions
102 * thereof, and that both notices appear in supporting documentation.
104 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
105 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
106 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
108 * Carnegie Mellon requests users of this software to return to
110 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
111 * School of Computer Science
112 * Carnegie Mellon University
113 * Pittsburgh PA 15213-3890
115 * any improvements or extensions that they make and grant Carnegie Mellon
116 * the rights to redistribute these changes.
122 * Copyright 1988, 1989 by Intel Corporation, Santa Clara, California.
124 * All Rights Reserved
126 * Permission to use, copy, modify, and distribute this software and
127 * its documentation for any purpose and without fee is hereby
128 * granted, provided that the above copyright notice appears in all
129 * copies and that both the copyright notice and this permission notice
130 * appear in supporting documentation, and that the name of Intel
131 * not be used in advertising or publicity pertaining to distribution
132 * of the software without specific, written prior permission.
134 * INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
135 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
136 * IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
137 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
138 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
139 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
140 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
143 #define RTC_ADDR 0x70 /* I/O port address for register select */
144 #define RTC_DATA 0x71 /* I/O port address for data read/write */
147 * Register A definitions
149 #define RTC_A 0x0a /* register A address */
150 #define RTC_UIP 0x80 /* Update in progress bit */
151 #define RTC_DIV0 0x00 /* Time base of 4.194304 MHz */
152 #define RTC_DIV1 0x10 /* Time base of 1.048576 MHz */
153 #define RTC_DIV2 0x20 /* Time base of 32.768 KHz */
154 #define RTC_RATE6 0x06 /* interrupt rate of 976.562 */
157 * Register B definitions
159 #define RTC_B 0x0b /* register B address */
160 #define RTC_SET 0x80 /* stop updates for time set */
161 #define RTC_PIE 0x40 /* Periodic interrupt enable */
162 #define RTC_AIE 0x20 /* Alarm interrupt enable */
163 #define RTC_UIE 0x10 /* Update ended interrupt enable */
164 #define RTC_SQWE 0x08 /* Square wave enable */
165 #define RTC_DM 0x04 /* Date mode, 1 = binary, 0 = BCD */
166 #define RTC_HM 0x02 /* hour mode, 1 = 24 hour, 0 = 12 hour */
167 #define RTC_DSE 0x01 /* Daylight savings enable */
170 * Register C definitions
172 #define RTC_C 0x0c /* register C address */
173 #define RTC_IRQF 0x80 /* IRQ flag */
174 #define RTC_PF 0x40 /* PF flag bit */
175 #define RTC_AF 0x20 /* AF flag bit */
176 #define RTC_UF 0x10 /* UF flag bit */
179 * Register D definitions
181 #define RTC_D 0x0d /* register D address */
182 #define RTC_VRT 0x80 /* Valid RAM and time bit */
184 #define RTC_NREG 0x0e /* number of RTC registers */
185 #define RTC_NREGP 0x0a /* number of RTC registers to set time */
187 #define RTCRTIME _IOR('c', 0x01, struct rtc_st) /* Read time from RTC */
188 #define RTCSTIME _IOW('c', 0x02, struct rtc_st) /* Set time into RTC */
208 * this macro reads contents of real time clock to specified buffer
210 #define load_rtc(regs) \
214 for (i = 0; i < RTC_NREG; i++) { \
216 (regs)[i] = inb(RTC_DATA); \
221 * this macro writes contents of specified buffer to real time clock
223 #define save_rtc(regs) \
226 for (i = 0; i < RTC_NREGP; i++) { \
228 outb(RTC_DATA, (regs)[i]);\