[edk2-devel] [PATCH] RedfishPkg/RedfishDebugLib: add new interfaces

Nickle Wang via groups.io posted 1 patch 9 months, 3 weeks ago
Failed in applying to current master (apply log)
RedfishPkg/Include/Library/RedfishDebugLib.h  |  33 +++++
.../Library/RedfishDebugLib/RedfishDebugLib.c | 113 ++++++++++++++++++
2 files changed, 146 insertions(+)
[edk2-devel] [PATCH] RedfishPkg/RedfishDebugLib: add new interfaces
Posted by Nickle Wang via groups.io 9 months, 3 weeks ago
Introduce DumpHiiStatementValue() and DumpRedfishValue() to
RedfishDebugLib. Application uses these functions to debug
print the value of HII_STATEMENT_VALUE and EDKII_REDFISH_VALUE.

Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
---
 RedfishPkg/Include/Library/RedfishDebugLib.h  |  33 +++++
 .../Library/RedfishDebugLib/RedfishDebugLib.c | 113 ++++++++++++++++++
 2 files changed, 146 insertions(+)

diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h b/RedfishPkg/Include/Library/RedfishDebugLib.h
index 73f1469ac62b..da7e0d0bc9fc 100644
--- a/RedfishPkg/Include/Library/RedfishDebugLib.h
+++ b/RedfishPkg/Include/Library/RedfishDebugLib.h
@@ -11,12 +11,45 @@
 #define REDFISH_DEBUG_LIB_H_
 
 #include <Uefi.h>
+#include <Library/HiiUtilityLib.h>
 #include <Library/JsonLib.h>
 #include <Library/RedfishLib.h>
 
+#include <Protocol/EdkIIRedfishPlatformConfig.h>
+
 #define DEBUG_REDFISH_NETWORK         DEBUG_MANAGEABILITY   ///< Debug error level for Redfish networking function
 #define DEBUG_REDFISH_HOST_INTERFACE  DEBUG_MANAGEABILITY   ///< Debug error level for Redfish networking function
 
