Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/events/evgpeinit.c
+++ new/usr/src/common/acpica/components/events/evgpeinit.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: evgpeinit - System GPE initialization and update
4 4 *
5 5 *****************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2014, Intel Corp.
9 9 * All rights reserved.
10 10 *
11 11 * Redistribution and use in source and binary forms, with or without
12 12 * modification, are permitted provided that the following conditions
13 13 * are met:
14 14 * 1. Redistributions of source code must retain the above copyright
15 15 * notice, this list of conditions, and the following disclaimer,
16 16 * without modification.
17 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 18 * substantially similar to the "NO WARRANTY" disclaimer below
19 19 * ("Disclaimer") and any redistribution must be conditioned upon
20 20 * including a substantially similar Disclaimer requirement for further
21 21 * binary redistribution.
22 22 * 3. Neither the names of the above-listed copyright holders nor the names
23 23 * of any contributors may be used to endorse or promote products derived
24 24 * from this software without specific prior written permission.
25 25 *
26 26 * Alternatively, this software may be distributed under the terms of the
27 27 * GNU General Public License ("GPL") version 2 as published by the Free
28 28 * Software Foundation.
29 29 *
30 30 * NO WARRANTY
31 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 41 * POSSIBILITY OF SUCH DAMAGES.
42 42 */
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
43 43
44 44
45 45 #include "acpi.h"
46 46 #include "accommon.h"
47 47 #include "acevents.h"
48 48 #include "acnamesp.h"
49 49
50 50 #define _COMPONENT ACPI_EVENTS
51 51 ACPI_MODULE_NAME ("evgpeinit")
52 52
53 +#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
53 54
54 55 /*
55 56 * Note: History of _PRW support in ACPICA
56 57 *
57 58 * Originally (2000 - 2010), the GPE initialization code performed a walk of
58 59 * the entire namespace to execute the _PRW methods and detect all GPEs
59 60 * capable of waking the system.
60 61 *
61 62 * As of 10/2010, the _PRW method execution has been removed since it is
62 63 * actually unnecessary. The host OS must in fact execute all _PRW methods
63 64 * in order to identify the device/power-resource dependencies. We now put
64 65 * the onus on the host OS to identify the wake GPEs as part of this process
65 66 * and to inform ACPICA of these GPEs via the AcpiSetupGpeForWake interface. This
66 67 * not only reduces the complexity of the ACPICA initialization code, but in
67 68 * some cases (on systems with very large namespaces) it should reduce the
68 69 * kernel boot time as well.
69 70 */
70 71
71 72 /*******************************************************************************
72 73 *
73 74 * FUNCTION: AcpiEvGpeInitialize
74 75 *
75 76 * PARAMETERS: None
76 77 *
77 78 * RETURN: Status
78 79 *
79 80 * DESCRIPTION: Initialize the GPE data structures and the FADT GPE 0/1 blocks
80 81 *
81 82 ******************************************************************************/
82 83
83 84 ACPI_STATUS
84 85 AcpiEvGpeInitialize (
85 86 void)
↓ open down ↓ |
23 lines elided |
↑ open up ↑ |
86 87 {
87 88 UINT32 RegisterCount0 = 0;
88 89 UINT32 RegisterCount1 = 0;
89 90 UINT32 GpeNumberMax = 0;
90 91 ACPI_STATUS Status;
91 92
92 93
93 94 ACPI_FUNCTION_TRACE (EvGpeInitialize);
94 95
95 96
97 + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
98 + "Initializing General Purpose Events (GPEs):\n"));
99 +
96 100 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
97 101 if (ACPI_FAILURE (Status))
98 102 {
99 103 return_ACPI_STATUS (Status);
100 104 }
101 105
102 106 /*
103 107 * Initialize the GPE Block(s) defined in the FADT
104 108 *
105 109 * Why the GPE register block lengths are divided by 2: From the ACPI
106 110 * Spec, section "General-Purpose Event Registers", we have:
107 111 *
108 112 * "Each register block contains two registers of equal length
109 113 * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the
110 114 * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN
111 115 * The length of the GPE1_STS and GPE1_EN registers is equal to
112 116 * half the GPE1_LEN. If a generic register block is not supported
113 117 * then its respective block pointer and block length values in the
114 118 * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need
115 119 * to be the same size."
116 120 */
117 121
118 122 /*
119 123 * Determine the maximum GPE number for this machine.
120 124 *
121 125 * Note: both GPE0 and GPE1 are optional, and either can exist without
122 126 * the other.
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
123 127 *
124 128 * If EITHER the register length OR the block address are zero, then that
125 129 * particular block is not supported.
126 130 */
127 131 if (AcpiGbl_FADT.Gpe0BlockLength &&
128 132 AcpiGbl_FADT.XGpe0Block.Address)
129 133 {
130 134 /* GPE block 0 exists (has both length and address > 0) */
131 135
132 136 RegisterCount0 = (UINT16) (AcpiGbl_FADT.Gpe0BlockLength / 2);
133 -
134 137 GpeNumberMax = (RegisterCount0 * ACPI_GPE_REGISTER_WIDTH) - 1;
135 138
136 139 /* Install GPE Block 0 */
137 140
138 141 Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice,
139 142 &AcpiGbl_FADT.XGpe0Block, RegisterCount0, 0,
140 143 AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]);
141 144
142 145 if (ACPI_FAILURE (Status))
143 146 {
144 147 ACPI_EXCEPTION ((AE_INFO, Status,
145 148 "Could not create GPE Block 0"));
146 149 }
147 150 }
148 151
149 152 if (AcpiGbl_FADT.Gpe1BlockLength &&
150 153 AcpiGbl_FADT.XGpe1Block.Address)
151 154 {
152 155 /* GPE block 1 exists (has both length and address > 0) */
153 156
154 157 RegisterCount1 = (UINT16) (AcpiGbl_FADT.Gpe1BlockLength / 2);
155 158
156 159 /* Check for GPE0/GPE1 overlap (if both banks exist) */
157 160
158 161 if ((RegisterCount0) &&
159 162 (GpeNumberMax >= AcpiGbl_FADT.Gpe1Base))
160 163 {
161 164 ACPI_ERROR ((AE_INFO,
162 165 "GPE0 block (GPE 0 to %u) overlaps the GPE1 block "
163 166 "(GPE %u to %u) - Ignoring GPE1",
164 167 GpeNumberMax, AcpiGbl_FADT.Gpe1Base,
165 168 AcpiGbl_FADT.Gpe1Base +
166 169 ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1)));
167 170
168 171 /* Ignore GPE1 block by setting the register count to zero */
169 172
170 173 RegisterCount1 = 0;
171 174 }
172 175 else
173 176 {
174 177 /* Install GPE Block 1 */
175 178
176 179 Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice,
177 180 &AcpiGbl_FADT.XGpe1Block, RegisterCount1,
178 181 AcpiGbl_FADT.Gpe1Base,
179 182 AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[1]);
180 183
181 184 if (ACPI_FAILURE (Status))
182 185 {
183 186 ACPI_EXCEPTION ((AE_INFO, Status,
184 187 "Could not create GPE Block 1"));
185 188 }
186 189
187 190 /*
188 191 * GPE0 and GPE1 do not have to be contiguous in the GPE number
189 192 * space. However, GPE0 always starts at GPE number zero.
190 193 */
191 194 GpeNumberMax = AcpiGbl_FADT.Gpe1Base +
192 195 ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1);
193 196 }
194 197 }
195 198
196 199 /* Exit if there are no GPE registers */
197 200
↓ open down ↓ |
54 lines elided |
↑ open up ↑ |
198 201 if ((RegisterCount0 + RegisterCount1) == 0)
199 202 {
200 203 /* GPEs are not required by ACPI, this is OK */
201 204
202 205 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
203 206 "There are no GPE blocks defined in the FADT\n"));
204 207 Status = AE_OK;
205 208 goto Cleanup;
206 209 }
207 210
208 - /* Check for Max GPE number out-of-range */
209 211
210 - if (GpeNumberMax > ACPI_GPE_MAX)
211 - {
212 - ACPI_ERROR ((AE_INFO,
213 - "Maximum GPE number from FADT is too large: 0x%X",
214 - GpeNumberMax));
215 - Status = AE_BAD_VALUE;
216 - goto Cleanup;
217 - }
218 -
219 212 Cleanup:
220 213 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
221 214 return_ACPI_STATUS (AE_OK);
222 215 }
223 216
224 217
225 218 /*******************************************************************************
226 219 *
227 220 * FUNCTION: AcpiEvUpdateGpes
228 221 *
229 222 * PARAMETERS: TableOwnerId - ID of the newly-loaded ACPI table
230 223 *
231 224 * RETURN: None
232 225 *
233 226 * DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a
234 227 * result of a Load() or LoadTable() operation. If new GPE
235 228 * methods have been installed, register the new methods.
236 229 *
237 230 ******************************************************************************/
238 231
239 232 void
240 233 AcpiEvUpdateGpes (
241 234 ACPI_OWNER_ID TableOwnerId)
242 235 {
243 236 ACPI_GPE_XRUPT_INFO *GpeXruptInfo;
244 237 ACPI_GPE_BLOCK_INFO *GpeBlock;
245 238 ACPI_GPE_WALK_INFO WalkInfo;
246 239 ACPI_STATUS Status = AE_OK;
247 240
248 241
249 242 /*
250 243 * Find any _Lxx/_Exx GPE methods that have just been loaded.
251 244 *
252 245 * Any GPEs that correspond to new _Lxx/_Exx methods are immediately
253 246 * enabled.
254 247 *
255 248 * Examine the namespace underneath each GpeDevice within the
256 249 * GpeBlock lists.
257 250 */
258 251 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
259 252 if (ACPI_FAILURE (Status))
260 253 {
261 254 return;
262 255 }
263 256
264 257 WalkInfo.Count = 0;
265 258 WalkInfo.OwnerId = TableOwnerId;
266 259 WalkInfo.ExecuteByOwnerId = TRUE;
267 260
268 261 /* Walk the interrupt level descriptor list */
269 262
270 263 GpeXruptInfo = AcpiGbl_GpeXruptListHead;
271 264 while (GpeXruptInfo)
272 265 {
273 266 /* Walk all Gpe Blocks attached to this interrupt level */
274 267
275 268 GpeBlock = GpeXruptInfo->GpeBlockListHead;
276 269 while (GpeBlock)
277 270 {
278 271 WalkInfo.GpeBlock = GpeBlock;
279 272 WalkInfo.GpeDevice = GpeBlock->Node;
280 273
281 274 Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD,
282 275 WalkInfo.GpeDevice, ACPI_UINT32_MAX,
283 276 ACPI_NS_WALK_NO_UNLOCK, AcpiEvMatchGpeMethod,
284 277 NULL, &WalkInfo, NULL);
285 278 if (ACPI_FAILURE (Status))
286 279 {
287 280 ACPI_EXCEPTION ((AE_INFO, Status,
288 281 "While decoding _Lxx/_Exx methods"));
289 282 }
290 283
291 284 GpeBlock = GpeBlock->Next;
292 285 }
293 286
294 287 GpeXruptInfo = GpeXruptInfo->Next;
295 288 }
296 289
297 290 if (WalkInfo.Count)
298 291 {
299 292 ACPI_INFO ((AE_INFO, "Enabled %u new GPEs", WalkInfo.Count));
300 293 }
301 294
302 295 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
303 296 return;
304 297 }
305 298
306 299
307 300 /*******************************************************************************
308 301 *
309 302 * FUNCTION: AcpiEvMatchGpeMethod
310 303 *
311 304 * PARAMETERS: Callback from WalkNamespace
312 305 *
313 306 * RETURN: Status
314 307 *
315 308 * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a
316 309 * control method under the _GPE portion of the namespace.
317 310 * Extract the name and GPE type from the object, saving this
318 311 * information for quick lookup during GPE dispatch. Allows a
319 312 * per-OwnerId evaluation if ExecuteByOwnerId is TRUE in the
320 313 * WalkInfo parameter block.
321 314 *
322 315 * The name of each GPE control method is of the form:
323 316 * "_Lxx" or "_Exx", where:
324 317 * L - means that the GPE is level triggered
325 318 * E - means that the GPE is edge triggered
326 319 * xx - is the GPE number [in HEX]
327 320 *
328 321 * If WalkInfo->ExecuteByOwnerId is TRUE, we only execute examine GPE methods
329 322 * with that owner.
330 323 *
331 324 ******************************************************************************/
332 325
333 326 ACPI_STATUS
334 327 AcpiEvMatchGpeMethod (
335 328 ACPI_HANDLE ObjHandle,
336 329 UINT32 Level,
337 330 void *Context,
338 331 void **ReturnValue)
339 332 {
340 333 ACPI_NAMESPACE_NODE *MethodNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
341 334 ACPI_GPE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_GPE_WALK_INFO, Context);
342 335 ACPI_GPE_EVENT_INFO *GpeEventInfo;
343 336 UINT32 GpeNumber;
344 337 char Name[ACPI_NAME_SIZE + 1];
345 338 UINT8 Type;
346 339
347 340
348 341 ACPI_FUNCTION_TRACE (EvMatchGpeMethod);
349 342
350 343
351 344 /* Check if requested OwnerId matches this OwnerId */
352 345
353 346 if ((WalkInfo->ExecuteByOwnerId) &&
354 347 (MethodNode->OwnerId != WalkInfo->OwnerId))
355 348 {
356 349 return_ACPI_STATUS (AE_OK);
357 350 }
358 351
359 352 /*
360 353 * Match and decode the _Lxx and _Exx GPE method names
361 354 *
362 355 * 1) Extract the method name and null terminate it
363 356 */
364 357 ACPI_MOVE_32_TO_32 (Name, &MethodNode->Name.Integer);
365 358 Name[ACPI_NAME_SIZE] = 0;
366 359
367 360 /* 2) Name must begin with an underscore */
368 361
369 362 if (Name[0] != '_')
370 363 {
↓ open down ↓ |
142 lines elided |
↑ open up ↑ |
371 364 return_ACPI_STATUS (AE_OK); /* Ignore this method */
372 365 }
373 366
374 367 /*
375 368 * 3) Edge/Level determination is based on the 2nd character
376 369 * of the method name
377 370 */
378 371 switch (Name[1])
379 372 {
380 373 case 'L':
374 +
381 375 Type = ACPI_GPE_LEVEL_TRIGGERED;
382 376 break;
383 377
384 378 case 'E':
379 +
385 380 Type = ACPI_GPE_EDGE_TRIGGERED;
386 381 break;
387 382
388 383 default:
384 +
389 385 /* Unknown method type, just ignore it */
390 386
391 387 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
392 388 "Ignoring unknown GPE method type: %s "
393 389 "(name not of form _Lxx or _Exx)", Name));
394 390 return_ACPI_STATUS (AE_OK);
395 391 }
396 392
397 393 /* 4) The last two characters of the name are the hex GPE Number */
398 394
399 395 GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16);
400 396 if (GpeNumber == ACPI_UINT32_MAX)
401 397 {
402 398 /* Conversion failed; invalid method, just ignore it */
403 399
404 400 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
405 401 "Could not extract GPE number from name: %s "
406 402 "(name is not of form _Lxx or _Exx)", Name));
407 403 return_ACPI_STATUS (AE_OK);
408 404 }
409 405
410 406 /* Ensure that we have a valid GPE number for this GPE block */
411 407
412 408 GpeEventInfo = AcpiEvLowGetGpeInfo (GpeNumber, WalkInfo->GpeBlock);
413 409 if (!GpeEventInfo)
414 410 {
415 411 /*
416 412 * This GpeNumber is not valid for this GPE block, just ignore it.
417 413 * However, it may be valid for a different GPE block, since GPE0
418 414 * and GPE1 methods both appear under \_GPE.
419 415 */
420 416 return_ACPI_STATUS (AE_OK);
421 417 }
422 418
423 419 if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
424 420 ACPI_GPE_DISPATCH_HANDLER)
425 421 {
426 422 /* If there is already a handler, ignore this GPE method */
427 423
428 424 return_ACPI_STATUS (AE_OK);
429 425 }
430 426
431 427 if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
432 428 ACPI_GPE_DISPATCH_METHOD)
433 429 {
434 430 /*
435 431 * If there is already a method, ignore this method. But check
436 432 * for a type mismatch (if both the _Lxx AND _Exx exist)
437 433 */
438 434 if (Type != (GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK))
439 435 {
440 436 ACPI_ERROR ((AE_INFO,
441 437 "For GPE 0x%.2X, found both _L%2.2X and _E%2.2X methods",
442 438 GpeNumber, GpeNumber, GpeNumber));
443 439 }
444 440 return_ACPI_STATUS (AE_OK);
445 441 }
446 442
447 443 /*
448 444 * Add the GPE information from above to the GpeEventInfo block for
449 445 * use during dispatch of this GPE.
↓ open down ↓ |
51 lines elided |
↑ open up ↑ |
450 446 */
451 447 GpeEventInfo->Flags &= ~(ACPI_GPE_DISPATCH_MASK);
452 448 GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_METHOD);
453 449 GpeEventInfo->Dispatch.MethodNode = MethodNode;
454 450
455 451 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
456 452 "Registered GPE method %s as GPE number 0x%.2X\n",
457 453 Name, GpeNumber));
458 454 return_ACPI_STATUS (AE_OK);
459 455 }
456 +
457 +#endif /* !ACPI_REDUCED_HARDWARE */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX