xref: /xnu-11215/osfmk/arm/rtclock.h (revision a5e72196)
1 /*
2  * Copyright (c) 2007 Apple Inc. All rights reserved.
3  *
4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5  *
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.
14  *
15  * Please obtain a copy of the License at
16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17  *
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.
25  *
26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27  */
28 /*
29  * @OSF_COPYRIGHT@
30  */
31 /*
32  * @APPLE_FREE_COPYRIGHT@
33  */
34 
35 #ifndef _ARM_RTCLOCK_H_
36 #define _ARM_RTCLOCK_H_
37 
38 #include <mach/boolean.h>
39 #include <mach/mach_types.h>
40 #include <mach/mach_time.h>
41 #include <arm/machine_routines.h>
42 
43 #define EndOfAllTime            0xFFFFFFFFFFFFFFFFULL
44 #define DECREMENTER_MAX         0x7FFFFFFFUL
45 #define DECREMENTER_MIN         0xAUL
46 
47 typedef struct _rtclock_data_ {
48 	uint32_t                                                rtc_sec_divisor;
49 	uint32_t                                                rtc_usec_divisor;
50 	mach_timebase_info_data_t               rtc_timebase_const;
51 	union {
52 		uint64_t                abstime;
53 		struct {
54 			uint32_t        low;
55 			uint32_t        high;
56 		} abstime_val;
57 	}                                                               rtc_base;
58 	union {
59 		uint64_t                abstime;
60 		struct {
61 			uint32_t        low;
62 			uint32_t        high;
63 		} abstime_val;
64 	}                                                               rtc_adj;
65 	tbd_ops_data_t                                  rtc_timebase_func;
66 
67 	/* Only needed for AIC manipulation */
68 	vm_offset_t                                             rtc_timebase_addr;
69 	vm_offset_t                                             rtc_timebase_val;
70 } rtclock_data_t;
71 
72 extern rtclock_data_t                                   RTClockData;
73 #define rtclock_sec_divisor                             RTClockData.rtc_sec_divisor
74 #define rtclock_usec_divisor                    RTClockData.rtc_usec_divisor
75 #define rtclock_timebase_const                  RTClockData.rtc_timebase_const
76 #define rtclock_base_abstime                    RTClockData.rtc_base.abstime
77 #define rtclock_base_abstime_low                RTClockData.rtc_base.abstime_val.low
78 #define rtclock_base_abstime_high               RTClockData.rtc_base.abstime_val.high
79 #define rtclock_adj_abstime                             RTClockData.rtc_adj.abstime
80 #define rtclock_adj_abstime_low                 RTClockData.rtc_adj.abstime_val.low
81 #define rtclock_adj_abstime_high                RTClockData.rtc_adj.abstime_val.high
82 #define rtclock_timebase_func                   RTClockData.rtc_timebase_func
83 
84 /* Only needed for AIC manipulation */
85 #define rtclock_timebase_addr                   RTClockData.rtc_timebase_addr
86 #define rtclock_timebase_val                    RTClockData.rtc_timebase_val
87 
88 extern uint64_t arm_timer_slop_max;
89 
90 extern void rtclock_intr(unsigned int);
91 extern boolean_t SetIdlePop(void);
92 
93 extern void ClearIdlePop(boolean_t);
94 extern void rtclock_early_init(void);
95 
96 #endif /* _ARM_RTCLOCK_H_ */
97