ReactOS 0.4.16-dev-106-g10b08aa
achware.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ACPI_SST_INDICATOR_OFF   0
 
#define ACPI_SST_WORKING   1
 
#define ACPI_SST_WAKING   2
 
#define ACPI_SST_SLEEPING   3
 
#define ACPI_SST_SLEEP_CONTEXT   4
 

Functions

ACPI_STATUS AcpiHwSetMode (UINT32 Mode)
 
UINT32 AcpiHwGetMode (void)
 
ACPI_STATUS AcpiHwValidateRegister (ACPI_GENERIC_ADDRESS *Reg, UINT8 MaxBitWidth, UINT64 *Address)
 
ACPI_STATUS AcpiHwRead (UINT64 *Value, ACPI_GENERIC_ADDRESS *Reg)
 
ACPI_STATUS AcpiHwWrite (UINT64 Value, ACPI_GENERIC_ADDRESS *Reg)
 
ACPI_BIT_REGISTER_INFOAcpiHwGetBitRegisterInfo (UINT32 RegisterId)
 
ACPI_STATUS AcpiHwWritePm1Control (UINT32 Pm1aControl, UINT32 Pm1bControl)
 
ACPI_STATUS AcpiHwRegisterRead (UINT32 RegisterId, UINT32 *ReturnValue)
 
ACPI_STATUS AcpiHwRegisterWrite (UINT32 RegisterId, UINT32 Value)
 
ACPI_STATUS AcpiHwClearAcpiStatus (void)
 
ACPI_STATUS AcpiHwLegacySleep (UINT8 SleepState)
 
ACPI_STATUS AcpiHwLegacyWakePrep (UINT8 SleepState)
 
ACPI_STATUS AcpiHwLegacyWake (UINT8 SleepState)
 
void AcpiHwExecuteSleepMethod (char *MethodName, UINT32 IntegerArgument)
 
ACPI_STATUS AcpiHwExtendedSleep (UINT8 SleepState)
 
ACPI_STATUS AcpiHwExtendedWakePrep (UINT8 SleepState)
 
ACPI_STATUS AcpiHwExtendedWake (UINT8 SleepState)
 
ACPI_STATUS AcpiHwReadPort (ACPI_IO_ADDRESS Address, UINT32 *Value, UINT32 Width)
 
ACPI_STATUS AcpiHwWritePort (ACPI_IO_ADDRESS Address, UINT32 Value, UINT32 Width)
 
UINT32 AcpiHwGetGpeRegisterBit (ACPI_GPE_EVENT_INFO *GpeEventInfo)
 
ACPI_STATUS AcpiHwLowSetGpe (ACPI_GPE_EVENT_INFO *GpeEventInfo, UINT32 Action)
 
ACPI_STATUS AcpiHwDisableGpeBlock (ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
 
ACPI_STATUS AcpiHwClearGpe (ACPI_GPE_EVENT_INFO *GpeEventInfo)
 
ACPI_STATUS AcpiHwClearGpeBlock (ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
 
ACPI_STATUS AcpiHwGetGpeStatus (ACPI_GPE_EVENT_INFO *GpeEventInfo, ACPI_EVENT_STATUS *EventStatus)
 
ACPI_STATUS AcpiHwDisableAllGpes (void)
 
ACPI_STATUS AcpiHwEnableAllRuntimeGpes (void)
 
ACPI_STATUS AcpiHwEnableAllWakeupGpes (void)
 
UINT8 AcpiHwCheckAllGpes (void)
 
ACPI_STATUS AcpiHwEnableRuntimeGpeBlock (ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
 
ACPI_STATUS AcpiHwDerivePciId (ACPI_PCI_ID *PciId, ACPI_HANDLE RootPciDevice, ACPI_HANDLE PciRegion)
 

Macro Definition Documentation

◆ ACPI_SST_INDICATOR_OFF

#define ACPI_SST_INDICATOR_OFF   0

Definition at line 50 of file achware.h.

◆ ACPI_SST_SLEEP_CONTEXT

#define ACPI_SST_SLEEP_CONTEXT   4

Definition at line 54 of file achware.h.

◆ ACPI_SST_SLEEPING

#define ACPI_SST_SLEEPING   3

Definition at line 53 of file achware.h.

◆ ACPI_SST_WAKING

#define ACPI_SST_WAKING   2

Definition at line 52 of file achware.h.

◆ ACPI_SST_WORKING

#define ACPI_SST_WORKING   1

Definition at line 51 of file achware.h.

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().

◆ AcpiHwClearAcpiStatus()

ACPI_STATUS AcpiHwClearAcpiStatus ( void  )

Definition at line 452 of file hwregs.c.

454{
456 ACPI_CPU_FLAGS LockFlags = 0;
457
458
459 ACPI_FUNCTION_TRACE (HwClearAcpiStatus);
460
461
462 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n",
464 ACPI_FORMAT_UINT64 (AcpiGbl_XPm1aStatus.Address)));
465
466 LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock);
467
468 /* Clear the fixed events in PM1 A/B */
469
472
473 AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags);
474
475 if (ACPI_FAILURE (Status))
476 {
477 goto Exit;
478 }
479
480 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
481
483
484Exit:
486}
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define ACPI_BITMASK_ALL_FIXED_STATUS
Definition: aclocal.h:1204
#define ACPI_REGISTER_PM1_STATUS
Definition: aclocal.h:1184
#define ACPI_FORMAT_UINT64(i)
Definition: acmacros.h:71
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_DB_IO
Definition: acoutput.h:177
void AcpiOsReleaseLock(ACPI_SPINLOCK Handle, ACPI_CPU_FLAGS Flags)
Definition: osl.c:516
ACPI_CPU_FLAGS AcpiOsAcquireLock(ACPI_SPINLOCK Handle)
Definition: osl.c:498
#define ACPI_CPU_FLAGS
Definition: actypes.h:252
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define NULL
Definition: types.h:112
Status
Definition: gdiplustypes.h:25
ACPI_STATUS AcpiHwClearGpeBlock(ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
Definition: hwgpe.c:404
ACPI_STATUS AcpiHwRegisterWrite(UINT32 RegisterId, UINT32 Value)
Definition: hwregs.c:684
static void Exit(void)
Definition: sock.c:1330

Referenced by AcpiEnterSleepStateS4bios(), and AcpiHwLegacySleep().

◆ 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 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 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().

◆ AcpiHwDerivePciId()

ACPI_STATUS AcpiHwDerivePciId ( ACPI_PCI_ID PciId,
ACPI_HANDLE  RootPciDevice,
ACPI_HANDLE  PciRegion 
)

Definition at line 137 of file hwpci.c.

141{
143 ACPI_PCI_DEVICE *ListHead;
144
145
146 ACPI_FUNCTION_TRACE (HwDerivePciId);
147
148
149 if (!PciId)
150 {
152 }
153
154 /* Build a list of PCI devices, from PciRegion up to RootPciDevice */
155
156 Status = AcpiHwBuildPciList (RootPciDevice, PciRegion, &ListHead);
157 if (ACPI_SUCCESS (Status))
158 {
159 /* Walk the list, updating the PCI device/function/bus numbers */
160
161 Status = AcpiHwProcessPciList (PciId, ListHead);
162
163 /* Delete the list */
164
165 AcpiHwDeletePciList (ListHead);
166 }
167
169}
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
static ACPI_STATUS AcpiHwProcessPciList(ACPI_PCI_ID *PciId, ACPI_PCI_DEVICE *ListHead)
Definition: hwpci.c:266
static void AcpiHwDeletePciList(ACPI_PCI_DEVICE *ListHead)
Definition: hwpci.c:329
static ACPI_STATUS AcpiHwBuildPciList(ACPI_HANDLE RootPciDevice, ACPI_HANDLE PciRegion, ACPI_PCI_DEVICE **ReturnListHead)
Definition: hwpci.c:192

Referenced by AcpiEvPciConfigRegionSetup().

◆ AcpiHwDisableAllGpes()

ACPI_STATUS AcpiHwDisableAllGpes ( void  )

Definition at line 595 of file hwgpe.c.

597{
599
600
601 ACPI_FUNCTION_TRACE (HwDisableAllGpes);
602
603
606}
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().

◆ AcpiHwExecuteSleepMethod()

void AcpiHwExecuteSleepMethod ( char MethodName,
UINT32  IntegerArgument 
)

Definition at line 67 of file hwesleep.c.

70{
71 ACPI_OBJECT_LIST ArgList;
72 ACPI_OBJECT Arg;
74
75
76 ACPI_FUNCTION_TRACE (HwExecuteSleepMethod);
77
78
79 /* One argument, IntegerArgument; No return value expected */
80
81 ArgList.Count = 1;
82 ArgList.Pointer = &Arg;
84 Arg.Integer.Value = (UINT64) IntegerArgument;
85
86 Status = AcpiEvaluateObject (NULL, MethodPathname, &ArgList, NULL);
88 {
89 ACPI_EXCEPTION ((AE_INFO, Status, "While executing method %s",
90 MethodPathname));
91 }
92
94}
unsigned long long UINT64
#define AE_NOT_FOUND
Definition: acexcep.h:113
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
#define AE_INFO
Definition: acoutput.h:230
#define return_VOID
Definition: acoutput.h:495
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
ACPI_STATUS AcpiEvaluateObject(ACPI_HANDLE Handle, ACPI_STRING Pathname, ACPI_OBJECT_LIST *ExternalParams, ACPI_BUFFER *ReturnBuffer)
Definition: nsxfeval.c:217
ACPI_OBJECT * Pointer
Definition: actypes.h:1029
ACPI_OBJECT_TYPE Type
Definition: actypes.h:970
struct acpi_object::@617 Integer

Referenced by AcpiEnterSleepStatePrep(), AcpiHwExtendedWake(), and AcpiHwLegacyWake().

◆ AcpiHwExtendedSleep()

ACPI_STATUS AcpiHwExtendedSleep ( UINT8  SleepState)

Definition at line 112 of file hwesleep.c.

114{
116 UINT8 SleepControl;
117 UINT64 SleepStatus;
118
119
120 ACPI_FUNCTION_TRACE (HwExtendedSleep);
121
122
123 /* Extended sleep registers must be valid */
124
125 if (!AcpiGbl_FADT.SleepControl.Address ||
126 !AcpiGbl_FADT.SleepStatus.Address)
127 {
129 }
130
131 /* Clear wake status (WAK_STS) */
132
134 &AcpiGbl_FADT.SleepStatus);
135 if (ACPI_FAILURE (Status))
136 {
138 }
139
140 AcpiGbl_SystemAwakeAndRunning = FALSE;
141
142 /*
143 * Set the SLP_TYP and SLP_EN bits.
144 *
145 * Note: We only use the first value returned by the \_Sx method
146 * (AcpiGbl_SleepTypeA) - As per ACPI specification.
147 */
149 "Entering sleep state [S%u]\n", SleepState));
150
151 SleepControl = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) &
153
154 /* Flush caches, as per ACPI specification */
155
156 if (SleepState < ACPI_STATE_S4)
157 {
159 }
160
161 Status = AcpiOsEnterSleep (SleepState, SleepControl, 0);
163 {
165 }
166 if (ACPI_FAILURE (Status))
167 {
169 }
170
171 Status = AcpiWrite ((UINT64) SleepControl, &AcpiGbl_FADT.SleepControl);
172 if (ACPI_FAILURE (Status))
173 {
175 }
176
177 /* Wait for transition back to Working State */
178
179 do
180 {
181 Status = AcpiRead (&SleepStatus, &AcpiGbl_FADT.SleepStatus);
182 if (ACPI_FAILURE (Status))
183 {
185 }
186
187 } while (!(((UINT8) SleepStatus) & ACPI_X_WAKE_STATUS));
188
190}
#define ACPI_FLUSH_CPU_CACHE()
Definition: accygwin.h:53
#define AE_CTRL_TERMINATE
Definition: acexcep.h:226
#define ACPI_DB_INIT
Definition: acoutput.h:151
ACPI_STATUS AcpiOsEnterSleep(UINT8 SleepState, UINT32 RegaValue, UINT32 RegbValue)
Definition: osl.c:932
#define ACPI_X_SLEEP_TYPE_MASK
Definition: actbl.h:378
#define ACPI_X_SLEEP_TYPE_POSITION
Definition: actbl.h:379
#define ACPI_X_WAKE_STATUS
Definition: actbl.h:377
#define ACPI_X_SLEEP_ENABLE
Definition: actbl.h:380
#define ACPI_STATE_S4
Definition: actypes.h:628
#define FALSE
Definition: types.h:117
ACPI_STATUS AcpiRead(UINT64 *ReturnValue, ACPI_GENERIC_ADDRESS *Reg)
Definition: hwxface.c:138
ACPI_STATUS AcpiWrite(UINT64 Value, ACPI_GENERIC_ADDRESS *Reg)
Definition: hwxface.c:169

