/** @file\r
*\r
-* Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
+* Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r
* \r
* This program and the accompanying materials \r
* are licensed and made available under the terms and conditions of the BSD License \r
// Get all the UsbIo handles\r
UsbIoHandleCount = 0;\r
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiUsbIoProtocolGuid, NULL, &UsbIoHandleCount, &UsbIoBuffer);\r
- if (EFI_ERROR(Status) || (UsbIoHandleCount == 0)) {\r
+ if (EFI_ERROR (Status) || (UsbIoHandleCount == 0)) {\r
return Status;\r
}\r
\r
// Check if one of the handles matches the USB description\r
for (Index = 0; Index < UsbIoHandleCount; Index++) {\r
Status = gBS->HandleProtocol (UsbIoBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **) &UsbIoDevicePath);\r
- if (!EFI_ERROR(Status)) {\r
+ if (!EFI_ERROR (Status)) {\r
TmpDevicePath = UsbIoDevicePath;\r
while (!IsDevicePathEnd (TmpDevicePath)) {\r
// Check if the Device Path node is a USB Removable device Path node\r
WwidDevicePath2 = (USB_WWID_DEVICE_PATH*)TmpDevicePath;\r
if ((WwidDevicePath1->VendorId == WwidDevicePath2->VendorId) &&\r
(WwidDevicePath1->ProductId == WwidDevicePath2->ProductId) &&\r
- (CompareMem (WwidDevicePath1+1, WwidDevicePath2+1, DevicePathNodeLength(WwidDevicePath1)-sizeof(USB_WWID_DEVICE_PATH)) == 0))\r
+ (CompareMem (WwidDevicePath1+1, WwidDevicePath2+1, DevicePathNodeLength(WwidDevicePath1)-sizeof (USB_WWID_DEVICE_PATH)) == 0))\r
{\r
*DeviceHandle = UsbIoBuffer[Index];\r
// Add the additional original Device Path Nodes (eg: FilePath Device Path Node) to the new Device Path\r
- *NewDevicePath = AppendDevicePath (UsbIoDevicePath, NextDevicePathNode(RemovableDevicePath));\r
+ *NewDevicePath = AppendDevicePath (UsbIoDevicePath, NextDevicePathNode (RemovableDevicePath));\r
return EFI_SUCCESS;\r
}\r
} else {\r
{\r
*DeviceHandle = UsbIoBuffer[Index];\r
// Add the additional original Device Path Nodes (eg: FilePath Device Path Node) to the new Device Path\r
- *NewDevicePath = AppendDevicePath (UsbIoDevicePath, NextDevicePathNode(RemovableDevicePath));\r
+ *NewDevicePath = AppendDevicePath (UsbIoDevicePath, NextDevicePathNode (RemovableDevicePath));\r
return EFI_SUCCESS;\r
}\r
}\r
IN EFI_DEVICE_PATH* DevicePath\r
)\r
{\r
- return IS_DEVICE_PATH_NODE(DevicePath, MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP);\r
+ return IS_DEVICE_PATH_NODE (DevicePath, MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP);\r
}\r
\r
EFI_STATUS\r
// Get all the DiskIo handles\r
PartitionHandleCount = 0;\r
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiDiskIoProtocolGuid, NULL, &PartitionHandleCount, &PartitionBuffer);\r
- if (EFI_ERROR(Status) || (PartitionHandleCount == 0)) {\r
+ if (EFI_ERROR (Status) || (PartitionHandleCount == 0)) {\r
return Status;\r
}\r
\r
// Check if one of the handles matches the Hard Disk Description\r
for (Index = 0; Index < PartitionHandleCount; Index++) {\r
Status = gBS->HandleProtocol (PartitionBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **) &PartitionDevicePath);\r
- if (!EFI_ERROR(Status)) {\r
+ if (!EFI_ERROR (Status)) {\r
TmpDevicePath = PartitionDevicePath;\r
while (!IsDevicePathEnd (TmpDevicePath)) {\r
// Check if the Device Path node is a HD Removable device Path node\r
HardDriveDevicePath1 = (HARDDRIVE_DEVICE_PATH*)RemovableDevicePath;\r
HardDriveDevicePath2 = (HARDDRIVE_DEVICE_PATH*)TmpDevicePath;\r
if ((HardDriveDevicePath1->SignatureType == HardDriveDevicePath2->SignatureType) &&\r
- (CompareGuid ((EFI_GUID *)HardDriveDevicePath1->Signature,(EFI_GUID *)HardDriveDevicePath2->Signature) == TRUE) &&\r
+ (CompareGuid ((EFI_GUID *)HardDriveDevicePath1->Signature, (EFI_GUID *)HardDriveDevicePath2->Signature) == TRUE) &&\r
(HardDriveDevicePath1->PartitionNumber == HardDriveDevicePath2->PartitionNumber))\r
{\r
*DeviceHandle = PartitionBuffer[Index];\r
// Add the additional original Device Path Nodes (eg: FilePath Device Path Node) to the new Device Path\r
- *NewDevicePath = AppendDevicePath (PartitionDevicePath, NextDevicePathNode(RemovableDevicePath));\r
+ *NewDevicePath = AppendDevicePath (PartitionDevicePath, NextDevicePathNode (RemovableDevicePath));\r
return EFI_SUCCESS;\r
}\r
}\r
IN EFI_DEVICE_PATH* DevicePath\r
)\r
{\r
- return IS_DEVICE_PATH_NODE(DevicePath, MEDIA_DEVICE_PATH, MEDIA_CDROM_DP);\r
+ return IS_DEVICE_PATH_NODE (DevicePath, MEDIA_DEVICE_PATH, MEDIA_CDROM_DP);\r
}\r
\r
EFI_STATUS\r
\r
TmpDevicePath = DevicePath;\r
while (!IsDevicePathEnd (TmpDevicePath)) {\r
- for (Index = 0; Index < sizeof(RemovableDeviceSupport) / sizeof(BDS_REMOVABLE_DEVICE_SUPPORT); Index++) {\r
- if (RemovableDeviceSupport[Index].IsRemovable(TmpDevicePath)) {\r
+ for (Index = 0; Index < sizeof (RemovableDeviceSupport) / sizeof (BDS_REMOVABLE_DEVICE_SUPPORT); Index++) {\r
+ if (RemovableDeviceSupport[Index].IsRemovable (TmpDevicePath)) {\r
return TRUE;\r
}\r
}\r
TmpDevicePath = DevicePath;\r
\r
while (!IsDevicePathEnd (TmpDevicePath) && !RemovableFound) {\r
- for (Index = 0; Index < sizeof(RemovableDeviceSupport) / sizeof(BDS_REMOVABLE_DEVICE_SUPPORT); Index++) {\r
+ for (Index = 0; Index < sizeof (RemovableDeviceSupport) / sizeof (BDS_REMOVABLE_DEVICE_SUPPORT); Index++) {\r
RemovableDevice = &RemovableDeviceSupport[Index];\r
- if (RemovableDevice->IsRemovable(TmpDevicePath)) {\r
+ if (RemovableDevice->IsRemovable (TmpDevicePath)) {\r
RemovableDevicePath = TmpDevicePath;\r
RemovableFound = TRUE;\r
break;\r
}\r
\r
/*// We need to check if RemainingDevicePath does not point on the last node. Otherwise, calling\r
- // NextDevicePathNode() will return an undetermined Device Path Node\r
+ // NextDevicePathNode () will return an undetermined Device Path Node\r
if (!IsDevicePathEnd (RemainingDevicePath)) {\r
RemainingDevicePath = NextDevicePathNode (RemainingDevicePath);\r
}*/\r
// Now, we have got the whole Device Path connected, call again ConnectController to ensure all the supported Driver\r
// Binding Protocol are connected (such as DiskIo and SimpleFileSystem)\r
Remaining = DevicePath;\r
- Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid,&Remaining,Handle);\r
+ Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &Remaining, Handle);\r
if (!EFI_ERROR (Status)) {\r
Status = gBS->ConnectController (*Handle, NULL, Remaining, FALSE);\r
if (EFI_ERROR (Status)) {\r
EFI_STATUS Status;\r
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FsProtocol;\r
\r
- Status = gBS->HandleProtocol (Handle,&gEfiSimpleFileSystemProtocolGuid, (VOID **)&FsProtocol);\r
+ Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&FsProtocol);\r
\r
- return (!EFI_ERROR(Status) && IS_DEVICE_PATH_NODE(RemainingDevicePath,MEDIA_DEVICE_PATH,MEDIA_FILEPATH_DP));\r
+ return (!EFI_ERROR (Status) && IS_DEVICE_PATH_NODE (RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP));\r
}\r
\r
EFI_STATUS\r
EFI_FILE_PROTOCOL *File;\r
UINTN Size;\r
\r
- ASSERT (IS_DEVICE_PATH_NODE(RemainingDevicePath,MEDIA_DEVICE_PATH,MEDIA_FILEPATH_DP));\r
+ ASSERT (IS_DEVICE_PATH_NODE (RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP));\r
\r
FilePathDevicePath = (FILEPATH_DEVICE_PATH*)RemainingDevicePath;\r
\r
- Status = gBS->HandleProtocol(Handle,&gEfiSimpleFileSystemProtocolGuid, (VOID **)&FsProtocol);\r
- if (EFI_ERROR(Status)) {\r
+ Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&FsProtocol);\r
+ if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
// Try to Open the volume and get root directory\r
Status = FsProtocol->OpenVolume (FsProtocol, &Fs);\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
File = NULL;\r
- Status = Fs->Open(Fs, &File, FilePathDevicePath->PathName, EFI_FILE_MODE_READ, 0);\r
- if (EFI_ERROR(Status)) {\r
+ Status = Fs->Open (Fs, &File, FilePathDevicePath->PathName, EFI_FILE_MODE_READ, 0);\r
+ if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
Size = 0;\r
- File->GetInfo(File, &gEfiFileInfoGuid, &Size, NULL);\r
+ File->GetInfo (File, &gEfiFileInfoGuid, &Size, NULL);\r
FileInfo = AllocatePool (Size);\r
- Status = File->GetInfo(File, &gEfiFileInfoGuid, &Size, FileInfo);\r
- if (EFI_ERROR(Status)) {\r
+ Status = File->GetInfo (File, &gEfiFileInfoGuid, &Size, FileInfo);\r
+ if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
if (ImageSize) {\r
*ImageSize = Size;\r
}\r
- FreePool(FileInfo);\r
+ FreePool (FileInfo);\r
\r
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);\r
// Try to allocate in any pages if failed to allocate memory at the defined location\r
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {\r
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);\r
}\r
- if (!EFI_ERROR(Status)) {\r
+ if (!EFI_ERROR (Status)) {\r
Status = File->Read (File, &Size, (VOID*)(UINTN)(*Image));\r
}\r
\r
IN EFI_DEVICE_PATH *RemainingDevicePath\r
)\r
{\r
- return IS_DEVICE_PATH_NODE(DevicePath,HARDWARE_DEVICE_PATH,HW_MEMMAP_DP) ||\r
- IS_DEVICE_PATH_NODE(RemainingDevicePath,HARDWARE_DEVICE_PATH,HW_MEMMAP_DP);\r
+ return IS_DEVICE_PATH_NODE (DevicePath, HARDWARE_DEVICE_PATH, HW_MEMMAP_DP) ||\r
+ IS_DEVICE_PATH_NODE (RemainingDevicePath, HARDWARE_DEVICE_PATH, HW_MEMMAP_DP);\r
}\r
\r
EFI_STATUS\r
MEMMAP_DEVICE_PATH* MemMapPathDevicePath;\r
UINTN Size;\r
\r
- if (IS_DEVICE_PATH_NODE(RemainingDevicePath,HARDWARE_DEVICE_PATH,HW_MEMMAP_DP)) {\r
+ if (IS_DEVICE_PATH_NODE (RemainingDevicePath, HARDWARE_DEVICE_PATH, HW_MEMMAP_DP)) {\r
MemMapPathDevicePath = (MEMMAP_DEVICE_PATH*)RemainingDevicePath;\r
} else {\r
- ASSERT (IS_DEVICE_PATH_NODE(DevicePath,HARDWARE_DEVICE_PATH,HW_MEMMAP_DP));\r
+ ASSERT (IS_DEVICE_PATH_NODE (DevicePath, HARDWARE_DEVICE_PATH, HW_MEMMAP_DP));\r
MemMapPathDevicePath = (MEMMAP_DEVICE_PATH*)DevicePath;\r
}\r
\r
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {\r
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);\r
}\r
- if (!EFI_ERROR(Status)) {\r
+ if (!EFI_ERROR (Status)) {\r
CopyMem ((VOID*)(UINTN)(*Image), (CONST VOID*)(UINTN)MemMapPathDevicePath->StartingAddress, Size);\r
\r
if (ImageSize != NULL) {\r
IN EFI_DEVICE_PATH *RemainingDevicePath\r
)\r
{\r
- return IS_DEVICE_PATH_NODE(RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP);\r
+ return IS_DEVICE_PATH_NODE (RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP);\r
}\r
\r
EFI_STATUS\r
UINT32 AuthenticationStatus;\r
VOID* ImageBuffer;\r
\r
- ASSERT (IS_DEVICE_PATH_NODE(RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP));\r
+ ASSERT (IS_DEVICE_PATH_NODE (RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP));\r
\r
- Status = gBS->HandleProtocol(Handle,&gEfiFirmwareVolume2ProtocolGuid, (VOID **)&FwVol);\r
- if (EFI_ERROR(Status)) {\r
+ Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&FwVol);\r
+ if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
// In case the buffer has some address requirements, we must copy the buffer to a buffer following the requirements\r
if (Type != AllocateAnyPages) {\r
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize),Image);\r
- if (!EFI_ERROR(Status)) {\r
+ if (!EFI_ERROR (Status)) {\r
CopyMem ((VOID*)(UINTN)(*Image), ImageBuffer, *ImageSize);\r
FreePool (ImageBuffer);\r
}\r
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {\r
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image);\r
}\r
- if (!EFI_ERROR(Status)) {\r
+ if (!EFI_ERROR (Status)) {\r
CopyMem ((VOID*)(UINTN)(*Image), ImageBuffer, *ImageSize);\r
FreePool (ImageBuffer);\r
}\r
&Attrib,\r
&AuthenticationStatus\r
);\r
- if (!EFI_ERROR(Status)) {\r
+ if (!EFI_ERROR (Status)) {\r
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image);\r
// Try to allocate in any pages if failed to allocate memory at the defined location\r
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {\r
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image);\r
}\r
- if (!EFI_ERROR(Status)) {\r
+ if (!EFI_ERROR (Status)) {\r
Status = FwVol->ReadFile (\r
FwVol,\r
FvNameGuid,\r
EFI_STATUS Status;\r
EFI_PXE_BASE_CODE_PROTOCOL* PxeBcProtocol;\r
\r
- if (!IsDevicePathEnd(RemainingDevicePath)) {\r
+ if (!IsDevicePathEnd (RemainingDevicePath)) {\r
return FALSE;\r
}\r
\r
Status = LoadFileProtocol->LoadFile (LoadFileProtocol, DevicePath, TRUE, &BufferSize, NULL);\r
if (Status == EFI_BUFFER_TOO_SMALL) {\r
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(BufferSize), Image);\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
Status = LoadFileProtocol->LoadFile (LoadFileProtocol, DevicePath, TRUE, &BufferSize, (VOID*)(UINTN)(*Image));\r
- if (!EFI_ERROR(Status) && (ImageSize != NULL)) {\r
+ if (!EFI_ERROR (Status) && (ImageSize != NULL)) {\r
*ImageSize = BufferSize;\r
}\r
}\r
EFI_PXE_BASE_CODE_PROTOCOL *PxeBcProtocol;\r
\r
// Validate the Remaining Device Path\r
- if (IsDevicePathEnd(RemainingDevicePath)) {\r
+ if (IsDevicePathEnd (RemainingDevicePath)) {\r
return FALSE;\r
}\r
- if (!IS_DEVICE_PATH_NODE(RemainingDevicePath,MESSAGING_DEVICE_PATH,MSG_IPv4_DP) &&\r
- !IS_DEVICE_PATH_NODE(RemainingDevicePath,MESSAGING_DEVICE_PATH,MSG_IPv6_DP)) {\r
+ if (!IS_DEVICE_PATH_NODE (RemainingDevicePath, MESSAGING_DEVICE_PATH, MSG_IPv4_DP) &&\r
+ !IS_DEVICE_PATH_NODE (RemainingDevicePath, MESSAGING_DEVICE_PATH, MSG_IPv6_DP)) {\r
return FALSE;\r
}\r
NextDevicePath = NextDevicePathNode (RemainingDevicePath);\r
- if (IsDevicePathEnd(NextDevicePath)) {\r
+ if (IsDevicePathEnd (NextDevicePath)) {\r
return FALSE;\r
}\r
- if (!IS_DEVICE_PATH_NODE(NextDevicePath,MEDIA_DEVICE_PATH,MEDIA_FILEPATH_DP)) {\r
+ if (!IS_DEVICE_PATH_NODE (NextDevicePath, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP)) {\r
return FALSE;\r
}\r
\r
FILEPATH_DEVICE_PATH* FilePathDevicePath;\r
EFI_IP_ADDRESS LocalIp;\r
\r
- ASSERT(IS_DEVICE_PATH_NODE(RemainingDevicePath,MESSAGING_DEVICE_PATH,MSG_IPv4_DP));\r
+ ASSERT(IS_DEVICE_PATH_NODE (RemainingDevicePath, MESSAGING_DEVICE_PATH, MSG_IPv4_DP));\r
\r
IPv4DevicePathNode = (IPv4_DEVICE_PATH*)RemainingDevicePath;\r
FilePathDevicePath = (FILEPATH_DEVICE_PATH*)(IPv4DevicePathNode + 1);\r
\r
Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
Status = Pxe->Start (Pxe, FALSE);\r
- if (EFI_ERROR(Status) && (Status != EFI_ALREADY_STARTED)) {\r
+ if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {\r
return Status;\r
}\r
\r
CopyMem (&LocalIp.v4, &IPv4DevicePathNode->LocalIpAddress, sizeof (EFI_IPv4_ADDRESS));\r
Status = Pxe->SetStationIp (Pxe, &LocalIp, NULL);\r
}\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
NULL,\r
TRUE\r
);\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
// Allocate a buffer to hold the whole file.\r
- TftpBuffer = AllocatePool(TftpBufferSize);\r
+ TftpBuffer = AllocatePool (TftpBufferSize);\r
if (TftpBuffer == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
NULL,\r
FALSE\r
);\r
- if (EFI_ERROR(Status)) {\r
- FreePool(TftpBuffer);\r
+ if (EFI_ERROR (Status)) {\r
+ FreePool (TftpBuffer);\r
} else if (ImageSize != NULL) {\r
*ImageSize = (UINTN)TftpBufferSize;\r
}\r
\r
// Find the nearest supported file loader\r
Status = BdsLoadImage (DevicePath, AllocateAnyPages, &BinaryBuffer, &BinarySize);\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
// Load the image from the Buffer with Boot Services function\r
Status = gBS->LoadImage (TRUE, ParentImageHandle, DevicePath, (VOID*)(UINTN)BinaryBuffer, BinarySize, &ImageHandle);\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
// Passed LoadOptions to the EFI Application\r
if (LoadOptionsSize != 0) {\r
Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r