ReactOS 0.4.15-dev-7842-g558ab78
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
522ReturnValueCleanup:
523 AcpiUtRemoveReference (Info->ReturnObject);
524
525WarningCleanup:
526 if (ACPI_FAILURE (Status))
527 {
529 "While evaluating Sleep State [%s]",
530 Info->RelativePathname));
531 }
532
533FinalCleanup:
534 ACPI_FREE (Info);
536}
unsigned char UINT8
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define AE_NOT_FOUND
Definition: acexcep.h:113
#define AE_AML_PACKAGE_LIMIT
Definition: acexcep.h:190
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_AML_NO_RETURN_VALUE
Definition: acexcep.h:197
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
const char * AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT]
Definition: utglobal.c:62
ACPI_STATUS AcpiNsEvaluate(ACPI_EVALUATE_INFO *Info)
Definition: nseval.c:82
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_S_STATES_MAX
Definition: actypes.h:630
#define ACPI_FREE(a)
Definition: actypes.h:386
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:691
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:790
Status
Definition: gdiplustypes.h:25
ACPI_STATUS AcpiGetSleepTypeData(UINT8 SleepState, UINT8 *SleepTypeA, UINT8 *SleepTypeB)
Definition: hwxface.c:411
union acpi_operand_object ** Elements
Definition: acobject.h:161
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:520
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519
ACPI_OBJECT_PACKAGE Package
Definition: acobject.h:523
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Referenced by acpi_system_add(), AcpiEnterSleepStatePrep(), and AcpiGetSleepTypeData().

◆ AcpiRead()

ACPI_STATUS AcpiRead ( UINT64 ReturnValue,
ACPI_GENERIC_ADDRESS Reg 
)

Definition at line 138 of file hwxface.c.

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

Referenced by AcpiHwExtendedSleep(), and AcpiRead().

◆ 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;
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
254}
unsigned int UINT32
#define AE_OK
Definition: acexcep.h:97
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_FUNCTION_TRACE_U32(a, b)
Definition: acoutput.h:482
#define ACPI_DB_IO
Definition: acoutput.h:177
ACPI_STATUS AcpiHwRegisterRead(UINT32 RegisterId, UINT32 *ReturnValue)
Definition: hwregs.c:574
ACPI_BIT_REGISTER_INFO * AcpiHwGetBitRegisterInfo(UINT32 RegisterId)
Definition: hwregs.c:502
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 AcpiDisableEvent(), AcpiEnableEvent(), AcpiEnterSleepStateS4bios(), AcpiGetEventStatus(), AcpiHwGetMode(), AcpiHwLegacySleep(), and AcpiReadBitRegister().

◆ 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 AE_NOT_EXIST
Definition: acexcep.h:114
ACPI_STATUS AcpiOsWritePort(ACPI_IO_ADDRESS Address, UINT32 Value, UINT32 Width)
Definition: osl.c:731
#define ACPI_FADT_RESET_REGISTER
Definition: actbl.h:346
#define ACPI_RESET_REGISTER_WIDTH
Definition: actypes.h:411
#define ACPI_ADR_SPACE_SYSTEM_IO
Definition: actypes.h:862
ACPI_STATUS AcpiHwWrite(UINT64 Value, ACPI_GENERIC_ADDRESS *Reg)
Definition: hwregs.c:357
ACPI_STATUS AcpiReset(void)
Definition: hwxface.c:69

Referenced by AcpiReset().

◆ 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}
ACPI_STATUS AcpiWrite(UINT64 Value, ACPI_GENERIC_ADDRESS *Reg)
Definition: hwxface.c:169

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

◆ 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
361UnlockAndExit:
362
363 AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags);
365}
#define ACPI_REGISTER_PM1_STATUS
Definition: aclocal.h:1184
#define ACPI_REGISTER_INSERT_VALUE(Reg, Pos, Mask, Val)
Definition: acmacros.h:360
#define ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask)
Definition: acmacros.h:357
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
ACPI_STATUS AcpiHwRegisterWrite(UINT32 RegisterId, UINT32 Value)
Definition: hwregs.c:684
ACPI_STATUS AcpiWriteBitRegister(UINT32 RegisterId, UINT32 Value)
Definition: hwxface.c:282

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