◆ AcpiHwExtendedWake()

ACPI_STATUS AcpiHwExtendedWake ( UINT8  SleepState)

Definition at line 243 of file hwesleep.c.

245{
246 ACPI_FUNCTION_TRACE (HwExtendedWake);
247
248
249 /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */
250
251 AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID;
252
253 /* Execute the wake methods */
254
257
258 /*
259 * Some BIOS code assumes that WAK_STS will be cleared on resume
260 * and use it to determine whether the system is rebooting or
261 * resuming. Clear WAK_STS for compatibility.
262 */
263 (void) AcpiWrite ((UINT64) ACPI_X_WAKE_STATUS, &AcpiGbl_FADT.SleepStatus);
264 AcpiGbl_SystemAwakeAndRunning = TRUE;
265
268}
#define ACPI_SST_WORKING
Definition: achware.h:51
#define ACPI_SST_WAKING
Definition: achware.h:52
#define METHOD_PATHNAME__SST
Definition: acnames.h:81
#define METHOD_PATHNAME__WAK
Definition: acnames.h:82
#define ACPI_SLEEP_TYPE_INVALID
Definition: actypes.h:651
#define TRUE
Definition: types.h:120
void AcpiHwExecuteSleepMethod(char *MethodPathname, UINT32 IntegerArgument)
Definition: hwesleep.c:67

◆ AcpiHwExtendedWakePrep()

ACPI_STATUS AcpiHwExtendedWakePrep ( UINT8  SleepState)

Definition at line 207 of file hwesleep.c.

209{
210 UINT8 SleepTypeValue;
211
212
213 ACPI_FUNCTION_TRACE (HwExtendedWakePrep);
214
215
216 if (AcpiGbl_SleepTypeAS0 != ACPI_SLEEP_TYPE_INVALID)
217 {
218 SleepTypeValue = ((AcpiGbl_SleepTypeAS0 << ACPI_X_SLEEP_TYPE_POSITION) &
220
221 (void) AcpiWrite ((UINT64) (SleepTypeValue | ACPI_X_SLEEP_ENABLE),
222 &AcpiGbl_FADT.SleepControl);
223 }
224
226}

◆ AcpiHwGetBitRegisterInfo()

ACPI_BIT_REGISTER_INFO * AcpiHwGetBitRegisterInfo ( UINT32  RegisterId)

Definition at line 502 of file hwregs.c.

504{
506
507
508 if (RegisterId > ACPI_BITREG_MAX)
509 {
510 ACPI_ERROR ((AE_INFO, "Invalid BitRegister ID: 0x%X", RegisterId));
511 return (NULL);
512 }
513
514 return (&AcpiGbl_BitRegisterInfo[RegisterId]);
515}
ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG]
Definition: utglobal.c:145
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define ACPI_BITREG_MAX
Definition: actypes.h:933

Referenced by AcpiHwLegacySleep(), AcpiHwLegacyWakePrep(), AcpiReadBitRegister(), and AcpiWriteBitRegister().

◆ 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 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
ACPI_STATUS AcpiHwRead(UINT64 *Value, ACPI_GENERIC_ADDRESS *Reg)
Definition: hwregs.c:259
ACPI_GENERIC_ADDRESS EnableAddress
Definition: aclocal.h:568

Referenced by AcpiGetGpeStatus().

◆ AcpiHwGetMode()

UINT32 AcpiHwGetMode ( void  )

Definition at line 179 of file hwacpi.c.

181{
184
185
186 ACPI_FUNCTION_TRACE (HwGetMode);
187
188
189 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
190
191 if (AcpiGbl_ReducedHardware)
192 {
194 }
195
196 /*
197 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
198 * system does not support mode transition.
199 */
200 if (!AcpiGbl_FADT.SmiCommand)
201 {
203 }
204
206 if (ACPI_FAILURE (Status))
207 {
209 }
210
211 if (Value)
212 {
214 }
215 else
216 {
218 }
219}
#define return_UINT32(s)
Definition: acoutput.h:501
#define ACPI_BITREG_SCI_ENABLE
Definition: actypes.h:923
#define ACPI_SYS_MODE_ACPI
Definition: actypes.h:1084
#define ACPI_SYS_MODE_LEGACY
Definition: actypes.h:1085
ACPI_STATUS AcpiReadBitRegister(UINT32 RegisterId, UINT32 *ReturnValue)
Definition: hwxface.c:213
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by AcpiDisable(), AcpiEnable(), AcpiEnableSubsystem(), and AcpiHwSetMode().

◆ AcpiHwLegacySleep()

ACPI_STATUS AcpiHwLegacySleep ( UINT8  SleepState)

Definition at line 67 of file hwsleep.c.

