+/**\r
+ This function check if the memory region is in GCD MMIO region.\r
+\r
+ @param Addr The memory region start address to be checked.\r
+ @param Size The memory region length to be checked.\r
+\r
+ @retval TRUE This memory region is in GCD MMIO region.\r
+ @retval FALSE This memory region is not in GCD MMIO region.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+OpalIsValidMmioSpace (\r
+ IN EFI_PHYSICAL_ADDRESS Addr,\r
+ IN UINTN Size\r
+ )\r
+{\r
+ UINTN Index;\r
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Desc;\r
+\r
+ for (Index = 0; Index < mNumberOfDescriptors; Index ++) {\r
+ Desc = &mGcdMemSpace[Index];\r
+ if ((Desc->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) && (Addr >= Desc->BaseAddress) && ((Addr + Size) <= (Desc->BaseAddress + Desc->Length))) {\r
+ return TRUE;\r
+ }\r
+ }\r
+\r
+ return FALSE;\r
+}\r