VirtualBox

Ignore:
Timestamp:
Oct 19, 2010 10:37:24 AM (14 years ago)
Author:
vboxsync
Message:

Additions/WINNT/Graphics: more refactoring

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Miniport
Files:
6 edited

Legend:

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

    r33165 r33226  
    13811381#endif
    13821382
    1383 int VBoxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension, void **ppv, ULONG ulOffset, ULONG ulSize)
    1384 {
     1383int VBoxMapAdapterMemory (PVBOXVIDEO_COMMON pCommon, void **ppv, ULONG ulOffset, ULONG ulSize)
     1384{
     1385    PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon);
    13851386    dprintf(("VBoxVideo::VBoxMapAdapterMemory 0x%08X[0x%X]\n", ulOffset, ulSize));
    13861387
     
    16501651
    16511652      dprintf(("VBoxVideo::VBoxVideoFindAdapter: calling VideoPortGetAccessRanges\n"));
    1652 
    1653       /* pPrimary is not yet set */
    1654       ((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.commonInfo.IOPortHost = (RTIOPORT)VGA_PORT_HGSMI_HOST;
    1655       ((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.commonInfo.IOPortGuest = (RTIOPORT)VGA_PORT_HGSMI_GUEST;
    16561653
    16571654      VIDEO_ACCESS_RANGE tmpRanges[4];
     
    16951692      dprintf(("VBoxVideo::VBoxVideoFindAdapter: VbglInit returned 0x%x\n", rc));
    16961693
     1694      /* Preinitialize the primary extension.
     1695       */
     1696      ((PDEVICE_EXTENSION)HwDeviceExtension)->pNext                   = NULL;
     1697      ((PDEVICE_EXTENSION)HwDeviceExtension)->pPrimary                = (PDEVICE_EXTENSION)HwDeviceExtension;
     1698      ((PDEVICE_EXTENSION)HwDeviceExtension)->iDevice                 = 0;
     1699      ((PDEVICE_EXTENSION)HwDeviceExtension)->ulFrameBufferOffset     = 0;
     1700      ((PDEVICE_EXTENSION)HwDeviceExtension)->ulFrameBufferSize       = 0;
     1701      ((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.ulVbvaEnabled = 0;
     1702      ((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.cDisplays     = 1;
     1703      VBoxVideoCmnMemZero(&((PDEVICE_EXTENSION)HwDeviceExtension)->areaDisplay, sizeof(HGSMIAREA));
    16971704      /* Guest supports only HGSMI, the old VBVA via VMMDev is not supported. Old
    16981705       * code will be ifdef'ed and later removed.
     
    22022209        {
    22032210            dprintf(("VBoxVideo::VBoxVideoStartIO: IOCTL_VIDEO_INTERPRET_DISPLAY_MEMORY\n"));
    2204 
    2205             if (pDevExt->pPrimary->u.primary.bVBoxVideoSupported)
    2206             {
    2207                 /* The display driver must have prepared the monitor information. */
    2208                 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VBOX_VIDEO);
    2209                 VideoPortWritePortUlong((PULONG)VBE_DISPI_IOPORT_DATA, VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE + pDevExt->iDevice);
    2210             }
    2211             else
    2212             {
    2213                 RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
    2214             }
    2215             Result = pDevExt->pPrimary->u.primary.bVBoxVideoSupported;
     2211            /* Pre-HGSMI IOCTL */
     2212            RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
     2213            Result = false;
    22162214            break;
    22172215        }
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h

    r33165 r33226  
    268268           ULONG ulVbvaEnabled;                /* Indicates that VBVA mode is enabled. */
    269269
    270            BOOLEAN bVBoxVideoSupported;        /* TRUE if VBoxVideo extensions, including DualView, are supported by the host. */
    271 
    272270           int cDisplays;                      /* Number of displays. */
    273271
     
    342340    return &pExt->u.primary.commonInfo;
    343341#endif
     342}
     343
     344static inline PDEVICE_EXTENSION commonToPrimaryExt(PVBOXVIDEO_COMMON pCommon)
     345{
     346    return RT_FROM_MEMBER(pCommon, DEVICE_EXTENSION, u.primary.commonInfo);
    344347}
    345348
     
    843846   PSTATUS_BLOCK StatusBlock);
    844847
    845 int VBoxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
     848int VBoxMapAdapterMemory (PVBOXVIDEO_COMMON pCommon,
    846849                          void **ppv,
    847850                          ULONG ulOffset,
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp

    r33165 r33226  
    728728             PrimaryExtension));
    729729
    730     /* Preinitialize the primary extension.
    731      * Note: bVBoxVideoSupported is set to FALSE, because HGSMI is active instead.
    732      * Note 2: shouldn't be needed for WDDM.
    733      */
    734     PrimaryExtension->pNext                              = NULL;
    735 #ifndef VBOX_WITH_WDDM
    736     PrimaryExtension->pPrimary                           = PrimaryExtension;
    737     PrimaryExtension->iDevice                            = 0;
    738     PrimaryExtension->ulFrameBufferOffset                = 0;
    739     PrimaryExtension->ulFrameBufferSize                  = 0;
    740 #endif
    741     PrimaryExtension->u.primary.ulVbvaEnabled            = 0;
    742     PrimaryExtension->u.primary.bVBoxVideoSupported      = FALSE;
    743 #ifndef VBOX_WITH_WDDM
    744     PrimaryExtension->u.primary.cDisplays                = 1;
    745 #endif
    746     commonFromDeviceExt(PrimaryExtension)->cbVRAM                   = AdapterMemorySize;
    747     commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap           = 0;
    748     commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap           = NULL;
    749     commonFromDeviceExt(PrimaryExtension)->pvAdapterInformation     = NULL;
    750     commonFromDeviceExt(PrimaryExtension)->pHostFlags               = NULL;
    751     PrimaryExtension->u.primary.ulMaxFrameBufferSize     = 0;
    752     commonFromDeviceExt(PrimaryExtension)->fCaps         = fCaps;
    753     commonFromDeviceExt(PrimaryExtension)->bHGSMI        = VBoxHGSMIIsSupported ();
    754     VBoxVideoCmnMemZero(&commonFromDeviceExt(PrimaryExtension)->areaHostHeap, sizeof(HGSMIAREA));
    755     VBoxVideoCmnMemZero(&PrimaryExtension->areaDisplay, sizeof(HGSMIAREA));
    756 
    757     if (commonFromDeviceExt(PrimaryExtension)->IOPortGuest == 0)
    758     {
    759         commonFromDeviceExt(PrimaryExtension)->bHGSMI = false;
    760     }
    761 
     730    memset(commonFromDeviceExt(PrimaryExtension), 0,
     731           sizeof(*commonFromDeviceExt(PrimaryExtension)));
     732    commonFromDeviceExt(PrimaryExtension)->cbVRAM = AdapterMemorySize;
     733    commonFromDeviceExt(PrimaryExtension)->fCaps  = fCaps;
     734    commonFromDeviceExt(PrimaryExtension)->bHGSMI = VBoxHGSMIIsSupported ();
     735    /* Why does this use VBoxVideoCmnMemZero?  The MSDN docs say that it should
     736     * only be used on mapped display adapter memory.  Done with memset above. */
     737    // VBoxVideoCmnMemZero(&commonFromDeviceExt(PrimaryExtension)->areaHostHeap, sizeof(HGSMIAREA));
    762738    if (commonFromDeviceExt(PrimaryExtension)->bHGSMI)
    763739    {
     740        /** @note (michael) moved this here as it is done unconditionally in both
     741         * driver branches.  Feel free to fix if that is ever changed. */
     742        commonFromDeviceExt(PrimaryExtension)->IOPortHost = (RTIOPORT)VGA_PORT_HGSMI_HOST;
     743        commonFromDeviceExt(PrimaryExtension)->IOPortGuest = (RTIOPORT)VGA_PORT_HGSMI_GUEST;
     744
    764745        /* Map the adapter information. It will be needed for HGSMI IO. */
    765         rc = VBoxMapAdapterMemory (PrimaryExtension,
     746        rc = VBoxMapAdapterMemory (commonFromDeviceExt(PrimaryExtension),
    766747                                   &commonFromDeviceExt(PrimaryExtension)->pvAdapterInformation,
    767                                    commonFromDeviceExt(PrimaryExtension)->cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE,
     748                                   AdapterMemorySize - VBVA_ADAPTER_INFORMATION_SIZE,
    768749                                   VBVA_ADAPTER_INFORMATION_SIZE
    769750                                  );
     
    833814             *       display drivers.
    834815             */
    835             rc = VBoxMapAdapterMemory (PrimaryExtension,
     816            rc = VBoxMapAdapterMemory (commonFromDeviceExt(PrimaryExtension),
    836817                                       &commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap,
    837818                                       commonFromDeviceExt(PrimaryExtension)->cbVRAM
     
    10401021#endif
    10411022
    1042         rc = VBoxMapAdapterMemory(PrimaryExtension, (void**)&PrimaryExtension->pvVisibleVram,
     1023        rc = VBoxMapAdapterMemory(commonFromDeviceExt(PrimaryExtension), (void**)&PrimaryExtension->pvVisibleVram,
    10431024                                       0,
    10441025                                       vboxWddmVramCpuVisibleSize(PrimaryExtension));
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVbva.cpp

    r32989 r33226  
    106106    KeInitializeSpinLock(&pVbva->Lock);
    107107
    108     int rc = VBoxMapAdapterMemory (pDevExt,
     108    int rc = VBoxMapAdapterMemory (commonFromDeviceExt(pDevExt),
    109109                                       (void**)&pVbva->pVBVA,
    110110                                       offBuffer,
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVdma.cpp

    r33216 r33226  
    10881088    PVOID pvBuffer;
    10891089
    1090     rc = VBoxMapAdapterMemory (pDevExt,
     1090    rc = VBoxMapAdapterMemory (commonFromDeviceExt(pDevExt),
    10911091                                   &pvBuffer,
    10921092                                   offBuffer,
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp

    r33223 r33226  
    434434       if (VBoxHGSMIIsSupported ())
    435435       {
    436            commonFromDeviceExt(pContext)->IOPortHost = (RTIOPORT)VGA_PORT_HGSMI_HOST;
    437            commonFromDeviceExt(pContext)->IOPortGuest = (RTIOPORT)VGA_PORT_HGSMI_GUEST;
    438 
    439436           PCM_RESOURCE_LIST pRcList = pDeviceInfo->TranslatedResourceList;
    440437           /* @todo: verify resources */
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