ReactOS  0.4.15-dev-439-g292f67a
hwxfsleep.c File Reference
#include "acpi.h"
#include "accommon.h"
Include dependency graph for hwxfsleep.c:

Go to the source code of this file.

Macros

#define EXPORT_ACPI_INTERFACES
 
#define _COMPONENT   ACPI_HARDWARE
 
#define ACPI_SLEEP_FUNCTION_ID   0
 
#define ACPI_WAKE_PREP_FUNCTION_ID   1
 
#define ACPI_WAKE_FUNCTION_ID   2
 

Functions

static ACPI_STATUS AcpiHwSetFirmwareWakingVector (ACPI_TABLE_FACS *Facs, ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_PHYSICAL_ADDRESS PhysicalAddress64)
 
static ACPI_STATUS AcpiHwSleepDispatch (UINT8 SleepState, UINT32 FunctionId)
 
ACPI_STATUS AcpiSetFirmwareWakingVector (ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_PHYSICAL_ADDRESS PhysicalAddress64)
 
ACPI_STATUS AcpiEnterSleepStateS4bios (void)
 
ACPI_STATUS AcpiEnterSleepStatePrep (UINT8 SleepState)
 
ACPI_STATUS AcpiEnterSleepState (UINT8 SleepState)
 
ACPI_STATUS AcpiLeaveSleepStatePrep (UINT8 SleepState)
 
ACPI_STATUS AcpiLeaveSleepState (UINT8 SleepState)
 

Variables

static ACPI_SLEEP_FUNCTIONS AcpiSleepDispatch []
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_HARDWARE

Definition at line 49 of file hwxfsleep.c.

◆ ACPI_SLEEP_FUNCTION_ID

#define ACPI_SLEEP_FUNCTION_ID   0

Definition at line 71 of file hwxfsleep.c.

◆ ACPI_WAKE_FUNCTION_ID

#define ACPI_WAKE_FUNCTION_ID   2

Definition at line 73 of file hwxfsleep.c.

◆ ACPI_WAKE_PREP_FUNCTION_ID

#define ACPI_WAKE_PREP_FUNCTION_ID   1

Definition at line 72 of file hwxfsleep.c.

◆ EXPORT_ACPI_INTERFACES

#define EXPORT_ACPI_INTERFACES

Definition at line 44 of file hwxfsleep.c.

Function Documentation

◆ AcpiEnterSleepState()

ACPI_STATUS AcpiEnterSleepState ( UINT8  SleepState)

Definition at line 431 of file hwxfsleep.c.

433 {
435 
436 
438 
439 
440  if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) ||
441  (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX))
442  {
443  ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X",
444  AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB));
446  }
447 
450 }
#define AE_AML_OPERAND_VALUE
Definition: acexcep.h:183
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_SLEEP_TYPE_MAX
Definition: actypes.h:642
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_SLEEP_FUNCTION_ID
Definition: hwxfsleep.c:71
static ACPI_STATUS AcpiHwSleepDispatch(UINT8 SleepState, UINT32 FunctionId)
Definition: hwxfsleep.c:290
Status
Definition: gdiplustypes.h:24
#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
ACPI_STATUS AcpiEnterSleepState(UINT8 SleepState)
Definition: hwxfsleep.c:431

Referenced by acpi_suspend(), and acpi_system_suspend().

◆ AcpiEnterSleepStatePrep()

ACPI_STATUS AcpiEnterSleepStatePrep ( UINT8  SleepState)

Definition at line 347 of file hwxfsleep.c.

