3 Stateless fw_cfg library implementation.
5 Clients must call QemuFwCfgIsAvailable() first.
7 Copyright (C) 2013, Red Hat, Inc.
8 Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
9 Copyright (c) 2017, Advanced Micro Devices. All rights reserved.<BR>
11 This program and the accompanying materials are licensed and made available
12 under the terms and conditions of the BSD License which accompanies this
13 distribution. The full text of the license may be found at
14 http://opensource.org/licenses/bsd-license.php
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
17 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #include <Library/BaseLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/QemuFwCfgLib.h>
24 #include "QemuFwCfgLibInternal.h"
27 Returns a boolean indicating if the firmware configuration interface
30 This function may change fw_cfg state.
32 @retval TRUE The interface is available
33 @retval FALSE The interface is not available
38 QemuFwCfgIsAvailable (
45 QemuFwCfgSelectItem (QemuFwCfgItemSignature
);
46 Signature
= QemuFwCfgRead32 ();
47 DEBUG ((EFI_D_INFO
, "FW CFG Signature: 0x%x\n", Signature
));
48 QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion
);
49 Revision
= QemuFwCfgRead32 ();
50 DEBUG ((EFI_D_INFO
, "FW CFG Revision: 0x%x\n", Revision
));
51 if ((Signature
!= SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||
54 DEBUG ((EFI_D_INFO
, "QemuFwCfg interface not supported.\n"));
58 DEBUG ((EFI_D_INFO
, "QemuFwCfg interface is supported.\n"));
64 Returns a boolean indicating if the firmware configuration interface is
65 available for library-internal purposes.
67 This function never changes fw_cfg state.
69 @retval TRUE The interface is available internally.
70 @retval FALSE The interface is not available internally.
73 InternalQemuFwCfgIsAvailable (
78 // We always return TRUE, because the consumer of this library ought to have
79 // called QemuFwCfgIsAvailable before making other calls which would hit this
86 Returns a boolean indicating whether QEMU provides the DMA-like access method
89 @retval TRUE The DMA-like access method is available.
90 @retval FALSE The DMA-like access method is unavailable.
93 InternalQemuFwCfgDmaIsAvailable (
101 Transfer an array of bytes, or skip a number of bytes, using the DMA
104 @param[in] Size Size in bytes to transfer or skip.
106 @param[in,out] Buffer Buffer to read data into or write data from. Ignored,
107 and may be NULL, if Size is zero, or Control is
110 @param[in] Control One of the following:
111 FW_CFG_DMA_CTL_WRITE - write to fw_cfg from Buffer.
112 FW_CFG_DMA_CTL_READ - read from fw_cfg into Buffer.
113 FW_CFG_DMA_CTL_SKIP - skip bytes in fw_cfg.
116 InternalQemuFwCfgDmaBytes (
118 IN OUT VOID
*Buffer OPTIONAL
,
123 // We should never reach here