From 2ece0790f7c23292bb29a0f8008d7fac947852ea Mon Sep 17 00:00:00 2001 From: Chao Li Date: Wed, 18 Dec 2024 11:27:10 +0800 Subject: 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 Cc: Jiaxin Wu Cc: Zhiguang Liu Cc: Dun Tan Cc: Rahul Kumar Cc: Gerd Hoffmann Cc: Jiaxin Wu Signed-off-by: Chao Li --- .../LoongArch/ExceptionCommon.c | 36 ++++++++++++++++++++++ .../LoongArch/ExceptionCommon.h | 14 +++++++++ .../LoongArch/LoongArch64/ArchExceptionHandler.c | 11 +++++++ 3 files changed, 61 insertions(+) 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. @@ -66,6 +82,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. 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. @@ -27,6 +28,19 @@ GetExceptionNameStr ( IN EFI_EXCEPTION_TYPE ExceptionType ); +/** + 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. 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 @@ -95,6 +95,17 @@ DumpCpuContext ( GetExceptionNameStr (ExceptionType) ); + // + // 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 // -- cgit