349 {
351  ACPI_OBJECT_LIST ArgList;
352  ACPI_OBJECT Arg;
353  UINT32 SstValue;
354 
355 
357 
358 
359  Status = AcpiGetSleepTypeData (SleepState,
360  &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB);
361  if (ACPI_FAILURE (Status))
362  {
364  }
365 
366  /* Execute the _PTS method (Prepare To Sleep) */
367 
368  ArgList.Count = 1;
369  ArgList.Pointer = &Arg;
370  Arg.Type = ACPI_TYPE_INTEGER;
371  Arg.Integer.Value = SleepState;
372 
375  {
377  }
378 
379  /* Setup the argument to the _SST method (System STatus) */
380 
381  switch (SleepState)
382  {
383  case ACPI_STATE_S0:
384 
385  SstValue = ACPI_SST_WORKING;
386  break;
387 
388  case ACPI_STATE_S1:
389  case ACPI_STATE_S2:
390  case ACPI_STATE_S3:
391 
392  SstValue = ACPI_SST_SLEEPING;
393  break;
394 
395  case ACPI_STATE_S4:
396 
397  SstValue = ACPI_SST_SLEEP_CONTEXT;
398  break;
399 
400  default:
401 
402  SstValue = ACPI_SST_INDICATOR_OFF; /* Default is off */
403  break;
404  }
405 
406  /*
407  * Set the system indicators to show the desired sleep state.
408  * _SST is an optional method (return no error if not found)
409  */
412 }
#define ACPI_TYPE_INTEGER
Definition: actypes.h:680
#define METHOD_PATHNAME__PTS
Definition: acnames.h:79
void AcpiHwExecuteSleepMethod(char *MethodPathname, UINT32 IntegerArgument)
Definition: hwesleep.c:67
UINT32 ACPI_STATUS
Definition: actypes.h:460
struct acpi_object::@601 Integer
ACPI_STATUS AcpiGetSleepTypeData(UINT8 SleepState, UINT8 *SleepTypeA, UINT8 *SleepTypeB)
Definition: hwxface.c:411
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
unsigned int UINT32
#define ACPI_SST_WORKING
Definition: achware.h:51
smooth NULL
Definition: ftsmooth.c:416
#define ACPI_STATE_S4
Definition: actypes.h:620
#define ACPI_SST_SLEEPING
Definition: achware.h:53
#define AE_NOT_FOUND
Definition: acexcep.h:113
#define ACPI_SST_SLEEP_CONTEXT
Definition: achware.h:54
#define ACPI_STATE_S0
Definition: actypes.h:616
#define METHOD_PATHNAME__SST
Definition: acnames.h:80
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
ACPI_STATUS AcpiEvaluateObject(ACPI_HANDLE Handle, ACPI_STRING Pathname, ACPI_OBJECT_LIST *ExternalParams, ACPI_BUFFER *ReturnBuffer)
Definition: nsxfeval.c:217
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_STATE_S1
Definition: actypes.h:617
#define ACPI_STATE_S2
Definition: actypes.h:618
ACPI_OBJECT * Pointer
Definition: actypes.h:1020
ACPI_OBJECT_TYPE Type
Definition: actypes.h:961
#define ACPI_STATE_S3
Definition: actypes.h:619
#define ACPI_SST_INDICATOR_OFF
Definition: achware.h:50
#define AE_OK
Definition: acexcep.h:97
ACPI_STATUS AcpiEnterSleepStatePrep(UINT8 SleepState)
Definition: hwxfsleep.c:347

Referenced by acpi_suspend().

◆ AcpiEnterSleepStateS4bios()

ACPI_STATUS AcpiEnterSleepStateS4bios ( void  )

Definition at line 207 of file hwxfsleep.c.

209 {
210  UINT32 InValue;
212 
213 
215 
216 
217  /* Clear the wake status bit (PM1) */
218 
220  if (ACPI_FAILURE (Status))
221  {
223  }
224 
226  if (ACPI_FAILURE (Status))
227  {
229  }
230 
231  /*
232  * 1) Disable all GPEs
233  * 2) Enable all wakeup GPEs
234  */
236  if (ACPI_FAILURE (Status))
237  {
239  }
240  AcpiGbl_SystemAwakeAndRunning = FALSE;
241 
243  if (ACPI_FAILURE (Status))
244  {
246  }
247 
249 
250  Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand,
251  (UINT32) AcpiGbl_FADT.S4BiosRequest, 8);
252  if (ACPI_FAILURE (Status))
253  {
255  }
256 
257  do {
260  if (ACPI_FAILURE (Status))
261  {
263  }
264 
265  } while (!InValue);
266 
268 }
ACPI_STATUS AcpiHwDisableAllGpes(void)
Definition: hwgpe.c:595
ACPI_STATUS AcpiHwClearAcpiStatus(void)
Definition: hwregs.c:452
ACPI_STATUS AcpiWriteBitRegister(UINT32 RegisterId, UINT32 Value)
Definition: hwxface.c:282
#define ACPI_CLEAR_STATUS
Definition: actypes.h:930
void AcpiOsStall(UINT32 Microseconds)
Definition: osl.c:264
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
unsigned int UINT32
ACPI_STATUS AcpiHwWritePort(ACPI_IO_ADDRESS Address, UINT32 Value, UINT32 Width)
Definition: hwvalid.c:312
#define ACPI_FLUSH_CPU_CACHE()
Definition: accygwin.h:53
#define ACPI_USEC_PER_MSEC
Definition: actypes.h:470
ACPI_STATUS AcpiHwEnableAllWakeupGpes(void)
Definition: hwgpe.c:649
ACPI_STATUS AcpiReadBitRegister(UINT32 RegisterId, UINT32 *ReturnValue)
Definition: hwxface.c:213
Status
Definition: gdiplustypes.h:24
#define ACPI_BITREG_WAKE_STATUS
Definition: actypes.h:900
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_STATUS AcpiEnterSleepStateS4bios(void)
Definition: hwxfsleep.c:207
#define AE_OK
Definition: acexcep.h:97