+/**
+  Debug print the value of StatementValue.
+
+  @param[in]  ErrorLevel     DEBUG macro error level.
+  @param[in]  StatementValue The statement value to print.
+
+  @retval     EFI_SUCCESS            StatementValue is printed.
+  @retval     EFI_INVALID_PARAMETER  StatementValue is NULL.
+**/
+EFI_STATUS
+DumpHiiStatementValue (
+  IN UINTN                ErrorLevel,
+  IN HII_STATEMENT_VALUE  *StatementValue
+  );
+
+/**
+  Debug print the value of RedfishValue.
+
+  @param[in]  ErrorLevel     DEBUG macro error level.
+  @param[in]  RedfishValue   The statement value to print.
+
+  @retval     EFI_SUCCESS            RedfishValue is printed.
+  @retval     EFI_INVALID_PARAMETER  RedfishValue is NULL.
+**/
+EFI_STATUS
+DumpRedfishValue (
+  IN UINTN                ErrorLevel,
+  IN EDKII_REDFISH_VALUE  *RedfishValue
+  );
+
 /**
 
   This function dump the Json string in given error level.
diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
index 6f1d9de25e0a..0b2a9a5c4ec8 100644
--- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
+++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
@@ -22,6 +22,119 @@
 #define REDFISH_JSON_STRING_LENGTH  200
 #define REDFISH_JSON_OUTPUT_FORMAT  (EDKII_JSON_COMPACT | EDKII_JSON_INDENT(2))
 
+/**
+  Debug print the value of StatementValue.
+
+  @param[in]  ErrorLevel     DEBUG macro error level.
+  @param[in]  StatementValue The statement value to print.
+
+  @retval     EFI_SUCCESS            StatementValue is printed.
+  @retval     EFI_INVALID_PARAMETER  StatementValue is NULL.
+**/
+EFI_STATUS
+DumpHiiStatementValue (
+  IN UINTN                ErrorLevel,
+  IN HII_STATEMENT_VALUE  *StatementValue
+  )
+{
+  if (StatementValue == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  DEBUG ((ErrorLevel, "BufferValueType: 0x%x\n", StatementValue->BufferValueType));
+  DEBUG ((ErrorLevel, "BufferLen: 0x%x\n", StatementValue->BufferLen));
+  DEBUG ((ErrorLevel, "Buffer:    0x%p\n", StatementValue->Buffer));
+  DEBUG ((ErrorLevel, "Type:      0x%p\n", StatementValue->Type));
+
+  switch (StatementValue->Type) {
+    case EFI_IFR_TYPE_NUM_SIZE_8:
+      DEBUG ((ErrorLevel, "Value:     0x%x\n", StatementValue->Value.u8));
+      break;
+    case EFI_IFR_TYPE_NUM_SIZE_16:
+      DEBUG ((ErrorLevel, "Value:     0x%x\n", StatementValue->Value.u16));
+      break;
+    case EFI_IFR_TYPE_NUM_SIZE_32:
+      DEBUG ((ErrorLevel, "Value:     0x%x\n", StatementValue->Value.u32));
+      break;
+    case EFI_IFR_TYPE_NUM_SIZE_64:
+      DEBUG ((ErrorLevel, "Value:     0x%lx\n", StatementValue->Value.u64));
+      break;
+    case EFI_IFR_TYPE_BOOLEAN:
+      DEBUG ((ErrorLevel, "Value:     %a\n", (StatementValue->Value.b ? "true" : "false")));
+      break;
+    case EFI_IFR_TYPE_STRING:
+      DEBUG ((ErrorLevel, "Value:     0x%x\n", StatementValue->Value.string));
+      break;
+    case EFI_IFR_TYPE_TIME:
+    case EFI_IFR_TYPE_DATE:
+    default:
+      break;
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Debug print the value of RedfishValue.
+
+  @param[in]  ErrorLevel     DEBUG macro error level.
+  @param[in]  RedfishValue   The statement value to print.
+
+  @retval     EFI_SUCCESS            RedfishValue is printed.
+  @retval     EFI_INVALID_PARAMETER  RedfishValue is NULL.
+**/
+EFI_STATUS
+DumpRedfishValue (
+  IN UINTN                ErrorLevel,
+  IN EDKII_REDFISH_VALUE  *RedfishValue
+  )
+{
+  UINTN  Index;
+
+  if (RedfishValue == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  DEBUG ((ErrorLevel, "Type:       0x%x\n", RedfishValue->Type));
+  DEBUG ((ErrorLevel, "ArrayCount: 0x%x\n", RedfishValue->ArrayCount));
+
+  switch (RedfishValue->Type) {
+    case RedfishValueTypeInteger:
+      DEBUG ((ErrorLevel, "Value:      0x%x\n", RedfishValue->Value.Integer));
+      break;
+    case RedfishValueTypeBoolean:
+      DEBUG ((ErrorLevel, "Value:      %a\n", (RedfishValue->Value.Boolean ? "true" : "false")));
+      break;
+    case RedfishValueTypeString:
+      DEBUG ((ErrorLevel, "Value:      %a\n", RedfishValue->Value.Buffer));
+      break;
+    case RedfishValueTypeStringArray:
+      for (Index = 0; Index < RedfishValue->ArrayCount; Index++) {
+        DEBUG ((ErrorLevel, "Value[%d]:      %a\n", Index, RedfishValue->Value.StringArray[Index]));
+      }
+
+      break;
+    case RedfishValueTypeIntegerArray:
+      for (Index = 0; Index < RedfishValue->ArrayCount; Index++) {
+        DEBUG ((ErrorLevel, "Value[%d]:      0x%x\n", Index, RedfishValue->Value.IntegerArray[Index]));
+      }
+
+      break;
+    case RedfishValueTypeBooleanArray:
+      for (Index = 0; Index < RedfishValue->ArrayCount; Index++) {
+        DEBUG ((ErrorLevel, "Value[%d]:      %a\n", Index, (RedfishValue->Value.BooleanArray[Index] ? "true" : "false")));
+      }
+
+      break;
+    case RedfishValueTypeUnknown:
+    case RedfishValueTypeMax:
+    default:
+      break;
+  }
+
+  return EFI_SUCCESS;
+}
+
 /**
 
   This function dump the Json string in given error level.
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#106652): https://edk2.groups.io/g/devel/message/106652
Mute This Topic: https://groups.io/mt/99958452/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH] RedfishPkg/RedfishDebugLib: add new interfaces
Posted by Chang, Abner via groups.io 9 months, 3 weeks ago
[AMD Official Use Only - General]

Reviewed-by: Abner Chang <abner.chang@amd.com>

> -----Original Message-----
> From: Nickle Wang <nicklew@nvidia.com>
> Sent: Wednesday, July 5, 2023 10:50 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
> <igork@ami.com>
> Subject: [PATCH] RedfishPkg/RedfishDebugLib: add new interfaces
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Introduce DumpHiiStatementValue() and DumpRedfishValue() to
> RedfishDebugLib. Application uses these functions to debug
> print the value of HII_STATEMENT_VALUE and EDKII_REDFISH_VALUE.
>
> Signed-off-by: Nickle Wang <nicklew@nvidia.com>
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> ---
>  RedfishPkg/Include/Library/RedfishDebugLib.h  |  33 +++++
>  .../Library/RedfishDebugLib/RedfishDebugLib.c | 113 ++++++++++++++++++
>  2 files changed, 146 insertions(+)
>
> diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h
> b/RedfishPkg/Include/Library/RedfishDebugLib.h
> index 73f1469ac62b..da7e0d0bc9fc 100644
> --- a/RedfishPkg/Include/Library/RedfishDebugLib.h
> +++ b/RedfishPkg/Include/Library/RedfishDebugLib.h
> @@ -11,12 +11,45 @@
>  #define REDFISH_DEBUG_LIB_H_
>
>  #include <Uefi.h>
> +#include <Library/HiiUtilityLib.h>
>  #include <Library/JsonLib.h>
>  #include <Library/RedfishLib.h>
>
> +#include <Protocol/EdkIIRedfishPlatformConfig.h>
> +
>  #define DEBUG_REDFISH_NETWORK         DEBUG_MANAGEABILITY   ///<
> Debug error level for Redfish networking function
>  #define DEBUG_REDFISH_HOST_INTERFACE  DEBUG_MANAGEABILITY   ///<
> Debug error level for Redfish networking function
>
> +/**
> +  Debug print the value of StatementValue.
> +
> +  @param[in]  ErrorLevel     DEBUG macro error level.
> +  @param[in]  StatementValue The statement value to print.
> +
> +  @retval     EFI_SUCCESS            StatementValue is printed.
> +  @retval     EFI_INVALID_PARAMETER  StatementValue is NULL.
> +**/
> +EFI_STATUS
> +DumpHiiStatementValue (
> +  IN UINTN                ErrorLevel,
> +  IN HII_STATEMENT_VALUE  *StatementValue
> +  );
> +
> +/**
> +  Debug print the value of RedfishValue.
> +
> +  @param[in]  ErrorLevel     DEBUG macro error level.
> +  @param[in]  RedfishValue   The statement value to print.
> +
> +  @retval     EFI_SUCCESS            RedfishValue is printed.
> +  @retval     EFI_INVALID_PARAMETER  RedfishValue is NULL.
> +**/
> +EFI_STATUS
> +DumpRedfishValue (
> +  IN UINTN                ErrorLevel,
> +  IN EDKII_REDFISH_VALUE  *RedfishValue
> +  );
> +
>  /**
>
>    This function dump the Json string in given error level.
> diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
> b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
> index 6f1d9de25e0a..0b2a9a5c4ec8 100644
> --- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
> +++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
> @@ -22,6 +22,119 @@
>  #define REDFISH_JSON_STRING_LENGTH  200
>  #define REDFISH_JSON_OUTPUT_FORMAT  (EDKII_JSON_COMPACT |
> EDKII_JSON_INDENT(2))
>
> +/**
> +  Debug print the value of StatementValue.
> +
> +  @param[in]  ErrorLevel     DEBUG macro error level.
> +  @param[in]  StatementValue The statement value to print.
> +
> +  @retval     EFI_SUCCESS            StatementValue is printed.
> +  @retval     EFI_INVALID_PARAMETER  StatementValue is NULL.
> +**/
> +EFI_STATUS
> +DumpHiiStatementValue (
> +  IN UINTN                ErrorLevel,
> +  IN HII_STATEMENT_VALUE  *StatementValue
> +  )
> +{
> +  if (StatementValue == NULL) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  DEBUG ((ErrorLevel, "BufferValueType: 0x%x\n", StatementValue-
> >BufferValueType));
> +  DEBUG ((ErrorLevel, "BufferLen: 0x%x\n", StatementValue->BufferLen));
> +  DEBUG ((ErrorLevel, "Buffer:    0x%p\n", StatementValue->Buffer));
> +  DEBUG ((ErrorLevel, "Type:      0x%p\n", StatementValue->Type));
> +
> +  switch (StatementValue->Type) {
> +    case EFI_IFR_TYPE_NUM_SIZE_8:
> +      DEBUG ((ErrorLevel, "Value:     0x%x\n", StatementValue->Value.u8));
> +      break;
> +    case EFI_IFR_TYPE_NUM_SIZE_16:
> +      DEBUG ((ErrorLevel, "Value:     0x%x\n", StatementValue->Value.u16));
> +      break;
> +    case EFI_IFR_TYPE_NUM_SIZE_32:
> +      DEBUG ((ErrorLevel, "Value:     0x%x\n", StatementValue->Value.u32));
> +      break;
> +    case EFI_IFR_TYPE_NUM_SIZE_64:
> +      DEBUG ((ErrorLevel, "Value:     0x%lx\n", StatementValue->Value.u64));
> +      break;
> +    case EFI_IFR_TYPE_BOOLEAN:
> +      DEBUG ((ErrorLevel, "Value:     %a\n", (StatementValue->Value.b ? "true" :
> "false")));
> +      break;
> +    case EFI_IFR_TYPE_STRING:
> +      DEBUG ((ErrorLevel, "Value:     0x%x\n", StatementValue->Value.string));
> +      break;
> +    case EFI_IFR_TYPE_TIME:
> +    case EFI_IFR_TYPE_DATE:
> +    default:
> +      break;
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/**
> +  Debug print the value of RedfishValue.
> +
> +  @param[in]  ErrorLevel     DEBUG macro error level.
> +  @param[in]  RedfishValue   The statement value to print.
> +
> +  @retval     EFI_SUCCESS            RedfishValue is printed.
> +  @retval     EFI_INVALID_PARAMETER  RedfishValue is NULL.
> +**/
> +EFI_STATUS
> +DumpRedfishValue (
> +  IN UINTN                ErrorLevel,
> +  IN EDKII_REDFISH_VALUE  *RedfishValue
> +  )
> +{
> +  UINTN  Index;
> +
> +  if (RedfishValue == NULL) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  DEBUG ((ErrorLevel, "Type:       0x%x\n", RedfishValue->Type));
> +  DEBUG ((ErrorLevel, "ArrayCount: 0x%x\n", RedfishValue->ArrayCount));
> +
> +  switch (RedfishValue->Type) {
> +    case RedfishValueTypeInteger:
> +      DEBUG ((ErrorLevel, "Value:      0x%x\n", RedfishValue->Value.Integer));
> +      break;
> +    case RedfishValueTypeBoolean:
> +      DEBUG ((ErrorLevel, "Value:      %a\n", (RedfishValue->Value.Boolean ?
> "true" : "false")));
> +      break;
> +    case RedfishValueTypeString:
> +      DEBUG ((ErrorLevel, "Value:      %a\n", RedfishValue->Value.Buffer));
> +      break;
> +    case RedfishValueTypeStringArray:
> +      for (Index = 0; Index < RedfishValue->ArrayCount; Index++) {
> +        DEBUG ((ErrorLevel, "Value[%d]:      %a\n", Index, RedfishValue-
> >Value.StringArray[Index]));
> +      }
> +
> +      break;
> +    case RedfishValueTypeIntegerArray:
> +      for (Index = 0; Index < RedfishValue->ArrayCount; Index++) {
> +        DEBUG ((ErrorLevel, "Value[%d]:      0x%x\n", Index, RedfishValue-
> >Value.IntegerArray[Index]));
> +      }
> +
> +      break;
> +    case RedfishValueTypeBooleanArray:
> +      for (Index = 0; Index < RedfishValue->ArrayCount; Index++) {
> +        DEBUG ((ErrorLevel, "Value[%d]:      %a\n", Index, (RedfishValue-
> >Value.BooleanArray[Index] ? "true" : "false")));
> +      }
> +
> +      break;
> +    case RedfishValueTypeUnknown:
> +    case RedfishValueTypeMax:
> +    default:
> +      break;
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
>  /**
>
>    This function dump the Json string in given error level.
> --
> 2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#106694): https://edk2.groups.io/g/devel/message/106694
Mute This Topic: https://groups.io/mt/99958452/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-