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>
This commit is contained in:
Abner Chang
2024-03-18 10:32:44 +08:00
committed by mergify[bot]
parent 29114fc574
commit b0be42516e
4 changed files with 57 additions and 54 deletions

View File

@@ -2,6 +2,7 @@
This file defines the Redfish debug library interface.
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
@@ -11,28 +12,48 @@
#define REDFISH_DEBUG_LIB_H_
#include <Uefi.h>
#include <Library/DebugLib.h>
#include <RedfishServiceData.h>
#include <Library/HiiUtilityLib.h>
#include <Library/JsonLib.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
// Used with MdePKg DEBUG macro.
#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 Host INterface
#define DEBUG_REDFISH_PLATFORM_CONFIG DEBUG_MANAGEABILITY ///< Debug error level for Redfish Platform Configure Driver
//
// Definitions of Redfish debug capability in Redfish component scope, used with DEBUG_REDFISH macro
// For example, Redfish Platform Config Driver
// DEBUG_REDFISH(DEBUG_REDFISH_PLATFORM_CONFIG_DXE, ...)
//
#define DEBUG_REDFISH_COMPONENT_PLATFORM_CONFIG_DXE 0x00000001
#define DEBUG_REDFISH(DebugCategory, ...) \
do { \
if (!DebugPrintEnabled()) { \
break; \
} \
if (!DebugRedfishComponentEnabled (DebugCategory)) { \
break; \
} \
DEBUG ((DEBUG_MANAGEABILITY, ##__VA_ARGS__)); \
} while (FALSE)
/**
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] DebugCategory 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 DebugCategory
);
/**