1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
/** @file
This file defines the manageability transport interface library and functions.
Copyright (C) 2023-2026 Advanced Micro Devices, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#pragma once
#include <Library/ManageabilityTransportLib.h>
#define DEBUG_MANAGEABILITY_INFO DEBUG_MANAGEABILITY
typedef struct _MANAGEABILITY_PROTOCOL_NAME MANAGEABILITY_PROTOCOL_NAME;
typedef struct {
UINT8 *PayloadPointer;
UINT32 PayloadSize;
} MANAGEABILITY_TRANSMISSION_PACKAGE_ATTR;
//
// The information of multi portions of payload it is
// splitted according to transport interface Maximum
// Transfer Unit.
typedef struct {
UINT16 NumberOfPackages; ///< Number of packages in MultiPackages.
MANAGEABILITY_TRANSMISSION_PACKAGE_ATTR MultiPackages[];
} MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES;
/**
Helper function returns the human readable name of Manageability specification.
@param[out] SpecificationGuid The Manageability specification GUID
@retval !NULL Human readable name is returned;
@retval NULL No string found, the given Manageability specification is
not supported.
**/
CHAR16 *
EFIAPI
HelperManageabilitySpecName (
IN EFI_GUID *SpecificationGuid
);
/**
Helper function to check if the Manageability specification is supported
by transport interface or not.
@param[in] TransportGuid GUID of the transport interface.
@param[in] SupportedManageabilityProtocolArray The Manageability protocols supported
by the transport interface.
@param[in] NumberOfSupportedProtocolInArray Number of protocols in the array.
@param[in] ManageabilityProtocolToCheck The Manageability specification to check.
@retval EFI_SUCCESS Token is created successfully.
@retval EFI_INVALID_PARAMETER Either NumberOfSupportedProtocolInArray = 0 or
SupportedManageabilityProtocolArray = NULL.
@retval EFI_UNSUPPORTED Out of resource to create a new transport session.
Otherwise Other errors.
**/
EFI_STATUS
EFIAPI
HelperManageabilityCheckSupportedSpec (
IN EFI_GUID *TransportGuid,
IN EFI_GUID **SupportedManageabilityProtocolArray,
IN UINT8 NumberOfSupportedProtocolInArray,
IN EFI_GUID *ManageabilityProtocolToCheck
);
/**
Helper function to acquire the Manageability transport token.
@param[in] ManageabilityProtocolSpec The Manageability protocol specification.
@param[out] TransportToken Pointer to receive Manageability transport
token.
@retval EFI_SUCCESS Token is created successfully.
@retval EFI_OUT_OF_RESOURCES Out of resource to create a new transport session.
@retval EFI_UNSUPPORTED Token is created successfully.
@retval EFI_DEVICE_ERROR The transport interface has problems
@retval EFI_INVALID_PARAMETER INput parameter is not valid.
Otherwise Other errors.
**/
EFI_STATUS
EFIAPI
HelperAcquireManageabilityTransport (
IN EFI_GUID *ManageabilityProtocolSpec,
OUT MANAGEABILITY_TRANSPORT_TOKEN **TransportToken
);
/**
Helper function to initial the transport interface.
@param[in] TransportToken Transport token.
@param[in] HardwareInfo Optional hardware information of transport interface.
@param[out] TransportAdditionalStatus Transport additional status.
@retval EFI_SUCCESS Transport interface is initiated successfully.
@retval EFI_DEVICE_ERROR The transport interface has problems
@retval EFI_INVALID_PARAMETER INput parameter is not valid.
Otherwise Other errors.
**/
EFI_STATUS
EFIAPI
HelperInitManageabilityTransport (
IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken,
IN MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION HardwareInfo OPTIONAL,
OUT MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS *TransportAdditionalStatus OPTIONAL
);
/**
This function splits payload into multiple packages according to
the given transport interface Maximum Transfer Unit (MTU).
@param[in] PreambleSize The additional data size precedes
each package.
@param[in] PostambleSize The additional data size succeeds
each package.
@param[in] Payload Pointer to payload.
@param[in] PayloadSize Payload size in byte.
@param[in] MaximumTransferUnit MTU of transport interface.
@param[out] MultiplePackages Pointer to receive
MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES
structure. Caller has to free the memory
allocated for MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES.
@retval EFI_SUCCESS MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES structure
is returned successfully.
@retval EFI_OUT_OF_RESOURCE Not enough resource to create
MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES structure.
**/
EFI_STATUS
EFIAPI
HelperManageabilitySplitPayload (
IN UINT16 PreambleSize,
IN UINT16 PostambleSize,
IN UINT8 *Payload,
IN UINT32 PayloadSize,
IN UINT32 MaximumTransferUnit,
OUT MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES **MultiplePackages
);
/**
This function generates CRC8 with given polynomial.
@param[in] Polynomial Polynomial in 8-bit.
@param[in] CrcInitialValue CRC initial value.
@param[in] BufferStart Pointer to buffer starts the CRC calculation.
@param[in] BufferSize Size of buffer.
@retval UINT8 CRC value.
**/
UINT8
EFIAPI
HelperManageabilityGenerateCrc8 (
IN UINT8 Polynomial,
IN UINT8 CrcInitialValue,
IN UINT8 *BufferStart,
IN UINT32 BufferSize
);
/**
Print out manageability transmit payload to the debug output device.
@param[in] Payload Payload to print.
@param[in] PayloadSize Payload size.
**/
VOID
EFIAPI
HelperManageabilityPayLoadDebugPrint (
IN VOID *Payload,
IN UINT32 PayloadSize
);
/**
Prints a debug message and manageability payload to the debug output device.
@param[in] Payload Payload to print.
@param[in] PayloadSize Payload size.
@param[in] Format The format string for the debug message to print.
@param[in] ... The variable argument list whose contents are accessed
based on the format string specified by Format.
**/
VOID
EFIAPI
HelperManageabilityDebugPrint (
IN VOID *Payload,
IN UINT32 PayloadSize,
IN CONST CHAR8 *Format,
...
);
///
/// IPMI Helper Functions.
///
/**
This function returns a human readable string of IPMI KCS Completion Code
and returns the corresponding additional status of transport interface.
@param [in] CompletionCode The Completion Code returned from KCS.
@param [out] CompletionCodeStr Human readable string of IPMI Completion Code.
@param [out] AdditionalStatus Return the additional status.
@retval EFI_SUCCESS The information of Completion Code is returned.
@retval EFI_NOT_FOUND No information of Completion Code is returned.
@retval EFI_INVALID_PARAMETER The given parameter is incorrect.
**/
EFI_STATUS
EFIAPI
IpmiHelperCheckCompletionCode (
IN UINT8 CompletionCode,
OUT CHAR16 **CompletionCodeStr,
OUT MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS *AdditionalStatus
);
|