VirtualBox

Ignore:
Timestamp:
Oct 12, 2010 11:10:48 PM (14 years ago)
Author:
vboxsync
Message:

Additions/WINNT/Graphics: more refactoring

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

Legend:

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

    r33048 r33085  
    2424#include <VBox/HGSMI/HGSMI.h>
    2525#include <VBox/HGSMI/HGSMIChSetup.h>
     26#include <VBox/VBoxVideo.h>
    2627#include "VBoxHGSMI.h"
    2728
     
    3435#include "video.h"
    3536#else
     37#   ifdef PAGE_SIZE
     38#    undef PAGE_SIZE
     39#   endif
     40#   ifdef PAGE_SHIFT
     41#    undef PAGE_SHIFT
     42#   endif
    3643#   define VBOX_WITH_WORKAROUND_MISSING_PACK
    3744#   if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
     
    870877BOOLEAN VBoxHGSMIIsSupported (void);
    871878
     879typedef int FNHGSMIFILLVIEWINFO (void *pvData, VBVAINFOVIEW *pInfo);
     880typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO;
     881
     882int VBoxHGSMISendViewInfo(PVBOXVIDEO_COMMON pCommon, uint32_t u32Count, PFNHGSMIFILLVIEWINFO pfnFill, void *pvData);
     883
    872884VOID VBoxSetupDisplaysHGSMI (PDEVICE_EXTENSION PrimaryExtension,
    873885#ifndef VBOX_WITH_WDDM
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp

    r33022 r33085  
    176176}
    177177
    178 typedef int FNHGSMICALLINIT (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData);
     178typedef int FNHGSMICALLINIT (PVBOXVIDEO_COMMON pCommon, void *pvContext, void *pvData);
    179179typedef FNHGSMICALLINIT *PFNHGSMICALLINIT;
    180180
    181 typedef int FNHGSMICALLFINALIZE (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData);
     181typedef int FNHGSMICALLFINALIZE (PVBOXVIDEO_COMMON pCommon, void *pvContext, void *pvData);
    182182typedef FNHGSMICALLFINALIZE *PFNHGSMICALLFINALIZE;
    183183
     
    217217}
    218218
    219 static int vboxCallChannel (PDEVICE_EXTENSION PrimaryExtension,
     219static int vboxCallChannel (PVBOXVIDEO_COMMON pCommon,
    220220                         uint8_t u8Ch,
    221221                         uint16_t u16Op,
     
    228228
    229229    /* Allocate the IO buffer. */
    230 #ifndef VBOX_WITH_WDDM
    231     if (PrimaryExtension->pPrimary != PrimaryExtension)
    232     {
    233         dprintf(("VBoxVideo::vboxCallChannel: not primary extension %p!!!\n", PrimaryExtension));
    234         return VERR_INVALID_PARAMETER;
    235     }
    236 #endif
    237 
    238     void *p = HGSMIHeapAlloc (&commonFromDeviceExt(PrimaryExtension)->hgsmiAdapterHeap, cbData, u8Ch, u16Op);
     230    void *p = HGSMIHeapAlloc (&pCommon->hgsmiAdapterHeap, cbData, u8Ch, u16Op);
    239231
    240232    if (!p)
     
    247239        if (pfnInit)
    248240        {
    249             rc = pfnInit (PrimaryExtension, pvContext, p);
     241            rc = pfnInit (pCommon, pvContext, p);
    250242        }
    251243
     
    253245        {
    254246            /* Initialize the buffer and get the offset for port IO. */
    255             HGSMIOFFSET offBuffer = HGSMIHeapBufferOffset (&commonFromDeviceExt(PrimaryExtension)->hgsmiAdapterHeap,
     247            HGSMIOFFSET offBuffer = HGSMIHeapBufferOffset (&pCommon->hgsmiAdapterHeap,
    256248                                                           p);
    257249
    258250            /* Submit the buffer to the host. */
    259             VBoxHGSMIGuestWrite(commonFromDeviceExt(PrimaryExtension), offBuffer);
     251            VBoxHGSMIGuestWrite(pCommon, offBuffer);
    260252
    261253            if (pfnFinalize)
    262254            {
    263                 rc = pfnFinalize (PrimaryExtension, pvContext, p);
     255                rc = pfnFinalize (pCommon, pvContext, p);
    264256            }
    265257        }
     
    271263
    272264        /* Free the IO buffer. */
    273         HGSMIHeapFree (&commonFromDeviceExt(PrimaryExtension)->hgsmiAdapterHeap, p);
     265        HGSMIHeapFree (&pCommon->hgsmiAdapterHeap, p);
    274266    }
    275267
     
    277269}
    278270
    279 static int vboxCallVBVA (PDEVICE_EXTENSION PrimaryExtension,
     271static int vboxCallVBVA (PVBOXVIDEO_COMMON pCommon,
    280272                         uint16_t u16Op,
    281273                         HGSMISIZE cbData,
     
    284276                         void *pvContext)
    285277{
    286     return vboxCallChannel (PrimaryExtension,
     278    return vboxCallChannel (pCommon,
    287279                            HGSMI_CH_VBVA,
    288280                            u16Op,
     
    299291} QUERYCONFCTX;
    300292
    301 static int vbvaInitQueryConf (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData)
    302 {
    303     NOREF (PrimaryExtension);
    304 
     293static int vbvaInitQueryConf (PVBOXVIDEO_COMMON, void *pvContext, void *pvData)
     294{
    305295    QUERYCONFCTX *pCtx = (QUERYCONFCTX *)pvContext;
    306296    VBVACONF32 *p = (VBVACONF32 *)pvData;
     
    312302}
    313303
    314 static int vbvaFinalizeQueryConf (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData)
    315 {
    316     NOREF (PrimaryExtension);
    317 
     304static int vbvaFinalizeQueryConf (PVBOXVIDEO_COMMON, void *pvContext, void *pvData)
     305{
    318306    QUERYCONFCTX *pCtx = (QUERYCONFCTX *)pvContext;
    319307    VBVACONF32 *p = (VBVACONF32 *)pvData;
     
    337325    context.pulValue = pulValue;
    338326
    339     int rc = vboxCallVBVA (PrimaryExtension,
     327    int rc = vboxCallVBVA (commonFromDeviceExt(PrimaryExtension),
    340328                           VBVA_QUERY_CONF32,
    341329                           sizeof (VBVACONF32),
     
    348336    return rc;
    349337}
     338
     339int VBoxHGSMISendViewInfo(PVBOXVIDEO_COMMON pCommon, uint32_t u32Count, PFNHGSMIFILLVIEWINFO pfnFill, void *pvData)
     340{
     341    int rc;
     342    /* Issue the screen info command. */
     343    void *p = vboxHGSMIBufferAlloc (pCommon, sizeof(VBVAINFOVIEW) * u32Count,
     344                                    HGSMI_CH_VBVA, VBVA_INFO_VIEW);
     345    Assert(p);
     346    if (p)
     347    {
     348        VBVAINFOVIEW *pInfo = (VBVAINFOVIEW *)p;
     349        rc = pfnFill(pvData, pInfo);
     350        if (RT_SUCCESS(rc))
     351            vboxHGSMIBufferSubmit (pCommon, p);
     352        vboxHGSMIBufferFree (pCommon, p);
     353    }
     354    else
     355        rc = VERR_NO_MEMORY;
     356    return rc;
     357}
     358
    350359#ifndef VBOX_WITH_WDDM
    351 static int vbvaInitInfoDisplay (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData)
    352 {
    353     NOREF (pvContext);
    354     VBVAINFOVIEW *p = (VBVAINFOVIEW *)pvData;
     360static int vbvaInitInfoDisplay (void *pvData, VBVAINFOVIEW *p)
     361{
     362    PDEVICE_EXTENSION PrimaryExtension = (PDEVICE_EXTENSION) pvData;
    355363
    356364    int i;
     
    382390}
    383391#else
    384 int vbvaInitInfoCaps (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData)
     392int vbvaInitInfoCaps (PVBOXVIDEO_COMMON, void *pvContext, void *pvData)
    385393{
    386394    VBVACAPS *pCaps = (VBVACAPS*)pvData;
     
    391399
    392400
    393 int vbvaFinalizeInfoCaps (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData)
     401int vbvaFinalizeInfoCaps (PVBOXVIDEO_COMMON, void *pvContext, void *pvData)
    394402{
    395403    VBVACAPS *pCaps = (VBVACAPS*)pvData;
     
    399407#endif
    400408
    401 static int vbvaInitInfoHeap (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData)
     409static int vbvaInitInfoHeap (PVBOXVIDEO_COMMON pCommon, void *pvContext, void *pvData)
    402410{
    403411    NOREF (pvContext);
    404412    VBVAINFOHEAP *p = (VBVAINFOHEAP *)pvData;
    405413
    406     p->u32HeapOffset = commonFromDeviceExt(PrimaryExtension)->cbVRAM
    407                        - commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap
     414    p->u32HeapOffset = pCommon->cbVRAM
     415                       - pCommon->cbMiniportHeap
    408416                       - VBVA_ADAPTER_INFORMATION_SIZE;
    409     p->u32HeapSize = commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap;
     417    p->u32HeapSize = pCommon->cbMiniportHeap;
    410418
    411419    return VINF_SUCCESS;
    412420}
    413421
    414 static int hgsmiInitFlagsLocation (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData)
     422static int hgsmiInitFlagsLocation (PVBOXVIDEO_COMMON pCommon, void *pvContext, void *pvData)
    415423{
    416424    NOREF (pvContext);
    417425    HGSMIBUFFERLOCATION *p = (HGSMIBUFFERLOCATION *)pvData;
    418426
    419     p->offLocation = commonFromDeviceExt(PrimaryExtension)->cbVRAM - sizeof (HGSMIHOSTFLAGS);
     427    p->offLocation = pCommon->cbVRAM - sizeof (HGSMIHOSTFLAGS);
    420428    p->cbLocation = sizeof (HGSMIHOSTFLAGS);
    421429
     
    429437
    430438    /* setup the flags first to ensure they are initialized by the time the host heap is ready */
    431     int rc = vboxCallChannel(PrimaryExtension,
     439    int rc = vboxCallChannel(commonFromDeviceExt(PrimaryExtension),
    432440            HGSMI_CH_HGSMI,
    433441            HGSMI_CC_HOST_FLAGS_LOCATION,
     
    440448    {
    441449#ifndef VBOX_WITH_WDDM
    442         rc = vboxCallVBVA (PrimaryExtension,
    443                                VBVA_INFO_VIEW,
    444                                sizeof (VBVAINFOVIEW) * PrimaryExtension->u.primary.cDisplays,
     450        rc = VBoxHGSMISendViewInfo (commonFromDeviceExt(PrimaryExtension),
     451                               PrimaryExtension->u.primary.cDisplays,
    445452                               vbvaInitInfoDisplay,
    446                                NULL,
    447                                NULL);
     453                               (void *) PrimaryExtension);
    448454        AssertRC(rc);
    449455        if (RT_SUCCESS (rc))
     
    454460
    455461        /* Inform about caps */
    456         rc = vboxCallVBVA (PrimaryExtension,
     462        rc = vboxCallVBVA (commonFromDeviceExt(PrimaryExtension),
    457463                               VBVA_INFO_CAPS,
    458464                               sizeof (VBVACAPS),
     
    465471        {
    466472            /* Report the host heap location. */
    467             rc = vboxCallVBVA (PrimaryExtension,
     473            rc = vboxCallVBVA (commonFromDeviceExt(PrimaryExtension),
    468474                               VBVA_INFO_HEAP,
    469475                               sizeof (VBVAINFOHEAP),
     
    11281134} MOUSEPOINTERSHAPECTX;
    11291135
    1130 static int vbvaInitMousePointerShape (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData)
    1131 {
    1132     NOREF (PrimaryExtension);
    1133 
     1136static int vbvaInitMousePointerShape (PVBOXVIDEO_COMMON, void *pvContext, void *pvData)
     1137{
    11341138    MOUSEPOINTERSHAPECTX *pCtx = (MOUSEPOINTERSHAPECTX *)pvContext;
    11351139    VBVAMOUSEPOINTERSHAPE *p = (VBVAMOUSEPOINTERSHAPE *)pvData;
     
    11601164}
    11611165
    1162 static int vbvaFinalizeMousePointerShape (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData)
    1163 {
    1164     NOREF (PrimaryExtension);
    1165 
     1166static int vbvaFinalizeMousePointerShape (PVBOXVIDEO_COMMON, void *pvContext, void *pvData)
     1167{
    11661168    MOUSEPOINTERSHAPECTX *pCtx = (MOUSEPOINTERSHAPECTX *)pvContext;
    11671169    VBVAMOUSEPOINTERSHAPE *p = (VBVAMOUSEPOINTERSHAPE *)pvData;
     
    12321234    ctx.i32Result = VERR_NOT_SUPPORTED;
    12331235
    1234     int rc = vboxCallVBVA (PrimaryExtension,
     1236    int rc = vboxCallVBVA (commonFromDeviceExt(PrimaryExtension),
    12351237                           VBVA_MOUSE_POINTER_SHAPE,
    12361238                           sizeof (VBVAMOUSEPOINTERSHAPE) + cbData,
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