]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiDxe.c
OvmfPkg: Add IoMmuDxe driver
[mirror_edk2.git] / OvmfPkg / Library / QemuFwCfgLib / QemuFwCfgPeiDxe.c
index f693cff29e012c03a960e274f57ae4e52047690f..ac05f4c347f38986ad474373dfa19bef3512b0ca 100644 (file)
 #include <Library/DebugLib.h>\r
 #include <Library/QemuFwCfgLib.h>\r
 \r
+#include "QemuFwCfgLibInternal.h"\r
+\r
 STATIC BOOLEAN mQemuFwCfgSupported = FALSE;\r
+STATIC BOOLEAN mQemuFwCfgDmaSupported;\r
 \r
 \r
 /**\r
@@ -51,8 +54,10 @@ QemuFwCfgInitialize (
 \r
   //\r
   // Enable the access routines while probing to see if it is supported.\r
+  // For probing we always use the IO Port (IoReadFifo8()) access method.\r
   //\r
   mQemuFwCfgSupported = TRUE;\r
+  mQemuFwCfgDmaSupported = FALSE;\r
 \r
   QemuFwCfgSelectItem (QemuFwCfgItemSignature);\r
   Signature = QemuFwCfgRead32 ();\r
@@ -68,7 +73,12 @@ QemuFwCfgInitialize (
     return RETURN_SUCCESS;\r
   }\r
 \r
-  DEBUG ((EFI_D_INFO, "QemuFwCfg interface is supported.\n"));\r
+  if ((Revision & FW_CFG_F_DMA) == 0) {\r
+    DEBUG ((DEBUG_INFO, "QemuFwCfg interface (IO Port) is supported.\n"));\r
+  } else {\r
+    mQemuFwCfgDmaSupported = TRUE;\r
+    DEBUG ((DEBUG_INFO, "QemuFwCfg interface (DMA) is supported.\n"));\r
+  }\r
   return RETURN_SUCCESS;\r
 }\r
 \r
@@ -83,10 +93,24 @@ QemuFwCfgInitialize (
   @retval    FALSE  The interface is not available internally.\r
 **/\r
 BOOLEAN\r
-EFIAPI\r
 InternalQemuFwCfgIsAvailable (\r
   VOID\r
   )\r
 {\r
   return mQemuFwCfgSupported;\r
 }\r
+\r
+/**\r
+  Returns a boolean indicating whether QEMU provides the DMA-like access method\r
+  for fw_cfg.\r
+\r
+  @retval    TRUE   The DMA-like access method is available.\r
+  @retval    FALSE  The DMA-like access method is unavailable.\r
+**/\r
+BOOLEAN\r
+InternalQemuFwCfgDmaIsAvailable (\r
+  VOID\r
+  )\r
+{\r
+  return mQemuFwCfgDmaSupported;\r
+}\r