VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c@ 85788

Last change on this file since 85788 was 85718, checked in by vboxsync, 5 years ago

Devices/EFI: Merge edk-stable202005 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
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 Copyright (c) 2017, Advanced Micro Devices. All rights reserved.<BR>
10
11 SPDX-License-Identifier: BSD-2-Clause-Patent
12**/
13
14#include <Library/BaseLib.h>
15#include <Library/DebugLib.h>
16#include <Library/QemuFwCfgLib.h>
17
18#include "QemuFwCfgLibInternal.h"
19
20/**
21 Returns a boolean indicating if the firmware configuration interface
22 is available or not.
23
24 This function may change fw_cfg state.
25
26 @retval TRUE The interface is available
27 @retval FALSE The interface is not available
28
29**/
30BOOLEAN
31EFIAPI
32QemuFwCfgIsAvailable (
33 VOID
34 )
35{
36 UINT32 Signature;
37 UINT32 Revision;
38
39 QemuFwCfgSelectItem (QemuFwCfgItemSignature);
40 Signature = QemuFwCfgRead32 ();
41 DEBUG ((DEBUG_INFO, "FW CFG Signature: 0x%x\n", Signature));
42 QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion);
43 Revision = QemuFwCfgRead32 ();
44 DEBUG ((DEBUG_INFO, "FW CFG Revision: 0x%x\n", Revision));
45 if ((Signature != SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||
46 (Revision < 1)
47 ) {
48 DEBUG ((DEBUG_INFO, "QemuFwCfg interface not supported.\n"));
49 return FALSE;
50 }
51
52 DEBUG ((DEBUG_INFO, "QemuFwCfg interface is supported.\n"));
53 return TRUE;
54}
55
56
57/**
58 Returns a boolean indicating if the firmware configuration interface is
59 available for library-internal purposes.
60
61 This function never changes fw_cfg state.
62
63 @retval TRUE The interface is available internally.
64 @retval FALSE The interface is not available internally.
65**/
66BOOLEAN
67InternalQemuFwCfgIsAvailable (
68 VOID
69 )
70{
71 //
72 // We always return TRUE, because the consumer of this library ought to have
73 // called QemuFwCfgIsAvailable before making other calls which would hit this
74 // path.
75 //
76 return TRUE;
77}
78
79/**
80 Returns a boolean indicating whether QEMU provides the DMA-like access method
81 for fw_cfg.
82
83 @retval TRUE The DMA-like access method is available.
84 @retval FALSE The DMA-like access method is unavailable.
85**/
86BOOLEAN
87InternalQemuFwCfgDmaIsAvailable (
88 VOID
89 )
90{
91 return FALSE;
92}
93
94/**
95 Transfer an array of bytes, or skip a number of bytes, using the DMA
96 interface.
97
98 @param[in] Size Size in bytes to transfer or skip.
99
100 @param[in,out] Buffer Buffer to read data into or write data from. Ignored,
101 and may be NULL, if Size is zero, or Control is
102 FW_CFG_DMA_CTL_SKIP.
103
104 @param[in] Control One of the following:
105 FW_CFG_DMA_CTL_WRITE - write to fw_cfg from Buffer.
106 FW_CFG_DMA_CTL_READ - read from fw_cfg into Buffer.
107 FW_CFG_DMA_CTL_SKIP - skip bytes in fw_cfg.
108**/
109VOID
110InternalQemuFwCfgDmaBytes (
111 IN UINT32 Size,
112 IN OUT VOID *Buffer OPTIONAL,
113 IN UINT32 Control
114 )
115{
116 //
117 // We should never reach here
118 //
119 ASSERT (FALSE);
120 CpuDeadLoop ();
121}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette