ReactOS  0.4.14-dev-323-g6fe6a88
hwxface.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acnamesp.h"
Include dependency graph for hwxface.c:

Go to the source code of this file.

Macros

#define EXPORT_ACPI_INTERFACES
 
#define _COMPONENT   ACPI_HARDWARE
 

Functions

ACPI_STATUS AcpiReset (void)
 
ACPI_STATUS AcpiRead (UINT64 *ReturnValue, ACPI_GENERIC_ADDRESS *Reg)
 
ACPI_STATUS AcpiWrite (UINT64 Value, ACPI_GENERIC_ADDRESS *Reg)
 
ACPI_STATUS AcpiReadBitRegister (UINT32 RegisterId, UINT32 *ReturnValue)
 
ACPI_STATUS AcpiWriteBitRegister (UINT32 RegisterId, UINT32 Value)
 
ACPI_STATUS AcpiGetSleepTypeData (UINT8 SleepState, UINT8 *SleepTypeA, UINT8 *SleepTypeB)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_HARDWARE

Definition at line 50 of file hwxface.c.

◆ EXPORT_ACPI_INTERFACES

#define EXPORT_ACPI_INTERFACES

Definition at line 44 of file hwxface.c.

Function Documentation

◆ AcpiGetSleepTypeData()

ACPI_STATUS AcpiGetSleepTypeData ( UINT8  SleepState,
UINT8 SleepTypeA,
UINT8 SleepTypeB 
)

Definition at line 411 of file hwxface.c.

415 {
418  ACPI_OPERAND_OBJECT **Elements;
419 
420 
422 
423 
424  /* Validate parameters */
425 
426  if ((SleepState > ACPI_S_STATES_MAX) ||
427  !SleepTypeA || !SleepTypeB)
428  {
430  }
431 
432  /* Allocate the evaluation information block */
433 
435  if (!Info)
436  {
438  }
439 
440  /*
441  * Evaluate the \_Sx namespace object containing the register values
442  * for this state
443  */
444  Info->RelativePathname = AcpiGbl_SleepStateNames[SleepState];
445 
447  if (ACPI_FAILURE (Status))
448  {
449  if (Status == AE_NOT_FOUND)
450  {
451  /* The _Sx states are optional, ignore NOT_FOUND */
452 
453  goto FinalCleanup;
454  }
455 
456  goto WarningCleanup;
457  }
458 
459  /* Must have a return object */
460 
461  if (!Info->ReturnObject)
462  {
463  ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]",
464  Info->RelativePathname));
466  goto WarningCleanup;
467  }
468 
469  /* Return object must be of type Package */
470 
471  if (Info->ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
472  {
473  ACPI_ERROR ((AE_INFO, "Sleep State return object is not a Package"));
475  goto ReturnValueCleanup;
476  }
477 
478  /*
479  * Any warnings about the package length or the object types have
480  * already been issued by the predefined name module -- there is no
481  * need to repeat them here.
482  */
483  Elements = Info->ReturnObject->Package.Elements;
484  switch (Info->ReturnObject->Package.Count)
485  {
486  case 0:
487 
489  break;
490 
491  case 1:
492 
493  if (Elements[0]->Common.Type != ACPI_TYPE_INTEGER)
494  {
496  break;
497  }
498 
499  /* A valid _Sx_ package with one integer */
500 
501  *SleepTypeA = (UINT8) Elements[0]->Integer.Value;
502  *SleepTypeB = (UINT8) (Elements[0]->Integer.Value >> 8);
503  break;
504 
505  case 2:
506  default:
507 
508  if ((Elements[0]->Common.Type != ACPI_TYPE_INTEGER) ||
509  (Elements[1]->Common.Type != ACPI_TYPE_INTEGER))
510  {
512  break;
513  }
514 
515  /* A valid _Sx_ package with two integers */
516 
517  *SleepTypeA = (UINT8) Elements[0]->Integer.Value;
518  *SleepTypeB = (UINT8) Elements[1]->Integer.Value;
519  break;
520  }
521 
522 ReturnValueCleanup:
523  AcpiUtRemoveReference (Info->ReturnObject);
524 
525 WarningCleanup:
526  if (ACPI_FAILURE (Status))
527  {
529  "While evaluating Sleep State [%s]",
530  Info->RelativePathname));
531  }
532 
533 FinalCleanup:
534  ACPI_FREE (Info);
536 }
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
#define ACPI_FREE(a)
Definition: actypes.h:386
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define ACPI_TYPE_INTEGER
Definition: actypes.h:679
#define ACPI_S_STATES_MAX
Definition: actypes.h:621
ACPI_STATUS AcpiNsEvaluate(ACPI_EVALUATE_INFO *Info)
Definition: nseval.c:82
UINT32 ACPI_STATUS
Definition: actypes.h:460
struct TraceInfo Info
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
ACPI_STATUS AcpiGetSleepTypeData(UINT8 SleepState, UINT8 *SleepTypeA, UINT8 *SleepTypeB)
Definition: hwxface.c:411
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:682
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_INFO
Definition: acoutput.h:230
#define AE_AML_NO_RETURN_VALUE
Definition: acexcep.h:197
const char * AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT]
Definition: utglobal.c:62
#define AE_NOT_FOUND
Definition: acexcep.h:113
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:517
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_OBJECT_COMMON Common
Definition: acobject.h:516
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:784
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_AML_PACKAGE_LIMIT
Definition: acexcep.h:190
unsigned char UINT8

