]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiDxe.c
OvmfPkg QemuFwCfgLib: Convert Ia32/IoLibExAsm.asm to NASM
[mirror_edk2.git] / OvmfPkg / Library / QemuFwCfgLib / QemuFwCfgPeiDxe.c
CommitLineData
2ce7e221
LE
1/** @file\r
2\r
3 Stateful and implicitly initialized fw_cfg library implementation.\r
4\r
5 Copyright (C) 2013, Red Hat, Inc.\r
6 Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>\r
7\r
8 This program and the accompanying materials are licensed and made available\r
9 under the terms and conditions of the BSD License which accompanies this\r
10 distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
14 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15**/\r
16\r
17#include <Library/DebugLib.h>\r
18#include <Library/QemuFwCfgLib.h>\r
19\r
20STATIC BOOLEAN mQemuFwCfgSupported = FALSE;\r
21\r
22\r
23/**\r
24 Returns a boolean indicating if the firmware configuration interface\r
25 is available or not.\r
26\r
27 This function may change fw_cfg state.\r
28\r
29 @retval TRUE The interface is available\r
30 @retval FALSE The interface is not available\r
31\r
32**/\r
33BOOLEAN\r
34EFIAPI\r
35QemuFwCfgIsAvailable (\r
36 VOID\r
37 )\r
38{\r
39 return InternalQemuFwCfgIsAvailable ();\r
40}\r
41\r
42\r
43RETURN_STATUS\r
44EFIAPI\r
45QemuFwCfgInitialize (\r
46 VOID\r
47 )\r
48{\r
49 UINT32 Signature;\r
50 UINT32 Revision;\r
51\r
52 //\r
53 // Enable the access routines while probing to see if it is supported.\r
54 //\r
55 mQemuFwCfgSupported = TRUE;\r
56\r
57 QemuFwCfgSelectItem (QemuFwCfgItemSignature);\r
58 Signature = QemuFwCfgRead32 ();\r
59 DEBUG ((EFI_D_INFO, "FW CFG Signature: 0x%x\n", Signature));\r
60 QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion);\r
61 Revision = QemuFwCfgRead32 ();\r
62 DEBUG ((EFI_D_INFO, "FW CFG Revision: 0x%x\n", Revision));\r
63 if ((Signature != SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||\r
64 (Revision < 1)\r
65 ) {\r
66 DEBUG ((EFI_D_INFO, "QemuFwCfg interface not supported.\n"));\r
67 mQemuFwCfgSupported = FALSE;\r
68 return RETURN_SUCCESS;\r
69 }\r
70\r
71 DEBUG ((EFI_D_INFO, "QemuFwCfg interface is supported.\n"));\r
72 return RETURN_SUCCESS;\r
73}\r
74\r
75\r
76/**\r
77 Returns a boolean indicating if the firmware configuration interface is\r
78 available for library-internal purposes.\r
79\r
80 This function never changes fw_cfg state.\r
81\r
82 @retval TRUE The interface is available internally.\r
83 @retval FALSE The interface is not available internally.\r
84**/\r
85BOOLEAN\r
86EFIAPI\r
87InternalQemuFwCfgIsAvailable (\r
88 VOID\r
89 )\r
90{\r
91 return mQemuFwCfgSupported;\r
92}\r