]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c
OvmfPkg: Modify QemuFwCfgLib to use new IoLib class library
[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
9\r
10 This program and the accompanying materials are licensed and made available\r
11 under the terms and conditions of the BSD License which accompanies this\r
12 distribution. The full text of the license may be found at\r
13 http://opensource.org/licenses/bsd-license.php\r
14\r
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
16 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
17**/\r
18\r
19#include <Library/DebugLib.h>\r
20#include <Library/QemuFwCfgLib.h>\r
21\r
5297c0bf 22#include "QemuFwCfgLibInternal.h"\r
c90decb9
LE
23\r
24/**\r
25 Returns a boolean indicating if the firmware configuration interface\r
26 is available or not.\r
27\r
28 This function may change fw_cfg state.\r
29\r
30 @retval TRUE The interface is available\r
31 @retval FALSE The interface is not available\r
32\r
33**/\r
34BOOLEAN\r
35EFIAPI\r
36QemuFwCfgIsAvailable (\r
37 VOID\r
38 )\r
39{\r
40 UINT32 Signature;\r
41 UINT32 Revision;\r
42\r
43 QemuFwCfgSelectItem (QemuFwCfgItemSignature);\r
44 Signature = QemuFwCfgRead32 ();\r
45 DEBUG ((EFI_D_INFO, "FW CFG Signature: 0x%x\n", Signature));\r
46 QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion);\r
47 Revision = QemuFwCfgRead32 ();\r
48 DEBUG ((EFI_D_INFO, "FW CFG Revision: 0x%x\n", Revision));\r
49 if ((Signature != SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||\r
50 (Revision < 1)\r
51 ) {\r
52 DEBUG ((EFI_D_INFO, "QemuFwCfg interface not supported.\n"));\r
53 return FALSE;\r
54 }\r
55\r
56 DEBUG ((EFI_D_INFO, "QemuFwCfg interface is supported.\n"));\r
57 return TRUE;\r
58}\r
59\r
60\r
61/**\r
62 Returns a boolean indicating if the firmware configuration interface is\r
63 available for library-internal purposes.\r
64\r
65 This function never changes fw_cfg state.\r
66\r
67 @retval TRUE The interface is available internally.\r
68 @retval FALSE The interface is not available internally.\r
69**/\r
70BOOLEAN\r
c90decb9
LE
71InternalQemuFwCfgIsAvailable (\r
72 VOID\r
73 )\r
74{\r
75 //\r
76 // We always return TRUE, because the consumer of this library ought to have\r
77 // called QemuFwCfgIsAvailable before making other calls which would hit this\r
78 // path.\r
79 //\r
80 return TRUE;\r
81}\r
2c8dcbc6
LE
82\r
83/**\r
84 Returns a boolean indicating whether QEMU provides the DMA-like access method\r
85 for fw_cfg.\r
86\r
87 @retval TRUE The DMA-like access method is available.\r
88 @retval FALSE The DMA-like access method is unavailable.\r
89**/\r
90BOOLEAN\r
91InternalQemuFwCfgDmaIsAvailable (\r
92 VOID\r
93 )\r
94{\r
95 return FALSE;\r
96}\r