]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Introduced CPU Exception Handler Library to provide the CPU exception handlers...
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 15 Mar 2012 05:20:41 +0000 (05:20 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 15 Mar 2012 05:20:41 +0000 (05:20 +0000)
2. Updated DXE Core, BootScriptExecutorDxe and CapsuleX64Pei to consume CPU Exception Library to setup the default CPU Exception handlers.

Signed-off-by: vanjeff
Reviewed-by: jyao1
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13097 6f19259b-4bc3-4df7-8a09-765794883524

13 files changed:
MdeModulePkg/Core/Dxe/DxeMain.h
MdeModulePkg/Core/Dxe/DxeMain.inf
MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
MdeModulePkg/Include/Library/CpuExceptionHandlerLib.h [new file with mode: 0644]
MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.c [new file with mode: 0644]
MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.inf [new file with mode: 0644]
MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/MdeModulePkg.dsc
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.h
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c

index cf65c1526b642158b0c1882d8f4d42698a6611fd..48a57df65016e2c87280100bfe509d9602eccaa1 100644 (file)
@@ -2,7 +2,7 @@
   The internal header file includes the common header files, defines\r
   internal structure and functions used by DxeCore module.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 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
@@ -87,6 +87,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/TimerLib.h>\r
 #include <Library/DxeServicesLib.h>\r
 #include <Library/DebugAgentLib.h>\r
+#include <Library/CpuExceptionHandlerLib.h>\r
 \r
 \r
 //\r
index 6bdab9058db4e8e94f401c0f8389783cc6fdc307..dda17aea04afc06b536eb785d7940f9625dd3f10 100644 (file)
@@ -2,7 +2,7 @@
 #  This is core module in DXE phase. It provides an implementation of DXE Core that is\r
 #  compliant with DXE CIS.  \r
 #  \r
-#  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2006 - 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
@@ -92,6 +92,7 @@
   TimerLib\r
   DxeServicesLib\r
   DebugAgentLib\r
+  CpuExceptionHandlerLib\r
 \r
 [Guids]\r
   gEfiEventMemoryMapChangeGuid                  ## CONSUMES ## Event\r
index 3d3c3ef6ff221bee296898f6513e918f9952bc4b..84a3583a6bcf60c13da1adf9fa9733b8798585b6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   DXE Core Main Entry Point\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 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
@@ -242,6 +242,11 @@ DxeMain (
   UINT64                        MemoryLength;\r
   PE_COFF_LOADER_IMAGE_CONTEXT  ImageContext;\r
 \r
+  //\r
+  // Setup the default exception handlers\r
+  //\r
+  SetupCpuExceptionHandlers ();\r
+  \r
   //\r
   // Initialize Debug Agent to support source level debug in DXE phase\r
   //\r
diff --git a/MdeModulePkg/Include/Library/CpuExceptionHandlerLib.h b/MdeModulePkg/Include/Library/CpuExceptionHandlerLib.h
new file mode 100644 (file)
index 0000000..6be32b2
--- /dev/null
@@ -0,0 +1,28 @@
+/** @file\r
+  CPU Exception library provides the CPU exception handler.\r
+\r
+  Copyright (c) 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
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __CPU_EXCEPTION_LIB_H__\r
+#define __CPU_EXCEPTION_LIB_H__\r
+\r
+/**\r
+  Setup CPU exception handlers.\r
\r
+**/\r
+VOID\r
+EFIAPI\r
+SetupCpuExceptionHandlers (\r
+  VOID\r
+  );\r
+\r
+#endif\r
diff --git a/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.c b/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.c
new file mode 100644 (file)
index 0000000..3dd9da8
--- /dev/null
@@ -0,0 +1,27 @@
+/** @file\r
+  CPU Exception Handler library implementition with empty functions.\r
+\r
+  Copyright (c) 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
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+/**\r
+  Setup CPU exception handlers.\r
\r
+**/\r
+VOID\r
+EFIAPI\r
+SetupCpuExceptionHandlers (\r
+  VOID\r
+  )\r
+{  \r
+}\r
+\r
diff --git a/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.inf b/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.inf
new file mode 100644 (file)
index 0000000..47e55fe
--- /dev/null
@@ -0,0 +1,35 @@
+## @file\r
+# Null instance of CPU Exception Handler Library with empty functions.\r
+#\r
+#  Copyright (c) 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 of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = CpuExceptionHandlerLibNull\r
+  FILE_GUID                      = 3175E6B9-4B01-496a-9A2B-64AF02D87E34\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = CpuExceptionHandlerLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  CpuExceptionHandlerLibNull.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
index b65e98841c368731de00965f306006e643b54c12..7facc063797d4d4f51d7333d7b6ead54cd2c683d 100644 (file)
@@ -4,7 +4,7 @@
 # It also provides the defintions(including PPIs/PROTOCOLs/GUIDs and library classes)\r
 # and libraries instances, which are used for those modules.\r
 #\r
-# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials are licensed and made available under \r
 # the terms and conditions of the BSD License that accompanies this distribution.  \r
 # The full text of the license may be found at\r
   #\r
   LockBoxLib|Include/Library/LockBoxLib.h\r
   \r
+  ##  @libraryclass  Provide the CPU exception handler.\r
+  #\r
+  CpuExceptionHandlerLib|Include/Library/CpuExceptionHandlerLib.h\r
+  \r
 [Guids]\r
   ## MdeModule package token space guid\r
   # Include/Guid/MdeModulePkgTokenSpace.h\r
index 215600dab7ee83b72eb221ee0e39b88791ca5e76..835f621b69ec1a6db20999336cc307c1c1f04578 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # EFI/PI Reference Module Package for All Architectures\r
 #\r
-# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 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 of the BSD License\r
@@ -89,6 +89,7 @@
   ResetSystemLib|MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.inf\r
   SmbusLib|MdePkg/Library/DxeSmbusLib/DxeSmbusLib.inf\r
   S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf\r
+  CpuExceptionHandlerLib|MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.inf\r
 \r
 [LibraryClasses.EBC.PEIM]\r
   IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf\r
   MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf\r
   MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf\r
   MdeModulePkg/Library/PeiDebugPrintHobLib/PeiDebugPrintHobLib.inf\r
+  MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.inf\r
 \r
   MdeModulePkg/Universal/CapsulePei/CapsulePei.inf\r
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
index 0869c9d775c0c0a8977c966362af90fb5067b7f6..592d010517cdfd49495b4a40d3527838ca31f3a1 100644 (file)
@@ -4,7 +4,7 @@
 # This is a standalone Boot Script Executor. Standalone means it does not\r
 # depends on any PEI or DXE service.\r
 #\r
-# Copyright (c) 2006 - 2010, 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 are\r
 # licensed and made available under the terms and conditions of the BSD License\r
@@ -68,6 +68,7 @@
   UefiLib\r
   DebugAgentLib\r
   LockBoxLib\r
+  CpuExceptionHandlerLib\r
 \r
 [Guids]\r
   gEfiBootScriptExecutorVariableGuid\r
index 6a97b7790e52b0f14e6b1e4791ce688be6f41344..8e4b328db76a059413759d5abc2702c81a265e93 100644 (file)
@@ -4,7 +4,7 @@
   This driver is dispatched by Dxe core and the driver will reload itself to ACPI NVS memory \r
   in the entry point. The functionality is to interpret and restore the S3 boot script \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 of the BSD License\r
@@ -36,6 +36,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiLib.h>\r
 #include <Library/DebugAgentLib.h>\r
 #include <Library/LockBoxLib.h>\r
+#include <Library/CpuExceptionHandlerLib.h>\r
 \r
 #include <Guid/AcpiS3Context.h>\r
 #include <Guid/BootScriptExecutorVariable.h>\r
index f70f2f986f1aa3df27757867d045ce59fe6f4932..975cf3a561757f5c1c8b034ca7b12b329e27d463 100644 (file)
@@ -3,7 +3,7 @@
 \r
   Set a IDT entry for interrupt vector 3 for debug purpose for x64 platform\r
 \r
-Copyright (c) 2006 - 2010, 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 of the BSD License\r
@@ -52,6 +52,16 @@ SetIdtEntry (
   // Restore IDT for debug\r
   //\r
   IdtDescriptor = (IA32_DESCRIPTOR *) (UINTN) (AcpiS3Context->IdtrProfile);\r
+  AsmWriteIdtr (IdtDescriptor);\r
+\r
+  //\r
+  // Setup the default CPU exception handlers\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
@@ -62,6 +72,5 @@ SetIdtEntry (
   IdtEntry->Offset63To32    = (UINT32)(S3DebugBuffer >> 32);\r
   IdtEntry->Reserved        = 0;\r
 \r
-  AsmWriteIdtr (IdtDescriptor);\r
 }\r
 \r
index b12d3e57e4b57ff1f70918fcbeb4e23a9a8c66c7..6242cc69d0680aaf2ffcc72a5fe69168d075b5ea 100644 (file)
@@ -4,7 +4,7 @@
 # The X64 entrypoint to process capsule in long mode.\r
 # This module is built as X64.\r
 #\r
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 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
@@ -41,6 +41,7 @@
 [LibraryClasses]\r
   BaseLib\r
   DebugLib\r
+  CpuExceptionHandlerLib\r
 \r
 [Depex]\r
   FALSE\r
index a4e44a4f5ef1964bf39963214ee322c663335821..fa29e3dbfb561a5187d3a197b1032abe7b69f9c1 100644 (file)
@@ -1,7 +1,7 @@
 /** @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
@@ -13,8 +13,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\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
@@ -32,7 +36,28 @@ _ModuleEntryPoint (
   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
@@ -46,6 +71,11 @@ _ModuleEntryPoint (
   \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