]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c
MdeModulePkg: use LShiftU64() instead of "<<" to avoid IA32 build error.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Mem / MemoryProfileRecord.c
index 1ba8488a0e041761c67e3fa5e25cc74684106c01..b67a17c86dff22e5c410dbadc816d6dbf0e52cc4 100644 (file)
@@ -63,6 +63,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED MEMORY_PROFILE_CONTEXT_DATA mMemoryProfileContext
 };\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
@@ -217,6 +218,28 @@ EDKII_MEMORY_PROFILE_PROTOCOL mProfileProtocol = {
   ProfileProtocolRecord,\r
 };\r
 \r
+/**\r
+  Acquire lock on mMemoryProfileLock.\r
+**/\r
+VOID\r
+CoreAcquireMemoryProfileLock (\r
+  VOID\r
+  )\r
+{\r
+  CoreAcquireLock (&mMemoryProfileLock);\r
+}\r
+\r
+/**\r
+  Release lock on mMemoryProfileLock.\r
+**/\r
+VOID\r
+CoreReleaseMemoryProfileLock (\r
+  VOID\r
+  )\r
+{\r
+  CoreReleaseLock (&mMemoryProfileLock);\r
+}\r
+\r
 /**\r
   Return memory profile context.\r
 \r
@@ -419,6 +442,7 @@ BuildDriverInfo (
   if (EFI_ERROR (Status)) {\r
     return NULL;\r
   }\r
+  ASSERT (DriverInfoData != NULL);\r
 \r
   ZeroMem (DriverInfoData, sizeof (*DriverInfoData));\r
 \r
@@ -1260,6 +1284,9 @@ CoreUpdateProfileFree (
       }\r
     }\r
 \r
+    ASSERT (DriverInfoData != NULL);\r
+    ASSERT (AllocInfoData != NULL);\r
+\r
     Found = TRUE;\r
 \r
     Context = &ContextData->Context;\r
@@ -1383,6 +1410,7 @@ CoreUpdateProfile (
     return EFI_UNSUPPORTED;\r
   }\r
 \r
+  CoreAcquireMemoryProfileLock ();\r
   switch (BasicAction) {\r
     case MemoryProfileActionAllocatePages:\r
       Status = CoreUpdateProfileAllocate (CallerAddress, Action, MemoryType, Size, Buffer, ActionString);\r
@@ -1401,6 +1429,8 @@ CoreUpdateProfile (
       Status = EFI_UNSUPPORTED;\r
       break;\r
   }\r
+  CoreReleaseMemoryProfileLock ();\r
+\r
   return Status;\r
 }\r
 \r