summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/VirtioGpuDxe
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:09 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commitac0a286f4d747a4c6c603a7b225917293cbe1e9f (patch)
tree32654f2b35755afc961e2c97296b2dec5762da75 /OvmfPkg/VirtioGpuDxe
parentd1050b9dff1cace252aff86630bfdb59dff5f507 (diff)
downloadedk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.gz
edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.bz2
edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.zip
OvmfPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the OvmfPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Andrew Fish <afish@apple.com>
Diffstat (limited to 'OvmfPkg/VirtioGpuDxe')
-rw-r--r--OvmfPkg/VirtioGpuDxe/Commands.c202
-rw-r--r--OvmfPkg/VirtioGpuDxe/DriverBinding.c688
-rw-r--r--OvmfPkg/VirtioGpuDxe/Gop.c360
-rw-r--r--OvmfPkg/VirtioGpuDxe/VirtioGpu.h139
4 files changed, 824 insertions, 565 deletions
diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Commands.c
index 1645100a05..873a716567 100644
--- a/OvmfPkg/VirtioGpuDxe/Commands.c
+++ b/OvmfPkg/VirtioGpuDxe/Commands.c
@@ -31,14 +31,14 @@
**/
EFI_STATUS
VirtioGpuInit (
- IN OUT VGPU_DEV *VgpuDev
+ IN OUT VGPU_DEV *VgpuDev
)
{
- UINT8 NextDevStat;
- EFI_STATUS Status;
- UINT64 Features;
- UINT16 QueueSize;
- UINT64 RingBaseShift;
+ UINT8 NextDevStat;
+ EFI_STATUS Status;
+ UINT64 Features;
+ UINT16 QueueSize;
+ UINT64 RingBaseShift;
//
// Execute virtio-v1.0-cs04, 3.1.1 Driver Requirements: Device
@@ -47,7 +47,7 @@ VirtioGpuInit (
// 1. Reset the device.
//
NextDevStat = 0;
- Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
+ Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -56,7 +56,7 @@ VirtioGpuInit (
// 2. Set the ACKNOWLEDGE status bit [...]
//
NextDevStat |= VSTAT_ACK;
- Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
+ Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -65,7 +65,7 @@ VirtioGpuInit (
// 3. Set the DRIVER status bit [...]
//
NextDevStat |= VSTAT_DRIVER;
- Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
+ Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -77,10 +77,12 @@ VirtioGpuInit (
if (EFI_ERROR (Status)) {
goto Failed;
}
+
if ((Features & VIRTIO_F_VERSION_1) == 0) {
Status = EFI_UNSUPPORTED;
goto Failed;
}
+
//
// We only want the most basic 2D features.
//
@@ -101,11 +103,14 @@ VirtioGpuInit (
// 7. Perform device-specific setup, including discovery of virtqueues for
// the device [...]
//
- Status = VgpuDev->VirtIo->SetQueueSel (VgpuDev->VirtIo,
- VIRTIO_GPU_CONTROL_QUEUE);
+ Status = VgpuDev->VirtIo->SetQueueSel (
+ VgpuDev->VirtIo,
+ VIRTIO_GPU_CONTROL_QUEUE
+ );
if (EFI_ERROR (Status)) {
goto Failed;
}
+
Status = VgpuDev->VirtIo->GetQueueNumMax (VgpuDev->VirtIo, &QueueSize);
if (EFI_ERROR (Status)) {
goto Failed;
@@ -127,6 +132,7 @@ VirtioGpuInit (
if (EFI_ERROR (Status)) {
goto Failed;
}
+
//
// If anything fails from here on, we have to release the ring.
//
@@ -139,6 +145,7 @@ VirtioGpuInit (
if (EFI_ERROR (Status)) {
goto ReleaseQueue;
}
+
//
// If anything fails from here on, we have to unmap the ring.
//
@@ -155,7 +162,7 @@ VirtioGpuInit (
// 8. Set the DRIVER_OK status bit.
//
NextDevStat |= VSTAT_DRIVER_OK;
- Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
+ Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto UnmapQueue;
}
@@ -193,7 +200,7 @@ Failed:
**/
VOID
VirtioGpuUninit (
- IN OUT VGPU_DEV *VgpuDev
+ IN OUT VGPU_DEV *VgpuDev
)
{
//
@@ -235,15 +242,15 @@ VirtioGpuUninit (
**/
EFI_STATUS
VirtioGpuAllocateZeroAndMapBackingStore (
- IN VGPU_DEV *VgpuDev,
- IN UINTN NumberOfPages,
- OUT VOID **HostAddress,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
+ IN VGPU_DEV *VgpuDev,
+ IN UINTN NumberOfPages,
+ OUT VOID **HostAddress,
+ OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
+ OUT VOID **Mapping
)
{
- EFI_STATUS Status;
- VOID *NewHostAddress;
+ EFI_STATUS Status;
+ VOID *NewHostAddress;
Status = VgpuDev->VirtIo->AllocateSharedPages (
VgpuDev->VirtIo,
@@ -308,10 +315,10 @@ FreeSharedPages:
**/
VOID
VirtioGpuUnmapAndFreeBackingStore (
- IN VGPU_DEV *VgpuDev,
- IN UINTN NumberOfPages,
- IN VOID *HostAddress,
- IN VOID *Mapping
+ IN VGPU_DEV *VgpuDev,
+ IN UINTN NumberOfPages,
+ IN VOID *HostAddress,
+ IN VOID *Mapping
)
{
VgpuDev->VirtIo->UnmapSharedBuffer (
@@ -341,11 +348,11 @@ VirtioGpuUnmapAndFreeBackingStore (
VOID
EFIAPI
VirtioGpuExitBoot (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- VGPU_DEV *VgpuDev;
+ VGPU_DEV *VgpuDev;
DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __FUNCTION__, Context));
VgpuDev = Context;
@@ -398,26 +405,26 @@ VirtioGpuExitBoot (
STATIC
EFI_STATUS
VirtioGpuSendCommand (
- IN OUT VGPU_DEV *VgpuDev,
- IN VIRTIO_GPU_CONTROL_TYPE RequestType,
- IN BOOLEAN Fence,
- IN OUT volatile VIRTIO_GPU_CONTROL_HEADER *Header,
- IN UINTN RequestSize
+ IN OUT VGPU_DEV *VgpuDev,
+ IN VIRTIO_GPU_CONTROL_TYPE RequestType,
+ IN BOOLEAN Fence,
+ IN OUT volatile VIRTIO_GPU_CONTROL_HEADER *Header,
+ IN UINTN RequestSize
)
{
- DESC_INDICES Indices;
- volatile VIRTIO_GPU_CONTROL_HEADER Response;
- EFI_STATUS Status;
- UINT32 ResponseSize;
- EFI_PHYSICAL_ADDRESS RequestDeviceAddress;
- VOID *RequestMap;
- EFI_PHYSICAL_ADDRESS ResponseDeviceAddress;
- VOID *ResponseMap;
+ DESC_INDICES Indices;
+ volatile VIRTIO_GPU_CONTROL_HEADER Response;
+ EFI_STATUS Status;
+ UINT32 ResponseSize;
+ EFI_PHYSICAL_ADDRESS RequestDeviceAddress;
+ VOID *RequestMap;
+ EFI_PHYSICAL_ADDRESS ResponseDeviceAddress;
+ VOID *ResponseMap;
//
// Initialize Header.
//
- Header->Type = RequestType;
+ Header->Type = RequestType;
if (Fence) {
Header->Flags = VIRTIO_GPU_FLAG_FENCE;
Header->FenceId = VgpuDev->FenceId++;
@@ -425,8 +432,9 @@ VirtioGpuSendCommand (
Header->Flags = 0;
Header->FenceId = 0;
}
- Header->CtxId = 0;
- Header->Padding = 0;
+
+ Header->CtxId = 0;
+ Header->Padding = 0;
ASSERT (RequestSize >= sizeof *Header);
ASSERT (RequestSize <= MAX_UINT32);
@@ -445,6 +453,7 @@ VirtioGpuSendCommand (
if (EFI_ERROR (Status)) {
return Status;
}
+
Status = VirtioMapAllBytesInSharedBuffer (
VgpuDev->VirtIo,
VirtioOperationBusMasterWrite,
@@ -479,8 +488,13 @@ VirtioGpuSendCommand (
//
// Send the command.
//
- Status = VirtioFlush (VgpuDev->VirtIo, VIRTIO_GPU_CONTROL_QUEUE,
- &VgpuDev->Ring, &Indices, &ResponseSize);
+ Status = VirtioFlush (
+ VgpuDev->VirtIo,
+ VIRTIO_GPU_CONTROL_QUEUE,
+ &VgpuDev->Ring,
+ &Indices,
+ &ResponseSize
+ );
if (EFI_ERROR (Status)) {
goto UnmapResponse;
}
@@ -489,8 +503,12 @@ VirtioGpuSendCommand (
// Verify response size.
//
if (ResponseSize != sizeof Response) {
- DEBUG ((DEBUG_ERROR, "%a: malformed response to Request=0x%x\n",
- __FUNCTION__, (UINT32)RequestType));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: malformed response to Request=0x%x\n",
+ __FUNCTION__,
+ (UINT32)RequestType
+ ));
Status = EFI_PROTOCOL_ERROR;
goto UnmapResponse;
}
@@ -504,6 +522,7 @@ VirtioGpuSendCommand (
if (EFI_ERROR (Status)) {
goto UnmapRequest;
}
+
Status = VgpuDev->VirtIo->UnmapSharedBuffer (VgpuDev->VirtIo, RequestMap);
if (EFI_ERROR (Status)) {
return Status;
@@ -516,8 +535,13 @@ VirtioGpuSendCommand (
return EFI_SUCCESS;
}
- DEBUG ((DEBUG_ERROR, "%a: Request=0x%x Response=0x%x\n", __FUNCTION__,
- (UINT32)RequestType, Response.Type));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Request=0x%x Response=0x%x\n",
+ __FUNCTION__,
+ (UINT32)RequestType,
+ Response.Type
+ ));
return EFI_DEVICE_ERROR;
UnmapResponse:
@@ -557,14 +581,14 @@ UnmapRequest:
**/
EFI_STATUS
VirtioGpuResourceCreate2d (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 ResourceId,
- IN VIRTIO_GPU_FORMATS Format,
- IN UINT32 Width,
- IN UINT32 Height
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 ResourceId,
+ IN VIRTIO_GPU_FORMATS Format,
+ IN UINT32 Width,
+ IN UINT32 Height
)
{
- volatile VIRTIO_GPU_RESOURCE_CREATE_2D Request;
+ volatile VIRTIO_GPU_RESOURCE_CREATE_2D Request;
if (ResourceId == 0) {
return EFI_INVALID_PARAMETER;
@@ -586,11 +610,11 @@ VirtioGpuResourceCreate2d (
EFI_STATUS
VirtioGpuResourceUnref (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 ResourceId
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 ResourceId
)
{
- volatile VIRTIO_GPU_RESOURCE_UNREF Request;
+ volatile VIRTIO_GPU_RESOURCE_UNREF Request;
if (ResourceId == 0) {
return EFI_INVALID_PARAMETER;
@@ -610,13 +634,13 @@ VirtioGpuResourceUnref (
EFI_STATUS
VirtioGpuResourceAttachBacking (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 ResourceId,
- IN EFI_PHYSICAL_ADDRESS BackingStoreDeviceAddress,
- IN UINTN NumberOfPages
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 ResourceId,
+ IN EFI_PHYSICAL_ADDRESS BackingStoreDeviceAddress,
+ IN UINTN NumberOfPages
)
{
- volatile VIRTIO_GPU_RESOURCE_ATTACH_BACKING Request;
+ volatile VIRTIO_GPU_RESOURCE_ATTACH_BACKING Request;
if (ResourceId == 0) {
return EFI_INVALID_PARAMETER;
@@ -639,11 +663,11 @@ VirtioGpuResourceAttachBacking (
EFI_STATUS
VirtioGpuResourceDetachBacking (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 ResourceId
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 ResourceId
)
{
- volatile VIRTIO_GPU_RESOURCE_DETACH_BACKING Request;
+ volatile VIRTIO_GPU_RESOURCE_DETACH_BACKING Request;
if (ResourceId == 0) {
return EFI_INVALID_PARAMETER;
@@ -669,16 +693,16 @@ VirtioGpuResourceDetachBacking (
EFI_STATUS
VirtioGpuSetScanout (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 X,
- IN UINT32 Y,
- IN UINT32 Width,
- IN UINT32 Height,
- IN UINT32 ScanoutId,
- IN UINT32 ResourceId
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 X,
+ IN UINT32 Y,
+ IN UINT32 Width,
+ IN UINT32 Height,
+ IN UINT32 ScanoutId,
+ IN UINT32 ResourceId
)
{
- volatile VIRTIO_GPU_SET_SCANOUT Request;
+ volatile VIRTIO_GPU_SET_SCANOUT Request;
//
// Unlike for most other commands, ResourceId=0 is valid; it
@@ -702,16 +726,16 @@ VirtioGpuSetScanout (
EFI_STATUS
VirtioGpuTransferToHost2d (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 X,
- IN UINT32 Y,
- IN UINT32 Width,
- IN UINT32 Height,
- IN UINT64 Offset,
- IN UINT32 ResourceId
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 X,
+ IN UINT32 Y,
+ IN UINT32 Width,
+ IN UINT32 Height,
+ IN UINT64 Offset,
+ IN UINT32 ResourceId
)
{
- volatile VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D Request;
+ volatile VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D Request;
if (ResourceId == 0) {
return EFI_INVALID_PARAMETER;
@@ -736,15 +760,15 @@ VirtioGpuTransferToHost2d (
EFI_STATUS
VirtioGpuResourceFlush (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 X,
- IN UINT32 Y,
- IN UINT32 Width,
- IN UINT32 Height,
- IN UINT32 ResourceId
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 X,
+ IN UINT32 Y,
+ IN UINT32 Width,
+ IN UINT32 Height,
+ IN UINT32 ResourceId
)
{
- volatile VIRTIO_GPU_RESOURCE_FLUSH Request;
+ volatile VIRTIO_GPU_RESOURCE_FLUSH Request;
if (ResourceId == 0) {
return EFI_INVALID_PARAMETER;
diff --git a/OvmfPkg/VirtioGpuDxe/DriverBinding.c b/OvmfPkg/VirtioGpuDxe/DriverBinding.c
index 666d577547..21bf2babc8 100644
--- a/OvmfPkg/VirtioGpuDxe/DriverBinding.c
+++ b/OvmfPkg/VirtioGpuDxe/DriverBinding.c
@@ -29,13 +29,14 @@
// in the ACPI 3.0b spec, or more recently, to Table B-379, section "B.3.2
// _DOD" in the ACPI 6.0 spec.
//
-STATIC CONST ACPI_ADR_DEVICE_PATH mAcpiAdr = {
+STATIC CONST ACPI_ADR_DEVICE_PATH mAcpiAdr = {
{ // Header
ACPI_DEVICE_PATH, // Type
ACPI_ADR_DP, // SubType
{ sizeof mAcpiAdr, 0 }, // Length
},
- ACPI_DISPLAY_ADR ( // ADR
+ ACPI_DISPLAY_ADR (
+ // ADR
1, // DeviceIdScheme: use the ACPI
// bit-field definitions
0, // HeadId
@@ -51,7 +52,7 @@ STATIC CONST ACPI_ADR_DEVICE_PATH mAcpiAdr = {
//
// Component Name 2 Protocol implementation.
//
-STATIC CONST EFI_UNICODE_STRING_TABLE mDriverNameTable[] = {
+STATIC CONST EFI_UNICODE_STRING_TABLE mDriverNameTable[] = {
{ "en", L"Virtio GPU Driver" },
{ NULL, NULL }
};
@@ -60,51 +61,72 @@ STATIC
EFI_STATUS
EFIAPI
VirtioGpuGetDriverName (
- IN EFI_COMPONENT_NAME2_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
)
{
- return LookupUnicodeString2 (Language, This->SupportedLanguages,
- mDriverNameTable, DriverName, FALSE /* Iso639Language */);
+ return LookupUnicodeString2 (
+ Language,
+ This->SupportedLanguages,
+ mDriverNameTable,
+ DriverName,
+ FALSE /* Iso639Language */
+ );
}
STATIC
EFI_STATUS
EFIAPI
VirtioGpuGetControllerName (
- IN EFI_COMPONENT_NAME2_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
- EFI_STATUS Status;
- VGPU_DEV *VgpuDev;
+ EFI_STATUS Status;
+ VGPU_DEV *VgpuDev;
//
// Look up the VGPU_DEV "protocol interface" on ControllerHandle.
//
- Status = gBS->OpenProtocol (ControllerHandle, &gEfiCallerIdGuid,
- (VOID **)&VgpuDev, gImageHandle, ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiCallerIdGuid,
+ (VOID **)&VgpuDev,
+ gImageHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Sanity check: if we found gEfiCallerIdGuid on ControllerHandle, then we
// keep its Virtio Device Protocol interface open BY_DRIVER.
//
- ASSERT_EFI_ERROR (EfiTestManagedDevice (ControllerHandle, gImageHandle,
- &gVirtioDeviceProtocolGuid));
+ ASSERT_EFI_ERROR (
+ EfiTestManagedDevice (
+ ControllerHandle,
+ gImageHandle,
+ &gVirtioDeviceProtocolGuid
+ )
+ );
if (ChildHandle == NULL) {
//
// The caller is querying the name of the VGPU_DEV controller.
//
- return LookupUnicodeString2 (Language, This->SupportedLanguages,
- VgpuDev->BusName, ControllerName, FALSE /* Iso639Language */);
+ return LookupUnicodeString2 (
+ Language,
+ This->SupportedLanguages,
+ VgpuDev->BusName,
+ ControllerName,
+ FALSE /* Iso639Language */
+ );
}
//
@@ -113,22 +135,32 @@ VirtioGpuGetControllerName (
// condition below covers the case when we haven't produced the GOP child
// controller yet, or we've destroyed it since.)
//
- if (VgpuDev->Child == NULL || ChildHandle != VgpuDev->Child->GopHandle) {
+ if ((VgpuDev->Child == NULL) || (ChildHandle != VgpuDev->Child->GopHandle)) {
return EFI_UNSUPPORTED;
}
+
//
// Sanity check: our GOP child controller keeps the VGPU_DEV controller's
// Virtio Device Protocol interface open BY_CHILD_CONTROLLER.
//
- ASSERT_EFI_ERROR (EfiTestChildHandle (ControllerHandle, ChildHandle,
- &gVirtioDeviceProtocolGuid));
-
- return LookupUnicodeString2 (Language, This->SupportedLanguages,
- VgpuDev->Child->GopName, ControllerName,
- FALSE /* Iso639Language */);
+ ASSERT_EFI_ERROR (
+ EfiTestChildHandle (
+ ControllerHandle,
+ ChildHandle,
+ &gVirtioDeviceProtocolGuid
+ )
+ );
+
+ return LookupUnicodeString2 (
+ Language,
+ This->SupportedLanguages,
+ VgpuDev->Child->GopName,
+ ControllerName,
+ FALSE /* Iso639Language */
+ );
}
-STATIC CONST EFI_COMPONENT_NAME2_PROTOCOL mComponentName2 = {
+STATIC CONST EFI_COMPONENT_NAME2_PROTOCOL mComponentName2 = {
VirtioGpuGetDriverName,
VirtioGpuGetControllerName,
"en" // SupportedLanguages (RFC 4646)
@@ -137,6 +169,7 @@ STATIC CONST EFI_COMPONENT_NAME2_PROTOCOL mComponentName2 = {
//
// Helper functions for the Driver Binding Protocol Implementation.
//
+
/**
Format the VGPU_DEV controller name, to be looked up and returned by
VirtioGpuGetControllerName().
@@ -170,32 +203,55 @@ STATIC CONST EFI_COMPONENT_NAME2_PROTOCOL mComponentName2 = {
STATIC
EFI_STATUS
FormatVgpuDevName (
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE AgentHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT CHAR16 **ControllerName
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE AgentHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT CHAR16 **ControllerName
)
{
- EFI_HANDLE PciIoHandle;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINTN Segment, Bus, Device, Function;
- STATIC CONST CHAR16 ControllerNameStem[] = L"Virtio GPU Device";
- UINTN ControllerNameSize;
-
- if (EFI_ERROR (gBS->LocateDevicePath (&gEfiPciIoProtocolGuid, &DevicePath,
- &PciIoHandle)) ||
- EFI_ERROR (gBS->OpenProtocol (PciIoHandle, &gEfiPciIoProtocolGuid,
- (VOID **)&PciIo, AgentHandle, ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL)) ||
- EFI_ERROR (PciIo->GetLocation (PciIo, &Segment, &Bus, &Device,
- &Function))) {
+ EFI_HANDLE PciIoHandle;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINTN Segment, Bus, Device, Function;
+ STATIC CONST CHAR16 ControllerNameStem[] = L"Virtio GPU Device";
+ UINTN ControllerNameSize;
+
+ if (EFI_ERROR (
+ gBS->LocateDevicePath (
+ &gEfiPciIoProtocolGuid,
+ &DevicePath,
+ &PciIoHandle
+ )
+ ) ||
+ EFI_ERROR (
+ gBS->OpenProtocol (
+ PciIoHandle,
+ &gEfiPciIoProtocolGuid,
+ (VOID **)&PciIo,
+ AgentHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ )
+ ) ||
+ EFI_ERROR (
+ PciIo->GetLocation (
+ PciIo,
+ &Segment,
+ &Bus,
+ &Device,
+ &Function
+ )
+ ))
+ {
//
// Failed to retrieve location info, return verbatim copy of static string.
//
- *ControllerName = AllocateCopyPool (sizeof ControllerNameStem,
- ControllerNameStem);
+ *ControllerName = AllocateCopyPool (
+ sizeof ControllerNameStem,
+ ControllerNameStem
+ );
return (*ControllerName == NULL) ? EFI_OUT_OF_RESOURCES : EFI_SUCCESS;
}
+
//
// Location info available, format ControllerName dynamically.
//
@@ -210,9 +266,16 @@ FormatVgpuDevName (
return EFI_OUT_OF_RESOURCES;
}
- UnicodeSPrintAsciiFormat (*ControllerName, ControllerNameSize,
- "%s %04x:%02x:%02x.%x", ControllerNameStem, (UINT32)Segment, (UINT32)Bus,
- (UINT32)Device, (UINT32)Function);
+ UnicodeSPrintAsciiFormat (
+ *ControllerName,
+ ControllerNameSize,
+ "%s %04x:%02x:%02x.%x",
+ ControllerNameStem,
+ (UINT32)Segment,
+ (UINT32)Bus,
+ (UINT32)Device,
+ (UINT32)Function
+ );
return EFI_SUCCESS;
}
@@ -254,20 +317,20 @@ FormatVgpuDevName (
STATIC
EFI_STATUS
InitVgpuGop (
- IN OUT VGPU_DEV *ParentBus,
- IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
- IN EFI_HANDLE ParentBusController,
- IN EFI_HANDLE DriverBindingHandle
+ IN OUT VGPU_DEV *ParentBus,
+ IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
+ IN EFI_HANDLE ParentBusController,
+ IN EFI_HANDLE DriverBindingHandle
)
{
- VGPU_GOP *VgpuGop;
- EFI_STATUS Status;
- CHAR16 *ParentBusName;
- STATIC CONST CHAR16 NameSuffix[] = L" Head #0";
- UINTN NameSize;
- CHAR16 *Name;
- EFI_TPL OldTpl;
- VOID *ParentVirtIo;
+ VGPU_GOP *VgpuGop;
+ EFI_STATUS Status;
+ CHAR16 *ParentBusName;
+ STATIC CONST CHAR16 NameSuffix[] = L" Head #0";
+ UINTN NameSize;
+ CHAR16 *Name;
+ EFI_TPL OldTpl;
+ VOID *ParentVirtIo;
VgpuGop = AllocateZeroPool (sizeof *VgpuGop);
if (VgpuGop == NULL) {
@@ -282,18 +345,29 @@ InitVgpuGop (
// VirtioGpuGetControllerName() to look up. We simply append NameSuffix to
// ParentBus->BusName.
//
- Status = LookupUnicodeString2 ("en", mComponentName2.SupportedLanguages,
- ParentBus->BusName, &ParentBusName, FALSE /* Iso639Language */);
+ Status = LookupUnicodeString2 (
+ "en",
+ mComponentName2.SupportedLanguages,
+ ParentBus->BusName,
+ &ParentBusName,
+ FALSE /* Iso639Language */
+ );
ASSERT_EFI_ERROR (Status);
NameSize = StrSize (ParentBusName) - sizeof (CHAR16) + sizeof NameSuffix;
- Name = AllocatePool (NameSize);
+ Name = AllocatePool (NameSize);
if (Name == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto FreeVgpuGop;
}
+
UnicodeSPrintAsciiFormat (Name, NameSize, "%s%s", ParentBusName, NameSuffix);
- Status = AddUnicodeString2 ("en", mComponentName2.SupportedLanguages,
- &VgpuGop->GopName, Name, FALSE /* Iso639Language */);
+ Status = AddUnicodeString2 (
+ "en",
+ mComponentName2.SupportedLanguages,
+ &VgpuGop->GopName,
+ Name,
+ FALSE /* Iso639Language */
+ );
FreePool (Name);
if (EFI_ERROR (Status)) {
goto FreeVgpuGop;
@@ -302,8 +376,10 @@ InitVgpuGop (
//
// Create the child device path.
//
- VgpuGop->GopDevicePath = AppendDevicePathNode (ParentDevicePath,
- &mAcpiAdr.Header);
+ VgpuGop->GopDevicePath = AppendDevicePathNode (
+ ParentDevicePath,
+ &mAcpiAdr.Header
+ );
if (VgpuGop->GopDevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto FreeVgpuGopName;
@@ -317,9 +393,12 @@ InitVgpuGop (
//
// Create the child handle with the child device path.
//
- Status = gBS->InstallProtocolInterface (&VgpuGop->GopHandle,
- &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
- VgpuGop->GopDevicePath);
+ Status = gBS->InstallProtocolInterface (
+ &VgpuGop->GopHandle,
+ &gEfiDevicePathProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ VgpuGop->GopDevicePath
+ );
if (EFI_ERROR (Status)) {
goto FreeDevicePath;
}
@@ -328,12 +407,18 @@ InitVgpuGop (
// The child handle must present a reference to the parent handle's Virtio
// Device Protocol interface.
//
- Status = gBS->OpenProtocol (ParentBusController, &gVirtioDeviceProtocolGuid,
- &ParentVirtIo, DriverBindingHandle, VgpuGop->GopHandle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER);
+ Status = gBS->OpenProtocol (
+ ParentBusController,
+ &gVirtioDeviceProtocolGuid,
+ &ParentVirtIo,
+ DriverBindingHandle,
+ VgpuGop->GopHandle,
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ );
if (EFI_ERROR (Status)) {
goto UninstallDevicePath;
}
+
ASSERT (ParentVirtIo == ParentBus->VirtIo);
//
@@ -351,9 +436,12 @@ InitVgpuGop (
//
// Install the Graphics Output Protocol on the child handle.
//
- Status = gBS->InstallProtocolInterface (&VgpuGop->GopHandle,
- &gEfiGraphicsOutputProtocolGuid, EFI_NATIVE_INTERFACE,
- &VgpuGop->Gop);
+ Status = gBS->InstallProtocolInterface (
+ &VgpuGop->GopHandle,
+ &gEfiGraphicsOutputProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &VgpuGop->Gop
+ );
if (EFI_ERROR (Status)) {
goto UninitGop;
}
@@ -369,12 +457,19 @@ UninitGop:
ReleaseGopResources (VgpuGop, TRUE /* DisableHead */);
CloseVirtIoByChild:
- gBS->CloseProtocol (ParentBusController, &gVirtioDeviceProtocolGuid,
- DriverBindingHandle, VgpuGop->GopHandle);
+ gBS->CloseProtocol (
+ ParentBusController,
+ &gVirtioDeviceProtocolGuid,
+ DriverBindingHandle,
+ VgpuGop->GopHandle
+ );
UninstallDevicePath:
- gBS->UninstallProtocolInterface (VgpuGop->GopHandle,
- &gEfiDevicePathProtocolGuid, VgpuGop->GopDevicePath);
+ gBS->UninstallProtocolInterface (
+ VgpuGop->GopHandle,
+ &gEfiDevicePathProtocolGuid,
+ VgpuGop->GopDevicePath
+ );
FreeDevicePath:
gBS->RestoreTPL (OldTpl);
@@ -412,17 +507,20 @@ FreeVgpuGop:
STATIC
VOID
UninitVgpuGop (
- IN OUT VGPU_DEV *ParentBus,
- IN EFI_HANDLE ParentBusController,
- IN EFI_HANDLE DriverBindingHandle
+ IN OUT VGPU_DEV *ParentBus,
+ IN EFI_HANDLE ParentBusController,
+ IN EFI_HANDLE DriverBindingHandle
)
{
- VGPU_GOP *VgpuGop;
- EFI_STATUS Status;
+ VGPU_GOP *VgpuGop;
+ EFI_STATUS Status;
VgpuGop = ParentBus->Child;
- Status = gBS->UninstallProtocolInterface (VgpuGop->GopHandle,
- &gEfiGraphicsOutputProtocolGuid, &VgpuGop->Gop);
+ Status = gBS->UninstallProtocolInterface (
+ VgpuGop->GopHandle,
+ &gEfiGraphicsOutputProtocolGuid,
+ &VgpuGop->Gop
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -430,12 +528,19 @@ UninitVgpuGop (
//
ReleaseGopResources (VgpuGop, TRUE /* DisableHead */);
- Status = gBS->CloseProtocol (ParentBusController, &gVirtioDeviceProtocolGuid,
- DriverBindingHandle, VgpuGop->GopHandle);
+ Status = gBS->CloseProtocol (
+ ParentBusController,
+ &gVirtioDeviceProtocolGuid,
+ DriverBindingHandle,
+ VgpuGop->GopHandle
+ );
ASSERT_EFI_ERROR (Status);
- Status = gBS->UninstallProtocolInterface (VgpuGop->GopHandle,
- &gEfiDevicePathProtocolGuid, VgpuGop->GopDevicePath);
+ Status = gBS->UninstallProtocolInterface (
+ VgpuGop->GopHandle,
+ &gEfiDevicePathProtocolGuid,
+ VgpuGop->GopDevicePath
+ );
ASSERT_EFI_ERROR (Status);
FreePool (VgpuGop->GopDevicePath);
@@ -452,13 +557,13 @@ STATIC
EFI_STATUS
EFIAPI
VirtioGpuDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
- VIRTIO_DEVICE_PROTOCOL *VirtIo;
+ EFI_STATUS Status;
+ VIRTIO_DEVICE_PROTOCOL *VirtIo;
//
// - If RemainingDevicePath is NULL: the caller is interested in creating all
@@ -469,19 +574,25 @@ VirtioGpuDriverBindingSupported (
// specified in RemainingDevicePath. In this case we have to see if the
// requested device path is supportable.
//
- if (RemainingDevicePath != NULL &&
+ if ((RemainingDevicePath != NULL) &&
!IsDevicePathEnd (RemainingDevicePath) &&
- (DevicePathNodeLength (RemainingDevicePath) != sizeof mAcpiAdr ||
- CompareMem (RemainingDevicePath, &mAcpiAdr, sizeof mAcpiAdr) != 0)) {
+ ((DevicePathNodeLength (RemainingDevicePath) != sizeof mAcpiAdr) ||
+ (CompareMem (RemainingDevicePath, &mAcpiAdr, sizeof mAcpiAdr) != 0)))
+ {
return EFI_UNSUPPORTED;
}
//
// Open the Virtio Device Protocol interface on the controller, BY_DRIVER.
//
- Status = gBS->OpenProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid,
- (VOID **)&VirtIo, This->DriverBindingHandle,
- ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gVirtioDeviceProtocolGuid,
+ (VOID **)&VirtIo,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
if (EFI_ERROR (Status)) {
//
// If this fails, then by default we cannot support ControllerHandle. There
@@ -491,17 +602,23 @@ VirtioGpuDriverBindingSupported (
// allowed.
//
if (Status == EFI_ALREADY_STARTED) {
- EFI_STATUS Status2;
- VGPU_DEV *VgpuDev;
-
- Status2 = gBS->OpenProtocol (ControllerHandle, &gEfiCallerIdGuid,
- (VOID **)&VgpuDev, This->DriverBindingHandle,
- ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ EFI_STATUS Status2;
+ VGPU_DEV *VgpuDev;
+
+ Status2 = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiCallerIdGuid,
+ (VOID **)&VgpuDev,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
ASSERT_EFI_ERROR (Status2);
- if (VgpuDev->Child == NULL &&
- (RemainingDevicePath == NULL ||
- !IsDevicePathEnd (RemainingDevicePath))) {
+ if ((VgpuDev->Child == NULL) &&
+ ((RemainingDevicePath == NULL) ||
+ !IsDevicePathEnd (RemainingDevicePath)))
+ {
Status = EFI_SUCCESS;
}
}
@@ -512,8 +629,9 @@ VirtioGpuDriverBindingSupported (
//
// First BY_DRIVER open; check the VirtIo revision and subsystem.
//
- if (VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0) ||
- VirtIo->SubSystemDeviceId != VIRTIO_SUBSYSTEM_GPU_DEVICE) {
+ if ((VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) ||
+ (VirtIo->SubSystemDeviceId != VIRTIO_SUBSYSTEM_GPU_DEVICE))
+ {
Status = EFI_UNSUPPORTED;
goto CloseVirtIo;
}
@@ -522,13 +640,22 @@ VirtioGpuDriverBindingSupported (
// We'll need the device path of the VirtIo device both for formatting
// VGPU_DEV.BusName and for populating VGPU_GOP.GopDevicePath.
//
- Status = gBS->OpenProtocol (ControllerHandle, &gEfiDevicePathProtocolGuid,
- NULL, This->DriverBindingHandle, ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL);
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ NULL,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
CloseVirtIo:
- gBS->CloseProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid,
- This->DriverBindingHandle, ControllerHandle);
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gVirtioDeviceProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
return Status;
}
@@ -537,16 +664,16 @@ STATIC
EFI_STATUS
EFIAPI
VirtioGpuDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
- VIRTIO_DEVICE_PROTOCOL *VirtIo;
- BOOLEAN VirtIoBoundJustNow;
- VGPU_DEV *VgpuDev;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STATUS Status;
+ VIRTIO_DEVICE_PROTOCOL *VirtIo;
+ BOOLEAN VirtIoBoundJustNow;
+ VGPU_DEV *VgpuDev;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
//
// Open the Virtio Device Protocol.
@@ -556,9 +683,14 @@ VirtioGpuDriverBindingStart (
// binding the VirtIo controller on this call (with or without creating child
// controllers), or else we're *only* creating child controllers.
//
- Status = gBS->OpenProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid,
- (VOID **)&VirtIo, This->DriverBindingHandle,
- ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gVirtioDeviceProtocolGuid,
+ (VOID **)&VirtIo,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
if (EFI_ERROR (Status)) {
//
// The assertions below are based on the success of
@@ -568,14 +700,20 @@ VirtioGpuDriverBindingStart (
//
ASSERT (Status == EFI_ALREADY_STARTED);
- Status = gBS->OpenProtocol (ControllerHandle, &gEfiCallerIdGuid,
- (VOID **)&VgpuDev, This->DriverBindingHandle,
- ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiCallerIdGuid,
+ (VOID **)&VgpuDev,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
ASSERT_EFI_ERROR (Status);
ASSERT (VgpuDev->Child == NULL);
ASSERT (
- RemainingDevicePath == NULL || !IsDevicePathEnd (RemainingDevicePath));
+ RemainingDevicePath == NULL || !IsDevicePathEnd (RemainingDevicePath)
+ );
VirtIoBoundJustNow = FALSE;
} else {
@@ -589,6 +727,7 @@ VirtioGpuDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES;
goto CloseVirtIo;
}
+
VgpuDev->VirtIo = VirtIo;
}
@@ -596,9 +735,14 @@ VirtioGpuDriverBindingStart (
// Grab the VirtIo controller's device path. This is necessary regardless of
// VirtIoBoundJustNow.
//
- Status = gBS->OpenProtocol (ControllerHandle, &gEfiDevicePathProtocolGuid,
- (VOID **)&DevicePath, This->DriverBindingHandle,
- ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&DevicePath,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (EFI_ERROR (Status)) {
goto FreeVgpuDev;
}
@@ -608,19 +752,29 @@ VirtioGpuDriverBindingStart (
// if we aren't *only* creating child handles).
//
if (VirtIoBoundJustNow) {
- CHAR16 *VgpuDevName;
+ CHAR16 *VgpuDevName;
//
// Format a human-readable controller name for VGPU_DEV, and stash it for
// VirtioGpuGetControllerName() to look up.
//
- Status = FormatVgpuDevName (ControllerHandle, This->DriverBindingHandle,
- DevicePath, &VgpuDevName);
+ Status = FormatVgpuDevName (
+ ControllerHandle,
+ This->DriverBindingHandle,
+ DevicePath,
+ &VgpuDevName
+ );
if (EFI_ERROR (Status)) {
goto FreeVgpuDev;
}
- Status = AddUnicodeString2 ("en", mComponentName2.SupportedLanguages,
- &VgpuDev->BusName, VgpuDevName, FALSE /* Iso639Language */);
+
+ Status = AddUnicodeString2 (
+ "en",
+ mComponentName2.SupportedLanguages,
+ &VgpuDev->BusName,
+ VgpuDevName,
+ FALSE /* Iso639Language */
+ );
FreePool (VgpuDevName);
if (EFI_ERROR (Status)) {
goto FreeVgpuDev;
@@ -631,9 +785,13 @@ VirtioGpuDriverBindingStart (
goto FreeVgpuDevBusName;
}
- Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK,
- VirtioGpuExitBoot, VgpuDev /* NotifyContext */,
- &VgpuDev->ExitBoot);
+ Status = gBS->CreateEvent (
+ EVT_SIGNAL_EXIT_BOOT_SERVICES,
+ TPL_CALLBACK,
+ VirtioGpuExitBoot,
+ VgpuDev /* NotifyContext */,
+ &VgpuDev->ExitBoot
+ );
if (EFI_ERROR (Status)) {
goto UninitGpu;
}
@@ -641,18 +799,26 @@ VirtioGpuDriverBindingStart (
//
// Install the VGPU_DEV "protocol interface" on ControllerHandle.
//
- Status = gBS->InstallProtocolInterface (&ControllerHandle,
- &gEfiCallerIdGuid, EFI_NATIVE_INTERFACE, VgpuDev);
+ Status = gBS->InstallProtocolInterface (
+ &ControllerHandle,
+ &gEfiCallerIdGuid,
+ EFI_NATIVE_INTERFACE,
+ VgpuDev
+ );
if (EFI_ERROR (Status)) {
goto CloseExitBoot;
}
- if (RemainingDevicePath != NULL && IsDevicePathEnd (RemainingDevicePath)) {
+ if ((RemainingDevicePath != NULL) && IsDevicePathEnd (RemainingDevicePath)) {
//
// No child handle should be produced; we're done.
//
- DEBUG ((DEBUG_INFO, "%a: bound VirtIo=%p without producing GOP\n",
- __FUNCTION__, (VOID *)VgpuDev->VirtIo));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: bound VirtIo=%p without producing GOP\n",
+ __FUNCTION__,
+ (VOID *)VgpuDev->VirtIo
+ ));
return EFI_SUCCESS;
}
}
@@ -663,10 +829,15 @@ VirtioGpuDriverBindingStart (
//
ASSERT (VgpuDev->Child == NULL);
ASSERT (
- RemainingDevicePath == NULL || !IsDevicePathEnd (RemainingDevicePath));
-
- Status = InitVgpuGop (VgpuDev, DevicePath, ControllerHandle,
- This->DriverBindingHandle);
+ RemainingDevicePath == NULL || !IsDevicePathEnd (RemainingDevicePath)
+ );
+
+ Status = InitVgpuGop (
+ VgpuDev,
+ DevicePath,
+ ControllerHandle,
+ This->DriverBindingHandle
+ );
if (EFI_ERROR (Status)) {
goto UninstallVgpuDev;
}
@@ -674,15 +845,22 @@ VirtioGpuDriverBindingStart (
//
// We're done.
//
- DEBUG ((DEBUG_INFO, "%a: produced GOP %a VirtIo=%p\n", __FUNCTION__,
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: produced GOP %a VirtIo=%p\n",
+ __FUNCTION__,
VirtIoBoundJustNow ? "while binding" : "for pre-bound",
- (VOID *)VgpuDev->VirtIo));
+ (VOID *)VgpuDev->VirtIo
+ ));
return EFI_SUCCESS;
UninstallVgpuDev:
if (VirtIoBoundJustNow) {
- gBS->UninstallProtocolInterface (ControllerHandle, &gEfiCallerIdGuid,
- VgpuDev);
+ gBS->UninstallProtocolInterface (
+ ControllerHandle,
+ &gEfiCallerIdGuid,
+ VgpuDev
+ );
}
CloseExitBoot:
@@ -707,8 +885,12 @@ FreeVgpuDev:
CloseVirtIo:
if (VirtIoBoundJustNow) {
- gBS->CloseProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid,
- This->DriverBindingHandle, ControllerHandle);
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gVirtioDeviceProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
}
return Status;
@@ -718,101 +900,134 @@ STATIC
EFI_STATUS
EFIAPI
VirtioGpuDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
- EFI_STATUS Status;
- VGPU_DEV *VgpuDev;
+ EFI_STATUS Status;
+ VGPU_DEV *VgpuDev;
//
// Look up the VGPU_DEV "protocol interface" on ControllerHandle.
//
- Status = gBS->OpenProtocol (ControllerHandle, &gEfiCallerIdGuid,
- (VOID **)&VgpuDev, This->DriverBindingHandle,
- ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiCallerIdGuid,
+ (VOID **)&VgpuDev,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Sanity check: if we found gEfiCallerIdGuid on ControllerHandle, then we
// keep its Virtio Device Protocol interface open BY_DRIVER.
//
- ASSERT_EFI_ERROR (EfiTestManagedDevice (ControllerHandle,
- This->DriverBindingHandle, &gVirtioDeviceProtocolGuid));
+ ASSERT_EFI_ERROR (
+ EfiTestManagedDevice (
+ ControllerHandle,
+ This->DriverBindingHandle,
+ &gVirtioDeviceProtocolGuid
+ )
+ );
switch (NumberOfChildren) {
- case 0:
- //
- // The caller wants us to unbind the VirtIo controller.
- //
- if (VgpuDev->Child != NULL) {
+ case 0:
//
- // We still have the GOP child.
+ // The caller wants us to unbind the VirtIo controller.
//
- Status = EFI_DEVICE_ERROR;
- break;
- }
-
- DEBUG ((DEBUG_INFO, "%a: unbinding GOP-less VirtIo=%p\n", __FUNCTION__,
- (VOID *)VgpuDev->VirtIo));
-
- Status = gBS->UninstallProtocolInterface (ControllerHandle,
- &gEfiCallerIdGuid, VgpuDev);
- ASSERT_EFI_ERROR (Status);
+ if (VgpuDev->Child != NULL) {
+ //
+ // We still have the GOP child.
+ //
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
- Status = gBS->CloseEvent (VgpuDev->ExitBoot);
- ASSERT_EFI_ERROR (Status);
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: unbinding GOP-less VirtIo=%p\n",
+ __FUNCTION__,
+ (VOID *)VgpuDev->VirtIo
+ ));
+
+ Status = gBS->UninstallProtocolInterface (
+ ControllerHandle,
+ &gEfiCallerIdGuid,
+ VgpuDev
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->CloseEvent (VgpuDev->ExitBoot);
+ ASSERT_EFI_ERROR (Status);
+
+ VirtioGpuUninit (VgpuDev);
+ FreeUnicodeStringTable (VgpuDev->BusName);
+ FreePool (VgpuDev);
+
+ Status = gBS->CloseProtocol (
+ ControllerHandle,
+ &gVirtioDeviceProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
+ ASSERT_EFI_ERROR (Status);
+ break;
- VirtioGpuUninit (VgpuDev);
- FreeUnicodeStringTable (VgpuDev->BusName);
- FreePool (VgpuDev);
+ case 1:
+ //
+ // The caller wants us to destroy our child GOP controller.
+ //
+ if ((VgpuDev->Child == NULL) ||
+ (ChildHandleBuffer[0] != VgpuDev->Child->GopHandle))
+ {
+ //
+ // We have no child controller at the moment, or it differs from the one
+ // the caller wants us to destroy. I.e., we don't own the child
+ // controller passed in.
+ //
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
- Status = gBS->CloseProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid,
- This->DriverBindingHandle, ControllerHandle);
- ASSERT_EFI_ERROR (Status);
- break;
+ //
+ // Sanity check: our GOP child controller keeps the VGPU_DEV controller's
+ // Virtio Device Protocol interface open BY_CHILD_CONTROLLER.
+ //
+ ASSERT_EFI_ERROR (
+ EfiTestChildHandle (
+ ControllerHandle,
+ VgpuDev->Child->GopHandle,
+ &gVirtioDeviceProtocolGuid
+ )
+ );
+
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: destroying GOP under VirtIo=%p\n",
+ __FUNCTION__,
+ (VOID *)VgpuDev->VirtIo
+ ));
+ UninitVgpuGop (VgpuDev, ControllerHandle, This->DriverBindingHandle);
+ break;
- case 1:
- //
- // The caller wants us to destroy our child GOP controller.
- //
- if (VgpuDev->Child == NULL ||
- ChildHandleBuffer[0] != VgpuDev->Child->GopHandle) {
+ default:
//
- // We have no child controller at the moment, or it differs from the one
- // the caller wants us to destroy. I.e., we don't own the child
- // controller passed in.
+ // Impossible, we never produced more than one child.
//
Status = EFI_DEVICE_ERROR;
break;
- }
- //
- // Sanity check: our GOP child controller keeps the VGPU_DEV controller's
- // Virtio Device Protocol interface open BY_CHILD_CONTROLLER.
- //
- ASSERT_EFI_ERROR (EfiTestChildHandle (ControllerHandle,
- VgpuDev->Child->GopHandle,
- &gVirtioDeviceProtocolGuid));
-
- DEBUG ((DEBUG_INFO, "%a: destroying GOP under VirtIo=%p\n", __FUNCTION__,
- (VOID *)VgpuDev->VirtIo));
- UninitVgpuGop (VgpuDev, ControllerHandle, This->DriverBindingHandle);
- break;
-
- default:
- //
- // Impossible, we never produced more than one child.
- //
- Status = EFI_DEVICE_ERROR;
- break;
}
+
return Status;
}
-STATIC EFI_DRIVER_BINDING_PROTOCOL mDriverBinding = {
+STATIC EFI_DRIVER_BINDING_PROTOCOL mDriverBinding = {
VirtioGpuDriverBindingSupported,
VirtioGpuDriverBindingStart,
VirtioGpuDriverBindingStop,
@@ -827,11 +1042,16 @@ STATIC EFI_DRIVER_BINDING_PROTOCOL mDriverBinding = {
EFI_STATUS
EFIAPI
VirtioGpuEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- return EfiLibInstallDriverBindingComponentName2 (ImageHandle, SystemTable,
- &mDriverBinding, ImageHandle, NULL /* ComponentName */,
- &mComponentName2);
+ return EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle,
+ SystemTable,
+ &mDriverBinding,
+ ImageHandle,
+ NULL /* ComponentName */,
+ &mComponentName2
+ );
}
diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c
index 3f0570eaad..2c15d542e3 100644
--- a/OvmfPkg/VirtioGpuDxe/Gop.c
+++ b/OvmfPkg/VirtioGpuDxe/Gop.c
@@ -37,11 +37,11 @@
**/
VOID
ReleaseGopResources (
- IN OUT VGPU_GOP *VgpuGop,
- IN BOOLEAN DisableHead
+ IN OUT VGPU_GOP *VgpuGop,
+ IN BOOLEAN DisableHead
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
ASSERT (VgpuGop->ResourceId != 0);
ASSERT (VgpuGop->BackingStore != NULL);
@@ -58,7 +58,10 @@ ReleaseGopResources (
//
Status = VirtioGpuSetScanout (
VgpuGop->ParentBus, // VgpuDev
- 0, 0, 0, 0, // X, Y, Width, Height
+ 0,
+ 0,
+ 0,
+ 0, // X, Y, Width, Height
0, // ScanoutId
0 // ResourceId
);
@@ -116,8 +119,8 @@ ReleaseGopResources (
VgpuGop->BackingStore, // HostAddress
VgpuGop->BackingStoreMap // Mapping
);
- VgpuGop->BackingStore = NULL;
- VgpuGop->NumberOfPages = 0;
+ VgpuGop->BackingStore = NULL;
+ VgpuGop->NumberOfPages = 0;
VgpuGop->BackingStoreMap = NULL;
//
@@ -131,6 +134,7 @@ ReleaseGopResources (
if (EFI_ERROR (Status)) {
CpuDeadLoop ();
}
+
VgpuGop->ResourceId = 0;
}
@@ -138,31 +142,31 @@ ReleaseGopResources (
// The resolutions supported by this driver.
//
typedef struct {
- UINT32 Width;
- UINT32 Height;
+ UINT32 Width;
+ UINT32 Height;
} GOP_RESOLUTION;
-STATIC CONST GOP_RESOLUTION mGopResolutions[] = {
- { 640, 480 },
- { 800, 480 },
- { 800, 600 },
- { 832, 624 },
- { 960, 640 },
- { 1024, 600 },
- { 1024, 768 },
- { 1152, 864 },
- { 1152, 870 },
- { 1280, 720 },
- { 1280, 760 },
- { 1280, 768 },
- { 1280, 800 },
- { 1280, 960 },
+STATIC CONST GOP_RESOLUTION mGopResolutions[] = {
+ { 640, 480 },
+ { 800, 480 },
+ { 800, 600 },
+ { 832, 624 },
+ { 960, 640 },
+ { 1024, 600 },
+ { 1024, 768 },
+ { 1152, 864 },
+ { 1152, 870 },
+ { 1280, 720 },
+ { 1280, 760 },
+ { 1280, 768 },
+ { 1280, 800 },
+ { 1280, 960 },
{ 1280, 1024 },
- { 1360, 768 },
- { 1366, 768 },
+ { 1360, 768 },
+ { 1366, 768 },
{ 1400, 1050 },
- { 1440, 900 },
- { 1600, 900 },
+ { 1440, 900 },
+ { 1600, 900 },
{ 1600, 1200 },
{ 1680, 1050 },
{ 1920, 1080 },
@@ -195,13 +199,13 @@ STATIC
EFI_STATUS
EFIAPI
GopQueryMode (
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN UINT32 ModeNumber,
- OUT UINTN *SizeOfInfo,
- OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ IN UINT32 ModeNumber,
+ OUT UINTN *SizeOfInfo,
+ OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
)
{
- EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo;
if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) {
return EFI_INVALID_PARAMETER;
@@ -218,7 +222,7 @@ GopQueryMode (
GopModeInfo->PixelsPerScanLine = mGopResolutions[ModeNumber].Width;
*SizeOfInfo = sizeof *GopModeInfo;
- *Info = GopModeInfo;
+ *Info = GopModeInfo;
return EFI_SUCCESS;
}
@@ -226,20 +230,20 @@ STATIC
EFI_STATUS
EFIAPI
GopSetMode (
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN UINT32 ModeNumber
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ IN UINT32 ModeNumber
)
{
- VGPU_GOP *VgpuGop;
- UINT32 NewResourceId;
- UINTN NewNumberOfBytes;
- UINTN NewNumberOfPages;
- VOID *NewBackingStore;
- EFI_PHYSICAL_ADDRESS NewBackingStoreDeviceAddress;
- VOID *NewBackingStoreMap;
+ VGPU_GOP *VgpuGop;
+ UINT32 NewResourceId;
+ UINTN NewNumberOfBytes;
+ UINTN NewNumberOfPages;
+ VOID *NewBackingStore;
+ EFI_PHYSICAL_ADDRESS NewBackingStoreDeviceAddress;
+ VOID *NewBackingStoreMap;
- EFI_STATUS Status;
- EFI_STATUS Status2;
+ EFI_STATUS Status;
+ EFI_STATUS Status2;
if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) {
return EFI_UNSUPPORTED;
@@ -260,9 +264,9 @@ GopSetMode (
//
VgpuGop->Gop.Mode = &VgpuGop->GopMode;
- VgpuGop->GopMode.MaxMode = (UINT32)(ARRAY_SIZE (mGopResolutions));
- VgpuGop->GopMode.Info = &VgpuGop->GopModeInfo;
- VgpuGop->GopMode.SizeOfInfo = sizeof VgpuGop->GopModeInfo;
+ VgpuGop->GopMode.MaxMode = (UINT32)(ARRAY_SIZE (mGopResolutions));
+ VgpuGop->GopMode.Info = &VgpuGop->GopModeInfo;
+ VgpuGop->GopMode.SizeOfInfo = sizeof VgpuGop->GopModeInfo;
VgpuGop->GopModeInfo.PixelFormat = PixelBltOnly;
@@ -302,13 +306,13 @@ GopSetMode (
NewNumberOfBytes = mGopResolutions[ModeNumber].Width *
mGopResolutions[ModeNumber].Height * sizeof (UINT32);
NewNumberOfPages = EFI_SIZE_TO_PAGES (NewNumberOfBytes);
- Status = VirtioGpuAllocateZeroAndMapBackingStore (
- VgpuGop->ParentBus, // VgpuDev
- NewNumberOfPages, // NumberOfPages
- &NewBackingStore, // HostAddress
- &NewBackingStoreDeviceAddress, // DeviceAddress
- &NewBackingStoreMap // Mapping
- );
+ Status = VirtioGpuAllocateZeroAndMapBackingStore (
+ VgpuGop->ParentBus, // VgpuDev
+ NewNumberOfPages, // NumberOfPages
+ &NewBackingStore, // HostAddress
+ &NewBackingStoreDeviceAddress, // DeviceAddress
+ &NewBackingStoreMap // Mapping
+ );
if (EFI_ERROR (Status)) {
goto DestroyHostResource;
}
@@ -375,6 +379,7 @@ GopSetMode (
if (EFI_ERROR (Status2)) {
CpuDeadLoop ();
}
+
goto DetachBackingStore;
}
@@ -393,19 +398,19 @@ GopSetMode (
ASSERT (VgpuGop->ResourceId == 0);
ASSERT (VgpuGop->BackingStore == NULL);
- VgpuGop->ResourceId = NewResourceId;
- VgpuGop->BackingStore = NewBackingStore;
- VgpuGop->NumberOfPages = NewNumberOfPages;
+ VgpuGop->ResourceId = NewResourceId;
+ VgpuGop->BackingStore = NewBackingStore;
+ VgpuGop->NumberOfPages = NewNumberOfPages;
VgpuGop->BackingStoreMap = NewBackingStoreMap;
//
// Populate Mode and ModeInfo (mutable fields only).
//
- VgpuGop->GopMode.Mode = ModeNumber;
+ VgpuGop->GopMode.Mode = ModeNumber;
VgpuGop->GopModeInfo.HorizontalResolution =
- mGopResolutions[ModeNumber].Width;
+ mGopResolutions[ModeNumber].Width;
VgpuGop->GopModeInfo.VerticalResolution = mGopResolutions[ModeNumber].Height;
- VgpuGop->GopModeInfo.PixelsPerScanLine = mGopResolutions[ModeNumber].Width;
+ VgpuGop->GopModeInfo.PixelsPerScanLine = mGopResolutions[ModeNumber].Width;
return EFI_SUCCESS;
DetachBackingStore:
@@ -437,27 +442,27 @@ STATIC
EFI_STATUS
EFIAPI
GopBlt (
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
- IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
- IN UINTN SourceX,
- IN UINTN SourceY,
- IN UINTN DestinationX,
- IN UINTN DestinationY,
- IN UINTN Width,
- IN UINTN Height,
- IN UINTN Delta OPTIONAL
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
+ IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
+ IN UINTN SourceX,
+ IN UINTN SourceY,
+ IN UINTN DestinationX,
+ IN UINTN DestinationY,
+ IN UINTN Width,
+ IN UINTN Height,
+ IN UINTN Delta OPTIONAL
)
{
- VGPU_GOP *VgpuGop;
- UINT32 CurrentHorizontal;
- UINT32 CurrentVertical;
- UINTN SegmentSize;
- UINTN Y;
- UINTN ResourceOffset;
- EFI_STATUS Status;
-
- VgpuGop = VGPU_GOP_FROM_GOP (This);
+ VGPU_GOP *VgpuGop;
+ UINT32 CurrentHorizontal;
+ UINT32 CurrentVertical;
+ UINTN SegmentSize;
+ UINTN Y;
+ UINTN ResourceOffset;
+ EFI_STATUS Status;
+
+ VgpuGop = VGPU_GOP_FROM_GOP (This);
CurrentHorizontal = VgpuGop->GopModeInfo.HorizontalResolution;
CurrentVertical = VgpuGop->GopModeInfo.VerticalResolution;
@@ -476,8 +481,9 @@ GopBlt (
// zero, then Width is the entire width of BltBuffer, and the stride is
// supposed to be calculated from Width.
//
- if (BltOperation == EfiBltVideoToBltBuffer ||
- BltOperation == EfiBltBufferToVideo) {
+ if ((BltOperation == EfiBltVideoToBltBuffer) ||
+ (BltOperation == EfiBltBufferToVideo))
+ {
if (Delta == 0) {
Delta = SegmentSize;
}
@@ -487,13 +493,15 @@ GopBlt (
// For operations that write to the display, check if the destination fits
// onto the display.
//
- if (BltOperation == EfiBltVideoFill ||
- BltOperation == EfiBltBufferToVideo ||
- BltOperation == EfiBltVideoToVideo) {
- if (DestinationX > CurrentHorizontal ||
- Width > CurrentHorizontal - DestinationX ||
- DestinationY > CurrentVertical ||
- Height > CurrentVertical - DestinationY) {
+ if ((BltOperation == EfiBltVideoFill) ||
+ (BltOperation == EfiBltBufferToVideo) ||
+ (BltOperation == EfiBltVideoToVideo))
+ {
+ if ((DestinationX > CurrentHorizontal) ||
+ (Width > CurrentHorizontal - DestinationX) ||
+ (DestinationY > CurrentVertical) ||
+ (Height > CurrentVertical - DestinationY))
+ {
return EFI_INVALID_PARAMETER;
}
}
@@ -502,12 +510,14 @@ GopBlt (
// For operations that read from the display, check if the source fits onto
// the display.
//
- if (BltOperation == EfiBltVideoToBltBuffer ||
- BltOperation == EfiBltVideoToVideo) {
- if (SourceX > CurrentHorizontal ||
- Width > CurrentHorizontal - SourceX ||
- SourceY > CurrentVertical ||
- Height > CurrentVertical - SourceY) {
+ if ((BltOperation == EfiBltVideoToBltBuffer) ||
+ (BltOperation == EfiBltVideoToVideo))
+ {
+ if ((SourceX > CurrentHorizontal) ||
+ (Width > CurrentHorizontal - SourceX) ||
+ (SourceY > CurrentVertical) ||
+ (Height > CurrentVertical - SourceY))
+ {
return EFI_INVALID_PARAMETER;
}
}
@@ -517,99 +527,103 @@ GopBlt (
// won't be further steps.
//
switch (BltOperation) {
- case EfiBltVideoFill:
- //
- // Write data from the BltBuffer pixel (0, 0) directly to every pixel of
- // the video display rectangle (DestinationX, DestinationY) (DestinationX +
- // Width, DestinationY + Height). Only one pixel will be used from the
- // BltBuffer. Delta is NOT used.
- //
- for (Y = 0; Y < Height; ++Y) {
- SetMem32 (
- VgpuGop->BackingStore +
+ case EfiBltVideoFill:
+ //
+ // Write data from the BltBuffer pixel (0, 0) directly to every pixel of
+ // the video display rectangle (DestinationX, DestinationY) (DestinationX +
+ // Width, DestinationY + Height). Only one pixel will be used from the
+ // BltBuffer. Delta is NOT used.
+ //
+ for (Y = 0; Y < Height; ++Y) {
+ SetMem32 (
+ VgpuGop->BackingStore +
(DestinationY + Y) * CurrentHorizontal + DestinationX,
- SegmentSize,
- *(UINT32 *)BltBuffer
- );
- }
- break;
-
- case EfiBltVideoToBltBuffer:
- //
- // Read data from the video display rectangle (SourceX, SourceY) (SourceX +
- // Width, SourceY + Height) and place it in the BltBuffer rectangle
- // (DestinationX, DestinationY ) (DestinationX + Width, DestinationY +
- // Height). If DestinationX or DestinationY is not zero then Delta must be
- // set to the length in bytes of a row in the BltBuffer.
- //
- for (Y = 0; Y < Height; ++Y) {
- CopyMem (
- (UINT8 *)BltBuffer +
- (DestinationY + Y) * Delta + DestinationX * sizeof *BltBuffer,
- VgpuGop->BackingStore +
- (SourceY + Y) * CurrentHorizontal + SourceX,
- SegmentSize
- );
- }
- return EFI_SUCCESS;
+ SegmentSize,
+ *(UINT32 *)BltBuffer
+ );
+ }
- case EfiBltBufferToVideo:
- //
- // Write data from the BltBuffer rectangle (SourceX, SourceY) (SourceX +
- // Width, SourceY + Height) directly to the video display rectangle
- // (DestinationX, DestinationY) (DestinationX + Width, DestinationY +
- // Height). If SourceX or SourceY is not zero then Delta must be set to the
- // length in bytes of a row in the BltBuffer.
- //
- for (Y = 0; Y < Height; ++Y) {
- CopyMem (
- VgpuGop->BackingStore +
- (DestinationY + Y) * CurrentHorizontal + DestinationX,
- (UINT8 *)BltBuffer +
- (SourceY + Y) * Delta + SourceX * sizeof *BltBuffer,
- SegmentSize
- );
- }
- break;
+ break;
- case EfiBltVideoToVideo:
- //
- // Copy from the video display rectangle (SourceX, SourceY) (SourceX +
- // Width, SourceY + Height) to the video display rectangle (DestinationX,
- // DestinationY) (DestinationX + Width, DestinationY + Height). The
- // BltBuffer and Delta are not used in this mode.
- //
- // A single invocation of CopyMem() handles overlap between source and
- // destination (that is, within a single line), but for multiple
- // invocations, we must handle overlaps.
- //
- if (SourceY < DestinationY) {
- Y = Height;
- while (Y > 0) {
- --Y;
+ case EfiBltVideoToBltBuffer:
+ //
+ // Read data from the video display rectangle (SourceX, SourceY) (SourceX +
+ // Width, SourceY + Height) and place it in the BltBuffer rectangle
+ // (DestinationX, DestinationY ) (DestinationX + Width, DestinationY +
+ // Height). If DestinationX or DestinationY is not zero then Delta must be
+ // set to the length in bytes of a row in the BltBuffer.
+ //
+ for (Y = 0; Y < Height; ++Y) {
CopyMem (
+ (UINT8 *)BltBuffer +
+ (DestinationY + Y) * Delta + DestinationX * sizeof *BltBuffer,
VgpuGop->BackingStore +
- (DestinationY + Y) * CurrentHorizontal + DestinationX,
- VgpuGop->BackingStore +
- (SourceY + Y) * CurrentHorizontal + SourceX,
+ (SourceY + Y) * CurrentHorizontal + SourceX,
SegmentSize
);
}
- } else {
+
+ return EFI_SUCCESS;
+
+ case EfiBltBufferToVideo:
+ //
+ // Write data from the BltBuffer rectangle (SourceX, SourceY) (SourceX +
+ // Width, SourceY + Height) directly to the video display rectangle
+ // (DestinationX, DestinationY) (DestinationX + Width, DestinationY +
+ // Height). If SourceX or SourceY is not zero then Delta must be set to the
+ // length in bytes of a row in the BltBuffer.
+ //
for (Y = 0; Y < Height; ++Y) {
CopyMem (
VgpuGop->BackingStore +
- (DestinationY + Y) * CurrentHorizontal + DestinationX,
- VgpuGop->BackingStore +
- (SourceY + Y) * CurrentHorizontal + SourceX,
+ (DestinationY + Y) * CurrentHorizontal + DestinationX,
+ (UINT8 *)BltBuffer +
+ (SourceY + Y) * Delta + SourceX * sizeof *BltBuffer,
SegmentSize
);
}
- }
- break;
- default:
- return EFI_INVALID_PARAMETER;
+ break;
+
+ case EfiBltVideoToVideo:
+ //
+ // Copy from the video display rectangle (SourceX, SourceY) (SourceX +
+ // Width, SourceY + Height) to the video display rectangle (DestinationX,
+ // DestinationY) (DestinationX + Width, DestinationY + Height). The
+ // BltBuffer and Delta are not used in this mode.
+ //
+ // A single invocation of CopyMem() handles overlap between source and
+ // destination (that is, within a single line), but for multiple
+ // invocations, we must handle overlaps.
+ //
+ if (SourceY < DestinationY) {
+ Y = Height;
+ while (Y > 0) {
+ --Y;
+ CopyMem (
+ VgpuGop->BackingStore +
+ (DestinationY + Y) * CurrentHorizontal + DestinationX,
+ VgpuGop->BackingStore +
+ (SourceY + Y) * CurrentHorizontal + SourceX,
+ SegmentSize
+ );
+ }
+ } else {
+ for (Y = 0; Y < Height; ++Y) {
+ CopyMem (
+ VgpuGop->BackingStore +
+ (DestinationY + Y) * CurrentHorizontal + DestinationX,
+ VgpuGop->BackingStore +
+ (SourceY + Y) * CurrentHorizontal + SourceX,
+ SegmentSize
+ );
+ }
+ }
+
+ break;
+
+ default:
+ return EFI_INVALID_PARAMETER;
}
//
@@ -648,7 +662,7 @@ GopBlt (
//
// Template for initializing VGPU_GOP.Gop.
//
-CONST EFI_GRAPHICS_OUTPUT_PROTOCOL mGopTemplate = {
+CONST EFI_GRAPHICS_OUTPUT_PROTOCOL mGopTemplate = {
GopQueryMode,
GopSetMode,
GopBlt,
diff --git a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h b/OvmfPkg/VirtioGpuDxe/VirtioGpu.h
index 236cc47892..2155b261d4 100644
--- a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h
+++ b/OvmfPkg/VirtioGpuDxe/VirtioGpu.h
@@ -36,35 +36,35 @@ typedef struct {
//
// VirtIo represents access to the Virtio GPU device. Never NULL.
//
- VIRTIO_DEVICE_PROTOCOL *VirtIo;
+ VIRTIO_DEVICE_PROTOCOL *VirtIo;
//
// BusName carries a customized name for
// EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName(). It is expressed in table
// form because it can theoretically support several languages. Never NULL.
//
- EFI_UNICODE_STRING_TABLE *BusName;
+ EFI_UNICODE_STRING_TABLE *BusName;
//
// VirtIo ring used for VirtIo communication.
//
- VRING Ring;
+ VRING Ring;
//
// Token associated with Ring's mapping for bus master common buffer
// operation, from VirtioRingMap().
//
- VOID *RingMap;
+ VOID *RingMap;
//
// Event to be signaled at ExitBootServices().
//
- EFI_EVENT ExitBoot;
+ EFI_EVENT ExitBoot;
//
// Common running counter for all VirtIo GPU requests that ask for fencing.
//
- UINT64 FenceId;
+ UINT64 FenceId;
//
// The Child field references the GOP wrapper structure. If this pointer is
@@ -77,85 +77,86 @@ typedef struct {
// In practice, this field represents the single head (scanout) that we
// support.
//
- VGPU_GOP *Child;
+ VGPU_GOP *Child;
} VGPU_DEV;
//
// The Graphics Output Protocol wrapper structure.
//
-#define VGPU_GOP_SIG SIGNATURE_64 ('V', 'G', 'P', 'U', '_', 'G', 'O', 'P')
+#define VGPU_GOP_SIG SIGNATURE_64 ('V', 'G', 'P', 'U', '_', 'G', 'O', 'P')
struct VGPU_GOP_STRUCT {
- UINT64 Signature;
+ UINT64 Signature;
//
// ParentBus points to the parent VGPU_DEV object. Never NULL.
//
- VGPU_DEV *ParentBus;
+ VGPU_DEV *ParentBus;
//
// GopName carries a customized name for
// EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName(). It is expressed in table
// form because it can theoretically support several languages. Never NULL.
//
- EFI_UNICODE_STRING_TABLE *GopName;
+ EFI_UNICODE_STRING_TABLE *GopName;
//
// GopHandle is the UEFI child handle that carries the device path ending
// with the ACPI ADR node, and the Graphics Output Protocol. Never NULL.
//
- EFI_HANDLE GopHandle;
+ EFI_HANDLE GopHandle;
//
// The GopDevicePath field is the device path installed on GopHandle,
// ending with an ACPI ADR node. Never NULL.
//
- EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
//
// The Gop field is installed on the child handle as Graphics Output Protocol
// interface.
//
- EFI_GRAPHICS_OUTPUT_PROTOCOL Gop;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL Gop;
//
// Referenced by Gop.Mode, GopMode provides a summary about the supported
// graphics modes, and the current mode.
//
- EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE GopMode;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE GopMode;
//
// Referenced by GopMode.Info, GopModeInfo provides detailed information
// about the current mode.
//
- EFI_GRAPHICS_OUTPUT_MODE_INFORMATION GopModeInfo;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION GopModeInfo;
//
// Identifier of the 2D host resource that is in use by this head (scanout)
// of the VirtIo GPU device. Zero until the first successful -- internal --
// Gop.SetMode() call, never zero afterwards.
//
- UINT32 ResourceId;
+ UINT32 ResourceId;
//
// A number of whole pages providing the backing store for the 2D host
// resource identified by ResourceId above. NULL until the first successful
// -- internal -- Gop.SetMode() call, never NULL afterwards.
//
- UINT32 *BackingStore;
- UINTN NumberOfPages;
+ UINT32 *BackingStore;
+ UINTN NumberOfPages;
//
// Token associated with BackingStore's mapping for bus master common
// buffer operation. BackingStoreMap is valid if, and only if,
// BackingStore is non-NULL.
//
- VOID *BackingStoreMap;
+ VOID *BackingStoreMap;
};
//
// VirtIo GPU initialization, and commands (primitives) for the GPU device.
//
+
/**
Configure the VirtIo GPU device that underlies VgpuDev.
@@ -174,7 +175,7 @@ struct VGPU_GOP_STRUCT {
**/
EFI_STATUS
VirtioGpuInit (
- IN OUT VGPU_DEV *VgpuDev
+ IN OUT VGPU_DEV *VgpuDev
);
/**
@@ -188,7 +189,7 @@ VirtioGpuInit (
**/
VOID
VirtioGpuUninit (
- IN OUT VGPU_DEV *VgpuDev
+ IN OUT VGPU_DEV *VgpuDev
);
/**
@@ -221,11 +222,11 @@ VirtioGpuUninit (
**/
EFI_STATUS
VirtioGpuAllocateZeroAndMapBackingStore (
- IN VGPU_DEV *VgpuDev,
- IN UINTN NumberOfPages,
- OUT VOID **HostAddress,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
+ IN VGPU_DEV *VgpuDev,
+ IN UINTN NumberOfPages,
+ OUT VOID **HostAddress,
+ OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
+ OUT VOID **Mapping
);
/**
@@ -252,10 +253,10 @@ VirtioGpuAllocateZeroAndMapBackingStore (
**/
VOID
VirtioGpuUnmapAndFreeBackingStore (
- IN VGPU_DEV *VgpuDev,
- IN UINTN NumberOfPages,
- IN VOID *HostAddress,
- IN VOID *Mapping
+ IN VGPU_DEV *VgpuDev,
+ IN UINTN NumberOfPages,
+ IN VOID *HostAddress,
+ IN VOID *Mapping
);
/**
@@ -274,8 +275,8 @@ VirtioGpuUnmapAndFreeBackingStore (
VOID
EFIAPI
VirtioGpuExitBoot (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -306,63 +307,63 @@ VirtioGpuExitBoot (
**/
EFI_STATUS
VirtioGpuResourceCreate2d (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 ResourceId,
- IN VIRTIO_GPU_FORMATS Format,
- IN UINT32 Width,
- IN UINT32 Height
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 ResourceId,
+ IN VIRTIO_GPU_FORMATS Format,
+ IN UINT32 Width,
+ IN UINT32 Height
);
EFI_STATUS
VirtioGpuResourceUnref (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 ResourceId
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 ResourceId
);
EFI_STATUS
VirtioGpuResourceAttachBacking (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 ResourceId,
- IN EFI_PHYSICAL_ADDRESS BackingStoreDeviceAddress,
- IN UINTN NumberOfPages
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 ResourceId,
+ IN EFI_PHYSICAL_ADDRESS BackingStoreDeviceAddress,
+ IN UINTN NumberOfPages
);
EFI_STATUS
VirtioGpuResourceDetachBacking (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 ResourceId
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 ResourceId
);
EFI_STATUS
VirtioGpuSetScanout (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 X,
- IN UINT32 Y,
- IN UINT32 Width,
- IN UINT32 Height,
- IN UINT32 ScanoutId,
- IN UINT32 ResourceId
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 X,
+ IN UINT32 Y,
+ IN UINT32 Width,
+ IN UINT32 Height,
+ IN UINT32 ScanoutId,
+ IN UINT32 ResourceId
);
EFI_STATUS
VirtioGpuTransferToHost2d (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 X,
- IN UINT32 Y,
- IN UINT32 Width,
- IN UINT32 Height,
- IN UINT64 Offset,
- IN UINT32 ResourceId
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 X,
+ IN UINT32 Y,
+ IN UINT32 Width,
+ IN UINT32 Height,
+ IN UINT64 Offset,
+ IN UINT32 ResourceId
);
EFI_STATUS
VirtioGpuResourceFlush (
- IN OUT VGPU_DEV *VgpuDev,
- IN UINT32 X,
- IN UINT32 Y,
- IN UINT32 Width,
- IN UINT32 Height,
- IN UINT32 ResourceId
+ IN OUT VGPU_DEV *VgpuDev,
+ IN UINT32 X,
+ IN UINT32 Y,
+ IN UINT32 Width,
+ IN UINT32 Height,
+ IN UINT32 ResourceId
);
/**
@@ -390,13 +391,13 @@ VirtioGpuResourceFlush (
**/
VOID
ReleaseGopResources (
- IN OUT VGPU_GOP *VgpuGop,
- IN BOOLEAN DisableHead
+ IN OUT VGPU_GOP *VgpuGop,
+ IN BOOLEAN DisableHead
);
//
// Template for initializing VGPU_GOP.Gop.
//
-extern CONST EFI_GRAPHICS_OUTPUT_PROTOCOL mGopTemplate;
+extern CONST EFI_GRAPHICS_OUTPUT_PROTOCOL mGopTemplate;
#endif // _VIRTIO_GPU_DXE_H_