+ // On QXL however, only a leading segment, "surface 0", can be used for\r
+ // drawing; the rest of the video memory is used for the QXL guest-host\r
+ // protocol. VBE_DISPI_INDEX_VIDEO_MEMORY_64K should report the size of\r
+ // "surface 0", but since it doesn't (up to and including qemu-2.1), we\r
+ // retrieve the size of the drawable portion from a field in the QXL ROM BAR,\r
+ // where it is also available.\r
+ //\r
+ if (IsQxl) {\r
+ UINT32 Signature;\r
+ UINT32 DrawStart;\r
+\r
+ Signature = 0;\r
+ DrawStart = 0xFFFFFFFF;\r
+ AvailableFbSize = 0;\r
+ if (EFI_ERROR (\r
+ Private->PciIo->Mem.Read (Private->PciIo, EfiPciIoWidthUint32,\r
+ PCI_BAR_IDX2, 0, 1, &Signature)) ||\r
+ Signature != SIGNATURE_32 ('Q', 'X', 'R', 'O') ||\r
+ EFI_ERROR (\r
+ Private->PciIo->Mem.Read (Private->PciIo, EfiPciIoWidthUint32,\r
+ PCI_BAR_IDX2, 36, 1, &DrawStart)) ||\r
+ DrawStart != 0 ||\r
+ EFI_ERROR (\r
+ Private->PciIo->Mem.Read (Private->PciIo, EfiPciIoWidthUint32,\r
+ PCI_BAR_IDX2, 40, 1, &AvailableFbSize))) {\r
+ DEBUG ((EFI_D_ERROR, "%a: can't read size of drawable buffer from QXL "\r
+ "ROM\n", __FUNCTION__));\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ } else {\r
+ AvailableFbSize = BochsRead (Private, VBE_DISPI_INDEX_VIDEO_MEMORY_64K);\r
+ AvailableFbSize *= SIZE_64KB;\r
+ }\r