diff options
author | Nickle Wang <nicklew@nvidia.com> | 2024-01-09 13:53:15 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-01-10 10:17:14 +0000 |
commit | bc34a79cd2a005e1d12d4b05bec6efc3b102cad6 (patch) | |
tree | 20a5f427c638eda813fdd7a50b3ac9e7279a24e8 /RedfishPkg | |
parent | 265b4ab91b8a31d6d1760ad1eaa1e16f9244cba7 (diff) | |
download | edk2-bc34a79cd2a005e1d12d4b05bec6efc3b102cad6.zip edk2-bc34a79cd2a005e1d12d4b05bec6efc3b102cad6.tar.gz edk2-bc34a79cd2a005e1d12d4b05bec6efc3b102cad6.tar.bz2 |
RedfishPkg/RedfishDebugLib: add function to print buffer.
Introduce DumpBuffer function to print the buffer content. This helps
developer to debug Redfish issue.
Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
Reviewed-by: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Abner Chang <abner.chang@amd.com>
Diffstat (limited to 'RedfishPkg')
-rw-r--r-- | RedfishPkg/Include/Library/RedfishDebugLib.h | 20 | ||||
-rw-r--r-- | RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c | 45 |
2 files changed, 61 insertions, 4 deletions
diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h b/RedfishPkg/Include/Library/RedfishDebugLib.h index 5f75bad..3430cf1 100644 --- a/RedfishPkg/Include/Library/RedfishDebugLib.h +++ b/RedfishPkg/Include/Library/RedfishDebugLib.h @@ -1,7 +1,7 @@ /** @file
This file defines the Redfish debug library interface.
- Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -138,4 +138,22 @@ DumpIpv4Address ( IN EFI_IPv4_ADDRESS *Ipv4Address
);
+/**
+ Debug output raw data buffer.
+
+ @param[in] ErrorLevel DEBUG macro error level
+ @param[in] Buffer Debug output data buffer.
+ @param[in] BufferSize The size of Buffer in byte.
+
+ @retval EFI_SUCCESS Debug dump finished.
+ @retval EFI_INVALID_PARAMETER Buffer is NULL.
+
+**/
+EFI_STATUS
+DumpBuffer (
+ IN UINTN ErrorLevel,
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize
+ );
+
#endif
diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c index efa9a5c..3728f51 100644 --- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c +++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c @@ -1,7 +1,7 @@ /** @file
Redfish debug library to debug Redfish application.
- Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -19,8 +19,9 @@ #define IS_EMPTY_STRING(a) ((a) == NULL || (a)[0] == '\0')
#endif
-#define REDFISH_JSON_STRING_LENGTH 200
-#define REDFISH_JSON_OUTPUT_FORMAT (EDKII_JSON_COMPACT | EDKII_JSON_INDENT(2))
+#define REDFISH_JSON_STRING_LENGTH 200
+#define REDFISH_JSON_OUTPUT_FORMAT (EDKII_JSON_COMPACT | EDKII_JSON_INDENT(2))
+#define REDFISH_PRINT_BUFFER_BYTES_PER_ROW 16
/**
Debug print the value of StatementValue.
@@ -366,3 +367,41 @@ DumpIpv4Address ( return EFI_SUCCESS;
}
+
+/**
+ Debug output raw data buffer.
+
+ @param[in] ErrorLevel DEBUG macro error level
+ @param[in] Buffer Debug output data buffer.
+ @param[in] BufferSize The size of Buffer in byte.
+
+ @retval EFI_SUCCESS Debug dump finished.
+ @retval EFI_INVALID_PARAMETER Buffer is NULL.
+
+**/
+EFI_STATUS
+DumpBuffer (
+ IN UINTN ErrorLevel,
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize
+ )
+{
+ UINTN Index;
+
+ if (Buffer == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ DEBUG ((ErrorLevel, "Address: 0x%p size: %d\n", Buffer, BufferSize));
+ for (Index = 0; Index < BufferSize; Index++) {
+ if (Index % REDFISH_PRINT_BUFFER_BYTES_PER_ROW == 0) {
+ DEBUG ((ErrorLevel, "\n%04X: ", Index));
+ }
+
+ DEBUG ((ErrorLevel, "%02X ", Buffer[Index]));
+ }
+
+ DEBUG ((ErrorLevel, "\n"));
+
+ return EFI_SUCCESS;
+}
|