]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c
OvmfPkg/IoMmuDxe: Unmap(): recycle MAP_INFO after BusMasterCommonBuffer[64]
[mirror_edk2.git] / OvmfPkg / Library / QemuFwCfgLib / QemuFwCfgSec.c
CommitLineData
c90decb9
LE
1/** @file\r
2\r
3 Stateless fw_cfg library implementation.\r
4\r
5 Clients must call QemuFwCfgIsAvailable() first.\r
6\r
7 Copyright (C) 2013, Red Hat, Inc.\r
8 Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>\r
6264abc2 9 Copyright (c) 2017, Advanced Micro Devices. All rights reserved.<BR>\r
c90decb9
LE
10\r
11 This program and the accompanying materials are licensed and made available\r
12 under the terms and conditions of the BSD License which accompanies this\r
13 distribution. The full text of the license may be found at\r
14 http://opensource.org/licenses/bsd-license.php\r
15\r
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
17 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
18**/\r
19\r
20#include <Library/DebugLib.h>\r
21#include <Library/QemuFwCfgLib.h>\r
22\r
5297c0bf 23#include "QemuFwCfgLibInternal.h"\r
c90decb9
LE
24\r
25/**\r
26 Returns a boolean indicating if the firmware configuration interface\r
27 is available or not.\r
28\r
29 This function may change fw_cfg state.\r
30\r
31 @retval TRUE The interface is available\r
32 @retval FALSE The interface is not available\r
33\r
34**/\r
35BOOLEAN\r
36EFIAPI\r
37QemuFwCfgIsAvailable (\r
38 VOID\r
39 )\r
40{\r
41 UINT32 Signature;\r
42 UINT32 Revision;\r
43\r
44 QemuFwCfgSelectItem (QemuFwCfgItemSignature);\r
45 Signature = QemuFwCfgRead32 ();\r
46 DEBUG ((EFI_D_INFO, "FW CFG Signature: 0x%x\n", Signature));\r
47 QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion);\r
48 Revision = QemuFwCfgRead32 ();\r
49 DEBUG ((EFI_D_INFO, "FW CFG Revision: 0x%x\n", Revision));\r
50 if ((Signature != SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||\r
51 (Revision < 1)\r
52 ) {\r
53 DEBUG ((EFI_D_INFO, "QemuFwCfg interface not supported.\n"));\r
54 return FALSE;\r
55 }\r
56\r
57 DEBUG ((EFI_D_INFO, "QemuFwCfg interface is supported.\n"));\r
58 return TRUE;\r
59}\r
60\r
61\r
62/**\r
63 Returns a boolean indicating if the firmware configuration interface is\r
64 available for library-internal purposes.\r
65\r
66 This function never changes fw_cfg state.\r
67\r
68 @retval TRUE The interface is available internally.\r
69 @retval FALSE The interface is not available internally.\r
70**/\r
71BOOLEAN\r
c90decb9
LE
72InternalQemuFwCfgIsAvailable (\r
73 VOID\r
74 )\r
75{\r
76 //\r
77 // We always return TRUE, because the consumer of this library ought to have\r
78 // called QemuFwCfgIsAvailable before making other calls which would hit this\r
79 // path.\r
80 //\r
81 return TRUE;\r
82}\r
2c8dcbc6
LE
83\r
84/**\r
85 Returns a boolean indicating whether QEMU provides the DMA-like access method\r
86 for fw_cfg.\r
87\r
88 @retval TRUE The DMA-like access method is available.\r
89 @retval FALSE The DMA-like access method is unavailable.\r
90**/\r
91BOOLEAN\r
92InternalQemuFwCfgDmaIsAvailable (\r
93 VOID\r
94 )\r
95{\r
96 return FALSE;\r
97}\r
6264abc2
BS
98\r
99/**\r
100\r
101 Returns a boolean indicating whether SEV is enabled\r
102\r
103 @retval TRUE SEV is enabled\r
104 @retval FALSE SEV is disabled\r
105**/\r
106BOOLEAN\r
107InternalQemuFwCfgSevIsEnabled (\r
108 VOID\r
109 )\r
110{\r
111 //\r
112 // DMA is not supported in SEC phase hence SEV support is irrelevant\r
113 //\r
114 return FALSE;\r
115}\r
116\r
117/**\r
118 Allocate a bounce buffer for SEV DMA.\r
119\r
120 @param[in] NumPage Number of pages.\r
121 @param[out] Buffer Allocated DMA Buffer pointer\r
122\r
123**/\r
124VOID\r
125InternalQemuFwCfgSevDmaAllocateBuffer (\r
126 OUT VOID **Buffer,\r
127 IN UINT32 NumPages\r
128 )\r
129{\r
130 //\r
131 // We should never reach here\r
132 //\r
133 ASSERT (FALSE);\r
134}\r
135\r
136/**\r
137 Free the DMA buffer allocated using InternalQemuFwCfgSevDmaAllocateBuffer\r
138\r
139 @param[in] NumPage Number of pages.\r
140 @param[in] Buffer DMA Buffer pointer\r
141\r
142**/\r
143VOID\r
144InternalQemuFwCfgSevDmaFreeBuffer (\r
145 IN VOID *Buffer,\r
146 IN UINT32 NumPages\r
147 )\r
148{\r
149 //\r
150 // We should never reach here\r
151 //\r
152 ASSERT (FALSE);\r
153}\r