]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/VirtioGpuDxe/VirtioGpu.h
OvmfPkg/VirtioGpuDxe: initialize and tear down VirtIo GPU device
[mirror_edk2.git] / OvmfPkg / VirtioGpuDxe / VirtioGpu.h
1 /** @file
2
3 Internal type and macro definitions for the Virtio GPU hybrid driver.
4
5 Copyright (C) 2016, Red Hat, Inc.
6
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
11
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.
14
15 **/
16
17 #ifndef _VIRTIO_GPU_DXE_H_
18 #define _VIRTIO_GPU_DXE_H_
19
20 #include <Library/DebugLib.h>
21 #include <Library/UefiLib.h>
22 #include <Protocol/VirtioDevice.h>
23
24 //
25 // Forward declaration of VGPU_GOP.
26 //
27 typedef struct VGPU_GOP_STRUCT VGPU_GOP;
28
29 //
30 // The abstraction that directly corresponds to a Virtio GPU device.
31 //
32 // This structure will be installed on the handle that has the VirtIo Device
33 // Protocol interface, with GUID gEfiCallerIdGuid. A similar trick is employed
34 // in TerminalDxe, and it is necessary so that we can look up VGPU_DEV just
35 // from the VirtIo Device Protocol handle in the Component Name 2 Protocol
36 // implementation.
37 //
38 typedef struct {
39 //
40 // VirtIo represents access to the Virtio GPU device. Never NULL.
41 //
42 VIRTIO_DEVICE_PROTOCOL *VirtIo;
43
44 //
45 // BusName carries a customized name for
46 // EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName(). It is expressed in table
47 // form because it can theoretically support several languages. Never NULL.
48 //
49 EFI_UNICODE_STRING_TABLE *BusName;
50
51 //
52 // VirtIo ring used for VirtIo communication.
53 //
54 VRING Ring;
55
56 //
57 // Event to be signaled at ExitBootServices().
58 //
59 EFI_EVENT ExitBoot;
60
61 //
62 // The Child field references the GOP wrapper structure. If this pointer is
63 // NULL, then the hybrid driver has bound (i.e., started) the
64 // VIRTIO_DEVICE_PROTOCOL controller without producing the child GOP
65 // controller (that is, after Start() was called with RemainingDevicePath
66 // pointing to and End of Device Path node). Child can be created and
67 // destroyed, even repeatedly, independently of VGPU_DEV.
68 //
69 // In practice, this field represents the single head (scanout) that we
70 // support.
71 //
72 VGPU_GOP *Child;
73 } VGPU_DEV;
74
75 //
76 // The Graphics Output Protocol wrapper structure.
77 //
78 #define VGPU_GOP_SIG SIGNATURE_64 ('V', 'G', 'P', 'U', '_', 'G', 'O', 'P')
79
80 struct VGPU_GOP_STRUCT {
81 UINT64 Signature;
82
83 //
84 // ParentBus points to the parent VGPU_DEV object. Never NULL.
85 //
86 VGPU_DEV *ParentBus;
87
88 //
89 // GopName carries a customized name for
90 // EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName(). It is expressed in table
91 // form because it can theoretically support several languages. Never NULL.
92 //
93 EFI_UNICODE_STRING_TABLE *GopName;
94
95 //
96 // GopHandle is the UEFI child handle that carries the device path ending
97 // with the ACPI ADR node, and the Graphics Output Protocol. Never NULL.
98 //
99 EFI_HANDLE GopHandle;
100
101 //
102 // The GopDevicePath field is the device path installed on GopHandle,
103 // ending with an ACPI ADR node. Never NULL.
104 //
105 EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
106
107 //
108 // The Gop field is installed on the child handle as Graphics Output Protocol
109 // interface.
110 //
111 // For now it is just a placeholder.
112 //
113 UINT8 Gop;
114 };
115
116 //
117 // VirtIo GPU initialization, and commands (primitives) for the GPU device.
118 //
119 /**
120 Configure the VirtIo GPU device that underlies VgpuDev.
121
122 @param[in,out] VgpuDev The VGPU_DEV object to set up VirtIo messaging for.
123 On input, the caller is responsible for having
124 initialized VgpuDev->VirtIo. On output, VgpuDev->Ring
125 has been initialized, and synchronous VirtIo GPU
126 commands (primitives) can be submitted to the device.
127
128 @retval EFI_SUCCESS VirtIo GPU configuration successful.
129
130 @retval EFI_UNSUPPORTED The host-side configuration of the VirtIo GPU is not
131 supported by this driver.
132
133 @retval Error codes from underlying functions.
134 **/
135 EFI_STATUS
136 VirtioGpuInit (
137 IN OUT VGPU_DEV *VgpuDev
138 );
139
140 /**
141 De-configure the VirtIo GPU device that underlies VgpuDev.
142
143 @param[in,out] VgpuDev The VGPU_DEV object to tear down VirtIo messaging
144 for. On input, the caller is responsible for having
145 called VirtioGpuInit(). On output, VgpuDev->Ring has
146 been uninitialized; VirtIo GPU commands (primitives)
147 can no longer be submitted to the device.
148 **/
149 VOID
150 VirtioGpuUninit (
151 IN OUT VGPU_DEV *VgpuDev
152 );
153
154 /**
155 EFI_EVENT_NOTIFY function for the VGPU_DEV.ExitBoot event. It resets the
156 VirtIo device, causing it to release its resources and to forget its
157 configuration.
158
159 This function may only be called (that is, VGPU_DEV.ExitBoot may only be
160 signaled) after VirtioGpuInit() returns and before VirtioGpuUninit() is
161 called.
162
163 @param[in] Event Event whose notification function is being invoked.
164
165 @param[in] Context Pointer to the associated VGPU_DEV object.
166 **/
167 VOID
168 EFIAPI
169 VirtioGpuExitBoot (
170 IN EFI_EVENT Event,
171 IN VOID *Context
172 );
173
174 #endif // _VIRTIO_GPU_DXE_H_