Referenced by acpi_system_add(), AcpiEnterSleepStatePrep(), AcpiHwExtendedWakePrep(), and AcpiHwLegacyWakePrep().

◆ AcpiRead()

ACPI_STATUS AcpiRead ( UINT64 ReturnValue,
ACPI_GENERIC_ADDRESS Reg 
)

Definition at line 138 of file hwxface.c.

141 {
143 
144 
146 
147 
148  Status = AcpiHwRead (ReturnValue, Reg);
149  return (Status);
150 }
UINT32 ACPI_STATUS
Definition: actypes.h:460
UINT32 void void ** ReturnValue
Definition: acevents.h:214
ACPI_STATUS AcpiHwRead(UINT64 *Value, ACPI_GENERIC_ADDRESS *Reg)
Definition: hwregs.c:259
Status
Definition: gdiplustypes.h:24
ACPI_STATUS AcpiRead(UINT64 *ReturnValue, ACPI_GENERIC_ADDRESS *Reg)
Definition: hwxface.c:138
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479

Referenced by AcpiHwExtendedSleep().

◆ AcpiReadBitRegister()

ACPI_STATUS AcpiReadBitRegister ( UINT32  RegisterId,
UINT32 ReturnValue 
)

Definition at line 213 of file hwxface.c.

216 {
217  ACPI_BIT_REGISTER_INFO *BitRegInfo;
218  UINT32 RegisterValue;
219  UINT32 Value;
221 
222 
224 
225 
226  /* Get the info structure corresponding to the requested ACPI Register */
227 
228  BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
229  if (!BitRegInfo)
230  {
232  }
233 
234  /* Read the entire parent register */
235 
237  &RegisterValue);
238  if (ACPI_FAILURE (Status))
239  {
241  }
242 
243  /* Normalize the value that was read, mask off other bits */
244 
245  Value = ((RegisterValue & BitRegInfo->AccessBitMask)
246  >> BitRegInfo->BitPosition);
247 
249  "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n",
250  RegisterId, BitRegInfo->ParentRegister, RegisterValue, Value));
251 
252  *ReturnValue = Value;
254 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define ACPI_DB_IO
Definition: acoutput.h:177
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_FUNCTION_TRACE_U32(a, b)
Definition: acoutput.h:482
ACPI_STATUS AcpiHwRegisterRead(UINT32 RegisterId, UINT32 *ReturnValue)
Definition: hwregs.c:574
ACPI_BIT_REGISTER_INFO * AcpiHwGetBitRegisterInfo(UINT32 RegisterId)
Definition: hwregs.c:502
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
UINT32 void void ** ReturnValue
Definition: acevents.h:214
unsigned int UINT32
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
ACPI_STATUS AcpiReadBitRegister(UINT32 RegisterId, UINT32 *ReturnValue)
Definition: hwxface.c:213
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiDisableEvent(), AcpiEnableEvent(), AcpiEnterSleepStateS4bios(), AcpiGetEventStatus(), AcpiHwGetMode(), and AcpiHwLegacySleep().

◆ AcpiReset()

ACPI_STATUS AcpiReset ( void  )

Definition at line 69 of file hwxface.c.

71 {
72  ACPI_GENERIC_ADDRESS *ResetReg;
74 
75 
77 
78 
79  ResetReg = &AcpiGbl_FADT.ResetRegister;
80 
81  /* Check if the reset register is supported */
82 
83  if (!(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER) ||
84  !ResetReg->Address)
85  {
87  }
88 
89  if (ResetReg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO)
90  {
91  /*
92  * For I/O space, write directly to the OSL. This bypasses the port
93  * validation mechanism, which may block a valid write to the reset
94  * register.
95  *
96  * NOTE:
97  * The ACPI spec requires the reset register width to be 8, so we
98  * hardcode it here and ignore the FADT value. This maintains
99  * compatibility with other ACPI implementations that have allowed
100  * BIOS code with bad register width values to go unnoticed.
101  */
102  Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ResetReg->Address,
103  AcpiGbl_FADT.ResetValue, ACPI_RESET_REGISTER_WIDTH);
104  }
105  else
106  {
107  /* Write the reset value to the reset register */
108 
109  Status = AcpiHwWrite (AcpiGbl_FADT.ResetValue, ResetReg);
110  }
111 
113 }
#define ACPI_FADT_RESET_REGISTER
Definition: actbl.h:346
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_RESET_REGISTER_WIDTH
Definition: actypes.h:411
#define ACPI_ADR_SPACE_SYSTEM_IO
Definition: actypes.h:852
#define AE_NOT_EXIST
Definition: acexcep.h:114
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_STATUS AcpiReset(void)
Definition: hwxface.c:69
ACPI_STATUS AcpiOsWritePort(ACPI_IO_ADDRESS Address, UINT32 Value, UINT32 Width)
Definition: osl.c:731
ACPI_STATUS AcpiHwWrite(UINT64 Value, ACPI_GENERIC_ADDRESS *Reg)
Definition: hwregs.c:357

