#include <Library/DebugLib.h>\r
#include <Library/HobLib.h>\r
#include <Library/EmuThunkLib.h>\r
-\r
-#include <Protocol/EmuThunk.h>\r
-\r
+#include <Library/BaseMemoryLib.h>\r
\r
EMU_THUNK_PROTOCOL *gEmuThunk = NULL;\r
\r
\r
return EFI_SUCCESS;\r
}\r
+\r
+\r
+/**\r
+ Serach the EMU IO Thunk database for a matching EMU IO Thunk \r
+ Protocol instance.\r
+\r
+ @param Protocol Protocol to search for.\r
+ @param Instance Instance of protocol to search for.\r
+\r
+ @retval NULL Protocol and Instance not found.\r
+ @retval other EMU IO Thunk protocol that matched.\r
+\r
+**/\r
+EMU_IO_THUNK_PROTOCOL *\r
+EFIAPI\r
+GetIoThunkInstance (\r
+ IN EFI_GUID *Protocol,\r
+ IN UINTN Instance\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EMU_IO_THUNK_PROTOCOL *EmuIoThunk;\r
+ \r
+ for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) {\r
+ Status = gEmuThunk->GetNextProtocol (FALSE, &EmuIoThunk);\r
+ if (EFI_ERROR (Status)) {\r
+ break;\r
+ }\r
+ \r
+ if (EmuIoThunk->Instance == Instance) {\r
+ if (CompareGuid (EmuIoThunk->Protocol, Protocol)) {\r
+ return EmuIoThunk;\r
+ }\r
+ }\r
+ }\r
+ \r
+ return NULL;\r
+}
\ No newline at end of file