◆ AcpiHwSetFirmwareWakingVector()

static ACPI_STATUS AcpiHwSetFirmwareWakingVector ( ACPI_TABLE_FACS Facs,
ACPI_PHYSICAL_ADDRESS  PhysicalAddress,
ACPI_PHYSICAL_ADDRESS  PhysicalAddress64 
)
static

Definition at line 118 of file hwxfsleep.c.

122 {
124 
125 
126  /*
127  * According to the ACPI specification 2.0c and later, the 64-bit
128  * waking vector should be cleared and the 32-bit waking vector should
129  * be used, unless we want the wake-up code to be called by the BIOS in
130  * Protected Mode. Some systems (for example HP dv5-1004nr) are known
131  * to fail to resume if the 64-bit vector is used.
132  */
133 
134  /* Set the 32-bit vector */
135 
137 
138  if (Facs->Length > 32)
139  {
140  if (Facs->Version >= 1)
141  {
142  /* Set the 64-bit vector */
143 
144  Facs->XFirmwareWakingVector = PhysicalAddress64;
145  }
146  else
147  {
148  /* Clear the 64-bit vector if it exists */
149 
150  Facs->XFirmwareWakingVector = 0;
151  }
152  }
153 
155 }
unsigned int UINT32
UINT32 Length
Definition: actbl.h:221
UINT8 Version
Definition: actbl.h:227
static ACPI_STATUS AcpiHwSetFirmwareWakingVector(ACPI_TABLE_FACS *Facs, ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_PHYSICAL_ADDRESS PhysicalAddress64)
Definition: hwxfsleep.c:118
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1061
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
UINT64 XFirmwareWakingVector
Definition: actbl.h:226
#define AE_OK
Definition: acexcep.h:97
UINT32 FirmwareWakingVector
Definition: actbl.h:223

Referenced by AcpiSetFirmwareWakingVector().

◆ AcpiHwSleepDispatch()

static ACPI_STATUS AcpiHwSleepDispatch ( UINT8  SleepState,
UINT32  FunctionId 
)
static

Definition at line 290 of file hwxfsleep.c.

293 {
295  ACPI_SLEEP_FUNCTIONS *SleepFunctions = &AcpiSleepDispatch[FunctionId];
296 
297 
298 #if (!ACPI_REDUCED_HARDWARE)
299  /*
300  * If the Hardware Reduced flag is set (from the FADT), we must
301  * use the extended sleep registers (FADT). Note: As per the ACPI
302  * specification, these extended registers are to be used for HW-reduced
303  * platforms only. They are not general-purpose replacements for the
304  * legacy PM register sleep support.
305  */
306  if (AcpiGbl_ReducedHardware)
307  {
308  Status = SleepFunctions->ExtendedFunction (SleepState);
309  }
310  else
311  {
312  /* Legacy sleep */
313 
314  Status = SleepFunctions->LegacyFunction (SleepState);
315  }
316 
317  return (Status);
318 
319 #else
320  /*
321  * For the case where reduced-hardware-only code is being generated,
322  * we know that only the extended sleep registers are available
323  */
324  Status = SleepFunctions->ExtendedFunction (SleepState);
325  return (Status);
326 
327 #endif /* !ACPI_REDUCED_HARDWARE */
328 }
static ACPI_SLEEP_FUNCTIONS AcpiSleepDispatch[]
Definition: hwxfsleep.c:77
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_SLEEP_FUNCTION LegacyFunction
Definition: actypes.h:945
ACPI_SLEEP_FUNCTION ExtendedFunction
Definition: actypes.h:946
Status
Definition: gdiplustypes.h:24

