Print this page
update to acpica-unix2-20130927
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/hardware/hwtimer.c
+++ new/usr/src/common/acpica/components/hardware/hwtimer.c
1 -
2 1 /******************************************************************************
3 2 *
4 3 * Name: hwtimer.c - ACPI Power Management Timer Interface
5 4 *
6 5 *****************************************************************************/
7 6
8 7 /*
9 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2013, Intel Corp.
10 9 * All rights reserved.
11 10 *
12 11 * Redistribution and use in source and binary forms, with or without
13 12 * modification, are permitted provided that the following conditions
14 13 * are met:
15 14 * 1. Redistributions of source code must retain the above copyright
16 15 * notice, this list of conditions, and the following disclaimer,
17 16 * without modification.
18 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 18 * substantially similar to the "NO WARRANTY" disclaimer below
20 19 * ("Disclaimer") and any redistribution must be conditioned upon
21 20 * including a substantially similar Disclaimer requirement for further
22 21 * binary redistribution.
23 22 * 3. Neither the names of the above-listed copyright holders nor the names
24 23 * of any contributors may be used to endorse or promote products derived
25 24 * from this software without specific prior written permission.
26 25 *
27 26 * Alternatively, this software may be distributed under the terms of the
28 27 * GNU General Public License ("GPL") version 2 as published by the Free
29 28 * Software Foundation.
30 29 *
31 30 * NO WARRANTY
32 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
35 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 41 * POSSIBILITY OF SUCH DAMAGES.
43 42 */
44 43
44 +#define EXPORT_ACPI_INTERFACES
45 +
45 46 #include "acpi.h"
46 47 #include "accommon.h"
47 48
48 49 #define _COMPONENT ACPI_HARDWARE
49 50 ACPI_MODULE_NAME ("hwtimer")
50 51
51 52
53 +#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
52 54 /******************************************************************************
53 55 *
54 56 * FUNCTION: AcpiGetTimerResolution
55 57 *
56 58 * PARAMETERS: Resolution - Where the resolution is returned
57 59 *
58 60 * RETURN: Status and timer resolution
59 61 *
60 62 * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits).
61 63 *
62 64 ******************************************************************************/
63 65
64 66 ACPI_STATUS
65 67 AcpiGetTimerResolution (
66 68 UINT32 *Resolution)
67 69 {
68 70 ACPI_FUNCTION_TRACE (AcpiGetTimerResolution);
69 71
70 72
71 73 if (!Resolution)
72 74 {
73 75 return_ACPI_STATUS (AE_BAD_PARAMETER);
74 76 }
75 77
76 78 if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0)
77 79 {
78 80 *Resolution = 24;
79 81 }
80 82 else
81 83 {
82 84 *Resolution = 32;
83 85 }
84 86
85 87 return_ACPI_STATUS (AE_OK);
86 88 }
87 89
88 90 ACPI_EXPORT_SYMBOL (AcpiGetTimerResolution)
89 91
90 92
91 93 /******************************************************************************
92 94 *
93 95 * FUNCTION: AcpiGetTimer
94 96 *
95 97 * PARAMETERS: Ticks - Where the timer value is returned
96 98 *
97 99 * RETURN: Status and current timer value (ticks)
98 100 *
99 101 * DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks).
100 102 *
101 103 ******************************************************************************/
102 104
103 105 ACPI_STATUS
104 106 AcpiGetTimer (
105 107 UINT32 *Ticks)
106 108 {
107 109 ACPI_STATUS Status;
↓ open down ↓ |
46 lines elided |
↑ open up ↑ |
108 110
109 111
110 112 ACPI_FUNCTION_TRACE (AcpiGetTimer);
111 113
112 114
113 115 if (!Ticks)
114 116 {
115 117 return_ACPI_STATUS (AE_BAD_PARAMETER);
116 118 }
117 119
118 - Status = AcpiHwRead (Ticks, &AcpiGbl_FADT.XPmTimerBlock);
120 + /* ACPI 5.0A: PM Timer is optional */
119 121
122 + if (!AcpiGbl_FADT.XPmTimerBlock.Address)
123 + {
124 + return_ACPI_STATUS (AE_SUPPORT);
125 + }
126 +
127 + Status = AcpiHwRead (Ticks, &AcpiGbl_FADT.XPmTimerBlock);
120 128 return_ACPI_STATUS (Status);
121 129 }
122 130
123 131 ACPI_EXPORT_SYMBOL (AcpiGetTimer)
124 132
125 133
126 134 /******************************************************************************
127 135 *
128 136 * FUNCTION: AcpiGetTimerDuration
129 137 *
130 138 * PARAMETERS: StartTicks - Starting timestamp
131 139 * EndTicks - End timestamp
132 140 * TimeElapsed - Where the elapsed time is returned
133 141 *
134 142 * RETURN: Status and TimeElapsed
135 143 *
↓ open down ↓ |
6 lines elided |
↑ open up ↑ |
136 144 * DESCRIPTION: Computes the time elapsed (in microseconds) between two
137 145 * PM Timer time stamps, taking into account the possibility of
138 146 * rollovers, the timer resolution, and timer frequency.
139 147 *
140 148 * The PM Timer's clock ticks at roughly 3.6 times per
141 149 * _microsecond_, and its clock continues through Cx state
142 150 * transitions (unlike many CPU timestamp counters) -- making it
143 151 * a versatile and accurate timer.
144 152 *
145 153 * Note that this function accommodates only a single timer
146 - * rollover. Thus for 24-bit timers, this function should only
154 + * rollover. Thus for 24-bit timers, this function should only
147 155 * be used for calculating durations less than ~4.6 seconds
148 156 * (~20 minutes for 32-bit timers) -- calculations below:
149 157 *
150 158 * 2**24 Ticks / 3,600,000 Ticks/Sec = 4.66 sec
151 159 * 2**32 Ticks / 3,600,000 Ticks/Sec = 1193 sec or 19.88 minutes
152 160 *
153 161 ******************************************************************************/
154 162
155 163 ACPI_STATUS
156 164 AcpiGetTimerDuration (
157 165 UINT32 StartTicks,
158 166 UINT32 EndTicks,
159 167 UINT32 *TimeElapsed)
160 168 {
161 169 ACPI_STATUS Status;
162 170 UINT32 DeltaTicks;
163 171 UINT64 Quotient;
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
164 172
165 173
166 174 ACPI_FUNCTION_TRACE (AcpiGetTimerDuration);
167 175
168 176
169 177 if (!TimeElapsed)
170 178 {
171 179 return_ACPI_STATUS (AE_BAD_PARAMETER);
172 180 }
173 181
182 + /* ACPI 5.0A: PM Timer is optional */
183 +
184 + if (!AcpiGbl_FADT.XPmTimerBlock.Address)
185 + {
186 + return_ACPI_STATUS (AE_SUPPORT);
187 + }
188 +
174 189 /*
175 190 * Compute Tick Delta:
176 191 * Handle (max one) timer rollovers on 24-bit versus 32-bit timers.
177 192 */
178 193 if (StartTicks < EndTicks)
179 194 {
180 195 DeltaTicks = EndTicks - StartTicks;
181 196 }
182 197 else if (StartTicks > EndTicks)
183 198 {
184 199 if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0)
185 200 {
186 201 /* 24-bit Timer */
187 202
188 203 DeltaTicks = (((0x00FFFFFF - StartTicks) + EndTicks) & 0x00FFFFFF);
189 204 }
190 205 else
191 206 {
192 207 /* 32-bit Timer */
193 208
194 209 DeltaTicks = (0xFFFFFFFF - StartTicks) + EndTicks;
195 210 }
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
196 211 }
197 212 else /* StartTicks == EndTicks */
198 213 {
199 214 *TimeElapsed = 0;
200 215 return_ACPI_STATUS (AE_OK);
201 216 }
202 217
203 218 /*
204 219 * Compute Duration (Requires a 64-bit multiply and divide):
205 220 *
206 - * TimeElapsed = (DeltaTicks * 1000000) / PM_TIMER_FREQUENCY;
221 + * TimeElapsed (microseconds) =
222 + * (DeltaTicks * ACPI_USEC_PER_SEC) / ACPI_PM_TIMER_FREQUENCY;
207 223 */
208 - Status = AcpiUtShortDivide (((UINT64) DeltaTicks) * 1000000,
209 - PM_TIMER_FREQUENCY, &Quotient, NULL);
224 + Status = AcpiUtShortDivide (((UINT64) DeltaTicks) * ACPI_USEC_PER_SEC,
225 + ACPI_PM_TIMER_FREQUENCY, &Quotient, NULL);
210 226
211 227 *TimeElapsed = (UINT32) Quotient;
212 228 return_ACPI_STATUS (Status);
213 229 }
214 230
215 231 ACPI_EXPORT_SYMBOL (AcpiGetTimerDuration)
216 232
233 +#endif /* !ACPI_REDUCED_HARDWARE */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX