]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Include/Library/QemuFwCfgLib.h
OvmfPkg/QemuFwCfgLib: extend lib class header with more definitions
[mirror_edk2.git] / OvmfPkg / Include / Library / QemuFwCfgLib.h
index 5a3db7e8099c135a475a6b720b66decece0123b4..3e017d53a97eacb05db39dae6cf9d73752688831 100644 (file)
@@ -1,7 +1,9 @@
 /** @file\r
   QEMU/KVM Firmware Configuration access\r
 \r
-  Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (C) 2013, Red Hat, Inc.\r
+\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 #ifndef __FW_CFG_LIB__\r
 #define __FW_CFG_LIB__\r
 \r
+//\r
+// The size, in bytes, of names of firmware configuration files, including at\r
+// least one terminating NUL byte.\r
+//\r
+#define QEMU_FW_CFG_FNAME_SIZE 56\r
+\r
+//\r
+// If the following bit is set in the UINT32 fw_cfg revision / feature bitmap\r
+// -- read from key 0x0001 with the basic IO Port or MMIO method --, then the\r
+// DMA interface is available.\r
+//\r
+#define FW_CFG_F_DMA BIT1\r
+\r
+//\r
+// Macros for the FW_CFG_DMA_ACCESS.Control bitmap (in native encoding).\r
+//\r
+#define FW_CFG_DMA_CTL_ERROR  BIT0\r
+#define FW_CFG_DMA_CTL_READ   BIT1\r
+#define FW_CFG_DMA_CTL_SKIP   BIT2\r
+#define FW_CFG_DMA_CTL_SELECT BIT3\r
+#define FW_CFG_DMA_CTL_WRITE  BIT4\r
+\r
 typedef enum {\r
   QemuFwCfgItemSignature            = 0x0000,\r
   QemuFwCfgItemInterfaceVersion     = 0x0001,\r
@@ -41,6 +65,7 @@ typedef enum {
   QemuFwCfgItemKernelSetupAddress   = 0x0016,\r
   QemuFwCfgItemKernelSetupSize      = 0x0017,\r
   QemuFwCfgItemKernelSetupData      = 0x0018,\r
+  QemuFwCfgItemFileDir              = 0x0019,\r
 \r
   QemuFwCfgItemX86AcpiTables        = 0x8000,\r
   QemuFwCfgItemX86SmbiosTables      = 0x8001,\r
@@ -50,11 +75,24 @@ typedef enum {
 \r
 } FIRMWARE_CONFIG_ITEM;\r
 \r
+//\r
+// Communication structure for the DMA access method. All fields are encoded in\r
+// big endian.\r
+//\r
+#pragma pack (1)\r
+typedef struct {\r
+  UINT32 Control;\r
+  UINT32 Length;\r
+  UINT64 Address;\r
+} FW_CFG_DMA_ACCESS;\r
+#pragma pack ()\r
 \r
 /**\r
   Returns a boolean indicating if the firmware configuration interface\r
   is available or not.\r
 \r
+  This function may change fw_cfg state.\r
+\r
   @retval    TRUE   The interface is available\r
   @retval    FALSE  The interface is not available\r
 \r
@@ -101,6 +139,25 @@ QemuFwCfgReadBytes (
   );\r
 \r
 \r
+/**\r
+  Writes firmware configuration bytes from a buffer\r
+\r
+  If called multiple times, then the data written will\r
+  continue at the offset of the firmware configuration\r
+  item where the previous write ended.\r
+\r
+  @param[in] Size - Size in bytes to write\r
+  @param[in] Buffer - Buffer to read data from\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+QemuFwCfgWriteBytes (\r
+  IN UINTN                  Size,\r
+  IN VOID                   *Buffer\r
+  );\r
+\r
+\r
 /**\r
   Reads a UINT8 firmware configuration value\r
 \r
@@ -153,5 +210,40 @@ QemuFwCfgRead64 (
   );\r
 \r
 \r
+/**\r
+  Find the configuration item corresponding to the firmware configuration file.\r
+\r
+  @param[in]  Name - Name of file to look up.\r
+  @param[out] Item - Configuration item corresponding to the file, to be passed\r
+                     to QemuFwCfgSelectItem ().\r
+  @param[out] Size - Number of bytes in the file.\r
+\r
+  @return    RETURN_SUCCESS       If file is found.\r
+             RETURN_NOT_FOUND     If file is not found.\r
+             RETURN_UNSUPPORTED   If firmware configuration is unavailable.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+QemuFwCfgFindFile (\r
+  IN   CONST CHAR8           *Name,\r
+  OUT  FIRMWARE_CONFIG_ITEM  *Item,\r
+  OUT  UINTN                 *Size\r
+  );\r
+\r
+\r
+/**\r
+  Determine if S3 support is explicitly enabled.\r
+\r
+  @retval  TRUE   if S3 support is explicitly enabled.\r
+           FALSE  otherwise. This includes unavailability of the firmware\r
+                  configuration interface.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+QemuFwCfgS3Enabled (\r
+  VOID\r
+  );\r
+\r
 #endif\r
 \r