summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/CapsulePei
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2012-03-15 05:20:41 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2012-03-15 05:20:41 +0000
commit1e172d6bbfeb75d3a5d9f0066eee97789fc617b7 (patch)
tree2c9b18b2dcee3c36b6c0a61a77124ce12adca80b /MdeModulePkg/Universal/CapsulePei
parentbf0f6c8321351303679d9bf020309c09c8c904eb (diff)
downloadedk2-1e172d6bbfeb75d3a5d9f0066eee97789fc617b7.tar.gz
edk2-1e172d6bbfeb75d3a5d9f0066eee97789fc617b7.tar.bz2
edk2-1e172d6bbfeb75d3a5d9f0066eee97789fc617b7.zip
1. Introduced CPU Exception Handler Library to provide the CPU exception handlers and add one NULL library instance.
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
Diffstat (limited to 'MdeModulePkg/Universal/CapsulePei')
-rw-r--r--MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf3
-rw-r--r--MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c34
2 files changed, 34 insertions, 3 deletions
diff --git a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
index b12d3e57e4..6242cc69d0 100644
--- a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
+++ b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
@@ -4,7 +4,7 @@
# The X64 entrypoint to process capsule in long mode.
# This module is built as X64.
#
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions
@@ -41,6 +41,7 @@
[LibraryClasses]
BaseLib
DebugLib
+ CpuExceptionHandlerLib
[Depex]
FALSE
diff --git a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
index a4e44a4f5e..fa29e3dbfb 100644
--- a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
+++ b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
@@ -1,7 +1,7 @@
/** @file
The X64 entrypoint is used to process capsule in long mode.
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -13,8 +13,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/CpuExceptionHandlerLib.h>
#include "CommonHeader.h"
+#define EXCEPTION_VECTOR_NUMBER 0x20
+
/**
The X64 entrypoint is used to process capsule in long mode then
return to 32-bit protected mode.
@@ -32,7 +36,28 @@ _ModuleEntryPoint (
SWITCH_64_TO_32_CONTEXT *ReturnContext
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ IA32_DESCRIPTOR Ia32Idtr;
+ IA32_DESCRIPTOR X64Idtr;
+ IA32_IDT_GATE_DESCRIPTOR IdtEntryTable[EXCEPTION_VECTOR_NUMBER];
+
+ //
+ // Save the IA32 IDT Descriptor
+ //
+ AsmReadIdtr ((IA32_DESCRIPTOR *) &Ia32Idtr);
+
+ //
+ // Setup X64 IDT table
+ //
+ ZeroMem (IdtEntryTable, sizeof (IA32_IDT_GATE_DESCRIPTOR) * EXCEPTION_VECTOR_NUMBER);
+ X64Idtr.Base = (UINTN) IdtEntryTable;
+ X64Idtr.Limit = (UINT16) (sizeof (IA32_IDT_GATE_DESCRIPTOR) * EXCEPTION_VECTOR_NUMBER - 1);
+ AsmWriteIdtr ((IA32_DESCRIPTOR *) &X64Idtr);
+
+ //
+ // Setup the default CPU exception handlers
+ //
+ SetupCpuExceptionHandlers ();
//
// Call CapsuleDataCoalesce to process capsule.
@@ -47,6 +72,11 @@ _ModuleEntryPoint (
ReturnContext->ReturnStatus = Status;
//
+ // Restore IA32 IDT table
+ //
+ AsmWriteIdtr ((IA32_DESCRIPTOR *) &Ia32Idtr);
+
+ //
// Finish to coalesce capsule, and return to 32-bit mode.
//
AsmDisablePaging64 (