18.12.2012 Views

Advanced Configuration and Power Interface Specification

Advanced Configuration and Power Interface Specification

Advanced Configuration and Power Interface Specification

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

*<br />

* Intel Architecture SetSleepingState example<br />

*/<br />

ULONG<br />

SetSystemSleeping (<br />

IN ULONG NewState<br />

)<br />

{<br />

PROCESSOR_CONTEXT Context;<br />

ULONG <strong>Power</strong>Seqeunce;<br />

BOOLEAN FlushCaches;<br />

USHORT SlpTyp;<br />

<strong>Power</strong> <strong>and</strong> Performance Management<br />

// Required environment: Executing on the system boot<br />

// processor. All other processors stopped. Interrupts<br />

// disabled. All <strong>Power</strong> Resources (<strong>and</strong> devices) are in<br />

// corresponding device state to support NewState.<br />

// Get h/w attributes for this system state<br />

FlushCaches = SleepType[NewState].FlushCache;<br />

SlpTyp = SleepType[NewState].SlpTyp & SLP_TYP_MASK;<br />

_asm {<br />

lea eax, OsResumeContext<br />

push eax ; Build real mode h<strong>and</strong>ler the resume<br />

push offset sp50 ; context, with eip = sp50<br />

call SaveProcessorState<br />

mov eax, ResumeVector ; set firmware’s resume vector<br />

mov [eax], offset OsRealModeResumeCode<br />

mov edx, PM1a_STS ; Make sure wake status is clear<br />

mov ax, WAK_STS ; (cleared by asserting the bit<br />

out dx, ax ; in the status register)<br />

mov edx, PM1b_STS ;<br />

out dx, ax ;<br />

<strong>and</strong> eax, not SLP_TYP_MASK<br />

or eax, SlpTyp ; set SLP_TYP<br />

or ax, SLP_EN ; set SLP_EN<br />

cmp FlushCaches, 0<br />

jz short sp10 ; If needed, ensure no dirty data in<br />

376 Hewlett-Packard/Intel/Microsoft/Phoenix/Toshiba

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!