* [PATCH 3/3] MdePkg/ReportStatusCodeLib: Add macros to identify status codes
2023-07-06 2:48 [PATCH 0/3] Small SMM status code handler fixes Isaac Oram
2023-07-06 2:48 ` [PATCH 1/3] MdeModulePkg/StatusCodeHandlerSmm: Remove unused code Isaac Oram
2023-07-06 2:48 ` [PATCH 2/3] MdeModulePkg/StatusCodeHandlerSmm: Clarify ASSERT source Isaac Oram
@ 2023-07-06 2:48 ` Isaac Oram
2 siblings, 0 replies; 4+ messages in thread
From: Isaac Oram @ 2023-07-06 2:48 UTC (permalink / raw)
To: devel; +Cc: Isaac Oram, Michael D Kinney, Liming Gao, Zhiguang Liu
Add macros that make it easier to determine if a status code
is an error, progress, or debug code.
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
---
.../Include/Guid/MemoryStatusCodeRecord.h | 2 +-
MdePkg/Include/Library/ReportStatusCodeLib.h | 61 +++++++++++--------
2 files changed, 35 insertions(+), 28 deletions(-)
diff --git a/MdeModulePkg/Include/Guid/MemoryStatusCodeRecord.h b/MdeModulePkg/Include/Guid/MemoryStatusCodeRecord.h
index a924c592c9..5e01600891 100644
--- a/MdeModulePkg/Include/Guid/MemoryStatusCodeRecord.h
+++ b/MdeModulePkg/Include/Guid/MemoryStatusCodeRecord.h
@@ -56,7 +56,7 @@ typedef struct {
///
typedef struct {
///
- /// The index pointing to the last recored being stored.
+ /// The index pointing to the last record being stored.
///
UINT32 RecordIndex;
///
diff --git a/MdePkg/Include/Library/ReportStatusCodeLib.h b/MdePkg/Include/Library/ReportStatusCodeLib.h
index 3763e69928..4b6647d91d 100644
--- a/MdePkg/Include/Library/ReportStatusCodeLib.h
+++ b/MdePkg/Include/Library/ReportStatusCodeLib.h
@@ -20,6 +20,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED 0x00000002
#define REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED 0x00000004
+//
+// Helpers for parsing status codes
+//
+#define IS_ERROR_STATUS_CODE(Type) (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)
+#define IS_PROGRESS_STATUS_CODE(Type) (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE)
+#define IS_DEBUG_STATUS_CODE(Type) (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)
+
/**
Converts a status code to an 8-bit POST code value.
@@ -363,13 +370,13 @@ ReportDebugCodeEnabled (
@retval EFI_UNSUPPORTED Report status code is not supported.
**/
-#define REPORT_STATUS_CODE(Type, Value) \
- (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
- ReportStatusCode(Type,Value) : \
- (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
- ReportStatusCode(Type,Value) : \
- (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
- ReportStatusCode(Type,Value) : \
+#define REPORT_STATUS_CODE(Type, Value) \
+ (ReportProgressCodeEnabled () && IS_PROGRESS_STATUS_CODE (Type)) ? \
+ ReportStatusCode (Type, Value) : \
+ (ReportErrorCodeEnabled () && IS_ERROR_STATUS_CODE (Type)) ? \
+ ReportStatusCode (Type, Value) : \
+ (ReportDebugCodeEnabled () && IS_DEBUG_STATUS_CODE (Type)) ? \
+ ReportStatusCode (Type, Value) : \
EFI_UNSUPPORTED
/**
@@ -393,13 +400,13 @@ ReportDebugCodeEnabled (
is already in progress.
**/
-#define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type, Value, DevicePathParameter) \
- (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
- ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
- (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
- ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
- (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
- ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
+#define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type, Value, DevicePathParameter) \
+ (ReportProgressCodeEnabled () && IS_PROGRESS_STATUS_CODE (Type)) ? \
+ ReportStatusCodeWithDevicePath (Type, Value, DevicePathParameter) : \
+ (ReportErrorCodeEnabled () && IS_ERROR_STATUS_CODE (Type)) ? \
+ ReportStatusCodeWithDevicePath (Type, Value, DevicePathParameter) : \
+ (ReportDebugCodeEnabled () && IS_DEBUG_STATUS_CODE (Type)) ? \
+ ReportStatusCodeWithDevicePath (Type, Value, DevicePathParameter) : \
EFI_UNSUPPORTED
/**
@@ -425,13 +432,13 @@ ReportDebugCodeEnabled (
is already in progress.
**/
-#define REPORT_STATUS_CODE_WITH_EXTENDED_DATA(Type, Value, ExtendedData, ExtendedDataSize) \
- (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
- ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
- (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
- ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
- (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
- ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
+#define REPORT_STATUS_CODE_WITH_EXTENDED_DATA(Type, Value, ExtendedData, ExtendedDataSize) \
+ (ReportProgressCodeEnabled () && IS_PROGRESS_STATUS_CODE (Type)) ? \
+ ReportStatusCodeWithExtendedData (Type, Value, ExtendedData, ExtendedDataSize) : \
+ (ReportErrorCodeEnabled () && IS_ERROR_STATUS_CODE (Type)) ? \
+ ReportStatusCodeWithExtendedData (Type, Value, ExtendedData, ExtendedDataSize) : \
+ (ReportDebugCodeEnabled () && IS_DEBUG_STATUS_CODE (Type)) ? \
+ ReportStatusCodeWithExtendedData (Type, Value, ExtendedData, ExtendedDataSize) : \
EFI_UNSUPPORTED
/**
@@ -463,12 +470,12 @@ ReportDebugCodeEnabled (
**/
#define REPORT_STATUS_CODE_EX(Type, Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, ExtendedDataSize) \
- (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
- ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
- (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
- ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
- (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
- ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
+ (ReportProgressCodeEnabled () && IS_PROGRESS_STATUS_CODE (Type)) ? \
+ ReportStatusCodeEx (Type, Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, ExtendedDataSize) : \
+ (ReportErrorCodeEnabled () && IS_ERROR_STATUS_CODE (Type)) ? \
+ ReportStatusCodeEx (Type, Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, ExtendedDataSize) : \
+ (ReportDebugCodeEnabled () && IS_DEBUG_STATUS_CODE (Type)) ? \
+ ReportStatusCodeEx (Type, Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, ExtendedDataSize) : \
EFI_UNSUPPORTED
#endif
--
2.40.0.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread