ReactOS 0.4.16-dev-295-g4aee028
hwgpe.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acevents.h"
Include dependency graph for hwgpe.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_HARDWARE
 

Functions

static ACPI_STATUS AcpiHwEnableWakeupGpeBlock (ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
 
static ACPI_STATUS AcpiHwGpeEnableWrite (UINT8 EnableMask, ACPI_GPE_REGISTER_INFO *GpeRegisterInfo)
 
UINT32 AcpiHwGetGpeRegisterBit (ACPI_GPE_EVENT_INFO *GpeEventInfo)
 
ACPI_STATUS AcpiHwLowSetGpe (ACPI_GPE_EVENT_INFO *GpeEventInfo, UINT32 Action)
 
ACPI_STATUS AcpiHwClearGpe (ACPI_GPE_EVENT_INFO *GpeEventInfo)
 
ACPI_STATUS AcpiHwGetGpeStatus (ACPI_GPE_EVENT_INFO *GpeEventInfo, ACPI_EVENT_STATUS *EventStatus)
 
ACPI_STATUS AcpiHwDisableGpeBlock (ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
 
ACPI_STATUS AcpiHwClearGpeBlock (ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
 
ACPI_STATUS AcpiHwEnableRuntimeGpeBlock (ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
 
static ACPI_STATUS AcpiHwGetGpeBlockStatus (ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *RetPtr)
 
ACPI_STATUS AcpiHwDisableAllGpes (void)
 
ACPI_STATUS AcpiHwEnableAllRuntimeGpes (void)
 
ACPI_STATUS AcpiHwEnableAllWakeupGpes (void)
 
UINT8 AcpiHwCheckAllGpes (void)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_HARDWARE

Definition at line 48 of file hwgpe.c.

Function Documentation

◆ AcpiHwCheckAllGpes()

UINT8 AcpiHwCheckAllGpes ( void  )

Definition at line 677 of file hwgpe.c.

679{
680 UINT8 Ret = 0;
681
682
684
686 return (Ret != 0);
687}
unsigned char UINT8
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_STATUS AcpiEvWalkGpeList(ACPI_GPE_CALLBACK GpeWalkCallback, void *Context)
Definition: evgpeutil.c:67
static ACPI_STATUS AcpiHwGetGpeBlockStatus(ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *RetPtr)
Definition: hwgpe.c:544
UINT8 AcpiHwCheckAllGpes(void)
Definition: hwgpe.c:677

Referenced by AcpiAnyGpeStatusSet(), and AcpiHwCheckAllGpes().

◆ AcpiHwClearGpe()

ACPI_STATUS AcpiHwClearGpe ( ACPI_GPE_EVENT_INFO GpeEventInfo)

Definition at line 190 of file hwgpe.c.

192{
193 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
195 UINT32 RegisterBit;
196
197
199
200 /* Get the info block for the entire GPE register */
201
202 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
203 if (!GpeRegisterInfo)
204 {
205 return (AE_NOT_EXIST);
206 }
207
208 /*
209 * Write a one to the appropriate bit in the status register to
210 * clear this GPE.
211 */
213
214 Status = AcpiHwWrite (RegisterBit, &GpeRegisterInfo->StatusAddress);
215 return (Status);
216}
unsigned int UINT32
ACPI_GPE_EVENT_INFO * GpeEventInfo
Definition: acevents.h:195
#define AE_NOT_EXIST
Definition: acexcep.h:114
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
UINT32 ACPI_STATUS
Definition: actypes.h:460
Status
Definition: gdiplustypes.h:25
UINT32 AcpiHwGetGpeRegisterBit(ACPI_GPE_EVENT_INFO *GpeEventInfo)
Definition: hwgpe.c:81
ACPI_STATUS AcpiHwWrite(UINT64 Value, ACPI_GENERIC_ADDRESS *Reg)
Definition: hwregs.c:357
struct acpi_gpe_register_info * RegisterInfo
Definition: aclocal.h:555
ACPI_GENERIC_ADDRESS StatusAddress
Definition: aclocal.h:567

Referenced by AcpiClearGpe(), AcpiEvAddGpeReference(), AcpiEvFinishGpe(), and AcpiEvGpeDispatch().

◆ AcpiHwClearGpeBlock()

ACPI_STATUS AcpiHwClearGpeBlock ( ACPI_GPE_XRUPT_INFO GpeXruptInfo,
ACPI_GPE_BLOCK_INFO GpeBlock,
void Context 
)

Definition at line 404 of file hwgpe.c.

408{
409 UINT32 i;
411
412
413 /* Examine each GPE Register within the block */
414
415 for (i = 0; i < GpeBlock->RegisterCount; i++)
416 {
417 /* Clear status on all GPEs in this register */
418
419 Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress);
420 if (ACPI_FAILURE (Status))
421 {
422 return (Status);
423 }
424 }
425
426 return (AE_OK);
427}
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_OK
Definition: acexcep.h:97
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
UINT32 RegisterCount
Definition: aclocal.h:590
ACPI_GPE_REGISTER_INFO * RegisterInfo
Definition: aclocal.h:587

Referenced by AcpiHwClearAcpiStatus().

◆ AcpiHwDisableAllGpes()

ACPI_STATUS AcpiHwDisableAllGpes ( void  )

Definition at line 595 of file hwgpe.c.

597{
599
600
601 ACPI_FUNCTION_TRACE (HwDisableAllGpes);
602
603
606}
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define NULL
Definition: types.h:112
ACPI_STATUS AcpiHwDisableGpeBlock(ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
Definition: hwgpe.c:364

Referenced by AcpiDisableAllGpes(), AcpiEnterSleepStateS4bios(), AcpiHwLegacySleep(), and AcpiHwLegacyWake().

◆ AcpiHwDisableGpeBlock()

ACPI_STATUS AcpiHwDisableGpeBlock ( ACPI_GPE_XRUPT_INFO GpeXruptInfo,
ACPI_GPE_BLOCK_INFO GpeBlock,
void Context 
)

Definition at line 364 of file hwgpe.c.

368{
369 UINT32 i;
371
372
373 /* Examine each GPE Register within the block */
374
375 for (i = 0; i < GpeBlock->RegisterCount; i++)
376 {
377 /* Disable all GPEs in this register */
378
379 Status = AcpiHwGpeEnableWrite (0x00, &GpeBlock->RegisterInfo[i]);
380 if (ACPI_FAILURE (Status))
381 {
382 return (Status);
383 }
384 }
385
386 return (AE_OK);
387}
static ACPI_STATUS AcpiHwGpeEnableWrite(UINT8 EnableMask, ACPI_GPE_REGISTER_INFO *GpeRegisterInfo)
Definition: hwgpe.c:336

Referenced by AcpiEvDeleteGpeBlock(), AcpiEvTerminate(), and AcpiHwDisableAllGpes().

◆ AcpiHwEnableAllRuntimeGpes()

ACPI_STATUS AcpiHwEnableAllRuntimeGpes ( void  )

Definition at line 622 of file hwgpe.c.

624{
626
627
628 ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes);
629
630
633}
ACPI_STATUS AcpiHwEnableRuntimeGpeBlock(ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
Definition: hwgpe.c:445

Referenced by AcpiEnableAllRuntimeGpes(), and AcpiHwLegacyWake().

◆ AcpiHwEnableAllWakeupGpes()

ACPI_STATUS AcpiHwEnableAllWakeupGpes ( void  )

Definition at line 649 of file hwgpe.c.

651{
653
654
655 ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes);
656
657
660}
static ACPI_STATUS AcpiHwEnableWakeupGpeBlock(ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
Definition: hwgpe.c:498

Referenced by AcpiEnableAllWakeupGpes(), AcpiEnterSleepStateS4bios(), and AcpiHwLegacySleep().

◆ AcpiHwEnableRuntimeGpeBlock()

ACPI_STATUS AcpiHwEnableRuntimeGpeBlock ( ACPI_GPE_XRUPT_INFO GpeXruptInfo,
ACPI_GPE_BLOCK_INFO GpeBlock,
void Context 
)

Definition at line 445 of file hwgpe.c.

449{
450 UINT32 i;
452 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
453 UINT8 EnableMask;
454
455
456 /* NOTE: assumes that all GPEs are currently disabled */
457
458 /* Examine each GPE Register within the block */
459
460 for (i = 0; i < GpeBlock->RegisterCount; i++)
461 {
462 GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
463 if (!GpeRegisterInfo->EnableForRun)
464 {
465 continue;
466 }
467
468 /* Enable all "runtime" GPEs in this register */
469
470 EnableMask = GpeRegisterInfo->EnableForRun &
471 ~GpeRegisterInfo->MaskForRun;
472 Status = AcpiHwGpeEnableWrite (EnableMask, GpeRegisterInfo);
473 if (ACPI_FAILURE (Status))
474 {
475 return (Status);
476 }
477 }
478
479 return (AE_OK);
480}

Referenced by AcpiHwEnableAllRuntimeGpes().

◆ AcpiHwEnableWakeupGpeBlock()

static ACPI_STATUS AcpiHwEnableWakeupGpeBlock ( ACPI_GPE_XRUPT_INFO GpeXruptInfo,
ACPI_GPE_BLOCK_INFO GpeBlock,
void Context 
)
static

Definition at line 498 of file hwgpe.c.

502{
503 UINT32 i;
505 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
506
507
508 /* Examine each GPE Register within the block */
509
510 for (i = 0; i < GpeBlock->RegisterCount; i++)
511 {
512 GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
513
514 /*
515 * Enable all "wake" GPEs in this register and disable the
516 * remaining ones.
517 */
518 Status = AcpiHwGpeEnableWrite (GpeRegisterInfo->EnableForWake,
519 GpeRegisterInfo);
520 if (ACPI_FAILURE (Status))
521 {
522 return (Status);
523 }
524 }
525
526 return (AE_OK);
527}

Referenced by AcpiHwEnableAllWakeupGpes().

◆ AcpiHwGetGpeBlockStatus()

static ACPI_STATUS AcpiHwGetGpeBlockStatus ( ACPI_GPE_XRUPT_INFO GpeXruptInfo,
ACPI_GPE_BLOCK_INFO GpeBlock,
void RetPtr 
)
static

Definition at line 544 of file hwgpe.c.

548{
549 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
550 UINT64 InEnable;
551 UINT64 InStatus;
553 UINT8 *Ret = RetPtr;
554 UINT32 i;
555
556
557 /* Examine each GPE Register within the block */
558
559 for (i = 0; i < GpeBlock->RegisterCount; i++)
560 {
561 GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
562
563 Status = AcpiHwRead (&InEnable, &GpeRegisterInfo->EnableAddress);
564 if (ACPI_FAILURE (Status))
565 {
566 continue;
567 }
568
569 Status = AcpiHwRead (&InStatus, &GpeRegisterInfo->StatusAddress);
570 if (ACPI_FAILURE (Status))
571 {
572 continue;
573 }
574
575 *Ret |= InEnable & InStatus;
576 }
577
578 return (AE_OK);
579}
unsigned long long UINT64
ACPI_STATUS AcpiHwRead(UINT64 *Value, ACPI_GENERIC_ADDRESS *Reg)
Definition: hwregs.c:259
ACPI_GENERIC_ADDRESS EnableAddress
Definition: aclocal.h:568

Referenced by AcpiHwCheckAllGpes().

◆ AcpiHwGetGpeRegisterBit()

UINT32 AcpiHwGetGpeRegisterBit ( ACPI_GPE_EVENT_INFO GpeEventInfo)

◆ AcpiHwGetGpeStatus()

ACPI_STATUS AcpiHwGetGpeStatus ( ACPI_GPE_EVENT_INFO GpeEventInfo,
ACPI_EVENT_STATUS EventStatus 
)

Definition at line 233 of file hwgpe.c.

236{
237 UINT64 InByte;
238 UINT32 RegisterBit;
239 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
240 ACPI_EVENT_STATUS LocalEventStatus = 0;
242
243
245
246
247 if (!EventStatus)
248 {
249 return (AE_BAD_PARAMETER);
250 }
251
252 /* GPE currently handled? */
253
256 {
257 LocalEventStatus |= ACPI_EVENT_FLAG_HAS_HANDLER;
258 }
259
260 /* Get the info block for the entire GPE register */
261
262 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
263
264 /* Get the register bitmask for this GPE */
265
267
268 /* GPE currently enabled? (enabled for runtime?) */
269
270 if (RegisterBit & GpeRegisterInfo->EnableForRun)
271 {
272 LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
273 }
274
275 /* GPE currently masked? (masked for runtime?) */
276
277 if (RegisterBit & GpeRegisterInfo->MaskForRun)
278 {
279 LocalEventStatus |= ACPI_EVENT_FLAG_MASKED;
280 }
281
282 /* GPE enabled for wake? */
283
284 if (RegisterBit & GpeRegisterInfo->EnableForWake)
285 {
286 LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
287 }
288
289 /* GPE currently enabled (enable bit == 1)? */
290
291 Status = AcpiHwRead (&InByte, &GpeRegisterInfo->EnableAddress);
292 if (ACPI_FAILURE (Status))
293 {
294 return (Status);
295 }
296
297 if (RegisterBit & InByte)
298 {
299 LocalEventStatus |= ACPI_EVENT_FLAG_ENABLE_SET;
300 }
301
302 /* GPE currently active (status bit == 1)? */
303
304 Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress);
305 if (ACPI_FAILURE (Status))
306 {
307 return (Status);
308 }
309
310 if (RegisterBit & InByte)
311 {
312 LocalEventStatus |= ACPI_EVENT_FLAG_STATUS_SET;
313 }
314
315 /* Set return value */
316
317 (*EventStatus) = LocalEventStatus;
318 return (AE_OK);
319}
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define ACPI_EVENT_FLAG_ENABLED
Definition: actypes.h:793
#define ACPI_EVENT_FLAG_MASKED
Definition: actypes.h:798
#define ACPI_GPE_DISPATCH_NONE
Definition: actypes.h:819
#define ACPI_GPE_DISPATCH_TYPE(flags)
Definition: actypes.h:825
#define ACPI_EVENT_FLAG_HAS_HANDLER
Definition: actypes.h:797
#define ACPI_EVENT_FLAG_STATUS_SET
Definition: actypes.h:795
UINT32 ACPI_EVENT_STATUS
Definition: actypes.h:790
#define ACPI_EVENT_FLAG_ENABLE_SET
Definition: actypes.h:796
#define ACPI_EVENT_FLAG_WAKE_ENABLED
Definition: actypes.h:794

Referenced by AcpiGetGpeStatus().

◆ AcpiHwGpeEnableWrite()

static ACPI_STATUS AcpiHwGpeEnableWrite ( UINT8  EnableMask,
ACPI_GPE_REGISTER_INFO GpeRegisterInfo 
)
static

Definition at line 336 of file hwgpe.c.

339{
341
342
343 GpeRegisterInfo->EnableMask = EnableMask;
344
345 Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
346 return (Status);
347}

Referenced by AcpiHwDisableGpeBlock(), AcpiHwEnableRuntimeGpeBlock(), and AcpiHwEnableWakeupGpeBlock().

◆ AcpiHwLowSetGpe()

ACPI_STATUS AcpiHwLowSetGpe ( ACPI_GPE_EVENT_INFO GpeEventInfo,
UINT32  Action 
)

Definition at line 106 of file hwgpe.c.

109{
110 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
112 UINT64 EnableMask;
113 UINT32 RegisterBit;
114
115
117
118
119 /* Get the info block for the entire GPE register */
120
121 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
122 if (!GpeRegisterInfo)
123 {
124 return (AE_NOT_EXIST);
125 }
126
127 /* Get current value of the enable register that contains this GPE */
128
129 Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress);
130 if (ACPI_FAILURE (Status))
131 {
132 return (Status);
133 }
134
135 /* Set or clear just the bit that corresponds to this GPE */
136
138 switch (Action)
139 {
141
142 /* Only enable if the corresponding EnableMask bit is set */
143
144 if (!(RegisterBit & GpeRegisterInfo->EnableMask))
145 {
146 return (AE_BAD_PARAMETER);
147 }
148
150
151 case ACPI_GPE_ENABLE:
152
153 ACPI_SET_BIT (EnableMask, RegisterBit);
154 break;
155
156 case ACPI_GPE_DISABLE:
157
158 ACPI_CLEAR_BIT (EnableMask, RegisterBit);
159 break;
160
161 default:
162
163 ACPI_ERROR ((AE_INFO, "Invalid GPE Action, %u", Action));
164 return (AE_BAD_PARAMETER);
165 }
166
167 if (!(RegisterBit & GpeRegisterInfo->MaskForRun))
168 {
169 /* Write the updated enable mask */
170
171 Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
172 }
173 return (Status);
174}
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_GPE_ENABLE
Definition: actypes.h:803
#define ACPI_GPE_CONDITIONAL_ENABLE
Definition: actypes.h:805
#define ACPI_SET_BIT(target, bit)
Definition: actypes.h:533
#define ACPI_GPE_DISABLE
Definition: actypes.h:804
#define ACPI_CLEAR_BIT(target, bit)
Definition: actypes.h:534
#define ACPI_FALLTHROUGH
Definition: actypes.h:1466
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510

Referenced by AcpiEvEnableGpe(), AcpiEvFinishGpe(), AcpiEvGpeDispatch(), AcpiEvMaskGpe(), AcpiEvMatchGpeMethod(), AcpiEvRemoveGpeReference(), and AcpiSetGpe().