This is an implementation of the ACPI S3 Save protocol. This is defined in\r
S3 boot path specification 0.9.\r
\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions\r
ASSERT (AcpiS3Context->BootScriptStackBase != 0);\r
\r
//\r
- // Allocate a code buffer < 4G for S3 debug to load external code\r
+ // Allocate a code buffer < 4G for S3 debug to load external code, set invalid code instructions in it.\r
//\r
AcpiS3Context->S3DebugBufferAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateAcpiNvsMemoryBelow4G (EFI_PAGE_SIZE);\r
+ SetMem ((VOID *)(UINTN)AcpiS3Context->S3DebugBufferAddress, EFI_PAGE_SIZE, 0xff);\r
\r
DEBUG((EFI_D_INFO, "AcpiS3Context: AcpiFacsTable is 0x%8x\n", AcpiS3Context->AcpiFacsTable));\r
DEBUG((EFI_D_INFO, "AcpiS3Context: IdtrProfile is 0x%8x\n", AcpiS3Context->IdtrProfile));\r
// Restore IDT for debug\r
//\r
IdtDescriptor = (IA32_DESCRIPTOR *) (UINTN) (AcpiS3Context->IdtrProfile);\r
- IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));\r
- S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);\r
+ AsmWriteIdtr (IdtDescriptor);\r
\r
- IdtEntry->OffsetLow = (UINT16)S3DebugBuffer;\r
- IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();\r
- IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;\r
- IdtEntry->OffsetHigh = (UINT16)(S3DebugBuffer >> 16);\r
+ //\r
+ // Setup the default CPU exception handlers\r
+ //\r
+ SetupCpuExceptionHandlers ();\r
\r
- AsmWriteIdtr (IdtDescriptor);\r
+ DEBUG_CODE (\r
+ //\r
+ // Update IDT entry INT3 if the instruction is valid in it\r
+ //\r
+ S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);\r
+ if (*(UINTN *)S3DebugBuffer != (UINTN) -1) {\r
+ IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));\r
+ IdtEntry->OffsetLow = (UINT16)S3DebugBuffer;\r
+ IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();;\r
+ IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;\r
+ IdtEntry->OffsetHigh = (UINT16)(S3DebugBuffer >> 16);\r
+ }\r
+ );\r
}\r
\r
//\r
SetupCpuExceptionHandlers ();\r
\r
- //\r
- // Update IDT entry INT3\r
- //\r
- IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));\r
- S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);\r
-\r
- IdtEntry->Offset15To0 = (UINT16)S3DebugBuffer;\r
- IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();\r
- IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;\r
- IdtEntry->Offset31To16 = (UINT16)(S3DebugBuffer >> 16);\r
- IdtEntry->Offset63To32 = (UINT32)(S3DebugBuffer >> 32);\r
- IdtEntry->Reserved = 0;\r
+ DEBUG_CODE (\r
+ //\r
+ // Update IDT entry INT3 if the instruction is valid in it\r
+ //\r
+ S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);\r
+ if (*(UINTN *)S3DebugBuffer != (UINTN) -1) {\r
+ IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));\r
+ IdtEntry->Offset15To0 = (UINT16)S3DebugBuffer;\r
+ IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();\r
+ IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;\r
+ IdtEntry->Offset31To16 = (UINT16)(S3DebugBuffer >> 16);\r
+ IdtEntry->Offset63To32 = (UINT32)(S3DebugBuffer >> 32);\r
+ IdtEntry->Reserved = 0;\r
+ }\r
+ );\r
\r
IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (14 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));\r
HookPageFaultHandler (IdtEntry);\r
-\r
- AsmWriteIdtr (IdtDescriptor);\r
}\r
\r
/**\r