#include <Library/DebugLib.h>\r
#include <Library/HobLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
\r
CONST UINTN mDoFarReturnFlag = 0;\r
\r
IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL\r
)\r
{\r
- return InitializeCpuExceptionHandlers (VectorInfo);\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // To avoid repeat initialization of default handlers, the caller should pass\r
+ // an extended init data with InitDefaultHandlers set to FALSE. There's no\r
+ // need to call this method to just initialize default handlers. Call non-ex\r
+ // version instead; or this method must be implemented as a simple wrapper of\r
+ // non-ex version of it, if this version has to be called.\r
+ //\r
+ if (InitData == NULL || InitData->Ia32.InitDefaultHandlers) {\r
+ Status = InitializeCpuExceptionHandlers (VectorInfo);\r
+ } else {\r
+ Status = EFI_SUCCESS;\r
+ }\r
+\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Initializing stack switch is only necessary for Stack Guard functionality.\r
+ //\r
+ if (PcdGetBool (PcdCpuStackGuard) && InitData != NULL) {\r
+ Status = ArchSetupExcpetionStack (InitData);\r
+ }\r
+ }\r
+\r
+ return Status;\r
}\r