/** @file\r
Support routines for UEFI memory profile.\r
\r
- Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The 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
+ Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
};\r
GLOBAL_REMOVE_IF_UNREFERENCED MEMORY_PROFILE_CONTEXT_DATA *mMemoryProfileContextPtr = NULL;\r
\r
-EFI_LOCK mMemoryProfileLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);\r
-BOOLEAN mMemoryProfileGettingStatus = FALSE;\r
-BOOLEAN mMemoryProfileRecordingEnable = MEMORY_PROFILE_RECORDING_DISABLE;\r
-EFI_DEVICE_PATH_PROTOCOL *mMemoryProfileDriverPath;\r
-UINTN mMemoryProfileDriverPathSize;\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_LOCK mMemoryProfileLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);\r
+GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mMemoryProfileGettingStatus = FALSE;\r
+GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mMemoryProfileRecordingEnable = MEMORY_PROFILE_RECORDING_DISABLE;\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_PROTOCOL *mMemoryProfileDriverPath;\r
+GLOBAL_REMOVE_IF_UNREFERENCED UINTN mMemoryProfileDriverPathSize;\r
\r
/**\r
Get memory profile data.\r
@param[in, out] ProfileSize On entry, points to the size in bytes of the ProfileBuffer.\r
On return, points to the size of the data returned in ProfileBuffer.\r
@param[out] ProfileBuffer Profile buffer.\r
- \r
+\r
@return EFI_SUCCESS Get the memory profile data successfully.\r
@return EFI_UNSUPPORTED Memory profile is unsupported.\r
- @return EFI_BUFFER_TO_SMALL The ProfileSize is too small for the resulting data. \r
+ @return EFI_BUFFER_TO_SMALL The ProfileSize is too small for the resulting data.\r
ProfileSize is updated with the size required.\r
\r
**/\r
IN CHAR8 *ActionString OPTIONAL\r
);\r
\r
-EDKII_MEMORY_PROFILE_PROTOCOL mProfileProtocol = {\r
+GLOBAL_REMOVE_IF_UNREFERENCED EDKII_MEMORY_PROFILE_PROTOCOL mProfileProtocol = {\r
ProfileProtocolGetData,\r
ProfileProtocolRegisterImage,\r
ProfileProtocolUnregisterImage,\r
return mMemoryProfileContextPtr;\r
}\r
\r
-/**\r
- Retrieves the magic value from the PE/COFF header.\r
-\r
- @param Hdr The buffer in which to return the PE32, PE32+, or TE header.\r
-\r
- @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32\r
- @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+\r
-\r
-**/\r
-UINT16\r
-InternalPeCoffGetPeHeaderMagicValue (\r
- IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr\r
- )\r
-{\r
- //\r
- // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value\r
- // in the PE/COFF Header. If the MachineType is Itanium(IA64) and the\r
- // Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC\r
- // then override the returned value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
- //\r
- if (Hdr.Pe32->FileHeader.Machine == IMAGE_FILE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
- return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
- }\r
- //\r
- // Return the magic value from the PC/COFF Optional Header\r
- //\r
- return Hdr.Pe32->OptionalHeader.Magic;\r
-}\r
-\r
/**\r
Retrieves and returns the Subsystem of a PE/COFF image that has been loaded into system memory.\r
If Pe32Data is NULL, then ASSERT().\r
if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
return Hdr.Te->Subsystem;\r
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {\r
- Magic = InternalPeCoffGetPeHeaderMagicValue (Hdr);\r
+ Magic = Hdr.Pe32->OptionalHeader.Magic;\r
if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
return Hdr.Pe32->OptionalHeader.Subsystem;\r
} else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
if (EFI_ERROR (Status)) {\r
return NULL;\r
}\r
+ ASSERT (DriverInfoData != NULL);\r
\r
ZeroMem (DriverInfoData, sizeof (*DriverInfoData));\r
\r
//\r
return TRUE;\r
}\r
- \r
+\r
//\r
// Record FilePath without END node.\r
//\r
}\r
}\r
\r
+ ASSERT (DriverInfoData != NULL);\r
+ ASSERT (AllocInfoData != NULL);\r
+\r
Found = TRUE;\r
\r
Context = &ContextData->Context;\r
@param[in, out] ProfileSize On entry, points to the size in bytes of the ProfileBuffer.\r
On return, points to the size of the data returned in ProfileBuffer.\r
@param[out] ProfileBuffer Profile buffer.\r
- \r
+\r
@return EFI_SUCCESS Get the memory profile data successfully.\r
@return EFI_UNSUPPORTED Memory profile is unsupported.\r
- @return EFI_BUFFER_TO_SMALL The ProfileSize is too small for the resulting data. \r
+ @return EFI_BUFFER_TO_SMALL The ProfileSize is too small for the resulting data.\r
ProfileSize is updated with the size required.\r
\r
**/\r