\r
Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions\r
-of the BSD License which accompanies this distribution. The\r
-full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
**/\r
EFI_STATUS\r
RelocateImageUnder4GIfNeeded (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
- EFI_STATUS Status;\r
- UINT8 *Buffer;\r
- UINTN BufferSize;\r
- EFI_HANDLE NewImageHandle;\r
- UINTN Pages;\r
- EFI_PHYSICAL_ADDRESS FfsBuffer;\r
- PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;\r
- VOID *Interface;\r
+ EFI_STATUS Status;\r
+ UINT8 *Buffer;\r
+ UINTN BufferSize;\r
+ EFI_HANDLE NewImageHandle;\r
+ UINTN Pages;\r
+ EFI_PHYSICAL_ADDRESS FfsBuffer;\r
+ PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;\r
+ VOID *Interface;\r
\r
//\r
// If it is already <4G, no need do relocate\r
// Here we install a dummy handle\r
//\r
NewImageHandle = NULL;\r
- Status = gBS->InstallProtocolInterface (\r
- &NewImageHandle,\r
- &gEfiCallerIdGuid,\r
- EFI_NATIVE_INTERFACE,\r
- NULL\r
- );\r
+ Status = gBS->InstallProtocolInterface (\r
+ &NewImageHandle,\r
+ &gEfiCallerIdGuid,\r
+ EFI_NATIVE_INTERFACE,\r
+ NULL\r
+ );\r
ASSERT_EFI_ERROR (Status);\r
\r
//\r
// Reload image itself to <4G mem\r
//\r
- Status = GetSectionFromAnyFv (\r
+ Status = GetSectionFromAnyFv (\r
&gEfiCallerIdGuid,\r
EFI_SECTION_PE32,\r
0,\r
- (VOID **) &Buffer,\r
+ (VOID **)&Buffer,\r
&BufferSize\r
);\r
ASSERT_EFI_ERROR (Status);\r
Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
ASSERT_EFI_ERROR (Status);\r
if (ImageContext.SectionAlignment > EFI_PAGE_SIZE) {\r
- Pages = EFI_SIZE_TO_PAGES ((UINTN) (ImageContext.ImageSize + ImageContext.SectionAlignment));\r
+ Pages = EFI_SIZE_TO_PAGES ((UINTN)(ImageContext.ImageSize + ImageContext.SectionAlignment));\r
} else {\r
- Pages = EFI_SIZE_TO_PAGES ((UINTN) ImageContext.ImageSize);\r
+ Pages = EFI_SIZE_TO_PAGES ((UINTN)ImageContext.ImageSize);\r
}\r
+\r
FfsBuffer = 0xFFFFFFFF;\r
- Status = gBS->AllocatePages (\r
- AllocateMaxAddress,\r
- EfiBootServicesCode,\r
- Pages,\r
- &FfsBuffer\r
- );\r
+ Status = gBS->AllocatePages (\r
+ AllocateMaxAddress,\r
+ EfiBootServicesCode,\r
+ Pages,\r
+ &FfsBuffer\r
+ );\r
ASSERT_EFI_ERROR (Status);\r
ImageContext.ImageAddress = (PHYSICAL_ADDRESS)(UINTN)FfsBuffer;\r
//\r
InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);\r
\r
DEBUG ((DEBUG_INFO, "Loading driver at 0x%08x EntryPoint=0x%08x\n", (UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.EntryPoint));\r
- Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)(ImageContext.EntryPoint)) (NewImageHandle, gST);\r
+ Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)(ImageContext.EntryPoint))(NewImageHandle, gST);\r
if (EFI_ERROR (Status)) {\r
DEBUG ((DEBUG_ERROR, "Error: Image at 0x%08x start failed: %r\n", ImageContext.ImageAddress, Status));\r
gBS->FreePages (FfsBuffer, Pages);\r