VirtualBox

Changeset 4053 in vbox


Ignore:
Timestamp:
Aug 7, 2007 8:40:02 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
23489
Message:

Use the generic VBoxVideo interface in Windows guest video driver.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxVideo.h

    r4027 r4053  
    9292#define VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE 0x00010000
    9393
    94 /* The value for port IO to read the number of monitors.
    95  */
    96 #define VBOX_VIDEO_QUERY_MONITOR_COUNT           0x00020000
    97 
    98 /* The value for port IO to read the offscreen heap size value.
    99  */
    100 #define VBOX_VIDEO_QUERY_OFFSCREEN_HEAP_SIZE     0x00020001
    10194
    10295/* The end of the information. */
     
    112105/* Information about non-volatile guest VRAM heap. */
    113106#define VBOX_VIDEO_INFO_TYPE_NV_HEAP      5
     107/* VBVA enable/disable. */
     108#define VBOX_VIDEO_INFO_TYPE_VBVA_STATUS  6
     109/* VBVA flush. */
     110#define VBOX_VIDEO_INFO_TYPE_VBVA_FLUSH   7
     111/* Query configuration value. */
     112#define VBOX_VIDEO_INFO_TYPE_QUERY_CONF32 8
    114113
    115114
     
    201200
    202201} VBOXVIDEOINFONVHEAP;
     202
     203/* Display information area. */
     204typedef struct _VBOXVIDEOINFOVBVASTATUS
     205{
     206    /* Absolute offset in VRAM of the start of the VBVA QUEUE. 0 to disable VBVA. */
     207    uint32_t u32QueueOffset;
     208
     209    /* The size of the VBVA QUEUE. 0 to disable VBVA. */
     210    uint32_t u32QueueSize;
     211
     212} VBOXVIDEOINFOVBVASTATUS;
     213
     214typedef struct _VBOXVIDEOINFOVBVAFLUSH
     215{
     216    uint32_t u32DataStart;
     217
     218    uint32_t u32DataEnd;
     219
     220} VBOXVIDEOINFOVBVAFLUSH;
     221
     222#define VBOX_VIDEO_QCI32_MONITOR_COUNT       0
     223#define VBOX_VIDEO_QCI32_OFFSCREEN_HEAP_SIZE 1
     224
     225typedef struct _VBOXVIDEOINFOQUERYCONF32
     226{
     227    uint32_t u32Index;
     228
     229    uint32_t u32Value;
     230
     231} VBOXVIDEOINFOQUERYCONF32;
    203232#pragma pack()
    204233
  • 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;
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h

    r4027 r4053  
    9494                                                */
    9595           PVOID pvMiniportHeap;               /* The pointer to the miniport heap VRAM.
    96                                                 * This is mapped by miniport as one block together with adapter info.
    97                                                 */
    98 
    99            PVOID pvAdapterInformation;         /* The pointer to the last 4K of VRAM. Calculated as
    100                                                 *   (uint8_t *)pvMiniportHeap + cbMiniportHeap
     96                                                * This is mapped by miniport separately.
     97                                                */
     98
     99           PVOID pvAdapterInformation;         /* The pointer to the last 4K of VRAM.
     100                                                * This is mapped by miniport separately.
    101101                                                */
    102102           
  • trunk/src/VBox/Devices/Graphics/DevVGA.cpp

    r4027 r4053  
    5656/** The minimum amount of VRAM. */
    5757#define VGA_VRAM_MIN        (_1M)
    58 /** The maximum number of monitors. */
    59 #define VGA_MONITORS_MAX    64
    6058
    6159/** The size of the VGA GC mapping.
     
    583581          }
    584582      } else if (s->vbe_index == VBE_DISPI_INDEX_VBOX_VIDEO) {
    585             switch (s->vbox_video_command)
    586             {
    587                 case VBOX_VIDEO_QUERY_MONITOR_COUNT:
    588                     val = s->monitor_count;
    589                     break;
    590                 case VBOX_VIDEO_QUERY_OFFSCREEN_HEAP_SIZE:
    591                     val = _1M; /* @todo make configurable */
    592                     break;
    593             }
    594             Log(("VBE: s->vbox_video_command = 0x%x, s->monitor_count = %d read index=0x%x val=0x%x\n", s->monitor_count, s->vbe_index, val));
     583        /* Reading from the port yields nothing. */
     584        val = 0;
    595585      } else {
    596586        val = s->vbe_regs[s->vbe_index];
     
    859849                s->pDrv->pfnProcessDisplayData(s->pDrv, s->CTXSUFF(vram_ptr), val & 0xFFFF);
    860850            }
    861             s->vbox_video_command = val;
    862851#endif /* IN_RING3 */
    863852#endif /* VBOX */
     
    28982887    if (cb == 2)
    28992888    {
    2900         /* Reading 16 bit value always reads the count of monitor.
    2901          * That is for compatibility with old additions.
    2902          */
    2903         VGAState *s = PDMINS2DATA(pDevIns, PVGASTATE);
    2904         if (s->vbe_index == VBE_DISPI_INDEX_VBOX_VIDEO)
    2905         {
    2906             s->vbox_video_command = VBOX_VIDEO_QUERY_MONITOR_COUNT;
    2907         }
    29082889        *pu32 = vbe_ioport_read_data(PDMINS2DATA(pDevIns, PVGASTATE), Port);
    29092890        return VINF_SUCCESS;
     
    29122893    {
    29132894        VGAState *s = PDMINS2DATA(pDevIns, PVGASTATE);
    2914         if (s->vbe_index == VBE_DISPI_INDEX_VBOX_VIDEO)
    2915         {
    2916             *pu32 = vbe_ioport_read_data(PDMINS2DATA(pDevIns, PVGASTATE), Port);
    2917         }
    2918         else
    2919         {
    2920            /* Quick hack for getting the vram size. */
    2921            *pu32 = s->vram_size;
    2922         }
     2895        /* Quick hack for getting the vram size. */
     2896        *pu32 = s->vram_size;
    29232897        return VINF_SUCCESS;
    29242898    }
     
    43454319#ifdef CONFIG_BOCHS_VBE
    43464320    pData->vbe_regs[VBE_DISPI_INDEX_ID] = VBE_DISPI_ID0;
    4347     pData->vbe_regs[VBE_DISPI_INDEX_VBOX_VIDEO] = pData->monitor_count;
     4321    pData->vbe_regs[VBE_DISPI_INDEX_VBOX_VIDEO] = 0;
    43484322    pData->vbe_bank_mask    = ((pData->vram_size >> 16) - 1);
    43494323#endif /* CONFIG_BOCHS_VBE */
     
    45314505     */
    45324506    if (!CFGMR3AreValuesValid(pCfgHandle, "VRamSize\0"
    4533                                           "MonitorCount\0"
    45344507                                          "GCEnabled\0"
    45354508                                          "R0Enabled\0"
     
    45724545    }
    45734546    Log(("VGA: VRamSize=%#x\n", pData->vram_size));
    4574 
    4575     rc = CFGMR3QueryU32(pCfgHandle, "MonitorCount", &pData->monitor_count);
    4576     if (VBOX_FAILURE(rc) || !pData->monitor_count)
    4577         pData->monitor_count = 1;
    4578     else if (pData->monitor_count > VGA_MONITORS_MAX)
    4579     {
    4580         AssertMsgFailed(("monitor_count=%d max=%d\n", pData->monitor_count, VGA_MONITORS_MAX));
    4581         pData->monitor_count = 1;
    4582     }
    4583     pData->vbe_regs[VBE_DISPI_INDEX_VBOX_VIDEO] = pData->monitor_count;
    4584     Log(("VGA: MonitorCount=%d\n", pData->monitor_count));
    45854547
    45864548    pData->fGCEnabled = true;
  • trunk/src/VBox/Devices/Graphics/DevVGA.h

    r4027 r4053  
    282282    uint32_t                    cMilliesRefreshInterval;
    283283
    284     /** Number of virtual monitors */
    285     uint32_t                    monitor_count;
    286     /** The VBoxVideo extension command issued by guest. */
    287     uint32_t                    vbox_video_command;
    288 
    289284    /** Whether to render the guest VRAM to the framebuffer memory. False only for some LFB modes. */
    290285    uint32_t                    fRenderVRAM;
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r4041 r4053  
    48354835    BSTR            str = NULL;
    48364836    ULONG           cRamMBs;
    4837     ULONG           cMonitors;
    48384837    unsigned        i;
    48394838
     
    52355234    hrc = pMachine->COMGETTER(VRAMSize)(&cRamMBs);                                  H();
    52365235    rc = CFGMR3InsertInteger(pCfg,  "VRamSize",             cRamMBs * _1M);         RC_CHECK();
    5237     hrc = pMachine->COMGETTER(MonitorCount)(&cMonitors);                            H();
    5238     rc = CFGMR3InsertInteger(pCfg,  "MonitorCount",         cMonitors);             RC_CHECK();
    52395236
    52405237    /* Custom VESA mode list */
  • trunk/src/VBox/Main/DisplayImpl.cpp

    r4027 r4053  
    21972197
    21982198                 LogFlow(("VBOX_VIDEO_INFO_TYPE_DISPLAY: %d: at 0x%08X, size 0x%08X, info 0x%08X\n", pDisplay->u32Index, pDisplay->u32Offset, pDisplay->u32FramebufferSize, pDisplay->u32InformationSize));
     2199             }
     2200             else if (pHdr->u8Type == VBOX_VIDEO_INFO_TYPE_QUERY_CONF32)
     2201             {
     2202                 if (pHdr->u16Length != sizeof (VBOXVIDEOINFOQUERYCONF32))
     2203                 {
     2204                     LogRel(("VBoxVideo: Guest adapter information %s invalid length %d!!!\n", "CONF32", pHdr->u16Length));
     2205                     break;
     2206                 }
     2207
     2208                 VBOXVIDEOINFOQUERYCONF32 *pConf32 = (VBOXVIDEOINFOQUERYCONF32 *)pu8;
     2209
     2210                 switch (pConf32->u32Index)
     2211                 {
     2212                     case VBOX_VIDEO_QCI32_MONITOR_COUNT:
     2213                     {
     2214                         pConf32->u32Value = pDrv->pDisplay->mcMonitors;
     2215                     } break;
     2216                     
     2217                     case VBOX_VIDEO_QCI32_OFFSCREEN_HEAP_SIZE:
     2218                     {
     2219                         /* @todo make configurable. */
     2220                         pConf32->u32Value = _1M;
     2221                     } break;
     2222                     
     2223                     default:
     2224                         LogRel(("VBoxVideo: CONF32 %d not supported!!! Skipping.\n", pConf32->u32Index));
     2225                 }
    21992226             }
    22002227             else if (pHdr->u8Type == VBOX_VIDEO_INFO_TYPE_END)
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