3 Stateful and implicitly initialized fw_cfg library implementation.
5 Copyright (C) 2013, Red Hat, Inc.
6 Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials are licensed and made available
9 under the terms and conditions of the BSD License which accompanies this
10 distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
14 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Library/DebugLib.h>
18 #include <Library/QemuFwCfgLib.h>
20 STATIC BOOLEAN mQemuFwCfgSupported
= FALSE
;
24 Returns a boolean indicating if the firmware configuration interface
27 This function may change fw_cfg state.
29 @retval TRUE The interface is available
30 @retval FALSE The interface is not available
35 QemuFwCfgIsAvailable (
39 return InternalQemuFwCfgIsAvailable ();
53 // Enable the access routines while probing to see if it is supported.
55 mQemuFwCfgSupported
= TRUE
;
57 QemuFwCfgSelectItem (QemuFwCfgItemSignature
);
58 Signature
= QemuFwCfgRead32 ();
59 DEBUG ((EFI_D_INFO
, "FW CFG Signature: 0x%x\n", Signature
));
60 QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion
);
61 Revision
= QemuFwCfgRead32 ();
62 DEBUG ((EFI_D_INFO
, "FW CFG Revision: 0x%x\n", Revision
));
63 if ((Signature
!= SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||
66 DEBUG ((EFI_D_INFO
, "QemuFwCfg interface not supported.\n"));
67 mQemuFwCfgSupported
= FALSE
;
68 return RETURN_SUCCESS
;
71 DEBUG ((EFI_D_INFO
, "QemuFwCfg interface is supported.\n"));
72 return RETURN_SUCCESS
;
77 Returns a boolean indicating if the firmware configuration interface is
78 available for library-internal purposes.
80 This function never changes fw_cfg state.
82 @retval TRUE The interface is available internally.
83 @retval FALSE The interface is not available internally.
87 InternalQemuFwCfgIsAvailable (
91 return mQemuFwCfgSupported
;