69{
70 ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo;
71 ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo;
72 UINT32 Pm1aControl;
73 UINT32 Pm1bControl;
74 UINT32 InValue;
76
77
78 ACPI_FUNCTION_TRACE (HwLegacySleep);
79
80
83
84 /* Clear wake status */
85
88 if (ACPI_FAILURE (Status))
89 {
91 }
92
93 /* Disable all GPEs */
94
96 if (ACPI_FAILURE (Status))
97 {
99 }
101 if (ACPI_FAILURE(Status))
102 {
104 }
105 AcpiGbl_SystemAwakeAndRunning = FALSE;
106
107 /* Enable all wakeup GPEs */
108
110 if (ACPI_FAILURE (Status))
111 {
113 }
114
115 /* Get current value of PM1A control */
116
118 &Pm1aControl);
119 if (ACPI_FAILURE (Status))
120 {
122 }
124 "Entering sleep state [S%u]\n", SleepState));
125
126 /* Clear the SLP_EN and SLP_TYP fields */
127
128 Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask |
129 SleepEnableRegInfo->AccessBitMask);
130 Pm1bControl = Pm1aControl;
131
132 /* Insert the SLP_TYP bits */
133
134 Pm1aControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition);
135 Pm1bControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition);
136
137 /*
138 * We split the writes of SLP_TYP and SLP_EN to workaround
139 * poorly implemented hardware.
140 */
141
142 /* Write #1: write the SLP_TYP data to the PM1 Control registers */
143
144 Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl);
145 if (ACPI_FAILURE (Status))
146 {
148 }
149
150 /* Insert the sleep enable (SLP_EN) bit */
151
152 Pm1aControl |= SleepEnableRegInfo->AccessBitMask;
153 Pm1bControl |= SleepEnableRegInfo->AccessBitMask;
154
155 /* Flush caches, as per ACPI specification */
156
157 if (SleepState < ACPI_STATE_S4)
158 {
160 }
161
162 Status = AcpiOsEnterSleep (SleepState, Pm1aControl, Pm1bControl);
164 {
166 }
167 if (ACPI_FAILURE (Status))
168 {
170 }
171
172 /* Write #2: Write both SLP_TYP + SLP_EN */
173
174 Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl);
175 if (ACPI_FAILURE (Status))
176 {
178 }
179
180 if (SleepState > ACPI_STATE_S3)
181 {
182 /*
183 * We wanted to sleep > S3, but it didn't happen (by virtue of the
184 * fact that we are still executing!)
185 *
186 * Wait ten seconds, then try again. This is to get S4/S5 to work on
187 * all machines.
188 *
189 * We wait so long to allow chipsets that poll this reg very slowly
190 * to still read the right value. Ideally, this block would go
191 * away entirely.
192 */
194
196 SleepEnableRegInfo->AccessBitMask);
197 if (ACPI_FAILURE (Status))
198 {
200 }
201 }
202
203 /* Wait for transition back to Working State */
204
205 do
206 {
208 if (ACPI_FAILURE (Status))
209 {
211 }
212
213 } while (!InValue);
214
216}
#define ACPI_REGISTER_PM1_CONTROL
Definition: aclocal.h:1186
void AcpiOsStall(UINT32 Microseconds)
Definition: osl.c:264
#define ACPI_CLEAR_STATUS
Definition: actypes.h:939
#define ACPI_USEC_PER_SEC
Definition: actypes.h:471
#define ACPI_BITREG_SLEEP_ENABLE
Definition: actypes.h:927
#define ACPI_BITREG_SLEEP_TYPE
Definition: actypes.h:926
#define ACPI_BITREG_WAKE_STATUS
Definition: actypes.h:909
#define ACPI_STATE_S3
Definition: actypes.h:627
ACPI_STATUS AcpiHwEnableAllWakeupGpes(void)
Definition: hwgpe.c:649
ACPI_STATUS AcpiHwDisableAllGpes(void)
Definition: hwgpe.c:595
ACPI_STATUS AcpiHwWritePm1Control(UINT32 Pm1aControl, UINT32 Pm1bControl)
Definition: hwregs.c:536
ACPI_STATUS AcpiHwClearAcpiStatus(void)
Definition: hwregs.c:452
ACPI_STATUS AcpiHwRegisterRead(UINT32 RegisterId, UINT32 *ReturnValue)
Definition: hwregs.c:574
ACPI_BIT_REGISTER_INFO * AcpiHwGetBitRegisterInfo(UINT32 RegisterId)
Definition: hwregs.c:502
ACPI_STATUS AcpiWriteBitRegister(UINT32 RegisterId, UINT32 Value)
Definition: hwxface.c:282

◆ AcpiHwLegacyWake()

ACPI_STATUS AcpiHwLegacyWake ( UINT8  SleepState)

Definition at line 301 of file hwsleep.c.

303{
305
306
307 ACPI_FUNCTION_TRACE (HwLegacyWake);
308
309
310 /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */
311
312 AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID;
314
315 /*
316 * GPEs must be enabled before _WAK is called as GPEs
317 * might get fired there
318 *
319 * Restore the GPEs:
320 * 1) Disable all GPEs
321 * 2) Enable all runtime GPEs
322 */
324 if (ACPI_FAILURE (Status))
325 {
327 }
328
330 if (ACPI_FAILURE (Status))
331 {
333 }
334
335 /*
336 * Now we can execute _WAK, etc. Some machines require that the GPEs
337 * are enabled before the wake methods are executed.
338 */
340
341 /*
342 * Some BIOS code assumes that WAK_STS will be cleared on resume
343 * and use it to determine whether the system is rebooting or
344 * resuming. Clear WAK_STS for compatibility.
345 */
348 AcpiGbl_SystemAwakeAndRunning = TRUE;
349
350 /* Enable power button */
351
355
359
360 /* Enable sleep button */
361
365
369
370 /* Enable pcie wake event if support */
371 if ((AcpiGbl_FADT.Flags & ACPI_FADT_PCI_EXPRESS_WAKE)) {
378 }
379
382}
ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS]
Definition: utglobal.c:175
#define ACPI_FADT_PCI_EXPRESS_WAKE
Definition: actbl.h:350
#define ACPI_EVENT_POWER_BUTTON
Definition: actypes.h:765
#define ACPI_DISABLE_EVENT
Definition: actypes.h:944
#define ACPI_EVENT_PCIE_WAKE
Definition: actypes.h:768
#define ACPI_ENABLE_EVENT
Definition: actypes.h:943
#define ACPI_EVENT_SLEEP_BUTTON
Definition: actypes.h:766
ACPI_STATUS AcpiHwEnableAllRuntimeGpes(void)
Definition: hwgpe.c:622

◆ AcpiHwLegacyWakePrep()

ACPI_STATUS AcpiHwLegacyWakePrep ( UINT8  SleepState)

Definition at line 234 of file hwsleep.c.

236{
238 ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo;
239 ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo;
240 UINT32 Pm1aControl;
241 UINT32 Pm1bControl;
242
243
244 ACPI_FUNCTION_TRACE (HwLegacyWakePrep);
245
246 /*
247 * Set SLP_TYPE and SLP_EN to state S0.
248 * This is unclear from the ACPI Spec, but it is required
249 * by some machines.
250 */
251 if (AcpiGbl_SleepTypeAS0 != ACPI_SLEEP_TYPE_INVALID)
252 {
253 SleepTypeRegInfo =
255 SleepEnableRegInfo =
257
258 /* Get current value of PM1A control */
259
261 &Pm1aControl);
262 if (ACPI_SUCCESS (Status))
263 {
264 /* Clear the SLP_EN and SLP_TYP fields */
265
266 Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask |
267 SleepEnableRegInfo->AccessBitMask);
268 Pm1bControl = Pm1aControl;
269
270 /* Insert the SLP_TYP bits */
271
272 Pm1aControl |= (AcpiGbl_SleepTypeAS0 <<
273 SleepTypeRegInfo->BitPosition);
274 Pm1bControl |= (AcpiGbl_SleepTypeBS0 <<
275 SleepTypeRegInfo->BitPosition);
276
277 /* Write the control registers and ignore any errors */
278
279 (void) AcpiHwWritePm1Control (Pm1aControl, Pm1bControl);
280 }
281 }
282
284}

◆ 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_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().

◆ AcpiHwRead()

ACPI_STATUS AcpiHwRead ( UINT64 Value,
ACPI_GENERIC_ADDRESS Reg 
)

Definition at line 259 of file hwregs.c.

262{
264 UINT8 AccessWidth;
265 UINT32 BitWidth;
266 UINT8 BitOffset;
267 UINT64 Value64;
268 UINT32 Value32;
269 UINT8 Index;
271
272
273 ACPI_FUNCTION_NAME (HwRead);
274
275
276 /* Validate contents of the GAS register */
277
279 if (ACPI_FAILURE (Status))
280 {
281 return (Status);
282 }
283
284 /*
285 * Initialize entire 64-bit return value to zero, convert AccessWidth
286 * into number of bits based
287 */
288 *Value = 0;
289 AccessWidth = AcpiHwGetAccessBitWidth (Address, Reg, 64);
290 BitWidth = Reg->BitOffset + Reg->BitWidth;
291 BitOffset = Reg->BitOffset;
292
293 /*
294 * Two address spaces supported: Memory or IO. PCI_Config is
295 * not supported here because the GAS structure is insufficient
296 */
297 Index = 0;
298 while (BitWidth)
299 {
300 if (BitOffset >= AccessWidth)
301 {
302 Value64 = 0;
303 BitOffset -= AccessWidth;
304 }
305 else
306 {
308 {
309 Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
310 Address + Index * ACPI_DIV_8 (AccessWidth),
311 &Value64, AccessWidth);
312 }
313 else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
314 {
315 Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
316 Address + Index * ACPI_DIV_8 (AccessWidth),
317 &Value32, AccessWidth);
318 Value64 = (UINT64) Value32;
319 }
320 }
321
322 /*
323 * Use offset style bit writes because "Index * AccessWidth" is
324 * ensured to be less than 64-bits by AcpiHwValidateRegister().
325 */
326 ACPI_SET_BITS (Value, Index * AccessWidth,
327 ACPI_MASK_BITS_ABOVE_64 (AccessWidth), Value64);
328
329 BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth;
330 Index++;
331 }
332
334 "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n",
335 ACPI_FORMAT_UINT64 (*Value), AccessWidth,
337
338 return (Status);
339}
#define ACPI_SET_BITS(TargetPtr, Position, Mask, Value)
Definition: acmacros.h:371
#define ACPI_DIV_8(a)
Definition: acmacros.h:214
#define ACPI_MASK_BITS_ABOVE_64(width)
Definition: acmacros.h:348
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
ACPI_STATUS AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 *Value, UINT32 Width)
Definition: osl.c:634
#define ACPI_ADR_SPACE_SYSTEM_MEMORY
Definition: actypes.h:861
const char * AcpiUtGetRegionName(UINT8 SpaceId)
Definition: utdecode.c:125
ACPI_STATUS AcpiHwValidateRegister(ACPI_GENERIC_ADDRESS *Reg, UINT8 MaxBitWidth, UINT64 *Address)
Definition: hwregs.c:179
static UINT8 AcpiHwGetAccessBitWidth(UINT64 Address, ACPI_GENERIC_ADDRESS *Reg, UINT8 MaxBitWidth)
Definition: hwregs.c:93
ACPI_STATUS AcpiHwReadPort(ACPI_IO_ADDRESS Address, UINT32 *Value, UINT32 Width)
Definition: hwvalid.c:237
static WCHAR Address[46]
Definition: ping.c:68
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by AcpiEvDetectGpe(), AcpiGetTimer(), AcpiHwGetGpeBlockStatus(), AcpiHwGetGpeStatus(), AcpiHwLowSetGpe(), AcpiHwReadMultiple(), AcpiHwRegisterRead(), AcpiHwRegisterWrite(), and AcpiRead().

◆ AcpiHwReadPort()

ACPI_STATUS AcpiHwReadPort ( ACPI_IO_ADDRESS  Address,
UINT32 Value,
UINT32  Width 
)

Definition at line 237 of file hwvalid.c.

