27#define VERBOSE_COLUME_SIZE (16)
30UINT8 mRedfishProtocolDataSize;
49 RestExServiceDevicePathData =
NULL;
50 RestExServiceDevicePath =
NULL;
53 if ((RestExServiceDevicePathData ==
NULL) ||
54 (RestExServiceDevicePathData->DevicePathNum == 0) ||
60 RestExServiceDevicePath = RestExServiceDevicePathData->DevicePath;
61 if (RestExServiceDevicePathData->DevicePathMatchMode != DEVICE_PATH_MATCH_MAC_NODE) {
96 OUT UINT8 *DeviceType,
106 if (RedfishInterfaceData ==
NULL) {
107 return EFI_OUT_OF_RESOURCES;
110 RedfishInterfaceData->
DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
117 if (EFI_ERROR (Status)) {
119 return EFI_NOT_FOUND;
123 *DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
124 *DeviceDescriptor = RedfishInterfaceData;
145 IN UINT8 IndexOfProtocolData
150 if (mRedfishOverIpProtocolData == 0) {
151 return EFI_NOT_FOUND;
154 if (IndexOfProtocolData == 0) {
160 ThisProtocolRecord->ProtocolType = MCHostInterfaceProtocolTypeRedfishOverIP;
161 ThisProtocolRecord->ProtocolTypeDataLen = mRedfishProtocolDataSize;
162 CopyMem ((VOID *)&ThisProtocolRecord->ProtocolTypeData, (VOID *)mRedfishOverIpProtocolData, mRedfishProtocolDataSize);
163 *ProtocolRecord = ThisProtocolRecord;
167 return EFI_NOT_FOUND;
182 for (Index = 0; Index < 4; Index++) {
183 DEBUG ((DEBUG_VERBOSE,
"%d", Ip->Addr[Index]));
185 DEBUG ((DEBUG_VERBOSE,
"."));
189 DEBUG ((DEBUG_VERBOSE,
"\n"));
204 for (Index = 0; Index < 16; Index++) {
205 if (Ip->Addr[Index] != 0) {
206 DEBUG ((DEBUG_VERBOSE,
"%x", Ip->Addr[Index]));
215 if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) {
216 DEBUG ((DEBUG_VERBOSE,
"0"));
219 DEBUG ((DEBUG_VERBOSE,
"%x", Ip->Addr[Index]));
222 DEBUG ((DEBUG_VERBOSE,
":"));
226 DEBUG ((DEBUG_VERBOSE,
"\n"));
243 for (Index = 0; Index < Size; Index++) {
244 DEBUG ((DEBUG_VERBOSE,
"%02x ", (
UINTN)Data[Index]));
264 Count = Size / VERBOSE_COLUME_SIZE;
265 Left = Size % VERBOSE_COLUME_SIZE;
266 for (Index = 0; Index < Count; Index++) {
268 DEBUG ((DEBUG_VERBOSE,
"\n"));
273 DEBUG ((DEBUG_VERBOSE,
"\n"));
276 DEBUG ((DEBUG_VERBOSE,
"\n"));
288 IN UINT8 RedfishProtocolDataSize
293 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData: \n"));
294 InternalDumpHex ((UINT8 *)RedfishProtocolData, RedfishProtocolDataSize);
296 DEBUG ((DEBUG_VERBOSE,
"Parsing as below: \n"));
298 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData->ServiceUuid - %g\n", &(RedfishProtocolData->ServiceUuid)));
300 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData->HostIpAssignmentType - %d\n", RedfishProtocolData->HostIpAssignmentType));
302 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData->HostIpAddressFormat - %d\n", RedfishProtocolData->HostIpAddressFormat));
304 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData->HostIpAddress: \n"));
305 if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
311 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData->HostIpMask: \n"));
312 if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
318 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData->RedfishServiceIpDiscoveryType - %d\n", RedfishProtocolData->RedfishServiceIpDiscoveryType));
320 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData->RedfishServiceIpAddressFormat - %d\n", RedfishProtocolData->RedfishServiceIpAddressFormat));
322 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData->RedfishServiceIpAddress: \n"));
323 if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
329 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData->RedfishServiceIpMask: \n"));
330 if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
336 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData->RedfishServiceIpPort - %d\n", RedfishProtocolData->RedfishServiceIpPort));
338 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData->RedfishServiceVlanId - %d\n", RedfishProtocolData->RedfishServiceVlanId));
340 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData->RedfishServiceHostnameLength - %d\n", RedfishProtocolData->RedfishServiceHostnameLength));
342 AsciiStrToUnicodeStrS ((CHAR8 *)RedfishProtocolData->RedfishServiceHostname, Hostname, sizeof (Hostname) /
sizeof (Hostname[0]));
343 DEBUG ((DEBUG_VERBOSE,
"RedfishProtocolData->RedfishServiceHostname - %s\n", Hostname));
357 OUT UINT8 *RedfishProtocolDataSize
361 UINT8 HostIpAssignmentType;
362 UINTN HostIpAssignmentTypeSize;
368 UINT16 RedfishServiceIpPort;
369 UINTN IpPortDataSize;
371 CHAR8 RedfishHostName[20];
373 if ((RedfishProtocolData ==
NULL) || (RedfishProtocolDataSize ==
NULL)) {
374 return EFI_INVALID_PARAMETER;
380 Status =
gRT->GetVariable (
381 L
"HostIpAssignmentType",
382 &gEmuRedfishServiceGuid,
384 &HostIpAssignmentTypeSize,
385 &HostIpAssignmentType
387 if (EFI_ERROR (Status)) {
388 DEBUG ((DEBUG_ERROR,
"RedfishPlatformDxe: GetVariable HostIpAssignmentType - %r\n", Status));
393 if (HostIpAssignmentType == 1 ) {
394 Status =
gRT->GetVariable (
396 &gEmuRedfishServiceGuid,
401 if (EFI_ERROR (Status)) {
402 DEBUG ((DEBUG_ERROR,
"RedfishPlatformDxe: GetVariable HostIpAddress - %r\n", Status));
406 Status =
gRT->GetVariable (
408 &gEmuRedfishServiceGuid,
413 if (EFI_ERROR (Status)) {
414 DEBUG ((DEBUG_ERROR,
"RedfishPlatformDxe: GetVariable HostIpMask - %r\n", Status));
419 Status =
gRT->GetVariable (
420 L
"RedfishServiceIpAddress",
421 &gEmuRedfishServiceGuid,
424 &RedfishServiceIpAddress
426 if (EFI_ERROR (Status)) {
427 DEBUG ((DEBUG_ERROR,
"RedfishPlatformDxe: GetVariable RedfishServiceIpAddress - %r\n", Status));
431 Status =
gRT->GetVariable (
432 L
"RedfishServiceIpMask",
433 &gEmuRedfishServiceGuid,
436 &RedfishServiceIpMask
438 if (EFI_ERROR (Status)) {
439 DEBUG ((DEBUG_ERROR,
"RedfishPlatformDxe: GetVariable RedfishServiceIpMask - %r\n", Status));
443 Status =
gRT->GetVariable (
444 L
"RedfishServiceIpPort",
445 &gEmuRedfishServiceGuid,
448 &RedfishServiceIpPort
450 if (EFI_ERROR (Status)) {
451 DEBUG ((DEBUG_ERROR,
"RedfishPlatformDxe: GetVariable RedfishServiceIpPort - %r\n", Status));
457 sizeof (RedfishHostName),
459 RedfishServiceIpAddress.Addr[0],
460 RedfishServiceIpAddress.Addr[1],
461 RedfishServiceIpAddress.Addr[2],
462 RedfishServiceIpAddress.Addr[3]
465 HostNameSize = (UINT8)
AsciiStrLen (RedfishHostName) + 1;
476 if (*RedfishProtocolData ==
NULL) {
477 return EFI_OUT_OF_RESOURCES;
480 CopyGuid (&(*RedfishProtocolData)->ServiceUuid, &gEmuRedfishServiceGuid);
482 (*RedfishProtocolData)->HostIpAssignmentType = HostIpAssignmentType;
483 (*RedfishProtocolData)->HostIpAddressFormat = 1;
485 if (HostIpAssignmentType == 1 ) {
486 (*RedfishProtocolData)->HostIpAddress[0] = HostIpAddress.Addr[0];
487 (*RedfishProtocolData)->HostIpAddress[1] = HostIpAddress.Addr[1];
488 (*RedfishProtocolData)->HostIpAddress[2] = HostIpAddress.Addr[2];
489 (*RedfishProtocolData)->HostIpAddress[3] = HostIpAddress.Addr[3];
491 (*RedfishProtocolData)->HostIpMask[0] = HostIpMask.Addr[0];
492 (*RedfishProtocolData)->HostIpMask[1] = HostIpMask.Addr[1];
493 (*RedfishProtocolData)->HostIpMask[2] = HostIpMask.Addr[2];
494 (*RedfishProtocolData)->HostIpMask[3] = HostIpMask.Addr[3];
497 (*RedfishProtocolData)->RedfishServiceIpDiscoveryType = 1;
498 (*RedfishProtocolData)->RedfishServiceIpAddressFormat = 1;
500 (*RedfishProtocolData)->RedfishServiceIpAddress[0] = RedfishServiceIpAddress.Addr[0];
501 (*RedfishProtocolData)->RedfishServiceIpAddress[1] = RedfishServiceIpAddress.Addr[1];
502 (*RedfishProtocolData)->RedfishServiceIpAddress[2] = RedfishServiceIpAddress.Addr[2];
503 (*RedfishProtocolData)->RedfishServiceIpAddress[3] = RedfishServiceIpAddress.Addr[3];
505 (*RedfishProtocolData)->RedfishServiceIpMask[0] = RedfishServiceIpMask.Addr[0];
506 (*RedfishProtocolData)->RedfishServiceIpMask[1] = RedfishServiceIpMask.Addr[1];
507 (*RedfishProtocolData)->RedfishServiceIpMask[2] = RedfishServiceIpMask.Addr[2];
508 (*RedfishProtocolData)->RedfishServiceIpMask[3] = RedfishServiceIpMask.Addr[3];
510 (*RedfishProtocolData)->RedfishServiceIpPort = RedfishServiceIpPort;
511 (*RedfishProtocolData)->RedfishServiceVlanId = 0xffffffff;
513 (*RedfishProtocolData)->RedfishServiceHostnameLength = HostNameSize;
514 AsciiStrCpyS ((CHAR8 *)((*RedfishProtocolData)->RedfishServiceHostname), HostNameSize, RedfishHostName);
539 DEBUG ((DEBUG_INFO,
"%a: GetRedfishRecordFromVariable() - %r\n", __func__, Status));
540 if (!EFI_ERROR (Status)) {
567 return EFI_UNSUPPORTED;
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
RETURN_STATUS EFIAPI AsciiStrToUnicodeStrS(IN CONST CHAR8 *Source, OUT CHAR16 *Destination, IN UINTN DestMax)
RETURN_STATUS EFIAPI AsciiStrCpyS(OUT CHAR8 *Destination, IN UINTN DestMax, IN CONST CHAR8 *Source)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
#define MESSAGING_DEVICE_PATH
UINT8 EFIAPI DevicePathType(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathValid(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINTN MaxSize)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
UINTN EFIAPI AsciiSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString,...)
EFI_RUNTIME_SERVICES * gRT
#define DEBUG(Expression)
#define PcdGetPtr(TokenName)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
IPv4_ADDRESS EFI_IPv4_ADDRESS
EFI_MAC_ADDRESS MacAddress
UINT8 MacAddress[6]
The MAC address of the PCI/PCIe network device.
UINT8 Length
Length of the structure, including Device Type and Length fields.
Device descriptor data formated based on Device Type.
UINT8 DeviceType
The Device Type of the interface.