/** @file\r
- CPU Exception Hanlder Library common functions.\r
+ CPU Exception Handler Library common functions.\r
\r
- Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2012 - 2014, 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
#include "CpuExceptionCommon.h"\r
\r
//\r
-// Error code flag indicating whether or not an error code will be \r
+// Error code flag indicating whether or not an error code will be\r
// pushed on the stack if an exception occurs.\r
//\r
// 1 means an error code will be pushed, otherwise 0\r
//\r
-UINT32 mErrorCodeFlag = 0x00027d00;\r
+CONST UINT32 mErrorCodeFlag = 0x00027d00;\r
+RESERVED_VECTORS_DATA *mReservedVectors = NULL;\r
\r
//\r
// Define the maximum message length \r
/**\r
Find and display image base address and return image base and its entry point.\r
\r
- @return EFI_SUCCESS Image base address.\r
- @return 0 Image header cannot be found.\r
+ @param CurrentEip Current instruction pointer.\r
+ @param EntryPoint Return module entry point if module header is found.\r
+ \r
+ @return !0 Image base address.\r
+ @return 0 Image header cannot be found.\r
**/\r
UINTN \r
FindModuleImageBase (\r
// DOS image header is present, so read the PE header after the DOS image header.\r
//\r
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));\r
- if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {\r
- //\r
- // It's PE image.\r
- //\r
- InternalPrintMessage ("!!!! Find PE image ");\r
- *EntryPoint = (UINTN)Pe32Data + (UINTN)(Hdr.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff);\r
- break;\r
+ //\r
+ // Make sure PE header address does not overflow and is less than the initial address.\r
+ //\r
+ if (((UINTN)Hdr.Pe32 > Pe32Data) && ((UINTN)Hdr.Pe32 < CurrentEip)) {\r
+ if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {\r
+ //\r
+ // It's PE image.\r
+ //\r
+ InternalPrintMessage ("!!!! Find PE image ");\r
+ *EntryPoint = (UINTN)Pe32Data + (UINTN)(Hdr.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff);\r
+ break;\r
+ }\r
}\r
} else {\r
//\r
return Pe32Data;\r
}\r
\r
+/**\r
+ Read and save reserved vector information\r
+ \r
+ @param[in] VectorInfo Pointer to reserved vector list.\r
+ @param[out] ReservedVector Pointer to reserved vector data buffer.\r
+ @param[in] VectorCount Vector number to be updated.\r
+ \r
+ @return EFI_SUCCESS Read and save vector info successfully.\r
+ @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+ReadAndVerifyVectorInfo (\r
+ IN EFI_VECTOR_HANDOFF_INFO *VectorInfo,\r
+ OUT RESERVED_VECTORS_DATA *ReservedVector,\r
+ IN UINTN VectorCount\r
+ )\r
+{\r
+ while (VectorInfo->Attribute != EFI_VECTOR_HANDOFF_LAST_ENTRY) {\r
+ if (VectorInfo->Attribute > EFI_VECTOR_HANDOFF_HOOK_AFTER) {\r
+ //\r
+ // If vector attrubute is invalid\r
+ //\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ if (VectorInfo->VectorNumber < VectorCount) {\r
+ ReservedVector[VectorInfo->VectorNumber].Attribute = VectorInfo->Attribute;\r
+ }\r
+ VectorInfo ++;\r
+ }\r
+ return EFI_SUCCESS;\r
+}
\ No newline at end of file