28static VOID *mPlatformHostInterfaceReadyRegistration =
NULL;
43 UINT8 DeviceDataLength;
47 VOID *ProtocolRecords;
48 VOID *NewProtocolRecords;
50 UINT8 CurrentProtocolsDataLength;
51 UINT8 NewProtocolsDataLength;
52 UINT8 ProtocolDataSize;
55 EFI_SMBIOS_HANDLE MemArrayMappedAddrSmbiosHandle;
63 if (EFI_ERROR (Status)) {
64 if (Status == EFI_NOT_FOUND) {
65 DEBUG ((DEBUG_ERROR,
"%a: No Redfish host interface descriptor is provided on this platform.\n", __func__));
69 DEBUG ((DEBUG_ERROR,
"%a: Fail to get device descriptor, %r.", __func__, Status));
73 if ((DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2) &&
74 (DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2)
77 DEBUG ((DEBUG_ERROR,
"%a: Only support either protocol type 04h or 05h as Redfish host interface.", __func__));
78 return EFI_UNSUPPORTED;
81 if (DeviceType == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
90 ProtocolRecord =
NULL;
91 ProtocolRecords =
NULL;
92 NewProtocolRecords =
NULL;
95 CurrentProtocolsDataLength = 0;
96 NewProtocolsDataLength = 0;
99 if (Status == EFI_NOT_FOUND) {
103 if (EFI_ERROR (Status)) {
104 DEBUG ((DEBUG_ERROR,
"%a: Fail to get Redfish host interafce protocol type data.", __func__));
105 if (ProtocolRecords !=
NULL) {
109 if (ProtocolRecord !=
NULL) {
117 NewProtocolsDataLength += ProtocolDataSize;
118 if (ProtocolRecords ==
NULL) {
120 if (ProtocolRecords ==
NULL) {
122 return EFI_OUT_OF_RESOURCES;
125 CopyMem ((VOID *)ProtocolRecords, (VOID *)ProtocolRecord, ProtocolDataSize);
126 NewProtocolRecords = ProtocolRecords;
128 NewProtocolRecords =
ReallocatePool (CurrentProtocolsDataLength, NewProtocolsDataLength, (VOID *)ProtocolRecords);
129 if (NewProtocolRecords ==
NULL) {
130 DEBUG ((DEBUG_ERROR,
"%a: Fail to allocate memory for Redfish host interface protocol data.", __func__));
133 return EFI_OUT_OF_RESOURCES;
137 (VOID *)((UINT8 *)NewProtocolRecords + CurrentProtocolsDataLength),
138 (VOID *)ProtocolRecord,
144 CurrentProtocolsDataLength = NewProtocolsDataLength;
148 if (ProtocolCount == 0) {
169 + CurrentProtocolsDataLength
172 if (Type42Record ==
NULL) {
173 Status = EFI_OUT_OF_RESOURCES;
177 Type42Record->Hdr.Type = EFI_SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE;
181 + CurrentProtocolsDataLength;
182 Type42Record->Hdr.Handle = 0;
183 Type42Record->
InterfaceType = MCHostInterfaceTypeNetworkHostInterface;
188 Type42Record->InterfaceTypeSpecificDataLength = DeviceDataLength;
195 DeviceDescriptor =
NULL;
208 CurrentProtocolsDataLength
214 Status =
gBS->LocateProtocol (&gEfiSmbiosProtocolGuid,
NULL, (VOID **)&Smbios);
215 if (EFI_ERROR (Status)) {
220 Status = Smbios->Add (
223 &MemArrayMappedAddrSmbiosHandle,
226 DEBUG ((DEBUG_MANAGEABILITY,
"RedfishPlatformDxe: Smbios->Add() - %r\n", Status));
227 if (EFI_ERROR (Status)) {
234 Status =
gBS->InstallProtocolInterface (
236 &gEdkIIRedfishHostInterfaceReadyProtocolGuid,
240 if (EFI_ERROR (Status)) {
241 DEBUG ((DEBUG_ERROR,
"Failed to install gEdkIIRedfishHostInterfaceReadyProtocolGuid.\n"));
242 DEBUG ((DEBUG_ERROR,
"PlatformConfigHandler driver may not be triggered to acquire Redfish service.\n"));
250 if (DeviceDescriptor !=
NULL) {
254 if (NewProtocolRecords !=
NULL) {
258 if (Type42Record !=
NULL) {
280 DEBUG ((DEBUG_MANAGEABILITY,
"%a: Platform Redfish Host Interface informtion is ready\n", __func__));
287 gBS->CloseEvent (Event);
288 mPlatformHostInterfaceReadylEvent =
NULL;
312 DEBUG ((DEBUG_MANAGEABILITY,
"%a: Entry\n.", __func__));
320 DEBUG ((DEBUG_MANAGEABILITY,
" Create protocol install notification to know the installation of platform Redfish host interface readiness\n"));
321 DEBUG ((DEBUG_MANAGEABILITY,
" Protocol GUID: %g\n", ReadyGuid));
326 Status =
gBS->CreateEvent (
331 &mPlatformHostInterfaceReadylEvent
333 if (EFI_ERROR (Status)) {
334 DEBUG ((DEBUG_ERROR,
" Fail to create event for the installation of platform Redfish host interface readiness.\n"));
338 Status =
gBS->RegisterProtocolNotify (
340 mPlatformHostInterfaceReadylEvent,
341 &mPlatformHostInterfaceReadyRegistration
343 if (EFI_ERROR (Status)) {
344 DEBUG ((DEBUG_ERROR,
" Fail to register event for the installation of platform Redfish host interface readiness.\n"));
351 if ((Status == EFI_UNSUPPORTED) || (Status == EFI_ALREADY_STARTED)) {
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ReallocatePool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define SMBIOS_HANDLE_PI_RESERVED
#define DEBUG(Expression)
EFI_STATUS RedfishCreateSmbiosTable42(VOID)
EFI_STATUS EFIAPI RedfishHostInterfaceDxeEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID EFIAPI PlatformHostInterfaceInformationReady(IN EFI_EVENT Event, IN VOID *Context)
UINT8 Length
Length of the structure, including Device Type and Length fields.
Device descriptor data formated based on Device Type.
DEVICE_DESCRITOR DeviceDescriptor
The Device descriptor.
UINT8 InterfaceType
The enumeration value from MC_HOST_INTERFACE_TYPE.
UINT8 InterfaceTypeSpecificData[4]
This field has a minimum of four bytes.
PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 PciPcieDeviceV2
Device type PCI/PCIe V2 device discriptor.
USB_INTERFACE_DEVICE_DESCRIPTOR_V2 UsbDeviceV2
Device type USB V2 device discriptor.