Changeset 99404 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/QemuRamfbDxe/QemuRamfb.c
- Timestamp:
- Apr 14, 2023 3:17:44 PM (20 months ago)
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-145445 /vendor/edk2/current 103735-103757,103769-103776,129194-156846
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/QemuRamfbDxe/QemuRamfb.c
r80721 r99404 27 27 #pragma pack (1) 28 28 typedef struct RAMFB_CONFIG { 29 UINT64 Address;30 UINT32 FourCC;31 UINT32 Flags;32 UINT32 Width;33 UINT32 Height;34 UINT32 Stride;29 UINT64 Address; 30 UINT32 FourCC; 31 UINT32 Flags; 32 UINT32 Width; 33 UINT32 Height; 34 UINT32 Stride; 35 35 } RAMFB_CONFIG; 36 36 #pragma pack () 37 37 38 STATIC EFI_HANDLE 39 STATIC EFI_HANDLE 40 STATIC FRAME_BUFFER_CONFIGURE 41 STATIC UINTN 42 STATIC FIRMWARE_CONFIG_ITEM 43 44 STATIC EFI_GRAPHICS_OUTPUT_MODE_INFORMATION mQemuRamfbModeInfo[] = {38 STATIC EFI_HANDLE mRamfbHandle; 39 STATIC EFI_HANDLE mGopHandle; 40 STATIC FRAME_BUFFER_CONFIGURE *mQemuRamfbFrameBufferBltConfigure; 41 STATIC UINTN mQemuRamfbFrameBufferBltConfigureSize; 42 STATIC FIRMWARE_CONFIG_ITEM mRamfbFwCfgItem; 43 44 STATIC EFI_GRAPHICS_OUTPUT_MODE_INFORMATION mQemuRamfbModeInfo[] = { 45 45 { 46 46 0, // Version … … 58 58 }; 59 59 60 STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE mQemuRamfbMode = {60 STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE mQemuRamfbMode = { 61 61 ARRAY_SIZE (mQemuRamfbModeInfo), // MaxMode 62 62 0, // Mode … … 77 77 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *ModeInfo; 78 78 79 if (Info == NULL || SizeOfInfo == NULL || 80 ModeNumber >= mQemuRamfbMode.MaxMode) { 79 if ((Info == NULL) || (SizeOfInfo == NULL) || 80 (ModeNumber >= mQemuRamfbMode.MaxMode)) 81 { 81 82 return EFI_INVALID_PARAMETER; 82 83 } 84 83 85 ModeInfo = &mQemuRamfbModeInfo[ModeNumber]; 84 86 85 *Info = AllocateCopyPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION), 86 ModeInfo); 87 *Info = AllocateCopyPool ( 88 sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION), 89 ModeInfo 90 ); 87 91 if (*Info == NULL) { 88 92 return EFI_OUT_OF_RESOURCES; 89 93 } 94 90 95 *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); 91 96 … … 97 102 EFIAPI 98 103 QemuRamfbGraphicsOutputSetMode ( 99 IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,100 IN UINT32 ModeNumber104 IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, 105 IN UINT32 ModeNumber 101 106 ) 102 107 { … … 109 114 return EFI_UNSUPPORTED; 110 115 } 116 111 117 ModeInfo = &mQemuRamfbModeInfo[ModeNumber]; 112 118 113 DEBUG ((DEBUG_INFO, "Ramfb: SetMode %u (%ux%u)\n", ModeNumber, 114 ModeInfo->HorizontalResolution, ModeInfo->VerticalResolution)); 119 DEBUG (( 120 DEBUG_INFO, 121 "Ramfb: SetMode %u (%ux%u)\n", 122 ModeNumber, 123 ModeInfo->HorizontalResolution, 124 ModeInfo->VerticalResolution 125 )); 115 126 116 127 Config.Address = SwapBytes64 (mQemuRamfbMode.FrameBufferBase); … … 122 133 123 134 Status = FrameBufferBltConfigure ( 124 (VOID *)(UINTN)mQemuRamfbMode.FrameBufferBase,135 (VOID *)(UINTN)mQemuRamfbMode.FrameBufferBase, 125 136 ModeInfo, 126 137 mQemuRamfbFrameBufferBltConfigure, … … 132 143 FreePool (mQemuRamfbFrameBufferBltConfigure); 133 144 } 145 134 146 mQemuRamfbFrameBufferBltConfigure = 135 147 AllocatePool (mQemuRamfbFrameBufferBltConfigureSize); … … 140 152 141 153 Status = FrameBufferBltConfigure ( 142 (VOID *)(UINTN)mQemuRamfbMode.FrameBufferBase,154 (VOID *)(UINTN)mQemuRamfbMode.FrameBufferBase, 143 155 ModeInfo, 144 156 mQemuRamfbFrameBufferBltConfigure, … … 146 158 ); 147 159 } 160 148 161 if (RETURN_ERROR (Status)) { 149 162 ASSERT (Status == RETURN_UNSUPPORTED); … … 174 187 ); 175 188 if (RETURN_ERROR (Status)) { 176 DEBUG ((DEBUG_WARN, "%a: clearing the screen failed: %r\n", 177 __FUNCTION__, Status)); 189 DEBUG (( 190 DEBUG_WARN, 191 "%a: clearing the screen failed: %r\n", 192 __FUNCTION__, 193 Status 194 )); 178 195 } 179 196 … … 185 202 EFIAPI 186 203 QemuRamfbGraphicsOutputBlt ( 187 IN EFI_GRAPHICS_OUTPUT_PROTOCOL 188 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL189 IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION 190 IN UINTN 191 IN UINTN 192 IN UINTN 193 IN UINTN 194 IN UINTN 195 IN UINTN 196 IN UINTN 204 IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, 205 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL, 206 IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, 207 IN UINTN SourceX, 208 IN UINTN SourceY, 209 IN UINTN DestinationX, 210 IN UINTN DestinationY, 211 IN UINTN Width, 212 IN UINTN Height, 213 IN UINTN Delta 197 214 ) 198 215 { … … 211 228 } 212 229 213 STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL mQemuRamfbGraphicsOutput = {230 STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL mQemuRamfbGraphicsOutput = { 214 231 QemuRamfbGraphicsOutputQueryMode, 215 232 QemuRamfbGraphicsOutputSetMode, … … 221 238 EFIAPI 222 239 InitializeQemuRamfb ( 223 IN EFI_HANDLE 224 IN EFI_SYSTEM_TABLE 240 IN EFI_HANDLE ImageHandle, 241 IN EFI_SYSTEM_TABLE *SystemTable 225 242 ) 226 243 { … … 245 262 return EFI_NOT_FOUND; 246 263 } 264 247 265 if (FwCfgSize != sizeof (RAMFB_CONFIG)) { 248 DEBUG ((DEBUG_ERROR, "Ramfb: FwCfg size mismatch (expected %lu, got %lu)\n", 249 (UINT64)sizeof (RAMFB_CONFIG), (UINT64)FwCfgSize)); 266 DEBUG (( 267 DEBUG_ERROR, 268 "Ramfb: FwCfg size mismatch (expected %lu, got %lu)\n", 269 (UINT64)sizeof (RAMFB_CONFIG), 270 (UINT64)FwCfgSize 271 )); 250 272 return EFI_PROTOCOL_ERROR; 251 273 } … … 258 280 PixelBlueGreenRedReserved8BitPerColor; 259 281 FbSize = RAMFB_BPP * 260 mQemuRamfbModeInfo[Index].HorizontalResolution *261 mQemuRamfbModeInfo[Index].VerticalResolution;282 mQemuRamfbModeInfo[Index].HorizontalResolution * 283 mQemuRamfbModeInfo[Index].VerticalResolution; 262 284 if (MaxFbSize < FbSize) { 263 285 MaxFbSize = FbSize; 264 286 } 265 DEBUG ((DEBUG_INFO, "Ramfb: Mode %lu: %ux%u, %lu kB\n", (UINT64)Index, 287 288 DEBUG (( 289 DEBUG_INFO, 290 "Ramfb: Mode %lu: %ux%u, %lu kB\n", 291 (UINT64)Index, 266 292 mQemuRamfbModeInfo[Index].HorizontalResolution, 267 293 mQemuRamfbModeInfo[Index].VerticalResolution, 268 (UINT64)(FbSize / 1024))); 269 } 270 271 Pages = EFI_SIZE_TO_PAGES (MaxFbSize); 294 (UINT64)(FbSize / 1024) 295 )); 296 } 297 298 Pages = EFI_SIZE_TO_PAGES (MaxFbSize); 272 299 MaxFbSize = EFI_PAGES_TO_SIZE (Pages); 273 FbBase = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateReservedPages (Pages);300 FbBase = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateReservedPages (Pages); 274 301 if (FbBase == 0) { 275 302 DEBUG ((DEBUG_ERROR, "Ramfb: memory allocation failed\n")); 276 303 return EFI_OUT_OF_RESOURCES; 277 304 } 278 DEBUG ((DEBUG_INFO, "Ramfb: Framebuffer at 0x%lx, %lu kB, %lu pages\n", 279 (UINT64)FbBase, (UINT64)(MaxFbSize / 1024), (UINT64)Pages)); 305 306 DEBUG (( 307 DEBUG_INFO, 308 "Ramfb: Framebuffer at 0x%lx, %lu kB, %lu pages\n", 309 (UINT64)FbBase, 310 (UINT64)(MaxFbSize / 1024), 311 (UINT64)Pages 312 )); 280 313 mQemuRamfbMode.FrameBufferSize = MaxFbSize; 281 314 mQemuRamfbMode.FrameBufferBase = FbBase; … … 289 322 // ramfb vendor devpath 290 323 // 291 VendorDeviceNode.Header.Type = HARDWARE_DEVICE_PATH;324 VendorDeviceNode.Header.Type = HARDWARE_DEVICE_PATH; 292 325 VendorDeviceNode.Header.SubType = HW_VENDOR_DP; 293 326 CopyGuid (&VendorDeviceNode.Guid, &gQemuRamfbGuid); 294 SetDevicePathNodeLength (&VendorDeviceNode.Header, 295 sizeof (VENDOR_DEVICE_PATH)); 296 297 RamfbDevicePath = AppendDevicePathNode (NULL, 298 (EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode); 327 SetDevicePathNodeLength ( 328 &VendorDeviceNode.Header, 329 sizeof (VENDOR_DEVICE_PATH) 330 ); 331 332 RamfbDevicePath = AppendDevicePathNode ( 333 NULL, 334 (EFI_DEVICE_PATH_PROTOCOL *)&VendorDeviceNode 335 ); 299 336 if (RamfbDevicePath == NULL) { 300 337 Status = EFI_OUT_OF_RESOURCES; … … 309 346 ); 310 347 if (EFI_ERROR (Status)) { 311 DEBUG ((DEBUG_ERROR, "Ramfb: install Ramfb Vendor DevicePath failed: %r\n", 312 Status)); 348 DEBUG (( 349 DEBUG_ERROR, 350 "Ramfb: install Ramfb Vendor DevicePath failed: %r\n", 351 Status 352 )); 313 353 goto FreeRamfbDevicePath; 314 354 } … … 317 357 // gop devpath + protocol 318 358 // 319 AcpiDeviceNode.Header.Type = ACPI_DEVICE_PATH;359 AcpiDeviceNode.Header.Type = ACPI_DEVICE_PATH; 320 360 AcpiDeviceNode.Header.SubType = ACPI_ADR_DP; 321 AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR ( 322 1, // DeviceIdScheme 323 0, // HeadId 324 0, // NonVgaOutput 325 1, // BiosCanDetect 326 0, // VendorInfo 327 ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL, // Type 328 0, // Port 329 0 // Index 361 AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR ( 362 1, // DeviceIdScheme 363 0, // HeadId 364 0, // NonVgaOutput 365 1, // BiosCanDetect 366 0, // VendorInfo 367 ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL, // Type 368 0, // Port 369 0 // Index 370 ); 371 SetDevicePathNodeLength ( 372 &AcpiDeviceNode.Header, 373 sizeof (ACPI_ADR_DEVICE_PATH) 330 374 ); 331 SetDevicePathNodeLength (&AcpiDeviceNode.Header, 332 sizeof (ACPI_ADR_DEVICE_PATH));333 334 GopDevicePath = AppendDevicePathNode (RamfbDevicePath,335 (EFI_DEVICE_PATH_PROTOCOL *) &AcpiDeviceNode);375 376 GopDevicePath = AppendDevicePathNode ( 377 RamfbDevicePath, 378 (EFI_DEVICE_PATH_PROTOCOL *)&AcpiDeviceNode 379 ); 336 380 if (GopDevicePath == NULL) { 337 381 Status = EFI_OUT_OF_RESOURCES; … … 348 392 ); 349 393 if (EFI_ERROR (Status)) { 350 DEBUG ((DEBUG_ERROR, "Ramfb: install GOP DevicePath failed: %r\n", 351 Status)); 394 DEBUG (( 395 DEBUG_ERROR, 396 "Ramfb: install GOP DevicePath failed: %r\n", 397 Status 398 )); 352 399 goto FreeGopDevicePath; 353 400 } … … 389 436 FreePool (RamfbDevicePath); 390 437 FreeFramebuffer: 391 FreePages ((VOID *)(UINTN)mQemuRamfbMode.FrameBufferBase, Pages);438 FreePages ((VOID *)(UINTN)mQemuRamfbMode.FrameBufferBase, Pages); 392 439 return Status; 393 440 }
Note:
See TracChangeset
for help on using the changeset viewer.