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 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Library/BaseLib.h>
15 #include <Library/DebugLib.h>
16 #include <Library/QemuFwCfgLib.h>
18 #include "QemuFwCfgLibInternal.h"
21 Returns a boolean indicating if the firmware configuration interface
24 This function may change fw_cfg state.
26 @retval TRUE The interface is available
27 @retval FALSE The interface is not available
32 QemuFwCfgIsAvailable (
39 QemuFwCfgSelectItem (QemuFwCfgItemSignature
);
40 Signature
= QemuFwCfgRead32 ();
41 DEBUG ((EFI_D_INFO
, "FW CFG Signature: 0x%x\n", Signature
));
42 QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion
);
43 Revision
= QemuFwCfgRead32 ();
44 DEBUG ((EFI_D_INFO
, "FW CFG Revision: 0x%x\n", Revision
));
45 if ((Signature
!= SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||
48 DEBUG ((EFI_D_INFO
, "QemuFwCfg interface not supported.\n"));
52 DEBUG ((EFI_D_INFO
, "QemuFwCfg interface is supported.\n"));
58 Returns a boolean indicating if the firmware configuration interface is
59 available for library-internal purposes.
61 This function never changes fw_cfg state.
63 @retval TRUE The interface is available internally.
64 @retval FALSE The interface is not available internally.
67 InternalQemuFwCfgIsAvailable (
72 // We always return TRUE, because the consumer of this library ought to have
73 // called QemuFwCfgIsAvailable before making other calls which would hit this
80 Returns a boolean indicating whether QEMU provides the DMA-like access method
83 @retval TRUE The DMA-like access method is available.
84 @retval FALSE The DMA-like access method is unavailable.
87 InternalQemuFwCfgDmaIsAvailable (
95 Transfer an array of bytes, or skip a number of bytes, using the DMA
98 @param[in] Size Size in bytes to transfer or skip.
100 @param[in,out] Buffer Buffer to read data into or write data from. Ignored,
101 and may be NULL, if Size is zero, or Control is
104 @param[in] Control One of the following:
105 FW_CFG_DMA_CTL_WRITE - write to fw_cfg from Buffer.
106 FW_CFG_DMA_CTL_READ - read from fw_cfg into Buffer.
107 FW_CFG_DMA_CTL_SKIP - skip bytes in fw_cfg.
110 InternalQemuFwCfgDmaBytes (
112 IN OUT VOID
*Buffer OPTIONAL
,
117 // We should never reach here