summaryrefslogtreecommitdiffstats
path: root/RedfishPkg/Library
diff options
context:
space:
mode:
authorAbner Chang <abner.chang@amd.com>2024-03-18 10:32:44 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-04-04 14:24:31 +0000
commitb0be42516e757ff54fb92b9a984ecb84512460d7 (patch)
tree786315f90ff3ddcc9edc98edbdbf0a5df6a44235 /RedfishPkg/Library
parent29114fc5744be0fb877ad9775b6463b92f92c32d (diff)
downloadedk2-b0be42516e757ff54fb92b9a984ecb84512460d7.tar.gz
edk2-b0be42516e757ff54fb92b9a984ecb84512460d7.tar.bz2
edk2-b0be42516e757ff54fb92b9a984ecb84512460d7.zip
RedfishPkg/RedfishDebugLib: Introduce Redfish DEBUG macro
Introduce DEBUG_REDFISH macro for the debug message of edk2 Redfish components. DEBUG_REDFISH can be used in any edk2 Redfish component with Redfish DebugCatagory as the first parameter. Whether the debug message is output or not depends on the platform setting of PcdRedfishDebugCatagory. Signed-off-by: Abner Chang <abner.chang@amd.com> Cc: Nickle Wang <nicklew@nvidia.com> Cc: Igor Kulchytskyy <igork@ami.com> Reviewed-by: Nickle Wang <nicklew@nvidia.com> Reviewed-by: Igor Kulchytskyy <igork@ami.com>
Diffstat (limited to 'RedfishPkg/Library')
-rw-r--r--RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c55
-rw-r--r--RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf4
2 files changed, 16 insertions, 43 deletions
diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
index 8b0425b8c3..f8bb51ff53 100644
--- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
+++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
@@ -2,6 +2,7 @@
Redfish debug library to debug Redfish application.
Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -25,55 +26,23 @@
#define REDFISH_PRINT_BUFFER_BYTES_PER_ROW 16
/**
- Debug print the value of StatementValue.
+ Determine whether the Redfish debug category is enabled in
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory.
- @param[in] ErrorLevel DEBUG macro error level.
- @param[in] StatementValue The statement value to print.
+ @param[in] RedfishDebugCategory Redfish debug category.
- @retval EFI_SUCCESS StatementValue is printed.
- @retval EFI_INVALID_PARAMETER StatementValue is NULL.
+ @retval TRUE This debug category is enabled.
+ @retval FALSE This debug category is disabled..
**/
-EFI_STATUS
-DumpHiiStatementValue (
- IN UINTN ErrorLevel,
- IN HII_STATEMENT_VALUE *StatementValue
+BOOLEAN
+DebugRedfishComponentEnabled (
+ IN UINT64 RedfishDebugCategory
)
{
- if (StatementValue == NULL) {
- return EFI_INVALID_PARAMETER;
- }
+ UINT64 DebugCategory;
- 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;
+ DebugCategory = FixedPcdGet64 (PcdRedfishDebugCategory);
+ return ((DebugCategory & RedfishDebugCategory) != 0);
}
/**
diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf
index d468bb213b..42ff321b48 100644
--- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf
+++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf
@@ -2,6 +2,7 @@
# INF file for Redfish debug library.
#
# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -35,5 +36,8 @@
RedfishHttpLib
UefiLib
+[FixedPcd]
+ gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory
+
[Depex]
TRUE