◆ AcpiWrite()

ACPI_STATUS AcpiWrite ( UINT64  Value,
ACPI_GENERIC_ADDRESS Reg 
)

Definition at line 169 of file hwxface.c.

172 {
174 
175 
177 
178 
179  Status = AcpiHwWrite (Value, Reg);
180  return (Status);
181 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_STATUS AcpiWrite(UINT64 Value, ACPI_GENERIC_ADDRESS *Reg)
Definition: hwxface.c:169
Status
Definition: gdiplustypes.h:24
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
ACPI_STATUS AcpiHwWrite(UINT64 Value, ACPI_GENERIC_ADDRESS *Reg)
Definition: hwregs.c:357

Referenced by AcpiHwExtendedSleep(), AcpiHwExtendedWake(), and AcpiHwExtendedWakePrep().

◆ AcpiWriteBitRegister()

ACPI_STATUS AcpiWriteBitRegister ( UINT32  RegisterId,
UINT32  Value 
)

Definition at line 282 of file hwxface.c.

285 {
286  ACPI_BIT_REGISTER_INFO *BitRegInfo;
287  ACPI_CPU_FLAGS LockFlags;
288  UINT32 RegisterValue;
290 
291 
293 
294 
295  /* Get the info structure corresponding to the requested ACPI Register */
296 
297  BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
298  if (!BitRegInfo)
299  {
301  }
302 
303  LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock);
304 
305  /*
306  * At this point, we know that the parent register is one of the
307  * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control
308  */
309  if (BitRegInfo->ParentRegister != ACPI_REGISTER_PM1_STATUS)
310  {
311  /*
312  * 1) Case for PM1 Enable, PM1 Control, and PM2 Control
313  *
314  * Perform a register read to preserve the bits that we are not
315  * interested in
316  */
318  &RegisterValue);
319  if (ACPI_FAILURE (Status))
320  {
321  goto UnlockAndExit;
322  }
323 
324  /*
325  * Insert the input bit into the value that was just read
326  * and write the register
327  */
328  ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
329  BitRegInfo->AccessBitMask, Value);
330 
332  RegisterValue);
333  }
334  else
335  {
336  /*
337  * 2) Case for PM1 Status
338  *
339  * The Status register is different from the rest. Clear an event
340  * by writing 1, writing 0 has no effect. So, the only relevant
341  * information is the single bit we're interested in, all others
342  * should be written as 0 so they will be left unchanged.
343  */
344  RegisterValue = ACPI_REGISTER_PREPARE_BITS (Value,
345  BitRegInfo->BitPosition, BitRegInfo->AccessBitMask);
346 
347  /* No need to write the register if value is all zeros */
348 
349  if (RegisterValue)
350  {
352  RegisterValue);
353  }
354  }
355 
357  "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n",
358  RegisterId, BitRegInfo->ParentRegister, Value, RegisterValue));
359 
360 
361 UnlockAndExit:
362 
363  AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags);
365 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
ACPI_CPU_FLAGS AcpiOsAcquireLock(ACPI_SPINLOCK Handle)
Definition: osl.c:498
ACPI_STATUS AcpiWriteBitRegister(UINT32 RegisterId, UINT32 Value)
Definition: hwxface.c:282
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define ACPI_DB_IO
Definition: acoutput.h:177
#define ACPI_CPU_FLAGS
Definition: actypes.h:252
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask)
Definition: acmacros.h:357
#define ACPI_FUNCTION_TRACE_U32(a, b)
Definition: acoutput.h:482
ACPI_STATUS AcpiHwRegisterRead(UINT32 RegisterId, UINT32 *ReturnValue)
Definition: hwregs.c:574
ACPI_BIT_REGISTER_INFO * AcpiHwGetBitRegisterInfo(UINT32 RegisterId)
Definition: hwregs.c:502
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
unsigned int UINT32
#define ACPI_REGISTER_PM1_STATUS
Definition: aclocal.h:1184
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
ACPI_STATUS AcpiHwRegisterWrite(UINT32 RegisterId, UINT32 Value)
Definition: hwregs.c:684
void AcpiOsReleaseLock(ACPI_SPINLOCK Handle, ACPI_CPU_FLAGS Flags)
Definition: osl.c:516
#define ACPI_REGISTER_INSERT_VALUE(Reg, Pos, Mask, Val)
Definition: acmacros.h:360
#define AE_OK
Definition: acexcep.h:97

Referenced by acpi_bus_scan_fixed(), AcpiClearEvent(), AcpiDisableEvent(), AcpiEnableEvent(), AcpiEnterSleepStateS4bios(), AcpiEvFixedEventDispatch(), AcpiEvFixedEventInitialize(), AcpiEvReleaseGlobalLock(), AcpiHwLegacySleep(), and AcpiHwLegacyWake().