]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeSmmCpuException.c
Fix a bug about the iSCSI DHCP dependency issue.
[mirror_edk2.git] / UefiCpuPkg / Library / CpuExceptionHandlerLib / DxeSmmCpuException.c
1 /** @file
2 CPU Exception Library provides DXE/SMM CPU exception handler.
3
4 Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include <PiDxe.h>
16
17 #include "CpuExceptionCommon.h"
18 #include <Library/SynchronizationLib.h>
19
20 //
21 // Spinlock for CPU information display
22 //
23 SPIN_LOCK mDisplayMessageSpinLock;
24
25 //
26 // Image align size for DXE/SMM
27 //
28 CONST UINTN mImageAlignSize = SIZE_4KB;
29
30 /**
31 Common exception handler.
32
33 @param ExceptionType Exception type.
34 @param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
35 **/
36 VOID
37 EFIAPI
38 CommonExceptionHandler (
39 IN EFI_EXCEPTION_TYPE ExceptionType,
40 IN EFI_SYSTEM_CONTEXT SystemContext
41 )
42 {
43 //
44 // Get Spinlock to display CPU information
45 //
46 while (!AcquireSpinLockOrFail (&mDisplayMessageSpinLock)) {
47 CpuPause ();
48 }
49
50 //
51 // Display ExceptionType, CPU information and Image information
52 //
53 DumpCpuContent (ExceptionType, SystemContext);
54
55 //
56 // Release Spinlock
57 //
58 ReleaseSpinLock (&mDisplayMessageSpinLock);
59
60 //
61 // Enter a dead loop.
62 //
63 CpuDeadLoop ();
64 }
65
66 /**
67 Setup CPU exception handlers.
68
69 This API will setups the CPU exception handler to display CPU contents and run into
70 CpuDeadLoop().
71 Note: Before invoking this API, caller must allocate memory for IDT table and load
72 IDTR by AsmWriteIdtr().
73
74 **/
75 VOID
76 EFIAPI
77 SetupCpuExceptionHandlers (
78 IN VOID
79 )
80 {
81 InitializeSpinLock (&mDisplayMessageSpinLock);
82 InternalSetupCpuExceptionHandlers ();
83 }
84