]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/Library/CpuExceptionHandlerLib: Add exception type decoder
authorJeff Fan <jeff.fan@intel.com>
Wed, 8 Jul 2015 05:45:10 +0000 (05:45 +0000)
committervanjeff <vanjeff@Edk2>
Wed, 8 Jul 2015 05:45:10 +0000 (05:45 +0000)
Add exception type decoder to print exception name string beside print
exception type value. The exception names are from IA32 SDM.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17877 6f19259b-4bc3-4df7-8a09-765794883524

UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c
UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c

index f8cbcf080dbbe65ce4ee3c7c02ded18378121ae6..5d2816111fb9997dfb68819fa290272f6be9a066 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU Exception Handler Library common functions.\r
 \r
-  Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2012 - 2015, 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
@@ -24,15 +24,61 @@ CONST UINT32 mErrorCodeFlag             = 0x00027d00;
 RESERVED_VECTORS_DATA *mReservedVectors = NULL;\r
 \r
 //\r
-// Define the maximum message length \r
+// Define the maximum message length\r
 //\r
 #define MAX_DEBUG_MESSAGE_LENGTH  0x100\r
 \r
+CONST CHAR8 mExceptionReservedStr[] = "Reserved";\r
+CONST CHAR8 *mExceptionNameStr[] = {\r
+  "#DE - Divide Error",\r
+  "#DB - Debug",\r
+  "NMI Interrupt",\r
+  "#BP - Breakpoint",\r
+  "#OF - Overflow",\r
+  "#BR - BOUND Range Exceeded",\r
+  "#UD - Invalid Opcode",\r
+  "#NM - Device Not Available",\r
+  "#DF - Double Fault",\r
+  "Coprocessor Segment Overrun",\r
+  "#TS - Invalid TSS",\r
+  "#NP - Segment Not Present",\r
+  "#SS - Stack Fault Fault",\r
+  "#GP - General Protection",\r
+  "#PF - Page-Fault",\r
+  "Reserved",\r
+  "#MF - x87 FPU Floating-Point Error",\r
+  "#AC - Alignment Check",\r
+  "#MC - Machine-Check",\r
+  "#XM - SIMD floating-point",\r
+  "#VE - Virtualization"\r
+};\r
+\r
+#define EXCEPTION_KNOWN_NAME_NUM  (sizeof (mExceptionNameStr) / sizeof (CHAR8 *))\r
+\r
+/**\r
+  Get ASCII format string exception name by exception type.\r
+\r
+  @param ExceptionType  Exception type.\r
+\r
+  @return  ASCII format string exception name.\r
+**/\r
+CONST CHAR8 *\r
+GetExceptionNameStr (\r
+  IN EFI_EXCEPTION_TYPE          ExceptionType\r
+  )\r
+{\r
+  if ((UINTN) ExceptionType < EXCEPTION_KNOWN_NAME_NUM) {\r
+    return mExceptionNameStr[ExceptionType];\r
+  } else {\r
+    return mExceptionReservedStr;\r
+  }\r
+}\r
+\r
 /**\r
   Prints a message to the serial port.\r
 \r
   @param  Format      Format string for the message to print.\r
-  @param  ...         Variable argument list whose contents are accessed \r
+  @param  ...         Variable argument list whose contents are accessed\r
                       based on the format string specified by Format.\r
 \r
 **/\r
@@ -54,21 +100,21 @@ InternalPrintMessage (
   VA_END (Marker);\r
 \r
   //\r
-  // Send the print string to a Serial Port \r
+  // Send the print string to a Serial Port\r
   //\r
   SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));\r
 }\r
 \r
 /**\r
   Find and display image base address and return image base and its entry point.\r
-  \r
+\r
   @param CurrentEip      Current instruction pointer.\r
   @param EntryPoint      Return module entry point if module header is found.\r
-  \r
+\r
   @return !0     Image base address.\r
   @return 0      Image header cannot be found.\r
 **/\r
-UINTN \r
+UINTN\r
 FindModuleImageBase (\r
   IN  UINTN              CurrentEip,\r
   OUT UINTN              *EntryPoint\r
@@ -121,7 +167,7 @@ FindModuleImageBase (
 \r
     //\r
     // Not found the image base, check the previous aligned address\r
-    // \r
+    //\r
     Pe32Data -= mImageAlignSize;\r
   }\r
 \r
@@ -141,11 +187,11 @@ FindModuleImageBase (
 \r
 /**\r
   Read and save reserved vector information\r
-  \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
+\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
index efe77eb09f76f829d5bb69e1ea1387ea2dfc48a9..b28e9c574a65ec4a06ed24d9c1729f4b0b795e64 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Common header file for CPU Exception Handler Library.\r
 \r
-  Copyright (c) 2012 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2012 - 2015, 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
@@ -237,5 +237,17 @@ ReadAndVerifyVectorInfo (
   IN  UINTN                         VectorCount\r
   );\r
 \r
+/**\r
+  Get ASCII format string exception name by exception type.\r
+\r
+  @param ExceptionType  Exception type.\r
+\r
+  @return  ASCII format string exception name.\r
+**/\r
+CONST CHAR8 *\r
+GetExceptionNameStr (\r
+  IN EFI_EXCEPTION_TYPE          ExceptionType\r
+  );\r
+\r
 #endif\r
 \r
index 40cdedface31027fd5d6ff7a83038e8bf8afe084..7a183bf9a4fa836fb057882a5a8b4ac76d5ffb1c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   IA32 CPU Exception Handler functons.\r
 \r
-  Copyright (c) 2012 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2012 - 2015, 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
@@ -114,10 +114,12 @@ DumpCpuContent (
   UINTN                   EntryPoint;\r
 \r
   InternalPrintMessage (\r
-    "!!!! IA32 Exception Type - %08x    CPU Apic ID - %08x !!!!\n",\r
+    "!!!! IA32 Exception Type - %02x(%a)  CPU Apic ID - %08x !!!!\n",\r
     ExceptionType,\r
+    GetExceptionNameStr (ExceptionType),\r
     GetApicId ()\r
     );\r
+\r
   InternalPrintMessage (\r
     "EIP  - %08x, CS  - %08x, EFLAGS - %08x\n",\r
     SystemContext.SystemContextIa32->Eip,\r
index ee16ea856ad8a04b53f5ac7dfedbdf57aa53ab99..f711c3107be74cc152867fbd2b51f756b2db5ad1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   x64 CPU Exception Handler.\r
 \r
-  Copyright (c) 2012 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2012 - 2015, 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
@@ -118,10 +118,12 @@ DumpCpuContent (
   UINTN                   EntryPoint;\r
 \r
   InternalPrintMessage (\r
-    "!!!! X64 Exception Type - %016lx     CPU Apic ID - %08x !!!!\n",\r
+    "!!!! X64 Exception Type - %02x(%a)  CPU Apic ID - %08x !!!!\n",\r
     ExceptionType,\r
+    GetExceptionNameStr (ExceptionType),\r
     GetApicId ()\r
     );\r
+\r
   InternalPrintMessage (\r
     "RIP  - %016lx, CS  - %016lx, RFLAGS - %016lx\n",\r
     SystemContext.SystemContextX64->Rip,\r