Vishal Bhoj | 82c8071 | 2015-12-15 21:13:33 +0530 | [diff] [blame] | 1 | /** @file
|
| 2 |
|
| 3 | Stateless fw_cfg library implementation.
|
| 4 |
|
| 5 | Clients must call QemuFwCfgIsAvailable() first.
|
| 6 |
|
| 7 | Copyright (C) 2013, Red Hat, Inc.
|
| 8 | Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
|
| 9 |
|
| 10 | This program and the accompanying materials are licensed and made available
|
| 11 | under the terms and conditions of the BSD License which accompanies this
|
| 12 | distribution. The full text of the license may be found at
|
| 13 | http://opensource.org/licenses/bsd-license.php
|
| 14 |
|
| 15 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
|
| 16 | WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
| 17 | **/
|
| 18 |
|
| 19 | #include <Library/DebugLib.h>
|
| 20 | #include <Library/QemuFwCfgLib.h>
|
| 21 |
|
| 22 |
|
| 23 | /**
|
| 24 | Returns a boolean indicating if the firmware configuration interface
|
| 25 | is available or not.
|
| 26 |
|
| 27 | This function may change fw_cfg state.
|
| 28 |
|
| 29 | @retval TRUE The interface is available
|
| 30 | @retval FALSE The interface is not available
|
| 31 |
|
| 32 | **/
|
| 33 | BOOLEAN
|
| 34 | EFIAPI
|
| 35 | QemuFwCfgIsAvailable (
|
| 36 | VOID
|
| 37 | )
|
| 38 | {
|
| 39 | UINT32 Signature;
|
| 40 | UINT32 Revision;
|
| 41 |
|
| 42 | QemuFwCfgSelectItem (QemuFwCfgItemSignature);
|
| 43 | Signature = QemuFwCfgRead32 ();
|
| 44 | DEBUG ((EFI_D_INFO, "FW CFG Signature: 0x%x\n", Signature));
|
| 45 | QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion);
|
| 46 | Revision = QemuFwCfgRead32 ();
|
| 47 | DEBUG ((EFI_D_INFO, "FW CFG Revision: 0x%x\n", Revision));
|
| 48 | if ((Signature != SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||
|
| 49 | (Revision < 1)
|
| 50 | ) {
|
| 51 | DEBUG ((EFI_D_INFO, "QemuFwCfg interface not supported.\n"));
|
| 52 | return FALSE;
|
| 53 | }
|
| 54 |
|
| 55 | DEBUG ((EFI_D_INFO, "QemuFwCfg interface is supported.\n"));
|
| 56 | return TRUE;
|
| 57 | }
|
| 58 |
|
| 59 |
|
| 60 | /**
|
| 61 | Returns a boolean indicating if the firmware configuration interface is
|
| 62 | available for library-internal purposes.
|
| 63 |
|
| 64 | This function never changes fw_cfg state.
|
| 65 |
|
| 66 | @retval TRUE The interface is available internally.
|
| 67 | @retval FALSE The interface is not available internally.
|
| 68 | **/
|
| 69 | BOOLEAN
|
| 70 | EFIAPI
|
| 71 | InternalQemuFwCfgIsAvailable (
|
| 72 | VOID
|
| 73 | )
|
| 74 | {
|
| 75 | //
|
| 76 | // We always return TRUE, because the consumer of this library ought to have
|
| 77 | // called QemuFwCfgIsAvailable before making other calls which would hit this
|
| 78 | // path.
|
| 79 | //
|
| 80 | return TRUE;
|
| 81 | }
|