VirtualBox

Changeset 17583 in vbox for trunk


Ignore:
Timestamp:
Mar 9, 2009 3:17:42 PM (16 years ago)
Author:
vboxsync
Message:

Shared memory host guest interface (HGSMI) for the graphics device: the windows guest video driver prototype code.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Makefile.kmk

    r12446 r17583  
    5454        $(VBOX_LIB_IPRT_GUEST_R0_NT4)
    5555
     56ifdef VBOX_WITH_HGSMI
     57VBoxVideo_SOURCES     += \
     58        VBoxVideoHGSMI.cpp
     59VBoxVideo_LIBS         += \
     60        $(VBOX_PATH_ADDITIONS_LIB)/HGSMIGuestR0Lib$(VBOX_SUFF_LIB)
     61endif
     62
    5663include $(KBUILD_PATH)/subfooter.kmk
    5764
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp

    r13837 r17583  
    730730
    731731/* Computes the size of a framebuffer. DualView has a few framebuffers of the computed size. */
    732 static void vboxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension)
     732void VBoxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension)
    733733{
    734734    ULONG ulAvailable = PrimaryExtension->u.primary.cbVRAM
     
    743743    ulSize &= ~0xFFF;
    744744
    745     dprintf(("VBoxVideo::vboxComputeFrameBufferSizes: cbVRAM = 0x%08X, cDisplays = %d, ulSize = 0x%08X, ulSize * cDisplays = 0x%08X, slack = 0x%08X\n",
     745    dprintf(("VBoxVideo::VBoxComputeFrameBufferSizes: cbVRAM = 0x%08X, cDisplays = %d, ulSize = 0x%08X, ulSize * cDisplays = 0x%08X, slack = 0x%08X\n",
    746746             PrimaryExtension->u.primary.cbVRAM, PrimaryExtension->u.primary.cDisplays,
    747747             ulSize, ulSize * PrimaryExtension->u.primary.cDisplays,
     
    772772        Extension->ulFrameBufferSize = 0;
    773773
    774         dprintf(("VBoxVideo::vboxComputeFrameBufferSizes: [%d] ulFrameBufferOffset 0x%08X\n",
     774        dprintf(("VBoxVideo::VBoxComputeFrameBufferSizes: [%d] ulFrameBufferOffset 0x%08X\n",
    775775                 Extension->iDevice, ulFrameBufferOffset));
    776776
     
    782782}
    783783
    784 static int vboxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension, void **ppv, ULONG ulOffset, ULONG ulSize)
    785 {
    786     dprintf(("VBoxVideo::vboxMapAdapterMemory 0x%08X[0x%X]\n", ulOffset, ulSize));
     784int VBoxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension, void **ppv, ULONG ulOffset, ULONG ulSize)
     785{
     786    dprintf(("VBoxVideo::VBoxMapAdapterMemory 0x%08X[0x%X]\n", ulOffset, ulSize));
    787787
    788788    if (!ulSize)
     
    808808    }
    809809
    810     dprintf(("VBoxVideo::vboxMapAdapterMemory rc = %d\n", Status));
     810    dprintf(("VBoxVideo::VBoxMapAdapterMemory rc = %d\n", Status));
    811811
    812812    return Status;
    813813}
    814814
    815 static void vboxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension, void **ppv)
    816 {
    817     dprintf(("VBoxVideo::vboxMapAdapterMemory\n"));
     815void VBoxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension, void **ppv)
     816{
     817    dprintf(("VBoxVideo::VBoxMapAdapterMemory\n"));
    818818
    819819    if (*ppv)
     
    963963    {
    964964        /* Map the adapter information. It will be needed to query some configuration values. */
    965         rc = vboxMapAdapterMemory (PrimaryExtension,
     965        rc = VBoxMapAdapterMemory (PrimaryExtension,
    966966                                   &PrimaryExtension->u.primary.pvAdapterInformation,
    967967                                   PrimaryExtension->u.primary.cbVRAM - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE,
     
    970970        if (rc != NO_ERROR)
    971971        {
    972             dprintf(("VBoxVideo::VBoxSetupDisplays: vboxMapAdapterMemory pvAdapterInfoirrmation failed rc = %d\n",
     972            dprintf(("VBoxVideo::VBoxSetupDisplays: VBoxMapAdapterMemory pvAdapterInfoirrmation failed rc = %d\n",
    973973                     rc));
    974974
     
    10061006         *
    10071007         */
    1008         rc = vboxMapAdapterMemory (PrimaryExtension,
     1008        rc = VBoxMapAdapterMemory (PrimaryExtension,
    10091009                                   &PrimaryExtension->u.primary.pvMiniportHeap,
    10101010                                   PrimaryExtension->u.primary.cbVRAM
     
    10901090     * calculate the layout of framebuffers.
    10911091     */
    1092     vboxComputeFrameBufferSizes (PrimaryExtension);
     1092    VBoxComputeFrameBufferSizes (PrimaryExtension);
    10931093
    10941094    if (PrimaryExtension->u.primary.bVBoxVideoSupported)
     
    11001100    {
    11011101        /* Unmap the memory if VBoxVideo is not supported. */
    1102         vboxUnmapAdapterMemory (PrimaryExtension, &PrimaryExtension->u.primary.pvMiniportHeap);
    1103         vboxUnmapAdapterMemory (PrimaryExtension, &PrimaryExtension->u.primary.pvAdapterInformation);
     1102        VBoxUnmapAdapterMemory (PrimaryExtension, &PrimaryExtension->u.primary.pvMiniportHeap);
     1103        VBoxUnmapAdapterMemory (PrimaryExtension, &PrimaryExtension->u.primary.pvAdapterInformation);
    11041104    }
    11051105
     
    11821182      rc = NO_ERROR;
    11831183
     1184#ifndef VBOX_WITH_HGSMI
    11841185      /* Initialize VBoxGuest library */
    11851186      rc = VbglInit ();
     
    11891190      /* Setup the Device Extension and if possible secondary displays. */
    11901191      VBoxSetupDisplays((PDEVICE_EXTENSION)HwDeviceExtension, ConfigInfo, AdapterMemorySize);
     1192#else
     1193      if (VBoxHGSMIIsSupported ())
     1194      {
     1195          LogRel(("VBoxVideo: using HGSMI\n"));
     1196
     1197          VBoxSetupDisplaysHGSMI((PDEVICE_EXTENSION)HwDeviceExtension, ConfigInfo, AdapterMemorySize);
     1198      }
     1199      else
     1200      {
     1201          /* Initialize VBoxGuest library */
     1202          rc = VbglInit ();
     1203
     1204          dprintf(("VBoxVideo::VBoxVideoFindAdapter: VbglInit returned 0x%x\n", rc));
     1205
     1206          /* Setup the Device Extension and if possible secondary displays. */
     1207          VBoxSetupDisplays((PDEVICE_EXTENSION)HwDeviceExtension, ConfigInfo, AdapterMemorySize);
     1208      }
     1209#endif /* VBOX_WITH_HGSMI */
    11911210
    11921211      // pretend success to make the driver work.
     
    17851804        }
    17861805
     1806#ifdef VBOX_WITH_HGSMI
     1807        case IOCTL_VIDEO_QUERY_HGSMI_INFO:
     1808        {
     1809            dprintf(("VBoxVideo::VBoxVideoStartIO: IOCTL_VIDEO_QUERY_HGSMI_INFO\n"));
     1810
     1811            if (RequestPacket->OutputBufferLength < sizeof(QUERYHGSMIRESULT))
     1812            {
     1813                dprintf(("VBoxVideo::VBoxVideoStartIO: Output buffer too small: %d needed: %d!!!\n",
     1814                         RequestPacket->OutputBufferLength, sizeof(QUERYHGSMIRESULT)));
     1815                RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
     1816                return FALSE;
     1817            }
     1818
     1819            if (!pDevExt->pPrimary->u.primary.bHGSMI)
     1820            {
     1821                RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
     1822                return FALSE;
     1823            }
     1824
     1825            QUERYHGSMIRESULT *pInfo = (QUERYHGSMIRESULT *)RequestPacket->OutputBuffer;
     1826
     1827            pInfo->iDevice = pDevExt->iDevice;
     1828            pInfo->ulFlags = 0;
     1829
     1830            /* Describes VRAM chunk for this display device. */
     1831            pInfo->areaDisplay = pDevExt->areaDisplay;
     1832
     1833            RequestPacket->StatusBlock->Information = sizeof(QUERYHGSMIRESULT);
     1834            Result = TRUE;
     1835
     1836            break;
     1837        }
     1838#endif /* VBOX_WITH_HGSMI */
     1839
    17871840        default:
    17881841            dprintf(("VBoxVideo::VBoxVideoStartIO: Unsupported %p, fn %d(0x%x)\n",
     
    18331886    VbglTerminate ();
    18341887
    1835     vboxUnmapAdapterMemory (pDevExt, &pDevExt->u.primary.pvMiniportHeap);
    1836     vboxUnmapAdapterMemory (pDevExt, &pDevExt->u.primary.pvAdapterInformation);
     1888    VBoxUnmapAdapterMemory (pDevExt, &pDevExt->u.primary.pvMiniportHeap);
     1889    VBoxUnmapAdapterMemory (pDevExt, &pDevExt->u.primary.pvAdapterInformation);
    18371890
    18381891    return TRUE;
     
    20182071        /* Save the new framebuffer size */
    20192072        DeviceExtension->ulFrameBufferSize = MapInformation->FrameBufferLength;
     2073#ifdef VBOX_WITH_HGSMI
     2074        HGSMIAreaInitialize (&DeviceExtension->areaDisplay,
     2075                             MapInformation->FrameBufferBase,
     2076                             MapInformation->FrameBufferLength,
     2077                             DeviceExtension->ulFrameBufferOffset);
     2078#endif /* VBOX_WITH_HGSMI */
    20202079        return TRUE;
    20212080    }
     
    20342093{
    20352094    dprintf(("VBoxVideo::VBoxVideoUnmapVideoMemory\n"));
     2095#ifdef VBOX_WITH_HGSMI
     2096    HGSMIAreaClear (&DeviceExtension->areaDisplay);
     2097#endif /* VBOX_WITH_HGSMI */
    20362098    VideoPortUnmapMemory(DeviceExtension, VideoMemory->RequestedVirtualAddress, NULL);
    20372099    return TRUE;
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h

    r8433 r17583  
    2424#include <iprt/assert.h>
    2525
     26#ifdef VBOX_WITH_HGSMI
     27#include <VBox/HGSMI/HGSMI.h>
     28#endif /* VBOX_WITH_HGSMI */
     29
    2630__BEGIN_DECLS
    2731#include "dderror.h"
     
    4347#define VBE_DISPI_INDEX_VIRT_HEIGHT     0x7
    4448#define VBE_DISPI_INDEX_VBOX_VIDEO      0xa
     49#ifdef VBOX_WITH_HGSMI
     50#define VBE_DISPI_INDEX_VBVA_HOST       0xb
     51#define VBE_DISPI_INDEX_VBVA_GUEST      0xc
     52#endif /* VBOX_WITH_HGSMI */
     53
    4554#define VBE_DISPI_ID2                   0xB0C2
    4655/* The VBOX interface id. Indicates support for VBE_DISPI_INDEX_VBOX_VIDEO. */
    4756#define VBE_DISPI_ID_VBOX_VIDEO         0xBE00
     57#ifdef VBOX_WITH_HGSMI
     58#define VBE_DISPI_ID_HGSMI              0xBE01
     59#endif /* VBOX_WITH_HGSMI */
    4860#define VBE_DISPI_DISABLED              0x00
    4961#define VBE_DISPI_ENABLED               0x01
     
    109121                                                */
    110122           
     123#ifdef VBOX_WITH_HGSMI
     124           BOOLEAN bHGSMI;                     /* Whether HGSMI is enabled. */
     125
     126           HGSMIAREA areaHostHeap;             /* Host heap VRAM area. */
     127
     128           HGSMIHEAP hgsmiAdapterHeap;
     129#endif /* VBOX_WITH_HGSMI */
    111130       } primary;
    112131   
     
    116135       } secondary;
    117136   } u;
     137
     138#ifdef VBOX_WITH_HGSMI
     139   HGSMIAREA areaDisplay;                      /* Entire VRAM chunk for this display device. */
     140#endif /* VBOX_WITH_HGSMI */
    118141} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
    119142
     
    201224   PULONG pUnused);
    202225
     226int VBoxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
     227                          void **ppv,
     228                          ULONG ulOffset,
     229                          ULONG ulSize);
     230
     231void VBoxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
     232                             void **ppv);
     233                             
     234void VBoxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension);
     235
     236#ifdef VBOX_WITH_HGSMI
     237BOOLEAN VBoxHGSMIIsSupported (void);
     238
     239VOID VBoxSetupDisplaysHGSMI (PDEVICE_EXTENSION PrimaryExtension,
     240                             PVIDEO_PORT_CONFIG_INFO pConfigInfo,
     241                             ULONG AdapterMemorySize);
     242#endif /* VBOX_WITH_HGSMI */
    203243} /* extern "C" */
    204244
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/vboxioctl.h

    r8155 r17583  
    2525#include <VBox/VBoxGuest.h>
    2626
     27#ifdef VBOX_WITH_HGSMI
     28#include <VBox/HGSMI/HGSMI.h>
     29#endif /* VBOX_WITH_HGSMI */
     30
    2731#define IOCTL_VIDEO_INTERPRET_DISPLAY_MEMORY \
    2832    CTL_CODE(FILE_DEVICE_VIDEO, 0x420, METHOD_BUFFERED, FILE_ANY_ACCESS)
     
    4044#define IOCTL_VIDEO_VBVA_ENABLE \
    4145    CTL_CODE(FILE_DEVICE_VIDEO, 0x400, METHOD_BUFFERED, FILE_ANY_ACCESS)
     46
     47#ifdef VBOX_WITH_HGSMI
     48#define IOCTL_VIDEO_QUERY_HGSMI_INFO \
     49    CTL_CODE(FILE_DEVICE_VIDEO, 0x430, METHOD_BUFFERED, FILE_ANY_ACCESS)
     50#endif /* VBOX_WITH_HGSMI */
    4251
    4352#pragma pack(1)
     
    7786    uint32_t u32DisplayInfoSize;
    7887} QUERYDISPLAYINFORESULT;
     88
     89#ifdef VBOX_WITH_HGSMI
     90/**
     91 * Data returned by IOCTL_VIDEO_QUERY_HGSMI_INFO.
     92 *
     93 */
     94typedef struct _QUERYHGSMIRESULT
     95{
     96    /* Device index (0 for primary) */
     97    ULONG iDevice;
     98
     99    /* Flags. Currently none are defined and the field must be initialized to 0. */
     100    ULONG ulFlags;
     101
     102    /* Describes VRAM chunk for this display device. */
     103    HGSMIAREA areaDisplay;
     104
     105} QUERYHGSMIRESULT;
     106#endif /* VBOX_WITH_HGSMI */
    79107#pragma pack()
    80108
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