VirtualBox

Changeset 76900 in vbox for trunk/src/VBox/Devices/EFI


Ignore:
Timestamp:
Jan 19, 2019 12:43:26 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128268
Message:

EFI: Added very rudimentary support for VMSVGA II.

Location:
trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVga.c

    r76553 r76900  
    312312  //  if (((Pci.Hdr.Command & 0x01) == 0x01)) {
    313313  //
    314   // See if this is a VirtualBox VGA PCI controller
    315   //
    316   if (Pci.Hdr.VendorId == VBOX_VENDOR_ID) {
    317     if (Pci.Hdr.DeviceId == VBOX_VGA_DEVICE_ID) {
     314  // See if this is a VirtualBox VGA or VMSVGA II PCI controller
     315  //
     316  if ( (Pci.Hdr.VendorId == VBOX_VENDOR_ID) && (Pci.Hdr.DeviceId == VBOX_VGA_DEVICE_ID)
     317    || (Pci.Hdr.VendorId == VMSVGA_VENDOR_ID) && (Pci.Hdr.DeviceId == VMSVGA_II_DEVICE_ID)) {
    318318
    319319      Status = EFI_SUCCESS;
     
    337337        }
    338338      }
    339     }
    340339  }
    341340
     
    375374  EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;
    376375  ACPI_ADR_DEVICE_PATH            AcpiDeviceNode;
     376  PCI_TYPE00                      Pci;
    377377
    378378  PciAttributesSaved = FALSE;
     
    408408
    409409  //
     410  // Read the PCI Configuration Header from the PCI Device again to figure out the model.
     411  //
     412  Status = Private->PciIo->Pci.Read (
     413                                   Private->PciIo,
     414                                   EfiPciIoWidthUint32,
     415                                   0,
     416                                   sizeof (Pci) / sizeof (UINT32),
     417                                   &Pci
     418                                   );
     419  if (EFI_ERROR (Status)) {
     420    DEBUG((DEBUG_INFO, "%a:%d status:%r\n", __FILE__, __LINE__, Status));
     421    goto Error;
     422  }
     423
     424  Private->DeviceType = Pci.Hdr.DeviceId;
     425
     426  //
    410427  // Save original PCI attributes
    411428  //
     
    488505
    489506  //
    490   // Get VRAM size, needed for constructing a correct video mode list
    491   //
    492   Private->VRAMSize = ASMInU32(VBE_DISPI_IOPORT_DATA);
     507  // Now do some model-specific setup.
     508  //
     509  if (Private->DeviceType == VMSVGA_II_DEVICE_ID) {
     510      EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR     *IOPortDesc;
     511
     512      // VMSVGA
     513      Private->BarIndexFB = 1;
     514
     515      Private->PciIo->GetBarAttributes (
     516                          Private->PciIo,
     517                          0,    // BAR 0 is the I/O port space
     518                          NULL,
     519                          (VOID**) &IOPortDesc
     520                          );
     521      Private->IOBase = (UINT16)IOPortDesc->AddrRangeMin;
     522
     523      //
     524      // Query the VRAM size (for proper mode filtering)
     525      //
     526      ASMOutU32(Private->IOBase + SVGA_INDEX_PORT, SVGA_REG_VRAM_SIZE);
     527      Private->VRAMSize = ASMInU32(Private->IOBase + SVGA_VALUE_PORT);
     528
     529#if 0
     530      // Not used because of buggy emulation(?) which is not fully compatible
     531      // with the simple "legacy" VMSVGA II register interface.
     532
     533      // Enable the device, set initial mode
     534      ASMOutU32(Private->IOBase + SVGA_INDEX_PORT, SVGA_REG_WIDTH);
     535      ASMOutU32(Private->IOBase + SVGA_VALUE_PORT, 1024);
     536      ASMOutU32(Private->IOBase + SVGA_INDEX_PORT, SVGA_REG_HEIGHT);
     537      ASMOutU32(Private->IOBase + SVGA_VALUE_PORT, 768);
     538      ASMOutU32(Private->IOBase + SVGA_INDEX_PORT, SVGA_REG_BYTES_PER_LINE);
     539      ASMOutU32(Private->IOBase + SVGA_VALUE_PORT, 768 * 4);
     540      ASMOutU32(Private->IOBase + SVGA_INDEX_PORT, SVGA_REG_BITS_PER_PIXEL);
     541      ASMOutU32(Private->IOBase + SVGA_VALUE_PORT, 32);
     542      ASMOutU32(Private->IOBase + SVGA_INDEX_PORT, SVGA_REG_CONFIG_DONE);
     543      ASMOutU32(Private->IOBase + SVGA_VALUE_PORT, 1);
     544
     545      ASMOutU32(Private->IOBase + SVGA_INDEX_PORT, SVGA_REG_ENABLE);
     546      ASMOutU32(Private->IOBase + SVGA_VALUE_PORT, SVGA_REG_ENABLE_ENABLE);
     547#endif
     548  } else {
     549      // VBoxVGA / VBoxSVGA
     550      Private->BarIndexFB = 0;
     551      //
     552      // Get VRAM size, needed for constructing a correct video mode list
     553      //
     554      Private->VRAMSize = ASMInU32(VBE_DISPI_IOPORT_DATA);
     555  }
     556
    493557
    494558  //
     
    896960                        Private->PciIo,
    897961                        EfiPciIoWidthFillUint32,
    898                         0,
     962                        Private->BarIndexFB,
    899963                        0,
    900964                          Private->ModeData[Private->CurrentMode].HorizontalResolution
     
    10431107    Private->PciIo->GetBarAttributes (
    10441108                        Private->PciIo,
    1045                         0,
     1109                        Private->BarIndexFB,
    10461110                        NULL,
    10471111                        (VOID**) &FrameBufDesc
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVga.h

    r76553 r76900  
    7979// VirtualBox VGA PCI Configuration Header values
    8080//
    81 #define VBOX_VENDOR_ID           0x80ee
    82 #define VBOX_VGA_DEVICE_ID           0xbeef
     81#define VBOX_VENDOR_ID          0x80ee
     82#define VBOX_VGA_DEVICE_ID      0xbeef
     83
     84
     85//
     86// VMSVGA II PCI Configuration Header values
     87//
     88#define VMSVGA_VENDOR_ID        0x15ad
     89#define VMSVGA_II_DEVICE_ID     0x0405
     90
     91// Port offsets relative to BAR 0
     92#define SVGA_INDEX_PORT     0
     93#define SVGA_VALUE_PORT     1
     94
     95// SVGA_REG_ENABLE bits
     96#define SVGA_REG_ENABLE_DISABLE     0
     97#define SVGA_REG_ENABLE_ENABLE      1
     98
     99// Registers
     100#define SVGA_REG_ENABLE             1
     101#define SVGA_REG_WIDTH              2
     102#define SVGA_REG_HEIGHT             3
     103#define SVGA_REG_MAX_WIDTH          4
     104#define SVGA_REG_MAX_HEIGHT         5
     105#define SVGA_REG_DEPTH              6
     106#define SVGA_REG_BITS_PER_PIXEL     7
     107#define SVGA_REG_BYTES_PER_LINE     12
     108#define SVGA_REG_FB_START           13
     109#define SVGA_REG_FB_OFFSET          14
     110#define SVGA_REG_VRAM_SIZE          15
     111#define SVGA_REG_CONFIG_DONE        20      ///@todo: Why do we need this?
    83112
    84113//
     
    115144  VBOX_VGA_MODE_DATA                    *ModeData;
    116145  BOOLEAN                               HardwareNeedsStarting;
     146  UINT8                                 BarIndexFB;
     147  UINT16                                DeviceType;
     148  UINT16                                IOBase;
    117149  UINT32                                VRAMSize;
    118150} VBOX_VGA_PRIVATE_DATA;
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaGraphicsOutput.c

    r76553 r76900  
    7979  Private->PciIo->GetBarAttributes (
    8080                        Private->PciIo,
    81                         0,
     81                        Private->BarIndexFB,
    8282                        NULL,
    8383                        (VOID**) &FrameBufDesc
     
    317317                                    Private->PciIo,
    318318                                    EfiPciIoWidthUint32,
    319                                     0,
     319                                    Private->BarIndexFB,
    320320                                    ((SrcY * ScreenWidth) + SourceX) * 4,
    321321                                    Width,
     
    335335                                    Private->PciIo,
    336336                                    EfiPciIoWidthUint32,
    337                                     0,
     337                                    Private->BarIndexFB,
    338338                                    ((DstY * ScreenWidth) + DestinationX) * 4,
    339339                                    Width,
     
    355355                                    Private->PciIo,
    356356                                    EfiPciIoWidthUint32,
    357                                     0,
     357                                    Private->BarIndexFB,
    358358                                    ((DstY * ScreenWidth) + DestinationX) * 4,
    359                                     0,
     359                                    Private->BarIndexFB,
    360360                                    ((SrcY * ScreenWidth) + SourceX) * 4,
    361361                                    Width
     
    370370                                    Private->PciIo,
    371371                                    EfiPciIoWidthUint32,
    372                                     0,
     372                                    Private->BarIndexFB,
    373373                                    ((DstY * ScreenWidth) + DestinationX) * 4,
    374                                     0,
     374                                    Private->BarIndexFB,
    375375                                    ((SrcY * ScreenWidth) + SourceX) * 4,
    376376                                    Width
     
    390390                                    Private->PciIo,
    391391                                    EfiPciIoWidthFillUint32,
    392                                     0,
     392                                    Private->BarIndexFB,
    393393                                    DestinationY * ScreenWidth * 4,
    394394                                    (Width * Height),
     
    402402                                      Private->PciIo,
    403403                                      EfiPciIoWidthFillUint32,
    404                                       0,
     404                                      Private->BarIndexFB,
    405405                                      ((DstY * ScreenWidth) + DestinationX) * 4,
    406406                                      Width,
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaUgaDraw.c

    r76553 r76900  
    216216                                    Private->PciIo,
    217217                                    EfiPciIoWidthUint32,
    218                                     0,
     218                                    Private->BarIndexFB,
    219219                                    ((SrcY * ScreenWidth) + SourceX) * 4,
    220220                                    Width,
     
    234234                                    Private->PciIo,
    235235                                    EfiPciIoWidthUint32,
    236                                     0,
     236                                    Private->BarIndexFB,
    237237                                    ((DstY * ScreenWidth) + DestinationX) * 4,
    238238                                    Width,
     
    254254                                    Private->PciIo,
    255255                                    EfiPciIoWidthUint32,
    256                                     0,
     256                                    Private->BarIndexFB,
    257257                                    ((DstY * ScreenWidth) + DestinationX) * 4,
    258                                     0,
     258                                    Private->BarIndexFB,
    259259                                    ((SrcY * ScreenWidth) + SourceX) * 4,
    260260                                    Width
     
    269269                                    Private->PciIo,
    270270                                    EfiPciIoWidthUint32,
    271                                     0,
     271                                    Private->BarIndexFB,
    272272                                    ((DstY * ScreenWidth) + DestinationX) * 4,
    273                                     0,
     273                                    Private->BarIndexFB,
    274274                                    ((SrcY * ScreenWidth) + SourceX) * 4,
    275275                                    Width
     
    289289                                    Private->PciIo,
    290290                                    EfiPciIoWidthFillUint32,
    291                                     0,
     291                                    Private->BarIndexFB,
    292292                                    DestinationY * ScreenWidth * 4,
    293293                                    (Width * Height),
     
    301301                              Private->PciIo,
    302302                              EfiPciIoWidthFillUint32,
    303                               0,
     303                              Private->BarIndexFB,
    304304                              ((DstY * ScreenWidth) + DestinationX) * 4,
    305305                              Width,
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette