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