]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/VirtioGpuDxe/VirtioGpu.h
OvmfPkg/AcpiPlatformDxe: update PointerValue comments in "BootScript.c"
[mirror_edk2.git] / OvmfPkg / VirtioGpuDxe / VirtioGpu.h
index ca5805df8442c1bc3d119ae884106969da0d5e94..078b7d44d83e994bf93ee121d8ef81fd42a82f78 100644 (file)
 #ifndef _VIRTIO_GPU_DXE_H_\r
 #define _VIRTIO_GPU_DXE_H_\r
 \r
+#include <IndustryStandard/VirtioGpu.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiLib.h>\r
+#include <Protocol/GraphicsOutput.h>\r
 #include <Protocol/VirtioDevice.h>\r
 \r
 //\r
@@ -48,6 +50,21 @@ typedef struct {
   //\r
   EFI_UNICODE_STRING_TABLE *BusName;\r
 \r
+  //\r
+  // VirtIo ring used for VirtIo communication.\r
+  //\r
+  VRING                    Ring;\r
+\r
+  //\r
+  // Event to be signaled at ExitBootServices().\r
+  //\r
+  EFI_EVENT                ExitBoot;\r
+\r
+  //\r
+  // Common running counter for all VirtIo GPU requests that ask for fencing.\r
+  //\r
+  UINT64                   FenceId;\r
+\r
   //\r
   // The Child field references the GOP wrapper structure. If this pointer is\r
   // NULL, then the hybrid driver has bound (i.e., started) the\r
@@ -98,9 +115,213 @@ struct VGPU_GOP_STRUCT {
   // The Gop field is installed on the child handle as Graphics Output Protocol\r
   // interface.\r
   //\r
-  // For now it is just a placeholder.\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL         Gop;\r
+\r
+  //\r
+  // Referenced by Gop.Mode, GopMode provides a summary about the supported\r
+  // graphics modes, and the current mode.\r
+  //\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE    GopMode;\r
+\r
+  //\r
+  // Referenced by GopMode.Info, GopModeInfo provides detailed information\r
+  // about the current mode.\r
+  //\r
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION GopModeInfo;\r
+\r
+  //\r
+  // Identifier of the 2D host resource that is in use by this head (scanout)\r
+  // of the VirtIo GPU device. Zero until the first successful -- internal --\r
+  // Gop.SetMode() call, never zero afterwards.\r
+  //\r
+  UINT32                               ResourceId;\r
+\r
   //\r
-  UINT8                                Gop;\r
+  // A number of whole pages providing the backing store for the 2D host\r
+  // resource identified by ResourceId above. NULL until the first successful\r
+  // -- internal -- Gop.SetMode() call, never NULL afterwards.\r
+  //\r
+  UINT32                               *BackingStore;\r
+  UINTN                                NumberOfPages;\r
 };\r
 \r
+//\r
+// VirtIo GPU initialization, and commands (primitives) for the GPU device.\r
+//\r
+/**\r
+  Configure the VirtIo GPU device that underlies VgpuDev.\r
+\r
+  @param[in,out] VgpuDev  The VGPU_DEV object to set up VirtIo messaging for.\r
+                          On input, the caller is responsible for having\r
+                          initialized VgpuDev->VirtIo. On output, VgpuDev->Ring\r
+                          has been initialized, and synchronous VirtIo GPU\r
+                          commands (primitives) can be submitted to the device.\r
+\r
+  @retval EFI_SUCCESS      VirtIo GPU configuration successful.\r
+\r
+  @retval EFI_UNSUPPORTED  The host-side configuration of the VirtIo GPU is not\r
+                           supported by this driver.\r
+\r
+  @retval                  Error codes from underlying functions.\r
+**/\r
+EFI_STATUS\r
+VirtioGpuInit (\r
+  IN OUT VGPU_DEV *VgpuDev\r
+  );\r
+\r
+/**\r
+  De-configure the VirtIo GPU device that underlies VgpuDev.\r
+\r
+  @param[in,out] VgpuDev  The VGPU_DEV object to tear down VirtIo messaging\r
+                          for. On input, the caller is responsible for having\r
+                          called VirtioGpuInit(). On output, VgpuDev->Ring has\r
+                          been uninitialized; VirtIo GPU commands (primitives)\r
+                          can no longer be submitted to the device.\r
+**/\r
+VOID\r
+VirtioGpuUninit (\r
+  IN OUT VGPU_DEV *VgpuDev\r
+  );\r
+\r
+/**\r
+  EFI_EVENT_NOTIFY function for the VGPU_DEV.ExitBoot event. It resets the\r
+  VirtIo device, causing it to release its resources and to forget its\r
+  configuration.\r
+\r
+  This function may only be called (that is, VGPU_DEV.ExitBoot may only be\r
+  signaled) after VirtioGpuInit() returns and before VirtioGpuUninit() is\r
+  called.\r
+\r
+  @param[in] Event    Event whose notification function is being invoked.\r
+\r
+  @param[in] Context  Pointer to the associated VGPU_DEV object.\r
+**/\r
+VOID\r
+EFIAPI\r
+VirtioGpuExitBoot (\r
+  IN EFI_EVENT Event,\r
+  IN VOID      *Context\r
+  );\r
+\r
+/**\r
+  The following functions send requests to the VirtIo GPU device model, await\r
+  the answer from the host, and return a status. They share the following\r
+  interface details:\r
+\r
+  @param[in,out] VgpuDev  The VGPU_DEV object that represents the VirtIo GPU\r
+                          device. The caller is responsible to have\r
+                          successfully invoked VirtioGpuInit() on VgpuDev\r
+                          previously, while VirtioGpuUninit() must not have\r
+                          been called on VgpuDev.\r
+\r
+  @retval EFI_INVALID_PARAMETER  Invalid command-specific parameters were\r
+                                 detected by this driver.\r
+\r
+  @retval EFI_SUCCESS            Operation successful.\r
+\r
+  @retval EFI_DEVICE_ERROR       The host rejected the request. The host error\r
+                                 code has been logged on the EFI_D_ERROR level.\r
+\r
+  @return                        Codes for unexpected errors in VirtIo\r
+                                 messaging.\r
+\r
+  For the command-specific parameters, please consult the GPU Device section of\r
+  the VirtIo 1.0 specification (see references in\r
+  "OvmfPkg/Include/IndustryStandard/VirtioGpu.h").\r
+**/\r
+EFI_STATUS\r
+VirtioGpuResourceCreate2d (\r
+  IN OUT VGPU_DEV           *VgpuDev,\r
+  IN     UINT32             ResourceId,\r
+  IN     VIRTIO_GPU_FORMATS Format,\r
+  IN     UINT32             Width,\r
+  IN     UINT32             Height\r
+  );\r
+\r
+EFI_STATUS\r
+VirtioGpuResourceUnref (\r
+  IN OUT VGPU_DEV *VgpuDev,\r
+  IN     UINT32   ResourceId\r
+  );\r
+\r
+EFI_STATUS\r
+VirtioGpuResourceAttachBacking (\r
+  IN OUT VGPU_DEV *VgpuDev,\r
+  IN     UINT32   ResourceId,\r
+  IN     VOID     *FirstBackingPage,\r
+  IN     UINTN    NumberOfPages\r
+  );\r
+\r
+EFI_STATUS\r
+VirtioGpuResourceDetachBacking (\r
+  IN OUT VGPU_DEV *VgpuDev,\r
+  IN     UINT32   ResourceId\r
+  );\r
+\r
+EFI_STATUS\r
+VirtioGpuSetScanout (\r
+  IN OUT VGPU_DEV *VgpuDev,\r
+  IN     UINT32   X,\r
+  IN     UINT32   Y,\r
+  IN     UINT32   Width,\r
+  IN     UINT32   Height,\r
+  IN     UINT32   ScanoutId,\r
+  IN     UINT32   ResourceId\r
+  );\r
+\r
+EFI_STATUS\r
+VirtioGpuTransferToHost2d (\r
+  IN OUT VGPU_DEV *VgpuDev,\r
+  IN     UINT32   X,\r
+  IN     UINT32   Y,\r
+  IN     UINT32   Width,\r
+  IN     UINT32   Height,\r
+  IN     UINT64   Offset,\r
+  IN     UINT32   ResourceId\r
+  );\r
+\r
+EFI_STATUS\r
+VirtioGpuResourceFlush (\r
+  IN OUT VGPU_DEV *VgpuDev,\r
+  IN     UINT32   X,\r
+  IN     UINT32   Y,\r
+  IN     UINT32   Width,\r
+  IN     UINT32   Height,\r
+  IN     UINT32   ResourceId\r
+  );\r
+\r
+/**\r
+  Release guest-side and host-side resources that are related to an initialized\r
+  VGPU_GOP.Gop.\r
+\r
+  param[in,out] VgpuGop  The VGPU_GOP object to release resources for.\r
+\r
+                         On input, the caller is responsible for having called\r
+                         VgpuGop->Gop.SetMode() at least once successfully.\r
+                         (This is equivalent to the requirement that\r
+                         VgpuGop->BackingStore be non-NULL. It is also\r
+                         equivalent to the requirement that VgpuGop->ResourceId\r
+                         be nonzero.)\r
+\r
+                         On output, resources will be released, and\r
+                         VgpuGop->BackingStore and VgpuGop->ResourceId will be\r
+                         nulled.\r
+\r
+  param[in] DisableHead  Whether this head (scanout) currently references the\r
+                         resource identified by VgpuGop->ResourceId. Only pass\r
+                         FALSE when VgpuGop->Gop.SetMode() calls this function\r
+                         while switching between modes, and set it to TRUE\r
+                         every other time.\r
+**/\r
+VOID\r
+ReleaseGopResources (\r
+  IN OUT VGPU_GOP *VgpuGop,\r
+  IN     BOOLEAN  DisableHead\r
+  );\r
+\r
+//\r
+// Template for initializing VGPU_GOP.Gop.\r
+//\r
+extern CONST EFI_GRAPHICS_OUTPUT_PROTOCOL mGopTemplate;\r
+\r
 #endif // _VIRTIO_GPU_DXE_H_\r