3 Internal type and macro definitions for the Virtio GPU hybrid driver.
5 Copyright (C) 2016, Red Hat, Inc.
7 This program and the accompanying materials are licensed and made available
8 under the terms and conditions of the BSD License which accompanies this
9 distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
13 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #ifndef _VIRTIO_GPU_DXE_H_
18 #define _VIRTIO_GPU_DXE_H_
20 #include <IndustryStandard/VirtioGpu.h>
21 #include <Library/DebugLib.h>
22 #include <Library/UefiLib.h>
23 #include <Protocol/VirtioDevice.h>
26 // Forward declaration of VGPU_GOP.
28 typedef struct VGPU_GOP_STRUCT VGPU_GOP
;
31 // The abstraction that directly corresponds to a Virtio GPU device.
33 // This structure will be installed on the handle that has the VirtIo Device
34 // Protocol interface, with GUID gEfiCallerIdGuid. A similar trick is employed
35 // in TerminalDxe, and it is necessary so that we can look up VGPU_DEV just
36 // from the VirtIo Device Protocol handle in the Component Name 2 Protocol
41 // VirtIo represents access to the Virtio GPU device. Never NULL.
43 VIRTIO_DEVICE_PROTOCOL
*VirtIo
;
46 // BusName carries a customized name for
47 // EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName(). It is expressed in table
48 // form because it can theoretically support several languages. Never NULL.
50 EFI_UNICODE_STRING_TABLE
*BusName
;
53 // VirtIo ring used for VirtIo communication.
58 // Event to be signaled at ExitBootServices().
63 // Common running counter for all VirtIo GPU requests that ask for fencing.
68 // The Child field references the GOP wrapper structure. If this pointer is
69 // NULL, then the hybrid driver has bound (i.e., started) the
70 // VIRTIO_DEVICE_PROTOCOL controller without producing the child GOP
71 // controller (that is, after Start() was called with RemainingDevicePath
72 // pointing to and End of Device Path node). Child can be created and
73 // destroyed, even repeatedly, independently of VGPU_DEV.
75 // In practice, this field represents the single head (scanout) that we
82 // The Graphics Output Protocol wrapper structure.
84 #define VGPU_GOP_SIG SIGNATURE_64 ('V', 'G', 'P', 'U', '_', 'G', 'O', 'P')
86 struct VGPU_GOP_STRUCT
{
90 // ParentBus points to the parent VGPU_DEV object. Never NULL.
95 // GopName carries a customized name for
96 // EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName(). It is expressed in table
97 // form because it can theoretically support several languages. Never NULL.
99 EFI_UNICODE_STRING_TABLE
*GopName
;
102 // GopHandle is the UEFI child handle that carries the device path ending
103 // with the ACPI ADR node, and the Graphics Output Protocol. Never NULL.
105 EFI_HANDLE GopHandle
;
108 // The GopDevicePath field is the device path installed on GopHandle,
109 // ending with an ACPI ADR node. Never NULL.
111 EFI_DEVICE_PATH_PROTOCOL
*GopDevicePath
;
114 // The Gop field is installed on the child handle as Graphics Output Protocol
117 // For now it is just a placeholder.
123 // VirtIo GPU initialization, and commands (primitives) for the GPU device.
126 Configure the VirtIo GPU device that underlies VgpuDev.
128 @param[in,out] VgpuDev The VGPU_DEV object to set up VirtIo messaging for.
129 On input, the caller is responsible for having
130 initialized VgpuDev->VirtIo. On output, VgpuDev->Ring
131 has been initialized, and synchronous VirtIo GPU
132 commands (primitives) can be submitted to the device.
134 @retval EFI_SUCCESS VirtIo GPU configuration successful.
136 @retval EFI_UNSUPPORTED The host-side configuration of the VirtIo GPU is not
137 supported by this driver.
139 @retval Error codes from underlying functions.
143 IN OUT VGPU_DEV
*VgpuDev
147 De-configure the VirtIo GPU device that underlies VgpuDev.
149 @param[in,out] VgpuDev The VGPU_DEV object to tear down VirtIo messaging
150 for. On input, the caller is responsible for having
151 called VirtioGpuInit(). On output, VgpuDev->Ring has
152 been uninitialized; VirtIo GPU commands (primitives)
153 can no longer be submitted to the device.
157 IN OUT VGPU_DEV
*VgpuDev
161 EFI_EVENT_NOTIFY function for the VGPU_DEV.ExitBoot event. It resets the
162 VirtIo device, causing it to release its resources and to forget its
165 This function may only be called (that is, VGPU_DEV.ExitBoot may only be
166 signaled) after VirtioGpuInit() returns and before VirtioGpuUninit() is
169 @param[in] Event Event whose notification function is being invoked.
171 @param[in] Context Pointer to the associated VGPU_DEV object.
181 The following functions send requests to the VirtIo GPU device model, await
182 the answer from the host, and return a status. They share the following
185 @param[in,out] VgpuDev The VGPU_DEV object that represents the VirtIo GPU
186 device. The caller is responsible to have
187 successfully invoked VirtioGpuInit() on VgpuDev
188 previously, while VirtioGpuUninit() must not have
189 been called on VgpuDev.
191 @retval EFI_INVALID_PARAMETER Invalid command-specific parameters were
192 detected by this driver.
194 @retval EFI_SUCCESS Operation successful.
196 @retval EFI_DEVICE_ERROR The host rejected the request. The host error
197 code has been logged on the EFI_D_ERROR level.
199 @return Codes for unexpected errors in VirtIo
202 For the command-specific parameters, please consult the GPU Device section of
203 the VirtIo 1.0 specification (see references in
204 "OvmfPkg/Include/IndustryStandard/VirtioGpu.h").
207 VirtioGpuResourceCreate2d (
208 IN OUT VGPU_DEV
*VgpuDev
,
209 IN UINT32 ResourceId
,
210 IN VIRTIO_GPU_FORMATS Format
,
216 VirtioGpuResourceUnref (
217 IN OUT VGPU_DEV
*VgpuDev
,
222 VirtioGpuResourceAttachBacking (
223 IN OUT VGPU_DEV
*VgpuDev
,
224 IN UINT32 ResourceId
,
225 IN VOID
*FirstBackingPage
,
226 IN UINTN NumberOfPages
230 VirtioGpuResourceDetachBacking (
231 IN OUT VGPU_DEV
*VgpuDev
,
236 VirtioGpuSetScanout (
237 IN OUT VGPU_DEV
*VgpuDev
,
247 VirtioGpuTransferToHost2d (
248 IN OUT VGPU_DEV
*VgpuDev
,
258 VirtioGpuResourceFlush (
259 IN OUT VGPU_DEV
*VgpuDev
,
267 #endif // _VIRTIO_GPU_DXE_H_