+ return UnregisterMemoryProfileImage (&DriverEntry);\r
+}\r
+\r
+/**\r
+ Get memory profile recording state.\r
+\r
+ @param[in] This The EDKII_MEMORY_PROFILE_PROTOCOL instance.\r
+ @param[out] RecordingState Recording state.\r
+\r
+ @return EFI_SUCCESS Memory profile recording state is returned.\r
+ @return EFI_UNSUPPORTED Memory profile is unsupported.\r
+ @return EFI_INVALID_PARAMETER RecordingState is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ProfileProtocolGetRecordingState (\r
+ IN EDKII_MEMORY_PROFILE_PROTOCOL *This,\r
+ OUT BOOLEAN *RecordingState\r
+ )\r
+{\r
+ MEMORY_PROFILE_CONTEXT_DATA *ContextData;\r
+\r
+ ContextData = GetMemoryProfileContext ();\r
+ if (ContextData == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if (RecordingState == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ *RecordingState = mMemoryProfileRecordingEnable;\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Set memory profile recording state.\r
+\r
+ @param[in] This The EDKII_MEMORY_PROFILE_PROTOCOL instance.\r
+ @param[in] RecordingState Recording state.\r
+\r
+ @return EFI_SUCCESS Set memory profile recording state successfully.\r
+ @return EFI_UNSUPPORTED Memory profile is unsupported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ProfileProtocolSetRecordingState (\r
+ IN EDKII_MEMORY_PROFILE_PROTOCOL *This,\r
+ IN BOOLEAN RecordingState\r
+ )\r
+{\r
+ MEMORY_PROFILE_CONTEXT_DATA *ContextData;\r
+\r
+ ContextData = GetMemoryProfileContext ();\r
+ if (ContextData == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ mMemoryProfileRecordingEnable = RecordingState;\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Record memory profile of multilevel caller.\r
+\r
+ @param[in] This The EDKII_MEMORY_PROFILE_PROTOCOL instance.\r
+ @param[in] CallerAddress Address of caller.\r
+ @param[in] Action Memory profile action.\r
+ @param[in] MemoryType Memory type.\r
+ EfiMaxMemoryType means the MemoryType is unknown.\r
+ @param[in] Buffer Buffer address.\r
+ @param[in] Size Buffer size.\r
+ @param[in] ActionString String for memory profile action.\r
+ Only needed for user defined allocate action.\r
+\r
+ @return EFI_SUCCESS Memory profile is updated.\r
+ @return EFI_UNSUPPORTED Memory profile is unsupported,\r
+ or memory profile for the image is not required,\r
+ or memory profile for the memory type is not required.\r
+ @return EFI_ACCESS_DENIED It is during memory profile data getting.\r
+ @return EFI_ABORTED Memory profile recording is not enabled.\r
+ @return EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.\r
+ @return EFI_NOT_FOUND No matched allocate info found for free action.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ProfileProtocolRecord (\r
+ IN EDKII_MEMORY_PROFILE_PROTOCOL *This,\r
+ IN PHYSICAL_ADDRESS CallerAddress,\r
+ IN MEMORY_PROFILE_ACTION Action,\r
+ IN EFI_MEMORY_TYPE MemoryType,\r
+ IN VOID *Buffer,\r
+ IN UINTN Size,\r
+ IN CHAR8 *ActionString OPTIONAL\r
+ )\r
+{\r
+ return CoreUpdateProfile (CallerAddress, Action, MemoryType, Size, Buffer, ActionString);\r