42 IN BOOLEAN DisableHead
47 ASSERT (VgpuGop->ResourceId != 0);
48 ASSERT (VgpuGop->BackingStore !=
NULL);
60 Status = VirtioGpuSetScanout (
97 if (EFI_ERROR (Status)) {
105 Status = VirtioGpuResourceDetachBacking (
110 if (EFI_ERROR (Status)) {
119 VgpuGop->NumberOfPages,
120 VgpuGop->BackingStore,
121 VgpuGop->BackingStoreMap
123 VgpuGop->BackingStore =
NULL;
124 VgpuGop->NumberOfPages = 0;
125 VgpuGop->BackingStoreMap =
NULL;
130 Status = VirtioGpuResourceUnref (
135 if (EFI_ERROR (Status)) {
139 VgpuGop->ResourceId = 0;
193#define VGPU_GOP_FROM_GOP(GopPointer) \
194 CR (GopPointer, VGPU_GOP, Gop, VGPU_GOP_SIG)
209 Status = VirtioGpuGetDisplayInfo (VgpuGop->ParentBus, &DisplayInfo);
214 for (Index = 0; Index < VIRTIO_GPU_MAX_SCANOUTS; Index++) {
215 if (!DisplayInfo.Pmodes[Index].Enabled ||
216 !DisplayInfo.Pmodes[Index].Rectangle.Width ||
217 !DisplayInfo.Pmodes[Index].Rectangle.Height)
227 DisplayInfo.Pmodes[Index].Rectangle.Width,
228 DisplayInfo.Pmodes[Index].Rectangle.Height
230 if ((*XRes == 0) || (*YRes == 0)) {
231 *XRes = DisplayInfo.Pmodes[Index].Rectangle.Width;
232 *YRes = DisplayInfo.Pmodes[Index].Rectangle.Height;
246 UINT32 XRes = 0, YRes = 0, Index;
248 VgpuGop = VGPU_GOP_FROM_GOP (This);
256 VgpuGop->Gop.
Mode = &VgpuGop->GopMode;
259 VgpuGop->GopMode.
Info = &VgpuGop->GopModeInfo;
260 VgpuGop->GopMode.
SizeOfInfo =
sizeof VgpuGop->GopModeInfo;
267 GopNativeResolution (VgpuGop, &XRes, &YRes);
268 if ((XRes < 640) || (YRes < 480)) {
273 if (
PcdGet8 (PcdVideoResolutionSource) == 0) {
274 Status =
PcdSet32S (PcdVideoHorizontalResolution, XRes);
276 Status =
PcdSet32S (PcdVideoVerticalResolution, YRes);
278 Status =
PcdSet8S (PcdVideoResolutionSource, 2);
282 VgpuGop->NativeXRes = XRes;
283 VgpuGop->NativeYRes = YRes;
284 for (Index = 0; Index <
ARRAY_SIZE (mGopResolutions); Index++) {
285 if ((mGopResolutions[Index].Width == XRes) &&
286 (mGopResolutions[Index].Height == YRes))
305 IN UINT32 ModeNumber,
312 if ((Info ==
NULL) ||
313 (SizeOfInfo ==
NULL) ||
314 (ModeNumber >= This->Mode->MaxMode))
316 return EFI_INVALID_PARAMETER;
320 if (GopModeInfo ==
NULL) {
321 return EFI_OUT_OF_RESOURCES;
324 if (ModeNumber <
ARRAY_SIZE (mGopResolutions)) {
328 VGPU_GOP *VgpuGop = VGPU_GOP_FROM_GOP (This);
336 *SizeOfInfo =
sizeof *GopModeInfo;
350 UINT32 NewResourceId;
351 UINTN NewNumberOfBytes;
352 UINTN NewNumberOfPages;
353 VOID *NewBackingStore;
355 VOID *NewBackingStoreMap;
364 GopInitialize (This);
367 Status = GopQueryMode (This, ModeNumber, &SizeOfInfo, &GopModeInfo);
372 VgpuGop = VGPU_GOP_FROM_GOP (This);
378 if (VgpuGop->ResourceId == 0) {
391 NewResourceId = 3 - VgpuGop->ResourceId;
400 VirtioGpuFormatB8G8R8X8Unorm,
404 if (EFI_ERROR (Status)) {
419 &NewBackingStoreDeviceAddress,
422 if (EFI_ERROR (Status)) {
423 goto DestroyHostResource;
429 Status = VirtioGpuResourceAttachBacking (
432 NewBackingStoreDeviceAddress,
435 if (EFI_ERROR (Status)) {
436 goto UnmapAndFreeBackingStore;
442 Status = VirtioGpuSetScanout (
451 if (EFI_ERROR (Status)) {
452 goto DetachBackingStore;
460 if (VgpuGop->ResourceId != 0) {
461 Status = VirtioGpuResourceFlush (
469 if (EFI_ERROR (Status)) {
475 Status2 = VirtioGpuSetScanout (
485 if (EFI_ERROR (Status2)) {
489 goto DetachBackingStore;
504 ASSERT (VgpuGop->ResourceId == 0);
505 ASSERT (VgpuGop->BackingStore ==
NULL);
507 VgpuGop->ResourceId = NewResourceId;
508 VgpuGop->BackingStore = NewBackingStore;
509 VgpuGop->NumberOfPages = NewNumberOfPages;
510 VgpuGop->BackingStoreMap = NewBackingStoreMap;
515 VgpuGop->GopMode.
Mode = ModeNumber;
516 CopyMem (&VgpuGop->GopModeInfo, GopModeInfo,
sizeof VgpuGop->GopModeInfo);
521 Status2 = VirtioGpuResourceDetachBacking (VgpuGop->ParentBus, NewResourceId);
523 if (EFI_ERROR (Status2)) {
527UnmapAndFreeBackingStore:
536 Status2 = VirtioGpuResourceUnref (VgpuGop->ParentBus, NewResourceId);
538 if (EFI_ERROR (Status2)) {
563 UINT32 CurrentHorizontal;
564 UINT32 CurrentVertical;
567 UINTN ResourceOffset;
570 VgpuGop = VGPU_GOP_FROM_GOP (This);
579 SegmentSize = Width *
sizeof (UINT32);
605 if ((DestinationX > CurrentHorizontal) ||
606 (Width > CurrentHorizontal - DestinationX) ||
607 (DestinationY > CurrentVertical) ||
608 (Height > CurrentVertical - DestinationY))
610 return EFI_INVALID_PARAMETER;
621 if ((SourceX > CurrentHorizontal) ||
622 (Width > CurrentHorizontal - SourceX) ||
623 (SourceY > CurrentVertical) ||
624 (Height > CurrentVertical - SourceY))
626 return EFI_INVALID_PARAMETER;
634 switch (BltOperation) {
642 for (Y = 0; Y < Height; ++Y) {
644 VgpuGop->BackingStore +
645 (DestinationY + Y) * CurrentHorizontal + DestinationX,
661 for (Y = 0; Y < Height; ++Y) {
664 (DestinationY + Y) * Delta + DestinationX *
sizeof *BltBuffer,
665 VgpuGop->BackingStore +
666 (SourceY + Y) * CurrentHorizontal + SourceX,
681 for (Y = 0; Y < Height; ++Y) {
683 VgpuGop->BackingStore +
684 (DestinationY + Y) * CurrentHorizontal + DestinationX,
686 (SourceY + Y) * Delta + SourceX *
sizeof *BltBuffer,
704 if (SourceY < DestinationY) {
709 VgpuGop->BackingStore +
710 (DestinationY + Y) * CurrentHorizontal + DestinationX,
711 VgpuGop->BackingStore +
712 (SourceY + Y) * CurrentHorizontal + SourceX,
717 for (Y = 0; Y < Height; ++Y) {
719 VgpuGop->BackingStore +
720 (DestinationY + Y) * CurrentHorizontal + DestinationX,
721 VgpuGop->BackingStore +
722 (SourceY + Y) * CurrentHorizontal + SourceX,
731 return EFI_INVALID_PARAMETER;
738 ResourceOffset =
sizeof (UINT32) * (DestinationY * CurrentHorizontal +
740 Status = VirtioGpuTransferToHost2d (
742 (UINT32)DestinationX,
743 (UINT32)DestinationY,
749 if (EFI_ERROR (Status)) {
756 Status = VirtioGpuResourceFlush (
758 (UINT32)DestinationX,
759 (UINT32)DestinationY,
VOID EFIAPI CpuDeadLoop(VOID)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMem32(OUT VOID *Buffer, IN UINTN Length, IN UINT32 Value)
VOID VirtioGpuUnmapAndFreeBackingStore(IN VGPU_DEV *VgpuDev, IN UINTN NumberOfPages, IN VOID *HostAddress, IN VOID *Mapping)
EFI_STATUS VirtioGpuAllocateZeroAndMapBackingStore(IN VGPU_DEV *VgpuDev, IN UINTN NumberOfPages, OUT VOID **HostAddress, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
EFI_STATUS VirtioGpuResourceCreate2d(IN OUT VGPU_DEV *VgpuDev, IN UINT32 ResourceId, IN VIRTIO_GPU_FORMATS Format, IN UINT32 Width, IN UINT32 Height)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ARRAY_SIZE(Array)
#define ASSERT_EFI_ERROR(StatusParameter)
#define ASSERT_RETURN_ERROR(StatusParameter)
#define DEBUG(Expression)
EFI_GRAPHICS_OUTPUT_BLT_OPERATION
#define PcdGet8(TokenName)
#define PcdSet32S(TokenName, Value)
#define PcdSet8S(TokenName, Value)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_SIZE_TO_PAGES(Size)
VOID ReleaseGopResources(IN OUT VGPU_GOP *VgpuGop, IN BOOLEAN DisableHead)
EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE * Mode
UINT32 VerticalResolution
EFI_GRAPHICS_PIXEL_FORMAT PixelFormat
UINT32 HorizontalResolution
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * Info