1 | /** @file
|
---|
2 | This file defines the Redfish debug library interface.
|
---|
3 |
|
---|
4 | Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
---|
5 | Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
|
---|
6 |
|
---|
7 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
8 |
|
---|
9 | **/
|
---|
10 |
|
---|
11 | #ifndef REDFISH_DEBUG_LIB_H_
|
---|
12 | #define REDFISH_DEBUG_LIB_H_
|
---|
13 |
|
---|
14 | #include <Uefi.h>
|
---|
15 | #include <Library/DebugLib.h>
|
---|
16 | #include <RedfishServiceData.h>
|
---|
17 | #include <Library/HiiUtilityLib.h>
|
---|
18 | #include <Library/JsonLib.h>
|
---|
19 |
|
---|
20 | #include <Protocol/EdkIIRedfishPlatformConfig.h>
|
---|
21 |
|
---|
22 | // Used with MdePKg DEBUG macro.
|
---|
23 | #define DEBUG_REDFISH_NETWORK DEBUG_MANAGEABILITY ///< Debug error level for Redfish networking function
|
---|
24 | #define DEBUG_REDFISH_HOST_INTERFACE DEBUG_MANAGEABILITY ///< Debug error level for Redfish Host INterface
|
---|
25 | #define DEBUG_REDFISH_PLATFORM_CONFIG DEBUG_MANAGEABILITY ///< Debug error level for Redfish Platform Configure Driver
|
---|
26 |
|
---|
27 | //
|
---|
28 | // Definitions of Redfish debug capability in Redfish component scope, used with DEBUG_REDFISH macro
|
---|
29 | // For example, Redfish Platform Config Driver
|
---|
30 | // DEBUG_REDFISH(DEBUG_REDFISH_PLATFORM_CONFIG_DXE, ...)
|
---|
31 | //
|
---|
32 | #define DEBUG_REDFISH_COMPONENT_PLATFORM_CONFIG_DXE 0x00000001
|
---|
33 |
|
---|
34 | #define DEBUG_REDFISH(DebugCategory, ...) \
|
---|
35 | do { \
|
---|
36 | if (!DebugPrintEnabled()) { \
|
---|
37 | break; \
|
---|
38 | } \
|
---|
39 | if (!DebugRedfishComponentEnabled (DebugCategory)) { \
|
---|
40 | break; \
|
---|
41 | } \
|
---|
42 | DEBUG ((DEBUG_MANAGEABILITY, ##__VA_ARGS__)); \
|
---|
43 | } while (FALSE)
|
---|
44 |
|
---|
45 | /**
|
---|
46 | Determine whether the Redfish debug category is enabled in
|
---|
47 | gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory.
|
---|
48 |
|
---|
49 | @param[in] DebugCategory Redfish debug category.
|
---|
50 |
|
---|
51 | @retval TRUE This debug category is enabled.
|
---|
52 | @retval FALSE This debug category is disabled..
|
---|
53 | **/
|
---|
54 | BOOLEAN
|
---|
55 | DebugRedfishComponentEnabled (
|
---|
56 | IN UINT64 DebugCategory
|
---|
57 | );
|
---|
58 |
|
---|
59 | /**
|
---|
60 | Debug print the value of RedfishValue.
|
---|
61 |
|
---|
62 | @param[in] ErrorLevel DEBUG macro error level.
|
---|
63 | @param[in] RedfishValue The statement value to print.
|
---|
64 |
|
---|
65 | @retval EFI_SUCCESS RedfishValue is printed.
|
---|
66 | @retval EFI_INVALID_PARAMETER RedfishValue is NULL.
|
---|
67 | **/
|
---|
68 | EFI_STATUS
|
---|
69 | DumpRedfishValue (
|
---|
70 | IN UINTN ErrorLevel,
|
---|
71 | IN EDKII_REDFISH_VALUE *RedfishValue
|
---|
72 | );
|
---|
73 |
|
---|
74 | /**
|
---|
75 |
|
---|
76 | This function dump the Json string in given error level.
|
---|
77 |
|
---|
78 | @param[in] ErrorLevel DEBUG macro error level
|
---|
79 | @param[in] JsonValue Json value to dump.
|
---|
80 |
|
---|
81 | @retval EFI_SUCCESS Json string is printed.
|
---|
82 | @retval Others Errors occur.
|
---|
83 |
|
---|
84 | **/
|
---|
85 | EFI_STATUS
|
---|
86 | DumpJsonValue (
|
---|
87 | IN UINTN ErrorLevel,
|
---|
88 | IN EDKII_JSON_VALUE JsonValue
|
---|
89 | );
|
---|
90 |
|
---|
91 | /**
|
---|
92 |
|
---|
93 | This function dump the status code, header and body in given
|
---|
94 | Redfish payload.
|
---|
95 |
|
---|
96 | @param[in] ErrorLevel DEBUG macro error level
|
---|
97 | @param[in] Payload Redfish payload to dump
|
---|
98 |
|
---|
99 | @retval EFI_SUCCESS Redfish payload is printed.
|
---|
100 | @retval Others Errors occur.
|
---|
101 |
|
---|
102 | **/
|
---|
103 | EFI_STATUS
|
---|
104 | DumpRedfishPayload (
|
---|
105 | IN UINTN ErrorLevel,
|
---|
106 | IN REDFISH_PAYLOAD Payload
|
---|
107 | );
|
---|
108 |
|
---|
109 | /**
|
---|
110 |
|
---|
111 | This function dump the status code, header and body in given
|
---|
112 | Redfish response.
|
---|
113 |
|
---|
114 | @param[in] Message Message string
|
---|
115 | @param[in] ErrorLevel DEBUG macro error level
|
---|
116 | @param[in] Response Redfish response to dump
|
---|
117 |
|
---|
118 | @retval EFI_SUCCESS Redfish response is printed.
|
---|
119 | @retval Others Errors occur.
|
---|
120 |
|
---|
121 | **/
|
---|
122 | EFI_STATUS
|
---|
123 | DumpRedfishResponse (
|
---|
124 | IN CONST CHAR8 *Message,
|
---|
125 | IN UINTN ErrorLevel,
|
---|
126 | IN REDFISH_RESPONSE *Response
|
---|
127 | );
|
---|
128 |
|
---|
129 | /**
|
---|
130 |
|
---|
131 | This function dump the HTTP status code.
|
---|
132 |
|
---|
133 | @param[in] ErrorLevel DEBUG macro error level
|
---|
134 | @param[in] HttpStatusCode HTTP status code
|
---|
135 |
|
---|
136 | @retval EFI_SUCCESS HTTP status code is printed
|
---|
137 |
|
---|
138 | **/
|
---|
139 | EFI_STATUS
|
---|
140 | DumpHttpStatusCode (
|
---|
141 | IN UINTN ErrorLevel,
|
---|
142 | IN EFI_HTTP_STATUS_CODE HttpStatusCode
|
---|
143 | );
|
---|
144 |
|
---|
145 | /**
|
---|
146 |
|
---|
147 | This function dump the IPv4 address in given error level.
|
---|
148 |
|
---|
149 | @param[in] ErrorLevel DEBUG macro error level
|
---|
150 | @param[in] Ipv4Address IPv4 address to dump
|
---|
151 |
|
---|
152 | @retval EFI_SUCCESS IPv4 address string is printed.
|
---|
153 | @retval Others Errors occur.
|
---|
154 |
|
---|
155 | **/
|
---|
156 | EFI_STATUS
|
---|
157 | DumpIpv4Address (
|
---|
158 | IN UINTN ErrorLevel,
|
---|
159 | IN EFI_IPv4_ADDRESS *Ipv4Address
|
---|
160 | );
|
---|
161 |
|
---|
162 | /**
|
---|
163 | Debug output raw data buffer.
|
---|
164 |
|
---|
165 | @param[in] ErrorLevel DEBUG macro error level
|
---|
166 | @param[in] Buffer Debug output data buffer.
|
---|
167 | @param[in] BufferSize The size of Buffer in byte.
|
---|
168 |
|
---|
169 | @retval EFI_SUCCESS Debug dump finished.
|
---|
170 | @retval EFI_INVALID_PARAMETER Buffer is NULL.
|
---|
171 |
|
---|
172 | **/
|
---|
173 | EFI_STATUS
|
---|
174 | DumpBuffer (
|
---|
175 | IN UINTN ErrorLevel,
|
---|
176 | IN UINT8 *Buffer,
|
---|
177 | IN UINTN BufferSize
|
---|
178 | );
|
---|
179 |
|
---|
180 | #endif
|
---|