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/events/evxfgpe.c
+++ new/usr/src/common/acpica/components/events/evxfgpe.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: evxfgpe - External Interfaces for General Purpose Events (GPEs)
4 4 *
5 5 *****************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2013, 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
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
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 */
43 43
44 44
45 45 #define __EVXFGPE_C__
46 +#define EXPORT_ACPI_INTERFACES
46 47
47 48 #include "acpi.h"
48 49 #include "accommon.h"
49 50 #include "acevents.h"
50 51 #include "acnamesp.h"
51 52
52 53 #define _COMPONENT ACPI_EVENTS
53 54 ACPI_MODULE_NAME ("evxfgpe")
54 55
55 56
57 +#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
56 58 /*******************************************************************************
57 59 *
58 60 * FUNCTION: AcpiUpdateAllGpes
59 61 *
60 62 * PARAMETERS: None
61 63 *
62 64 * RETURN: Status
63 65 *
64 66 * DESCRIPTION: Complete GPE initialization and enable all GPEs that have
65 67 * associated _Lxx or _Exx methods and are not pointed to by any
66 68 * device _PRW methods (this indicates that these GPEs are
67 69 * generally intended for system or device wakeup. Such GPEs
68 70 * have to be enabled directly when the devices whose _PRW
69 71 * methods point to them are set up for wakeup signaling.)
70 72 *
71 73 * NOTE: Should be called after any GPEs are added to the system. Primarily,
72 74 * after the system _PRW methods have been run, but also after a GPE Block
73 75 * Device has been added or if any new GPE methods have been added via a
74 76 * dynamic table load.
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
75 77 *
76 78 ******************************************************************************/
77 79
78 80 ACPI_STATUS
79 81 AcpiUpdateAllGpes (
80 82 void)
81 83 {
82 84 ACPI_STATUS Status;
83 85
84 86
85 - ACPI_FUNCTION_TRACE (AcpiUpdateGpes);
87 + ACPI_FUNCTION_TRACE (AcpiUpdateAllGpes);
86 88
87 89
88 90 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
89 91 if (ACPI_FAILURE (Status))
90 92 {
91 93 return_ACPI_STATUS (Status);
92 94 }
93 95
94 96 if (AcpiGbl_AllGpesInitialized)
95 97 {
96 98 goto UnlockAndExit;
97 99 }
98 100
99 101 Status = AcpiEvWalkGpeList (AcpiEvInitializeGpeBlock, NULL);
100 102 if (ACPI_SUCCESS (Status))
101 103 {
102 104 AcpiGbl_AllGpesInitialized = TRUE;
103 105 }
104 106
105 107 UnlockAndExit:
106 108 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
107 109 return_ACPI_STATUS (Status);
108 110 }
109 111
110 112 ACPI_EXPORT_SYMBOL (AcpiUpdateAllGpes)
111 113
112 114
113 115 /*******************************************************************************
114 116 *
115 117 * FUNCTION: AcpiEnableGpe
116 118 *
117 119 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
118 120 * GpeNumber - GPE level within the GPE block
119 121 *
120 122 * RETURN: Status
121 123 *
122 124 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
123 125 * hardware-enabled.
124 126 *
125 127 ******************************************************************************/
126 128
127 129 ACPI_STATUS
128 130 AcpiEnableGpe (
129 131 ACPI_HANDLE GpeDevice,
130 132 UINT32 GpeNumber)
131 133 {
132 134 ACPI_STATUS Status = AE_BAD_PARAMETER;
133 135 ACPI_GPE_EVENT_INFO *GpeEventInfo;
134 136 ACPI_CPU_FLAGS Flags;
135 137
136 138
137 139 ACPI_FUNCTION_TRACE (AcpiEnableGpe);
138 140
139 141
140 142 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
141 143
142 144 /* Ensure that we have a valid GPE number */
143 145
144 146 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
145 147 if (GpeEventInfo)
146 148 {
147 149 Status = AcpiEvAddGpeReference (GpeEventInfo);
148 150 }
149 151
150 152 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
151 153 return_ACPI_STATUS (Status);
152 154 }
153 155
154 156 ACPI_EXPORT_SYMBOL (AcpiEnableGpe)
155 157
156 158
157 159 /*******************************************************************************
158 160 *
159 161 * FUNCTION: AcpiDisableGpe
160 162 *
161 163 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
162 164 * GpeNumber - GPE level within the GPE block
163 165 *
164 166 * RETURN: Status
165 167 *
166 168 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
167 169 * removed, only then is the GPE disabled (for runtime GPEs), or
168 170 * the GPE mask bit disabled (for wake GPEs)
169 171 *
170 172 ******************************************************************************/
171 173
172 174 ACPI_STATUS
173 175 AcpiDisableGpe (
174 176 ACPI_HANDLE GpeDevice,
175 177 UINT32 GpeNumber)
176 178 {
177 179 ACPI_STATUS Status = AE_BAD_PARAMETER;
178 180 ACPI_GPE_EVENT_INFO *GpeEventInfo;
179 181 ACPI_CPU_FLAGS Flags;
180 182
181 183
182 184 ACPI_FUNCTION_TRACE (AcpiDisableGpe);
183 185
184 186
185 187 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
186 188
187 189 /* Ensure that we have a valid GPE number */
188 190
189 191 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
190 192 if (GpeEventInfo)
191 193 {
192 194 Status = AcpiEvRemoveGpeReference (GpeEventInfo);
193 195 }
194 196
195 197 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
196 198 return_ACPI_STATUS (Status);
197 199 }
198 200
199 201 ACPI_EXPORT_SYMBOL (AcpiDisableGpe)
200 202
201 203
202 204 /*******************************************************************************
203 205 *
204 206 * FUNCTION: AcpiSetGpe
205 207 *
206 208 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
207 209 * GpeNumber - GPE level within the GPE block
208 210 * Action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
209 211 *
210 212 * RETURN: Status
211 213 *
212 214 * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
213 215 * the reference count mechanism used in the AcpiEnableGpe and
214 216 * AcpiDisableGpe interfaces -- and should be used with care.
215 217 *
216 218 * Note: Typically used to disable a runtime GPE for short period of time,
217 219 * then re-enable it, without disturbing the existing reference counts. This
218 220 * is useful, for example, in the Embedded Controller (EC) driver.
219 221 *
220 222 ******************************************************************************/
221 223
222 224 ACPI_STATUS
223 225 AcpiSetGpe (
224 226 ACPI_HANDLE GpeDevice,
225 227 UINT32 GpeNumber,
226 228 UINT8 Action)
227 229 {
228 230 ACPI_GPE_EVENT_INFO *GpeEventInfo;
229 231 ACPI_STATUS Status;
230 232 ACPI_CPU_FLAGS Flags;
231 233
232 234
233 235 ACPI_FUNCTION_TRACE (AcpiSetGpe);
234 236
235 237
236 238 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
237 239
238 240 /* Ensure that we have a valid GPE number */
239 241
240 242 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
241 243 if (!GpeEventInfo)
↓ open down ↓ |
146 lines elided |
↑ open up ↑ |
242 244 {
243 245 Status = AE_BAD_PARAMETER;
244 246 goto UnlockAndExit;
245 247 }
246 248
247 249 /* Perform the action */
248 250
249 251 switch (Action)
250 252 {
251 253 case ACPI_GPE_ENABLE:
254 +
252 255 Status = AcpiEvEnableGpe (GpeEventInfo);
253 256 break;
254 257
255 258 case ACPI_GPE_DISABLE:
259 +
256 260 Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE);
257 261 break;
258 262
259 263 default:
264 +
260 265 Status = AE_BAD_PARAMETER;
261 266 break;
262 267 }
263 268
264 269 UnlockAndExit:
265 270 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
266 271 return_ACPI_STATUS (Status);
267 272 }
268 273
269 274 ACPI_EXPORT_SYMBOL (AcpiSetGpe)
270 275
271 276
272 277 /*******************************************************************************
273 278 *
274 279 * FUNCTION: AcpiSetupGpeForWake
275 280 *
276 281 * PARAMETERS: WakeDevice - Device associated with the GPE (via _PRW)
277 282 * GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
278 283 * GpeNumber - GPE level within the GPE block
279 284 *
280 285 * RETURN: Status
281 286 *
282 287 * DESCRIPTION: Mark a GPE as having the ability to wake the system. This
283 288 * interface is intended to be used as the host executes the
284 289 * _PRW methods (Power Resources for Wake) in the system tables.
285 290 * Each _PRW appears under a Device Object (The WakeDevice), and
286 291 * contains the info for the wake GPE associated with the
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
287 292 * WakeDevice.
288 293 *
289 294 ******************************************************************************/
290 295
291 296 ACPI_STATUS
292 297 AcpiSetupGpeForWake (
293 298 ACPI_HANDLE WakeDevice,
294 299 ACPI_HANDLE GpeDevice,
295 300 UINT32 GpeNumber)
296 301 {
297 - ACPI_STATUS Status = AE_BAD_PARAMETER;
302 + ACPI_STATUS Status;
298 303 ACPI_GPE_EVENT_INFO *GpeEventInfo;
299 304 ACPI_NAMESPACE_NODE *DeviceNode;
305 + ACPI_GPE_NOTIFY_INFO *Notify;
306 + ACPI_GPE_NOTIFY_INFO *NewNotify;
300 307 ACPI_CPU_FLAGS Flags;
301 308
302 309
303 310 ACPI_FUNCTION_TRACE (AcpiSetupGpeForWake);
304 311
305 312
306 313 /* Parameter Validation */
307 314
308 315 if (!WakeDevice)
309 316 {
310 317 /*
311 318 * By forcing WakeDevice to be valid, we automatically enable the
312 319 * implicit notify feature on all hosts.
313 320 */
314 321 return_ACPI_STATUS (AE_BAD_PARAMETER);
315 322 }
316 323
317 324 /* Handle root object case */
318 325
319 326 if (WakeDevice == ACPI_ROOT_OBJECT)
320 327 {
321 328 DeviceNode = AcpiGbl_RootNode;
322 329 }
323 330 else
324 331 {
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
325 332 DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, WakeDevice);
326 333 }
327 334
328 335 /* Validate WakeDevice is of type Device */
329 336
330 337 if (DeviceNode->Type != ACPI_TYPE_DEVICE)
331 338 {
332 339 return_ACPI_STATUS (AE_BAD_PARAMETER);
333 340 }
334 341
342 + /*
343 + * Allocate a new notify object up front, in case it is needed.
344 + * Memory allocation while holding a spinlock is a big no-no
345 + * on some hosts.
346 + */
347 + NewNotify = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_NOTIFY_INFO));
348 + if (!NewNotify)
349 + {
350 + return_ACPI_STATUS (AE_NO_MEMORY);
351 + }
352 +
335 353 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
336 354
337 355 /* Ensure that we have a valid GPE number */
338 356
339 357 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
340 - if (GpeEventInfo)
358 + if (!GpeEventInfo)
341 359 {
360 + Status = AE_BAD_PARAMETER;
361 + goto UnlockAndExit;
362 + }
363 +
364 + /*
365 + * If there is no method or handler for this GPE, then the
366 + * WakeDevice will be notified whenever this GPE fires. This is
367 + * known as an "implicit notify". Note: The GPE is assumed to be
368 + * level-triggered (for windows compatibility).
369 + */
370 + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
371 + ACPI_GPE_DISPATCH_NONE)
372 + {
342 373 /*
343 - * If there is no method or handler for this GPE, then the
344 - * WakeDevice will be notified whenever this GPE fires (aka
345 - * "implicit notify") Note: The GPE is assumed to be
346 - * level-triggered (for windows compatibility).
374 + * This is the first device for implicit notify on this GPE.
375 + * Just set the flags here, and enter the NOTIFY block below.
347 376 */
348 - if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
349 - ACPI_GPE_DISPATCH_NONE)
377 + GpeEventInfo->Flags =
378 + (ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED);
379 + }
380 +
381 + /*
382 + * If we already have an implicit notify on this GPE, add
383 + * this device to the notify list.
384 + */
385 + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
386 + ACPI_GPE_DISPATCH_NOTIFY)
387 + {
388 + /* Ensure that the device is not already in the list */
389 +
390 + Notify = GpeEventInfo->Dispatch.NotifyList;
391 + while (Notify)
350 392 {
351 - GpeEventInfo->Flags =
352 - (ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED);
353 - GpeEventInfo->Dispatch.DeviceNode = DeviceNode;
393 + if (Notify->DeviceNode == DeviceNode)
394 + {
395 + Status = AE_ALREADY_EXISTS;
396 + goto UnlockAndExit;
397 + }
398 + Notify = Notify->Next;
354 399 }
355 400
356 - GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE;
357 - Status = AE_OK;
401 + /* Add this device to the notify list for this GPE */
402 +
403 + NewNotify->DeviceNode = DeviceNode;
404 + NewNotify->Next = GpeEventInfo->Dispatch.NotifyList;
405 + GpeEventInfo->Dispatch.NotifyList = NewNotify;
406 + NewNotify = NULL;
358 407 }
359 408
409 + /* Mark the GPE as a possible wake event */
410 +
411 + GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE;
412 + Status = AE_OK;
413 +
414 +
415 +UnlockAndExit:
360 416 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
417 +
418 + /* Delete the notify object if it was not used above */
419 +
420 + if (NewNotify)
421 + {
422 + ACPI_FREE (NewNotify);
423 + }
361 424 return_ACPI_STATUS (Status);
362 425 }
363 426
364 427 ACPI_EXPORT_SYMBOL (AcpiSetupGpeForWake)
365 428
366 429
367 430 /*******************************************************************************
368 431 *
369 432 * FUNCTION: AcpiSetGpeWakeMask
370 433 *
371 434 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
372 435 * GpeNumber - GPE level within the GPE block
373 436 * Action - Enable or Disable
374 437 *
375 438 * RETURN: Status
376 439 *
377 440 * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit. The GPE must
378 441 * already be marked as a WAKE GPE.
379 442 *
380 443 ******************************************************************************/
381 444
382 445 ACPI_STATUS
383 446 AcpiSetGpeWakeMask (
384 447 ACPI_HANDLE GpeDevice,
385 448 UINT32 GpeNumber,
386 449 UINT8 Action)
387 450 {
388 451 ACPI_STATUS Status = AE_OK;
389 452 ACPI_GPE_EVENT_INFO *GpeEventInfo;
390 453 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
391 454 ACPI_CPU_FLAGS Flags;
392 455 UINT32 RegisterBit;
393 456
394 457
395 458 ACPI_FUNCTION_TRACE (AcpiSetGpeWakeMask);
396 459
397 460
398 461 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
399 462
400 463 /*
401 464 * Ensure that we have a valid GPE number and that this GPE is in
402 465 * fact a wake GPE
403 466 */
404 467 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
405 468 if (!GpeEventInfo)
406 469 {
407 470 Status = AE_BAD_PARAMETER;
408 471 goto UnlockAndExit;
409 472 }
410 473
411 474 if (!(GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE))
412 475 {
413 476 Status = AE_TYPE;
↓ open down ↓ |
43 lines elided |
↑ open up ↑ |
414 477 goto UnlockAndExit;
415 478 }
416 479
417 480 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
418 481 if (!GpeRegisterInfo)
419 482 {
420 483 Status = AE_NOT_EXIST;
421 484 goto UnlockAndExit;
422 485 }
423 486
424 - RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
487 + RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
425 488
426 489 /* Perform the action */
427 490
428 491 switch (Action)
429 492 {
430 493 case ACPI_GPE_ENABLE:
494 +
431 495 ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
432 496 break;
433 497
434 498 case ACPI_GPE_DISABLE:
499 +
435 500 ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
436 501 break;
437 502
438 503 default:
504 +
439 505 ACPI_ERROR ((AE_INFO, "%u, Invalid action", Action));
440 506 Status = AE_BAD_PARAMETER;
441 507 break;
442 508 }
443 509
444 510 UnlockAndExit:
445 511 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
446 512 return_ACPI_STATUS (Status);
447 513 }
448 514
449 515 ACPI_EXPORT_SYMBOL (AcpiSetGpeWakeMask)
450 516
451 517
452 518 /*******************************************************************************
453 519 *
454 520 * FUNCTION: AcpiClearGpe
455 521 *
456 522 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
457 523 * GpeNumber - GPE level within the GPE block
458 524 *
459 525 * RETURN: Status
460 526 *
461 527 * DESCRIPTION: Clear an ACPI event (general purpose)
462 528 *
463 529 ******************************************************************************/
464 530
465 531 ACPI_STATUS
466 532 AcpiClearGpe (
467 533 ACPI_HANDLE GpeDevice,
468 534 UINT32 GpeNumber)
469 535 {
470 536 ACPI_STATUS Status = AE_OK;
471 537 ACPI_GPE_EVENT_INFO *GpeEventInfo;
472 538 ACPI_CPU_FLAGS Flags;
473 539
474 540
475 541 ACPI_FUNCTION_TRACE (AcpiClearGpe);
476 542
477 543
478 544 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
479 545
480 546 /* Ensure that we have a valid GPE number */
481 547
482 548 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
483 549 if (!GpeEventInfo)
484 550 {
485 551 Status = AE_BAD_PARAMETER;
486 552 goto UnlockAndExit;
487 553 }
488 554
489 555 Status = AcpiHwClearGpe (GpeEventInfo);
490 556
491 557 UnlockAndExit:
492 558 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
493 559 return_ACPI_STATUS (Status);
494 560 }
495 561
496 562 ACPI_EXPORT_SYMBOL (AcpiClearGpe)
497 563
498 564
499 565 /*******************************************************************************
500 566 *
501 567 * FUNCTION: AcpiGetGpeStatus
502 568 *
503 569 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
504 570 * GpeNumber - GPE level within the GPE block
505 571 * EventStatus - Where the current status of the event
506 572 * will be returned
507 573 *
508 574 * RETURN: Status
509 575 *
510 576 * DESCRIPTION: Get the current status of a GPE (signalled/not_signalled)
511 577 *
512 578 ******************************************************************************/
513 579
514 580 ACPI_STATUS
515 581 AcpiGetGpeStatus (
516 582 ACPI_HANDLE GpeDevice,
517 583 UINT32 GpeNumber,
518 584 ACPI_EVENT_STATUS *EventStatus)
519 585 {
520 586 ACPI_STATUS Status = AE_OK;
521 587 ACPI_GPE_EVENT_INFO *GpeEventInfo;
522 588 ACPI_CPU_FLAGS Flags;
523 589
524 590
525 591 ACPI_FUNCTION_TRACE (AcpiGetGpeStatus);
526 592
527 593
528 594 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
529 595
530 596 /* Ensure that we have a valid GPE number */
531 597
532 598 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
533 599 if (!GpeEventInfo)
534 600 {
535 601 Status = AE_BAD_PARAMETER;
536 602 goto UnlockAndExit;
537 603 }
538 604
539 605 /* Obtain status on the requested GPE number */
540 606
541 607 Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus);
542 608
543 609 UnlockAndExit:
544 610 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
545 611 return_ACPI_STATUS (Status);
546 612 }
547 613
548 614 ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus)
549 615
550 616
551 617 /*******************************************************************************
552 618 *
553 619 * FUNCTION: AcpiFinishGpe
554 620 *
555 621 * PARAMETERS: GpeDevice - Namespace node for the GPE Block
556 622 * (NULL for FADT defined GPEs)
557 623 * GpeNumber - GPE level within the GPE block
558 624 *
559 625 * RETURN: Status
560 626 *
561 627 * DESCRIPTION: Clear and conditionally reenable a GPE. This completes the GPE
562 628 * processing. Intended for use by asynchronous host-installed
563 629 * GPE handlers. The GPE is only reenabled if the EnableForRun bit
564 630 * is set in the GPE info.
565 631 *
566 632 ******************************************************************************/
567 633
568 634 ACPI_STATUS
569 635 AcpiFinishGpe (
570 636 ACPI_HANDLE GpeDevice,
571 637 UINT32 GpeNumber)
572 638 {
573 639 ACPI_GPE_EVENT_INFO *GpeEventInfo;
574 640 ACPI_STATUS Status;
575 641 ACPI_CPU_FLAGS Flags;
576 642
577 643
578 644 ACPI_FUNCTION_TRACE (AcpiFinishGpe);
579 645
580 646
581 647 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
582 648
583 649 /* Ensure that we have a valid GPE number */
584 650
585 651 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
586 652 if (!GpeEventInfo)
587 653 {
588 654 Status = AE_BAD_PARAMETER;
589 655 goto UnlockAndExit;
590 656 }
591 657
592 658 Status = AcpiEvFinishGpe (GpeEventInfo);
593 659
594 660 UnlockAndExit:
595 661 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
596 662 return_ACPI_STATUS (Status);
597 663 }
598 664
599 665 ACPI_EXPORT_SYMBOL (AcpiFinishGpe)
600 666
601 667
602 668 /******************************************************************************
603 669 *
604 670 * FUNCTION: AcpiDisableAllGpes
605 671 *
606 672 * PARAMETERS: None
607 673 *
608 674 * RETURN: Status
609 675 *
610 676 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
611 677 *
612 678 ******************************************************************************/
613 679
614 680 ACPI_STATUS
615 681 AcpiDisableAllGpes (
616 682 void)
617 683 {
618 684 ACPI_STATUS Status;
619 685
620 686
621 687 ACPI_FUNCTION_TRACE (AcpiDisableAllGpes);
622 688
623 689
624 690 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
625 691 if (ACPI_FAILURE (Status))
626 692 {
627 693 return_ACPI_STATUS (Status);
628 694 }
629 695
630 696 Status = AcpiHwDisableAllGpes ();
631 697 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
632 698
633 699 return_ACPI_STATUS (Status);
634 700 }
635 701
636 702 ACPI_EXPORT_SYMBOL (AcpiDisableAllGpes)
637 703
638 704
639 705 /******************************************************************************
640 706 *
641 707 * FUNCTION: AcpiEnableAllRuntimeGpes
642 708 *
643 709 * PARAMETERS: None
644 710 *
645 711 * RETURN: Status
646 712 *
647 713 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
648 714 *
649 715 ******************************************************************************/
650 716
651 717 ACPI_STATUS
652 718 AcpiEnableAllRuntimeGpes (
653 719 void)
654 720 {
655 721 ACPI_STATUS Status;
656 722
657 723
658 724 ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes);
659 725
660 726
661 727 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
662 728 if (ACPI_FAILURE (Status))
663 729 {
664 730 return_ACPI_STATUS (Status);
665 731 }
666 732
667 733 Status = AcpiHwEnableAllRuntimeGpes ();
668 734 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
669 735
670 736 return_ACPI_STATUS (Status);
671 737 }
672 738
673 739 ACPI_EXPORT_SYMBOL (AcpiEnableAllRuntimeGpes)
674 740
675 741
676 742 /*******************************************************************************
677 743 *
678 744 * FUNCTION: AcpiInstallGpeBlock
679 745 *
680 746 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
681 747 * GpeBlockAddress - Address and SpaceID
682 748 * RegisterCount - Number of GPE register pairs in the block
683 749 * InterruptNumber - H/W interrupt for the block
684 750 *
685 751 * RETURN: Status
686 752 *
687 753 * DESCRIPTION: Create and Install a block of GPE registers. The GPEs are not
688 754 * enabled here.
689 755 *
690 756 ******************************************************************************/
691 757
692 758 ACPI_STATUS
693 759 AcpiInstallGpeBlock (
694 760 ACPI_HANDLE GpeDevice,
695 761 ACPI_GENERIC_ADDRESS *GpeBlockAddress,
696 762 UINT32 RegisterCount,
697 763 UINT32 InterruptNumber)
698 764 {
699 765 ACPI_STATUS Status;
700 766 ACPI_OPERAND_OBJECT *ObjDesc;
701 767 ACPI_NAMESPACE_NODE *Node;
702 768 ACPI_GPE_BLOCK_INFO *GpeBlock;
703 769
704 770
705 771 ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock);
706 772
707 773
↓ open down ↓ |
259 lines elided |
↑ open up ↑ |
708 774 if ((!GpeDevice) ||
709 775 (!GpeBlockAddress) ||
710 776 (!RegisterCount))
711 777 {
712 778 return_ACPI_STATUS (AE_BAD_PARAMETER);
713 779 }
714 780
715 781 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
716 782 if (ACPI_FAILURE (Status))
717 783 {
718 - return (Status);
784 + return_ACPI_STATUS (Status);
719 785 }
720 786
721 787 Node = AcpiNsValidateHandle (GpeDevice);
722 788 if (!Node)
723 789 {
724 790 Status = AE_BAD_PARAMETER;
725 791 goto UnlockAndExit;
726 792 }
727 793
728 794 /*
729 795 * For user-installed GPE Block Devices, the GpeBlockBaseNumber
730 796 * is always zero
731 797 */
732 798 Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount,
733 799 0, InterruptNumber, &GpeBlock);
734 800 if (ACPI_FAILURE (Status))
735 801 {
736 802 goto UnlockAndExit;
737 803 }
738 804
739 805 /* Install block in the DeviceObject attached to the node */
740 806
741 807 ObjDesc = AcpiNsGetAttachedObject (Node);
742 808 if (!ObjDesc)
743 809 {
744 810 /*
745 811 * No object, create a new one (Device nodes do not always have
746 812 * an attached object)
747 813 */
748 814 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE);
749 815 if (!ObjDesc)
750 816 {
751 817 Status = AE_NO_MEMORY;
752 818 goto UnlockAndExit;
753 819 }
754 820
755 821 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE);
756 822
757 823 /* Remove local reference to the object */
758 824
759 825 AcpiUtRemoveReference (ObjDesc);
760 826 if (ACPI_FAILURE (Status))
761 827 {
762 828 goto UnlockAndExit;
763 829 }
764 830 }
765 831
766 832 /* Now install the GPE block in the DeviceObject */
767 833
768 834 ObjDesc->Device.GpeBlock = GpeBlock;
769 835
770 836
771 837 UnlockAndExit:
772 838 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
773 839 return_ACPI_STATUS (Status);
774 840 }
775 841
776 842 ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock)
777 843
778 844
779 845 /*******************************************************************************
780 846 *
781 847 * FUNCTION: AcpiRemoveGpeBlock
782 848 *
783 849 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
784 850 *
785 851 * RETURN: Status
786 852 *
787 853 * DESCRIPTION: Remove a previously installed block of GPE registers
788 854 *
789 855 ******************************************************************************/
790 856
791 857 ACPI_STATUS
792 858 AcpiRemoveGpeBlock (
793 859 ACPI_HANDLE GpeDevice)
794 860 {
795 861 ACPI_OPERAND_OBJECT *ObjDesc;
796 862 ACPI_STATUS Status;
797 863 ACPI_NAMESPACE_NODE *Node;
798 864
799 865
800 866 ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock);
↓ open down ↓ |
72 lines elided |
↑ open up ↑ |
801 867
802 868
803 869 if (!GpeDevice)
804 870 {
805 871 return_ACPI_STATUS (AE_BAD_PARAMETER);
806 872 }
807 873
808 874 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
809 875 if (ACPI_FAILURE (Status))
810 876 {
811 - return (Status);
877 + return_ACPI_STATUS (Status);
812 878 }
813 879
814 880 Node = AcpiNsValidateHandle (GpeDevice);
815 881 if (!Node)
816 882 {
817 883 Status = AE_BAD_PARAMETER;
818 884 goto UnlockAndExit;
819 885 }
820 886
821 887 /* Get the DeviceObject attached to the node */
822 888
823 889 ObjDesc = AcpiNsGetAttachedObject (Node);
824 890 if (!ObjDesc ||
825 891 !ObjDesc->Device.GpeBlock)
826 892 {
827 893 return_ACPI_STATUS (AE_NULL_OBJECT);
828 894 }
829 895
830 896 /* Delete the GPE block (but not the DeviceObject) */
831 897
832 898 Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock);
833 899 if (ACPI_SUCCESS (Status))
834 900 {
835 901 ObjDesc->Device.GpeBlock = NULL;
836 902 }
837 903
838 904 UnlockAndExit:
839 905 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
840 906 return_ACPI_STATUS (Status);
841 907 }
842 908
843 909 ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock)
844 910
845 911
846 912 /*******************************************************************************
847 913 *
848 914 * FUNCTION: AcpiGetGpeDevice
849 915 *
850 916 * PARAMETERS: Index - System GPE index (0-CurrentGpeCount)
851 917 * GpeDevice - Where the parent GPE Device is returned
852 918 *
853 919 * RETURN: Status
854 920 *
855 921 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
856 922 * gpe device indicates that the gpe number is contained in one of
857 923 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
858 924 *
859 925 ******************************************************************************/
860 926
861 927 ACPI_STATUS
862 928 AcpiGetGpeDevice (
863 929 UINT32 Index,
864 930 ACPI_HANDLE *GpeDevice)
865 931 {
866 932 ACPI_GPE_DEVICE_INFO Info;
867 933 ACPI_STATUS Status;
868 934
869 935
870 936 ACPI_FUNCTION_TRACE (AcpiGetGpeDevice);
871 937
872 938
873 939 if (!GpeDevice)
874 940 {
875 941 return_ACPI_STATUS (AE_BAD_PARAMETER);
876 942 }
877 943
878 944 if (Index >= AcpiCurrentGpeCount)
879 945 {
880 946 return_ACPI_STATUS (AE_NOT_EXIST);
881 947 }
882 948
883 949 /* Setup and walk the GPE list */
884 950
885 951 Info.Index = Index;
886 952 Info.Status = AE_NOT_EXIST;
887 953 Info.GpeDevice = NULL;
888 954 Info.NextBlockBaseIndex = 0;
889 955
890 956 Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info);
↓ open down ↓ |
69 lines elided |
↑ open up ↑ |
891 957 if (ACPI_FAILURE (Status))
892 958 {
893 959 return_ACPI_STATUS (Status);
894 960 }
895 961
896 962 *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice);
897 963 return_ACPI_STATUS (Info.Status);
898 964 }
899 965
900 966 ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice)
967 +
968 +#endif /* !ACPI_REDUCED_HARDWARE */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX