]> git.proxmox.com Git - mirror_edk2.git/blobdiff - InOsEmuPkg/Library/DxeEmuLib/DxeEmuLib.c
Add MP support. Based on PcdEmuApCount APs (Application Processors) are created in...
[mirror_edk2.git] / InOsEmuPkg / Library / DxeEmuLib / DxeEmuLib.c
index 79e9fbc1eee0711026212823150f81ac1da58368..2e42ea61519a50270789ebbac80bbc975f892b24 100644 (file)
@@ -17,9 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #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
@@ -50,3 +48,41 @@ DxeEmuLibConstructor (
   \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