Added LoongArch exception handler into CpuExceptionHandlerLib.
Adjust the file order in INF of CpuExceptionHandlerLib with alphabetical
order.
Adjust files order in CpuExceptionHandlerLib INF in alphabetical order.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584
Cc: Eric Dong
Cc: Ray Ni
Cc: Rahul Kumar
Cc: Gerd Hoffmann
Signed-off-by: Chao Li
Co-authored-by: Baoqi Zhang
---
.../DxeCpuExceptionHandlerLib.inf | 34 +-
.../LoongArch/DxeExceptionLib.c | 198 ++
.../LoongArch/ExceptionCommon.c | 171
.../LoongArch/ExceptionCommon.h | 131 +++
.../LoongArch64/ArchExceptionHandler.c| 268 +
.../LoongArch64/ExceptionHandlerAsm.S | 366 ++
.../LoongArch/SecPeiExceptionLib.c| 102 +
.../SecPeiCpuExceptionHandlerLib.inf | 29 +-
UefiCpuPkg/UefiCpuPkg.dec | 5 +
9 files changed, 1283 insertions(+), 21 deletions(-)
create mode 100644
UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/DxeExceptionLib.c
create mode 100644
UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.c
create mode 100644
UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.h
create mode 100644
UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ArchExceptionHandler.c
create mode 100644
UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ExceptionHandlerAsm.S
create mode 100644
UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/SecPeiExceptionLib.c
diff --git
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
index fdbebadab9..f5bacbe2bc 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
@@ -18,25 +18,32 @@
#
# The following information is for reference only and not required by the
build tools.
#
-# VALID_ARCHITECTURES = IA32 X64
+# VALID_ARCHITECTURES = IA32 X64 LOONGARCH64
#
[Sources.Ia32]
- Ia32/ExceptionHandlerAsm.nasm
- Ia32/ExceptionTssEntryAsm.nasm
Ia32/ArchExceptionHandler.c
Ia32/ArchInterruptDefs.h
+ Ia32/ExceptionHandlerAsm.nasm
+ Ia32/ExceptionTssEntryAsm.nasm
[Sources.X64]
- X64/ExceptionHandlerAsm.nasm
X64/ArchExceptionHandler.c
X64/ArchInterruptDefs.h
+ X64/ExceptionHandlerAsm.nasm
-[Sources.common]
+[Sources.Ia32, Sources.X64]
CpuExceptionCommon.h
CpuExceptionCommon.c
- PeiDxeSmmCpuException.c
DxeException.c
+ PeiDxeSmmCpuException.c
+
+[Sources.LoongArch64]
+ LoongArch/DxeExceptionLib.c
+ LoongArch/ExceptionCommon.h
+ LoongArch/ExceptionCommon.c
+ LoongArch/LoongArch64/ArchExceptionHandler.c
+ LoongArch/LoongArch64/ExceptionHandlerAsm.S | GCC
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard
@@ -51,16 +58,19 @@
MdeModulePkg/MdeModulePkg.dec
UefiCpuPkg/UefiCpuPkg.dec
-[LibraryClasses]
+[LibraryClasses.common]
BaseLib
- SerialPortLib
+ CpuLib
+ DebugLib
+ MemoryAllocationLib
+ PeCoffGetEntryPointLib
PrintLib
+ SerialPortLib
SynchronizationLib
- LocalApicLib
- PeCoffGetEntryPointLib
- MemoryAllocationLib
- DebugLib
+
+[LibraryClasses.Ia32, LibraryClasses.X64]
CcExitLib
+ LocalApicLib
[BuildOptions]
XCODE:*_*_X64_NASM_FLAGS = -D NO_ABSOLUTE_RELOCS_IN_TEXT
diff --git
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/DxeExceptionLib.c
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/DxeExceptionLib.c
new file mode 100644
index 00..2c5d202b33
--- /dev/null
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/DxeExceptionLib.c
@@ -0,0 +1,198 @@
+/** @file DxeExceptionLib.c
+
+ LoongArch exception library implemenation for DXE modules.
+
+ Copyright (c) 2024, Loongson Technology Corporation Limited. All rights
reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "ExceptionCommon.h"
+
+EFI_EXCEPTION_CALLBACK ExternalInterruptHandler[MAX_LOONGARCH_INTERRUPT + 1]
= { 0 };
+EFI_EXCEPTION_CALLBACK ExceptionHandler[MAX_LOONGARCH_EXCEPTION + 1]
= { 0 };
+
+/**
+ Registers a function to be called from the processor interrupt or exception
handler.
+
+ This function registers and enables the handler specified by
InterruptHandler for a processor
+ interrupt or exception type specified by InterruptType. If InterruptHandler
is NULL, then the
+ handler for the processor interrupt or exception type specified by
InterruptType is uninstalled.
+ The installed handler is called once for each processor interrupt or
exception.
+
+ @param InterruptTypeA pointer to the processor's current interrupt
state. Set to TRUE if interrupts
+ are enabled and FALSE if interrupts are disabled.
+ @param