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/DebugLib.h>
21 #include <Library/QemuFwCfgLib.h>
23 #include "QemuFwCfgLibInternal.h"
26 Returns a boolean indicating if the firmware configuration interface
29 This function may change fw_cfg state.
31 @retval TRUE The interface is available
32 @retval FALSE The interface is not available
37 QemuFwCfgIsAvailable (
44 QemuFwCfgSelectItem (QemuFwCfgItemSignature
);
45 Signature
= QemuFwCfgRead32 ();
46 DEBUG ((EFI_D_INFO
, "FW CFG Signature: 0x%x\n", Signature
));
47 QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion
);
48 Revision
= QemuFwCfgRead32 ();
49 DEBUG ((EFI_D_INFO
, "FW CFG Revision: 0x%x\n", Revision
));
50 if ((Signature
!= SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||
53 DEBUG ((EFI_D_INFO
, "QemuFwCfg interface not supported.\n"));
57 DEBUG ((EFI_D_INFO
, "QemuFwCfg interface is supported.\n"));
63 Returns a boolean indicating if the firmware configuration interface is
64 available for library-internal purposes.
66 This function never changes fw_cfg state.
68 @retval TRUE The interface is available internally.
69 @retval FALSE The interface is not available internally.
72 InternalQemuFwCfgIsAvailable (
77 // We always return TRUE, because the consumer of this library ought to have
78 // called QemuFwCfgIsAvailable before making other calls which would hit this
85 Returns a boolean indicating whether QEMU provides the DMA-like access method
88 @retval TRUE The DMA-like access method is available.
89 @retval FALSE The DMA-like access method is unavailable.
92 InternalQemuFwCfgDmaIsAvailable (
101 Returns a boolean indicating whether SEV is enabled
103 @retval TRUE SEV is enabled
104 @retval FALSE SEV is disabled
107 InternalQemuFwCfgSevIsEnabled (
112 // DMA is not supported in SEC phase hence SEV support is irrelevant
118 Allocate a bounce buffer for SEV DMA.
120 @param[in] NumPage Number of pages.
121 @param[out] Buffer Allocated DMA Buffer pointer
125 InternalQemuFwCfgSevDmaAllocateBuffer (
131 // We should never reach here
137 Free the DMA buffer allocated using InternalQemuFwCfgSevDmaAllocateBuffer
139 @param[in] NumPage Number of pages.
140 @param[in] Buffer DMA Buffer pointer
144 InternalQemuFwCfgSevDmaFreeBuffer (
150 // We should never reach here