summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Li <lichao@loongson.cn>2024-12-18 11:27:10 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-12-23 03:18:13 +0000
commit2ece0790f7c23292bb29a0f8008d7fac947852ea (patch)
tree114286704a1749e37cb59f67a95bc850d39f56d1
parent0fdffb71df7c99301c6430a95af207159cbe9655 (diff)
downloadedk2-2ece0790f7c23292bb29a0f8008d7fac947852ea.tar.gz
UefiCpuPkg: Add dump interrupt type on LoongArch64
If the exception type is INT, we need to know which interrupt could not be handled, so we added a method to dump them. Cc: Ray Ni <ray.ni@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Zhiguang Liu <zhiguang.liu@intel.com> Cc: Dun Tan <dun.tan@intel.com> Cc: Rahul Kumar <rahul1.kumar@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Signed-off-by: Chao Li <lichao@loongson.cn>
-rw-r--r--UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.c36
-rw-r--r--UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.h14
-rw-r--r--UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ArchExceptionHandler.c11
3 files changed, 61 insertions, 0 deletions
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.c
index 801c8393e8..fd30ce15ce 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.c
@@ -43,8 +43,24 @@ CONST CHAR8 *mExceptionNameStr[] = {
"#GCXC - Guest CSR Software/Hardware Change exception",
"#TBR - TLB refill exception" // !!! NOTICE: Because the TLB refill exception is not instructed in ECODE, so the TLB refill exception must be the last one!
};
+CONST CHAR8 *mInterruptNameStr[] = {
+ "#SIP0 - Software interrupt 0",
+ "#SIP1 - Software interrupt 1",
+ "#IP0 - Hardware interrupt 0",
+ "#IP1 - Hardware interrupt 1",
+ "#IP2 - Hardware interrupt 2",
+ "#IP3 - Hardware interrupt 3",
+ "#IP4 - Hardware interrupt 4",
+ "#IP5 - Hardware interrupt 5",
+ "#IP6 - Hardware interrupt 6",
+ "#IP7 - Hardware interrupt 7",
+ "#PMC - Performance counter overflow interrupt",
+ "#TIMER - Timer interrupt",
+ "#IPI - Inter-Processor interrupt"
+};
INTN mExceptionKnownNameNum = (sizeof (mExceptionNameStr) / sizeof (CHAR8 *));
+INTN mInterruptKnownNameNum = (sizeof (mInterruptNameStr) / sizeof (CHAR8 *));
/**
Get ASCII format string exception name by exception type.
@@ -67,6 +83,26 @@ GetExceptionNameStr (
}
/**
+ Get ASCII format string interrupt name by exception type.
+
+ @param InterruptType Interrupt type.
+
+ @return ASCII format string interrupt name.
+
+**/
+CONST CHAR8 *
+GetInterruptNameStr (
+ IN EFI_EXCEPTION_TYPE InterruptType
+ )
+{
+ if ((UINTN)InterruptType < mInterruptKnownNameNum) {
+ return mInterruptNameStr[InterruptType];
+ } else {
+ return mExceptionReservedStr;
+ }
+}
+
+/**
Prints a message to the serial port.
@param Format Format string for the message to print.
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.h b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.h
index 6b65001738..a8c1e7b10c 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.h
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/ExceptionCommon.h
@@ -13,6 +13,7 @@
#define MAX_DEBUG_MESSAGE_LENGTH 0x100
extern INTN mExceptionKnownNameNum;
+extern INTN mInterruptKnownNameNum;
/**
Get ASCII format string exception name by exception type.
@@ -28,6 +29,19 @@ GetExceptionNameStr (
);
/**
+ Get ASCII format string interrupt name by exception type.
+
+ @param InterruptType Interrupt type.
+
+ @return ASCII format string interrupt name.
+
+**/
+CONST CHAR8 *
+GetInterruptNameStr (
+ IN EFI_EXCEPTION_TYPE InterruptType
+ );
+
+/**
Prints a message to the serial port.
@param[in] Format Format string for the message to print.
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ArchExceptionHandler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ArchExceptionHandler.c
index ea299475f5..56891bcd3a 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ArchExceptionHandler.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ArchExceptionHandler.c
@@ -96,6 +96,17 @@ DumpCpuContext (
);
//
+ // Dump interrupt type if the exception type is INT.
+ //
+ if (ExceptionType == EXCEPT_LOONGARCH_INT) {
+ InternalPrintMessage (
+ "\n!!!! Unhandled interrupt Type - %02x(%a) !!!!\n",
+ GetInterruptType (SystemContext),
+ GetInterruptNameStr (GetInterruptType (SystemContext))
+ );
+ }
+
+ //
// Dump TLB refill ERA and BADV
//
if (ExceptionType == (mExceptionKnownNameNum - 1)) {