VirtualBox

Ignore:
Timestamp:
Aug 7, 2007 8:40:02 AM (17 years ago)
Author:
vboxsync
Message:

Use the generic VBoxVideo interface in Windows guest video driver.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp

    r4027 r4053  
    740740       
    741741        dprintf(("VBoxVideo::vboxComputeFrameBufferSizes: [%d] ulFrameBufferOffset 0x%08X\n",
    742                  ulFrameBufferOffset));
     742                 Extension->iDevice, ulFrameBufferOffset));
    743743       
    744744        ulFrameBufferOffset += PrimaryExtension->u.primary.ulMaxFrameBufferSize
     
    749749}
    750750
    751 static int vboxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension)
    752 {
    753     dprintf(("VBoxVideo::vboxMapAdapterMemory\n"));
     751static int vboxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension, void **ppv, ULONG ulOffset, ULONG ulSize)
     752{
     753    dprintf(("VBoxVideo::vboxMapAdapterMemory 0x%08X[0x%X]\n", ulOffset, ulSize));
    754754
    755755    PHYSICAL_ADDRESS FrameBuffer;
    756     FrameBuffer.QuadPart = VBE_DISPI_LFB_PHYSICAL_ADDRESS
    757                            + PrimaryExtension->u.primary.cbVRAM
    758                            - PrimaryExtension->u.primary.cbMiniportHeap
    759                            - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE;
     756    FrameBuffer.QuadPart = VBE_DISPI_LFB_PHYSICAL_ADDRESS + ulOffset;
    760757
    761758    PVOID VideoRamBase = NULL;
    762759    ULONG inIoSpace = 0;
    763     ULONG VideoRamLength = PrimaryExtension->u.primary.cbMiniportHeap
    764                            + VBOX_VIDEO_ADAPTER_INFORMATION_SIZE;
     760    ULONG VideoRamLength = ulSize;
    765761
    766762    VP_STATUS Status = VideoPortMapMemory (PrimaryExtension, FrameBuffer,
     
    770766    if (Status == NO_ERROR)
    771767    {
    772         PrimaryExtension->u.primary.pvMiniportHeap       = VideoRamBase;
    773         PrimaryExtension->u.primary.pvAdapterInformation = (uint8_t *)VideoRamBase
    774                                                            + PrimaryExtension->u.primary.cbMiniportHeap;
     768        *ppv = VideoRamBase;
    775769    }
    776770   
     
    780774}
    781775
    782 static void vboxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension)
     776static void vboxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension, void **ppv)
    783777{
    784778    dprintf(("VBoxVideo::vboxMapAdapterMemory\n"));
    785779   
    786     if (PrimaryExtension->u.primary.pvMiniportHeap)
    787     {
    788         VideoPortUnmapMemory(PrimaryExtension, PrimaryExtension->u.primary.pvMiniportHeap, NULL);
    789     }
    790    
    791     PrimaryExtension->u.primary.pvMiniportHeap       = NULL;
    792     PrimaryExtension->u.primary.pvAdapterInformation = NULL;
     780    if (*ppv)
     781    {
     782        VideoPortUnmapMemory(PrimaryExtension, *ppv, NULL);
     783    }
     784   
     785    *ppv = NULL;
     786}
     787
     788static void vboxQueryConf (PDEVICE_EXTENSION PrimaryExtension, uint32_t u32Index, ULONG *pulValue)
     789{
     790    dprintf(("VBoxVideo::vboxQueryConf: u32Index = %d\n", u32Index));
     791   
     792    typedef struct _VBOXVIDEOQCONF32
     793    {
     794        VBOXVIDEOINFOHDR hdrQuery;
     795        VBOXVIDEOINFOQUERYCONF32 query;
     796        VBOXVIDEOINFOHDR hdrEnd;
     797    } VBOXVIDEOQCONF32;
     798
     799    VBOXVIDEOQCONF32 *p = (VBOXVIDEOQCONF32 *)PrimaryExtension->u.primary.pvAdapterInformation;
     800
     801    p->hdrQuery.u8Type     = VBOX_VIDEO_INFO_TYPE_QUERY_CONF32;
     802    p->hdrQuery.u8Reserved = 0;
     803    p->hdrQuery.u16Length  = sizeof (VBOXVIDEOINFOQUERYCONF32);
     804   
     805    p->query.u32Index = u32Index;
     806    p->query.u32Value = 0;
     807   
     808    p->hdrEnd.u8Type     = VBOX_VIDEO_INFO_TYPE_END;
     809    p->hdrEnd.u8Reserved = 0;
     810    p->hdrEnd.u16Length  = 0;
     811   
     812    /* Inform the host about the display configuration. */
     813    VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VBOX_VIDEO);
     814    VideoPortWritePortUlong((PULONG)VBE_DISPI_IOPORT_DATA, VBOX_VIDEO_INTERPRET_ADAPTER_MEMORY);
     815   
     816    *pulValue = (ULONG)p->query.u32Value;
     817   
     818    dprintf(("VBoxVideo::vboxQueryConf: u32Value = %d\n", p->query.u32Value));
    793819}
    794820
     
    883909    PrimaryExtension->u.primary.ulDisplayInformationSize = 0;
    884910
    885    
    886911    /* Verify whether the HW supports VirtualBox extensions. */
    887912    VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);
     
    896921             PrimaryExtension->u.primary.bVBoxVideoSupported));
    897922   
     923    if (PrimaryExtension->u.primary.bVBoxVideoSupported)
     924    {
     925        /* Map the adapter information. It will be needed to query some configuration values. */
     926        rc = vboxMapAdapterMemory (PrimaryExtension,
     927                                   &PrimaryExtension->u.primary.pvAdapterInformation,
     928                                   PrimaryExtension->u.primary.cbVRAM - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE,
     929                                   VBOX_VIDEO_ADAPTER_INFORMATION_SIZE
     930                                  );
     931        if (rc != NO_ERROR)
     932        {
     933            dprintf(("VBoxVideo::VBoxSetupDisplays: vboxMapAdapterMemory pvAdapterInfoirrmation failed rc = %d\n",
     934                     rc));
     935   
     936            PrimaryExtension->u.primary.bVBoxVideoSupported = FALSE;
     937        }
     938    }
     939   
    898940    /* Setup the non-volatile heap and the adapter memory. */
    899941    if (PrimaryExtension->u.primary.bVBoxVideoSupported)
    900942    {
    901943        /* Query the size of the non-volatile heap. */
    902         VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VBOX_VIDEO);
    903         VideoPortWritePortUlong((PULONG)VBE_DISPI_IOPORT_DATA, VBOX_VIDEO_QUERY_OFFSCREEN_HEAP_SIZE);
    904        
    905         ULONG cbMiniportHeap = VideoPortReadPortUlong((PULONG)VBE_DISPI_IOPORT_DATA);
     944        ULONG cbMiniportHeap = 0;
     945        vboxQueryConf (PrimaryExtension, VBOX_VIDEO_QCI32_OFFSCREEN_HEAP_SIZE, &cbMiniportHeap);
    906946       
    907947        /* Do not allow too big heap. 50% of VRAM should be enough. */
     
    927967         *
    928968         */
    929         rc = vboxMapAdapterMemory (PrimaryExtension);
     969        rc = vboxMapAdapterMemory (PrimaryExtension,
     970                                   &PrimaryExtension->u.primary.pvMiniportHeap,
     971                                   PrimaryExtension->u.primary.cbVRAM
     972                                   - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE
     973                                   - PrimaryExtension->u.primary.cbMiniportHeap,
     974                                   PrimaryExtension->u.primary.cbMiniportHeap
     975                                  );
    930976       
    931977        if (rc != NO_ERROR)
     
    9541000        {
    9551001            /* Query the configured number of displays. */
    956             VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VBOX_VIDEO);
    957             int cDisplays = VideoPortReadPortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA);
    958            
     1002            ULONG cDisplays = 0;
     1003            vboxQueryConf (PrimaryExtension, VBOX_VIDEO_QCI32_MONITOR_COUNT, &cDisplays);
     1004       
    9591005            dprintf(("VBoxVideo::VBoxSetupDisplays: cDisplays = %d\n",
    9601006                     cDisplays));
     
    9681014            PDEVICE_EXTENSION pPrev = PrimaryExtension;
    9691015           
    970             int iDisplay;
     1016            ULONG iDisplay;
    9711017            for (iDisplay = 1; iDisplay < cDisplays; iDisplay++)
    9721018            {
     
    10111057        /* Setup the information for the host. */
    10121058        vboxSetupAdapterInfo (PrimaryExtension);
     1059    }
     1060    else
     1061    {
     1062        /* Unmap the memory if VBoxVideo is not supported. */
     1063        vboxUnmapAdapterMemory (PrimaryExtension, &PrimaryExtension->u.primary.pvMiniportHeap);
     1064        vboxUnmapAdapterMemory (PrimaryExtension, &PrimaryExtension->u.primary.pvAdapterInformation);
    10131065    }
    10141066   
     
    16671719    VbglTerminate ();
    16681720   
    1669     vboxUnmapAdapterMemory (pDevExt);
     1721    vboxUnmapAdapterMemory (pDevExt, &pDevExt->u.primary.pvMiniportHeap);
     1722    vboxUnmapAdapterMemory (pDevExt, &pDevExt->u.primary.pvAdapterInformation);
    16701723
    16711724    return TRUE;
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