241{
243 UINT32 OneByte;
244 UINT32 i;
245
246
247 /* Truncate address to 16 bits if requested */
248
249 if (AcpiGbl_TruncateIoAddresses)
250 {
252 }
253
254 /* Validate the entire request and perform the I/O */
255
257 if (ACPI_SUCCESS (Status))
258 {
260 return (Status);
261 }
262
264 {
265 return (Status);
266 }
267
268 /*
269 * There has been a protection violation within the request. Fall
270 * back to byte granularity port I/O and ignore the failing bytes.
271 * This provides compatibility with other ACPI implementations.
272 */
273 for (i = 0, *Value = 0; i < Width; i += 8)
274 {
275 /* Validate and read one byte */
276
278 {
279 Status = AcpiOsReadPort (Address, &OneByte, 8);
280 if (ACPI_FAILURE (Status))
281 {
282 return (Status);
283 }
284
285 *Value |= (OneByte << i);
286 }
287
288 Address++;
289 }
290
291 return (AE_OK);
292}
#define AE_AML_ILLEGAL_ADDRESS
Definition: acexcep.h:211
ACPI_STATUS AcpiOsReadPort(ACPI_IO_ADDRESS Address, UINT32 *Value, UINT32 Width)
Definition: osl.c:701
#define ACPI_UINT16_MAX
Definition: actypes.h:65
static ACPI_STATUS AcpiHwValidateIoRequest(ACPI_IO_ADDRESS Address, UINT32 BitWidth)
Definition: hwvalid.c:130
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89

Referenced by AcpiExSystemIoSpaceHandler(), AcpiHwRead(), and AcpiHwRegisterRead().

◆ AcpiHwRegisterRead()

ACPI_STATUS AcpiHwRegisterRead ( UINT32  RegisterId,
UINT32 ReturnValue 
)

Definition at line 574 of file hwregs.c.

577{
578 UINT32 Value = 0;
579 UINT64 Value64;
581
582
583 ACPI_FUNCTION_TRACE (HwRegisterRead);
584
585
586 switch (RegisterId)
587 {
588 case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
589
591 &AcpiGbl_XPm1aStatus,
592 &AcpiGbl_XPm1bStatus);
593 break;
594
595 case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */
596
598 &AcpiGbl_XPm1aEnable,
599 &AcpiGbl_XPm1bEnable);
600 break;
601
602 case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
603
605 &AcpiGbl_FADT.XPm1aControlBlock,
606 &AcpiGbl_FADT.XPm1bControlBlock);
607
608 /*
609 * Zero the write-only bits. From the ACPI specification, "Hardware
610 * Write-Only Bits": "Upon reads to registers with write-only bits,
611 * software masks out all write-only bits."
612 */
613 Value &= ~ACPI_PM1_CONTROL_WRITEONLY_BITS;
614 break;
615
616 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
617
618 Status = AcpiHwRead (&Value64, &AcpiGbl_FADT.XPm2ControlBlock);
619 if (ACPI_SUCCESS (Status))
620 {
621 Value = (UINT32) Value64;
622 }
623 break;
624
625 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
626
627 Status = AcpiHwRead (&Value64, &AcpiGbl_FADT.XPmTimerBlock);
628 if (ACPI_SUCCESS (Status))
629 {
630 Value = (UINT32) Value64;
631 }
632
633 break;
634
635 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
636
637 Status = AcpiHwReadPort (AcpiGbl_FADT.SmiCommand, &Value, 8);
638 break;
639
640 default:
641
642 ACPI_ERROR ((AE_INFO, "Unknown Register ID: 0x%X",
643 RegisterId));
645 break;
646 }
647
648 if (ACPI_SUCCESS (Status))
649 {
651 }
652
654}
UINT32 void void ** ReturnValue
Definition: acevents.h:216
#define ACPI_REGISTER_PM2_CONTROL
Definition: aclocal.h:1187
#define ACPI_REGISTER_PM1_ENABLE
Definition: aclocal.h:1185
#define ACPI_REGISTER_PM_TIMER
Definition: aclocal.h:1188
#define ACPI_REGISTER_SMI_COMMAND_BLOCK
Definition: aclocal.h:1190
static ACPI_STATUS AcpiHwReadMultiple(UINT32 *Value, ACPI_GENERIC_ADDRESS *RegisterA, ACPI_GENERIC_ADDRESS *RegisterB)
Definition: hwregs.c:806

Referenced by AcpiEvFixedEventDetect(), AcpiHwLegacySleep(), AcpiHwLegacyWakePrep(), AcpiReadBitRegister(), and AcpiWriteBitRegister().

◆ AcpiHwRegisterWrite()

ACPI_STATUS AcpiHwRegisterWrite ( UINT32  RegisterId,
UINT32  Value 
)

Definition at line 684 of file hwregs.c.

