24#define RAMFB_FORMAT 0x34325258
42STATIC FIRMWARE_CONFIG_ITEM mRamfbFwCfgItem;
70QemuRamfbGraphicsOutputQueryMode (
79 if ((Info ==
NULL) || (SizeOfInfo ==
NULL) ||
80 (ModeNumber >= mQemuRamfbMode.
MaxMode))
82 return EFI_INVALID_PARAMETER;
85 ModeInfo = &mQemuRamfbModeInfo[ModeNumber];
92 return EFI_OUT_OF_RESOURCES;
103QemuRamfbGraphicsOutputSetMode (
111 RETURN_STATUS Status;
113 if (ModeNumber >= mQemuRamfbMode.
MaxMode) {
114 return EFI_UNSUPPORTED;
117 ModeInfo = &mQemuRamfbModeInfo[ModeNumber];
121 "Ramfb: SetMode %u (%ux%u)\n",
137 mQemuRamfbFrameBufferBltConfigure,
138 &mQemuRamfbFrameBufferBltConfigureSize
142 if (mQemuRamfbFrameBufferBltConfigure !=
NULL) {
143 FreePool (mQemuRamfbFrameBufferBltConfigure);
146 mQemuRamfbFrameBufferBltConfigure =
148 if (mQemuRamfbFrameBufferBltConfigure ==
NULL) {
149 mQemuRamfbFrameBufferBltConfigureSize = 0;
150 return EFI_OUT_OF_RESOURCES;
156 mQemuRamfbFrameBufferBltConfigure,
157 &mQemuRamfbFrameBufferBltConfigureSize
166 mQemuRamfbMode.
Mode = ModeNumber;
167 mQemuRamfbMode.
Info = ModeInfo;
175 ZeroMem (&Black,
sizeof (Black));
177 mQemuRamfbFrameBufferBltConfigure,
191 "%a: clearing the screen failed: %r\n",
203QemuRamfbGraphicsOutputBlt (
217 mQemuRamfbFrameBufferBltConfigure,
231 QemuRamfbGraphicsOutputQueryMode,
232 QemuRamfbGraphicsOutputSetMode,
233 QemuRamfbGraphicsOutputBlt,
251 UINTN FbSize, MaxFbSize, Pages;
256 DEBUG ((DEBUG_INFO,
"Ramfb: no FwCfg\n"));
257 return EFI_NOT_FOUND;
261 if (EFI_ERROR (Status)) {
262 return EFI_NOT_FOUND;
268 "Ramfb: FwCfg size mismatch (expected %lu, got %lu)\n",
272 return EFI_PROTOCOL_ERROR;
276 for (Index = 0; Index <
ARRAY_SIZE (mQemuRamfbModeInfo); Index++) {
284 if (MaxFbSize < FbSize) {
290 "Ramfb: Mode %lu: %ux%u, %lu kB\n",
292 mQemuRamfbModeInfo[Index].HorizontalResolution,
293 mQemuRamfbModeInfo[Index].VerticalResolution,
294 (UINT64)(FbSize / 1024)
302 DEBUG ((DEBUG_ERROR,
"Ramfb: memory allocation failed\n"));
303 return EFI_OUT_OF_RESOURCES;
308 "Ramfb: Framebuffer at 0x%lx, %lu kB, %lu pages\n",
310 (UINT64)(MaxFbSize / 1024),
319 QemuRamfbGraphicsOutputSetMode (&mQemuRamfbGraphicsOutput, 1);
328 &VendorDeviceNode.Header,
336 if (RamfbDevicePath ==
NULL) {
337 Status = EFI_OUT_OF_RESOURCES;
338 goto FreeFramebuffer;
341 Status =
gBS->InstallMultipleProtocolInterfaces (
343 &gEfiDevicePathProtocolGuid,
347 if (EFI_ERROR (Status)) {
350 "Ramfb: install Ramfb Vendor DevicePath failed: %r\n",
353 goto FreeRamfbDevicePath;
361 AcpiDeviceNode.
ADR = ACPI_DISPLAY_ADR (
367 ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL,
372 &AcpiDeviceNode.Header,
380 if (GopDevicePath ==
NULL) {
381 Status = EFI_OUT_OF_RESOURCES;
382 goto FreeRamfbHandle;
385 Status =
gBS->InstallMultipleProtocolInterfaces (
387 &gEfiDevicePathProtocolGuid,
389 &gEfiGraphicsOutputProtocolGuid,
390 &mQemuRamfbGraphicsOutput,
393 if (EFI_ERROR (Status)) {
396 "Ramfb: install GOP DevicePath failed: %r\n",
399 goto FreeGopDevicePath;
402 Status =
gBS->OpenProtocol (
404 &gEfiDevicePathProtocolGuid,
408 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
410 if (EFI_ERROR (Status)) {
411 DEBUG ((DEBUG_ERROR,
"Ramfb: OpenProtocol failed: %r\n", Status));
418 gBS->UninstallMultipleProtocolInterfaces (
420 &gEfiDevicePathProtocolGuid,
422 &gEfiGraphicsOutputProtocolGuid,
423 &mQemuRamfbGraphicsOutput,
429 gBS->UninstallMultipleProtocolInterfaces (
431 &gEfiDevicePathProtocolGuid,
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
UINT64 EFIAPI SwapBytes64(IN UINT64 Value)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define HARDWARE_DEVICE_PATH
UINT16 EFIAPI SetDevicePathNodeLength(IN OUT VOID *Node, IN UINTN Length)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
VOID EFIAPI FreePages(IN VOID *Buffer, IN UINTN Pages)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateReservedPages(IN UINTN Pages)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
RETURN_STATUS EFIAPI FrameBufferBlt(IN FRAME_BUFFER_CONFIGURE *Configure, IN OUT 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)
RETURN_STATUS EFIAPI FrameBufferBltConfigure(IN VOID *FrameBuffer, IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, IN OUT FRAME_BUFFER_CONFIGURE *Configure, IN OUT UINTN *ConfigureSize)
#define RETURN_BUFFER_TOO_SMALL
#define RETURN_ERROR(StatusCode)
#define RETURN_UNSUPPORTED
#define ARRAY_SIZE(Array)
#define DEBUG(Expression)
EFI_GRAPHICS_OUTPUT_BLT_OPERATION
@ PixelBlueGreenRedReserved8BitPerColor
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
VOID EFIAPI QemuFwCfgWriteBytes(IN UINTN Size, IN VOID *Buffer)
RETURN_STATUS EFIAPI QemuFwCfgFindFile(IN CONST CHAR8 *Name, OUT FIRMWARE_CONFIG_ITEM *Item, OUT UINTN *Size)
VOID EFIAPI QemuFwCfgSelectItem(IN FIRMWARE_CONFIG_ITEM QemuFwCfgItem)
BOOLEAN EFIAPI QemuFwCfgIsAvailable(VOID)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)
#define EFI_SIZE_TO_PAGES(Size)
UINT32 VerticalResolution
EFI_GRAPHICS_PIXEL_FORMAT PixelFormat
UINT32 HorizontalResolution
EFI_PHYSICAL_ADDRESS FrameBufferBase
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * Info