/** @file\r
The X64 entrypoint is used to process capsule in long mode.\r
\r
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
**/\r
\r
#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/CpuExceptionHandlerLib.h>\r
#include "CommonHeader.h"\r
\r
+#define EXCEPTION_VECTOR_NUMBER 0x20\r
+\r
/**\r
The X64 entrypoint is used to process capsule in long mode then\r
return to 32-bit protected mode.\r
SWITCH_64_TO_32_CONTEXT *ReturnContext\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
+ IA32_DESCRIPTOR Ia32Idtr;\r
+ IA32_DESCRIPTOR X64Idtr;\r
+ IA32_IDT_GATE_DESCRIPTOR IdtEntryTable[EXCEPTION_VECTOR_NUMBER];\r
+\r
+ //\r
+ // Save the IA32 IDT Descriptor\r
+ //\r
+ AsmReadIdtr ((IA32_DESCRIPTOR *) &Ia32Idtr); \r
+\r
+ //\r
+ // Setup X64 IDT table\r
+ //\r
+ ZeroMem (IdtEntryTable, sizeof (IA32_IDT_GATE_DESCRIPTOR) * EXCEPTION_VECTOR_NUMBER);\r
+ X64Idtr.Base = (UINTN) IdtEntryTable;\r
+ X64Idtr.Limit = (UINT16) (sizeof (IA32_IDT_GATE_DESCRIPTOR) * EXCEPTION_VECTOR_NUMBER - 1);\r
+ AsmWriteIdtr ((IA32_DESCRIPTOR *) &X64Idtr); \r
+\r
+ //\r
+ // Setup the default CPU exception handlers\r
+ //\r
+ SetupCpuExceptionHandlers (); \r
\r
//\r
// Call CapsuleDataCoalesce to process capsule.\r
\r
ReturnContext->ReturnStatus = Status;\r
\r
+ //\r
+ // Restore IA32 IDT table\r
+ //\r
+ AsmWriteIdtr ((IA32_DESCRIPTOR *) &Ia32Idtr); \r
+ \r
//\r
// Finish to coalesce capsule, and return to 32-bit mode.\r
//\r