687{
689 UINT32 ReadValue;
690 UINT64 ReadValue64;
691
692
693 ACPI_FUNCTION_TRACE (HwRegisterWrite);
694
695
696 switch (RegisterId)
697 {
698 case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
699 /*
700 * Handle the "ignored" bit in PM1 Status. According to the ACPI
701 * specification, ignored bits are to be preserved when writing.
702 * Normally, this would mean a read/modify/write sequence. However,
703 * preserving a bit in the status register is different. Writing a
704 * one clears the status, and writing a zero preserves the status.
705 * Therefore, we must always write zero to the ignored bit.
706 *
707 * This behavior is clarified in the ACPI 4.0 specification.
708 */
709 Value &= ~ACPI_PM1_STATUS_PRESERVED_BITS;
710
712 &AcpiGbl_XPm1aStatus,
713 &AcpiGbl_XPm1bStatus);
714 break;
715
716 case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */
717
719 &AcpiGbl_XPm1aEnable,
720 &AcpiGbl_XPm1bEnable);
721 break;
722
723 case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
724 /*
725 * Perform a read first to preserve certain bits (per ACPI spec)
726 * Note: This includes SCI_EN, we never want to change this bit
727 */
728 Status = AcpiHwReadMultiple (&ReadValue,
729 &AcpiGbl_FADT.XPm1aControlBlock,
730 &AcpiGbl_FADT.XPm1bControlBlock);
731 if (ACPI_FAILURE (Status))
732 {
733 goto Exit;
734 }
735
736 /* Insert the bits to be preserved */
737
739
740 /* Now we can write the data */
741
743 &AcpiGbl_FADT.XPm1aControlBlock,
744 &AcpiGbl_FADT.XPm1bControlBlock);
745 break;
746
747 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
748 /*
749 * For control registers, all reserved bits must be preserved,
750 * as per the ACPI spec.
751 */
752 Status = AcpiHwRead (&ReadValue64, &AcpiGbl_FADT.XPm2ControlBlock);
753 if (ACPI_FAILURE (Status))
754 {
755 goto Exit;
756 }
757 ReadValue = (UINT32) ReadValue64;
758
759 /* Insert the bits to be preserved */
760
762
763 Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPm2ControlBlock);
764 break;
765
766 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
767
768 Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPmTimerBlock);
769 break;
770
771 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
772
773 /* SMI_CMD is currently always in IO space */
774
775 Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, Value, 8);
776 break;
777
778 default:
779
780 ACPI_ERROR ((AE_INFO, "Unknown Register ID: 0x%X",
781 RegisterId));
783 break;
784 }
785
786Exit:
788}
#define ACPI_PM1_CONTROL_PRESERVED_BITS
Definition: aclocal.h:1175
#define ACPI_PM2_CONTROL_PRESERVED_BITS
Definition: aclocal.h:1178
#define ACPI_INSERT_BITS(Target, Mask, Source)
Definition: acmacros.h:363
static ACPI_STATUS AcpiHwWriteMultiple(UINT32 Value, ACPI_GENERIC_ADDRESS *RegisterA, ACPI_GENERIC_ADDRESS *RegisterB)
Definition: hwregs.c:868
ACPI_STATUS AcpiHwWritePort(ACPI_IO_ADDRESS Address, UINT32 Value, UINT32 Width)
Definition: hwvalid.c:312

Referenced by AcpiHwClearAcpiStatus(), AcpiHwLegacySleep(), and AcpiWriteBitRegister().

◆ AcpiHwSetMode()

ACPI_STATUS AcpiHwSetMode ( UINT32  Mode)

Definition at line 66 of file hwacpi.c.

68{
69
72
73
74 ACPI_FUNCTION_TRACE (HwSetMode);
75
76
77 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
78
79 if (AcpiGbl_ReducedHardware)
80 {
82 }
83
84 /*
85 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
86 * system does not support mode transition.
87 */
88 if (!AcpiGbl_FADT.SmiCommand)
89 {
90 ACPI_ERROR ((AE_INFO, "No SMI_CMD in FADT, mode transition failed"));
92 }
93
94 /*
95 * ACPI 2.0 clarified the meaning of ACPI_ENABLE and ACPI_DISABLE
96 * in FADT: If it is zero, enabling or disabling is not supported.
97 * As old systems may have used zero for mode transition,
98 * we make sure both the numbers are zero to determine these
99 * transitions are not supported.
100 */
101 if (!AcpiGbl_FADT.AcpiEnable && !AcpiGbl_FADT.AcpiDisable)
102 {
104 "No ACPI mode transition supported in this system "
105 "(enable/disable both zero)"));
107 }
108
109 switch (Mode)
110 {
112
113 /* BIOS should have disabled ALL fixed and GP events */
114
115 Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand,
116 (UINT32) AcpiGbl_FADT.AcpiEnable, 8);
117 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n"));
118 break;
119
121 /*
122 * BIOS should clear all fixed status bits and restore fixed event
123 * enable bits to default
124 */
125 Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand,
126 (UINT32) AcpiGbl_FADT.AcpiDisable, 8);
128 "Attempting to enable Legacy (non-ACPI) mode\n"));
129 break;
130
131 default:
132
134 }
135
136 if (ACPI_FAILURE (Status))
137 {
139 "Could not write ACPI mode change"));
141 }
142
143 /*
144 * Some hardware takes a LONG time to switch modes. Give them 3 sec to
145 * do so, but allow faster systems to proceed more quickly.
146 */
147 Retry = 3000;
148 while (Retry)
149 {
150 if (AcpiHwGetMode () == Mode)
151 {
153 "Mode %X successfully enabled\n", Mode));
155 }
157 Retry--;
158 }
159
160 ACPI_ERROR ((AE_INFO, "Hardware did not change modes"));
162}
#define AE_NO_HARDWARE_RESPONSE
Definition: acexcep.h:130
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define ACPI_USEC_PER_MSEC
Definition: actypes.h:470
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
Definition: classpnp.h:312
UINT32 AcpiHwGetMode(void)
Definition: hwacpi.c:179
_In_ ULONG Mode
Definition: hubbusif.h:303

Referenced by AcpiDisable(), and AcpiEnable().

◆ AcpiHwValidateRegister()

ACPI_STATUS AcpiHwValidateRegister ( ACPI_GENERIC_ADDRESS Reg,
UINT8  MaxBitWidth,
UINT64 Address 
)

Definition at line 179 of file hwregs.c.

183{
184 UINT8 BitWidth;
185 UINT8 AccessWidth;
186
187
188 /* Must have a valid pointer to a GAS structure */
189
190 if (!Reg)
191 {
192 return (AE_BAD_PARAMETER);
193 }
194
195 /*
196 * Copy the target address. This handles possible alignment issues.
197 * Address must not be null. A null address also indicates an optional
198 * ACPI register that is not supported, so no error message.
199 */
201 if (!(*Address))
202 {
203 return (AE_BAD_ADDRESS);
204 }
205
206 /* Validate the SpaceID */
207
210 {
212 "Unsupported address space: 0x%X", Reg->SpaceId));
213 return (AE_SUPPORT);
214 }
215
216 /* Validate the AccessWidth */
217
218 if (Reg->AccessWidth > 4)
219 {
221 "Unsupported register access width: 0x%X", Reg->AccessWidth));
222 return (AE_SUPPORT);
223 }
224
225 /* Validate the BitWidth, convert AccessWidth into number of bits */
226
227 AccessWidth = AcpiHwGetAccessBitWidth (*Address, Reg, MaxBitWidth);
228 BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth);
229 if (MaxBitWidth < BitWidth)
230 {
232 "Requested bit width 0x%X is smaller than register bit width 0x%X",
233 MaxBitWidth, BitWidth));
234 return (AE_SUPPORT);
235 }
236
237 return (AE_OK);
238}
#define AE_SUPPORT
Definition: acexcep.h:123
#define AE_BAD_ADDRESS
Definition: acexcep.h:159
#define ACPI_MOVE_64_TO_64(d, s)
Definition: acmacros.h:155
#define ACPI_ROUND_UP(value, boundary)
Definition: acmacros.h:242
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
#define ACPI_ADR_SPACE_SYSTEM_IO
Definition: actypes.h:862