Referenced by AcpiEnterSleepState(), AcpiLeaveSleepState(), and AcpiLeaveSleepStatePrep().

◆ AcpiLeaveSleepState()

ACPI_STATUS AcpiLeaveSleepState ( UINT8  SleepState)

Definition at line 501 of file hwxfsleep.c.

503 {
505 
506 
508 
509 
512 }
#define ACPI_WAKE_FUNCTION_ID
Definition: hwxfsleep.c:73
UINT32 ACPI_STATUS
Definition: actypes.h:460
static ACPI_STATUS AcpiHwSleepDispatch(UINT8 SleepState, UINT32 FunctionId)
Definition: hwxfsleep.c:290
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 AcpiLeaveSleepState(UINT8 SleepState)
Definition: hwxfsleep.c:501

Referenced by acpi_suspend().

◆ AcpiLeaveSleepStatePrep()

ACPI_STATUS AcpiLeaveSleepStatePrep ( UINT8  SleepState)

Definition at line 471 of file hwxfsleep.c.

473 {
475 
476 
478 
479 
482 }
UINT32 ACPI_STATUS
Definition: actypes.h:460
static ACPI_STATUS AcpiHwSleepDispatch(UINT8 SleepState, UINT32 FunctionId)
Definition: hwxfsleep.c:290
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 AcpiLeaveSleepStatePrep(UINT8 SleepState)
Definition: hwxfsleep.c:471
#define ACPI_WAKE_PREP_FUNCTION_ID
Definition: hwxfsleep.c:72

◆ AcpiSetFirmwareWakingVector()

ACPI_STATUS AcpiSetFirmwareWakingVector ( ACPI_PHYSICAL_ADDRESS  PhysicalAddress,
ACPI_PHYSICAL_ADDRESS  PhysicalAddress64 
)

Definition at line 174 of file hwxfsleep.c.

177 {
178 
180 
181  if (AcpiGbl_FACS)
182  {
183  (void) AcpiHwSetFirmwareWakingVector (AcpiGbl_FACS,
184  PhysicalAddress, PhysicalAddress64);
185  }
186 
188 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
ACPI_STATUS AcpiSetFirmwareWakingVector(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_PHYSICAL_ADDRESS PhysicalAddress64)
Definition: hwxfsleep.c:174
static ACPI_STATUS AcpiHwSetFirmwareWakingVector(ACPI_TABLE_FACS *Facs, ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_PHYSICAL_ADDRESS PhysicalAddress64)
Definition: hwxfsleep.c:118
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1061
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define AE_OK
Definition: acexcep.h:97

Referenced by acpi_suspend().

Variable Documentation

◆ AcpiSleepDispatch

ACPI_SLEEP_FUNCTIONS AcpiSleepDispatch[]
static
Initial value:
=
{
{ACPI_STRUCT_INIT (LegacyFunction,
ACPI_STRUCT_INIT (ExtendedFunction,
{ACPI_STRUCT_INIT (LegacyFunction,
ACPI_STRUCT_INIT (ExtendedFunction,
{ACPI_STRUCT_INIT (LegacyFunction,
ACPI_STRUCT_INIT (ExtendedFunction,
}
ACPI_STATUS AcpiHwLegacySleep(UINT8 SleepState)
Definition: hwsleep.c:67
ACPI_STATUS AcpiHwLegacyWake(UINT8 SleepState)
Definition: hwsleep.c:300
ACPI_STATUS AcpiHwLegacyWakePrep(UINT8 SleepState)
Definition: hwsleep.c:231
#define ACPI_HW_OPTIONAL_FUNCTION(addr)
Definition: acmacros.h:483
#define ACPI_STRUCT_INIT(field, value)
Definition: acenv.h:314
ACPI_STATUS AcpiHwExtendedWake(UINT8 SleepState)
Definition: hwesleep.c:243
ACPI_STATUS AcpiHwExtendedWakePrep(UINT8 SleepState)
Definition: hwesleep.c:204
ACPI_STATUS AcpiHwExtendedSleep(UINT8 SleepState)
Definition: hwesleep.c:112

Definition at line 77 of file hwxfsleep.c.

Referenced by AcpiHwSleepDispatch().