+/**\r
+ Convert the memory range to tested.\r
+\r
+ @param BaseAddress Base address of the memory range.\r
+ @param Length Length of the memory range.\r
+ @param Capabilities Capabilities of the memory range.\r
+\r
+ @retval EFI_SUCCESS The memory range is converted to tested.\r
+ @retval others Error happens.\r
+**/\r
+EFI_STATUS\r
+ConvertToTestedMemory (\r
+ IN UINT64 BaseAddress,\r
+ IN UINT64 Length,\r
+ IN UINT64 Capabilities\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ Status = gDS->RemoveMemorySpace (\r
+ BaseAddress,\r
+ Length\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = gDS->AddMemorySpace (\r
+ ((Capabilities & EFI_MEMORY_MORE_RELIABLE) == EFI_MEMORY_MORE_RELIABLE) ?\r
+ EfiGcdMemoryTypeMoreReliable : EfiGcdMemoryTypeSystemMemory,\r
+ BaseAddress,\r
+ Length,\r
+ Capabilities &~\r
+ (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)\r
+ );\r
+ }\r
+ return Status;\r
+}\r
+\r