Referenced by AcpiHwRead(), and AcpiHwWrite().

◆ AcpiHwWrite()

ACPI_STATUS AcpiHwWrite ( UINT64  Value,
ACPI_GENERIC_ADDRESS Reg 
)

Definition at line 357 of file hwregs.c.

360{
362 UINT8 AccessWidth;
363 UINT32 BitWidth;
364 UINT8 BitOffset;
365 UINT64 Value64;
366 UINT8 Index;
368
369
370 ACPI_FUNCTION_NAME (HwWrite);
371
372
373 /* Validate contents of the GAS register */
374
376 if (ACPI_FAILURE (Status))
377 {
378 return (Status);
379 }
380
381 /* Convert AccessWidth into number of bits based */
382
383 AccessWidth = AcpiHwGetAccessBitWidth (Address, Reg, 64);
384 BitWidth = Reg->BitOffset + Reg->BitWidth;
385 BitOffset = Reg->BitOffset;
386
387 /*
388 * Two address spaces supported: Memory or IO. PCI_Config is
389 * not supported here because the GAS structure is insufficient
390 */
391 Index = 0;
392 while (BitWidth)
393 {
394 /*
395 * Use offset style bit reads because "Index * AccessWidth" is
396 * ensured to be less than 64-bits by AcpiHwValidateRegister().
397 */
398 Value64 = ACPI_GET_BITS (&Value, Index * AccessWidth,
399 ACPI_MASK_BITS_ABOVE_64 (AccessWidth));
400
401 if (BitOffset >= AccessWidth)
402 {
403 BitOffset -= AccessWidth;
404 }
405 else
406 {
408 {
409 Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS)
410 Address + Index * ACPI_DIV_8 (AccessWidth),
411 Value64, AccessWidth);
412 }
413 else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
414 {
415 Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
416 Address + Index * ACPI_DIV_8 (AccessWidth),
417 (UINT32) Value64, AccessWidth);
418 }
419 }
420
421 /*
422 * Index * AccessWidth is ensured to be less than 32-bits by
423 * AcpiHwValidateRegister().
424 */
425 BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth;
426 Index++;
427 }
428
430 "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n",
431 ACPI_FORMAT_UINT64 (Value), AccessWidth,
433
434 return (Status);
435}
#define ACPI_GET_BITS(SourcePtr, Position, Mask)
Definition: acmacros.h:368
ACPI_STATUS AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 Value, UINT32 Width)
Definition: osl.c:667

Referenced by AcpiEvCreateGpeInfoBlocks(), AcpiHwClearGpe(), AcpiHwClearGpeBlock(), AcpiHwGpeEnableWrite(), AcpiHwLowSetGpe(), AcpiHwRegisterWrite(), AcpiHwWriteMultiple(), AcpiHwWritePm1Control(), AcpiReset(), and AcpiWrite().

◆ AcpiHwWritePm1Control()

ACPI_STATUS AcpiHwWritePm1Control ( UINT32  Pm1aControl,
UINT32  Pm1bControl 
)

Definition at line 536 of file hwregs.c.

539{
541
542
543 ACPI_FUNCTION_TRACE (HwWritePm1Control);
544
545
546 Status = AcpiHwWrite (Pm1aControl, &AcpiGbl_FADT.XPm1aControlBlock);
547 if (ACPI_FAILURE (Status))
548 {
550 }
551
552 if (AcpiGbl_FADT.XPm1bControlBlock.Address)
553 {
554 Status = AcpiHwWrite (Pm1bControl, &AcpiGbl_FADT.XPm1bControlBlock);
555 }
557}

Referenced by AcpiHwLegacySleep(), and AcpiHwLegacyWakePrep().

◆ AcpiHwWritePort()

ACPI_STATUS AcpiHwWritePort ( ACPI_IO_ADDRESS  Address,
UINT32  Value,
UINT32  Width 
)

Definition at line 312 of file hwvalid.c.

316{
318 UINT32 i;
319
320
321 /* Truncate address to 16 bits if requested */
322
323 if (AcpiGbl_TruncateIoAddresses)
324 {
326 }
327
328 /* Validate the entire request and perform the I/O */
329
331 if (ACPI_SUCCESS (Status))
332 {
334 return (Status);
335 }
336
338 {
339 return (Status);
340 }
341
342 /*
343 * There has been a protection violation within the request. Fall
344 * back to byte granularity port I/O and ignore the failing bytes.
345 * This provides compatibility with other ACPI implementations.
346 */
347 for (i = 0; i < Width; i += 8)
348 {
349 /* Validate and write one byte */
350
352 {
353 Status = AcpiOsWritePort (Address, (Value >> i) & 0xFF, 8);
354 if (ACPI_FAILURE (Status))
355 {
356 return (Status);
357 }
358 }
359
360 Address++;
361 }
362
363 return (AE_OK);
364}
ACPI_STATUS AcpiOsWritePort(ACPI_IO_ADDRESS Address, UINT32 Value, UINT32 Width)
Definition: osl.c:731

Referenced by AcpiEnterSleepStateS4bios(), AcpiExSystemIoSpaceHandler(), AcpiHwRegisterWrite(), AcpiHwSetMode(), and AcpiHwWrite().