VirtualBox

Changeset 22444 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Aug 25, 2009 5:03:25 PM (15 years ago)
Author:
vboxsync
Message:

HGSMI/VBVA use PCI IO ports.

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

Legend:

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

    r22414 r22444  
    12061206         VBoxBiosString,
    12071207         sizeof(VBoxBiosString));
    1208 #if defined(VBOX_WITH_HGSMI) && defined(VBOX_WITH_VIDEOHWACCEL)
    1209       VIDEO_ACCESS_RANGE tmpRanges[1];
    1210       ULONG slot;
    1211 
    1212       /* need to call VideoPortGetAccessRanges to ensure interrupt info in ConfigInfo gets set up */
    1213       VP_STATUS status = VideoPortGetAccessRanges(HwDeviceExtension,
    1214                                         0,
    1215                                         NULL,
    1216                                         1,
    1217                                         tmpRanges,
    1218                                         NULL,
    1219                                         NULL,
    1220                                         (PULONG) &slot);
    1221       Assert(status == NO_ERROR );
    1222 //      Assert(AccessRanges[0].RangeStart.QuadPart == tmpRanges[0].RangeStart.QuadPart);
    1223 //      Assert(AccessRanges[0].RangeLength == tmpRanges[0].RangeLength);
    1224 //      Assert(AccessRanges[0].RangeInIoSpace == tmpRanges[0].RangeInIoSpace);
    1225 //      Assert(AccessRanges[0].RangeVisible == tmpRanges[0].RangeVisible);
    1226 //      Assert(AccessRanges[0].RangeShareable == tmpRanges[0].RangeShareable);
    1227 //      Assert(AccessRanges[0].RangePassive == tmpRanges[0].RangePassive);
    1228 
    1229       /* no matter what we get with VideoPortGetAccessRanges, we assert the default ranges */
    1230 #endif
     1208#ifdef VBOX_WITH_HGSMI
     1209      if (VBoxHGSMIIsSupported ((PDEVICE_EXTENSION)HwDeviceExtension))
     1210      {
     1211          dprintf(("VBoxVideo::VBoxVideoFindAdapter: calling VideoPortGetAccessRanges\n"));
     1212
     1213          /* Ports not yet found. */
     1214          ((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.IOPortHost = 0;
     1215          ((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.IOPortGuest = 0;
     1216
     1217          VIDEO_ACCESS_RANGE tmpRanges[2];
     1218          ULONG slot;
     1219
     1220          /* need to call VideoPortGetAccessRanges to ensure interrupt info in ConfigInfo gets set up */
     1221          VP_STATUS status = VideoPortGetAccessRanges(HwDeviceExtension,
     1222                                            0,
     1223                                            NULL,
     1224                                            sizeof (tmpRanges)/sizeof (tmpRanges[0]),
     1225                                            tmpRanges,
     1226                                            NULL,
     1227                                            NULL,
     1228                                            (PULONG) &slot);
     1229          if (status == NO_ERROR)
     1230          {
     1231              ULONG iRange = 0;
     1232              for (; iRange < sizeof (tmpRanges)/sizeof (tmpRanges[0]); iRange++)
     1233              {
     1234                  dprintf(("VBoxVideo::VBoxVideoFindAdapter: range[%i]:\n"
     1235                           "    RangeStart = 0x%llx\n"
     1236                           "    RangeLength = %d\n"
     1237                           "    RangeInIoSpace = %d\n"
     1238                           "    RangeVisible = %d\n"
     1239                           "    RangeShareable = %d\n"
     1240                           "    RangePassive = %d\n",
     1241                           iRange,
     1242                           tmpRanges[iRange].RangeStart.QuadPart,
     1243                           tmpRanges[iRange].RangeLength,
     1244                           tmpRanges[iRange].RangeInIoSpace,
     1245                           tmpRanges[iRange].RangeVisible,
     1246                           tmpRanges[iRange].RangeShareable,
     1247                           tmpRanges[iRange].RangePassive));
     1248                   if (tmpRanges[iRange].RangeInIoSpace)
     1249                   {
     1250                       PVOID ioBase = VideoPortGetDeviceBase(HwDeviceExtension, tmpRanges[iRange].RangeStart, 8, VIDEO_MEMORY_SPACE_IO);
     1251                       dprintf (("ioBase %p\n", ioBase));
     1252
     1253                       ((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.IOPortHost = (RTIOPORT)ioBase + VGA_PORT_OFF_HGSMI_HOST;
     1254                       ((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.IOPortGuest = (RTIOPORT)ioBase + VGA_PORT_OFF_HGSMI_GUEST;
     1255                   }
     1256              }
     1257          }
     1258
     1259          /* no matter what we get with VideoPortGetAccessRanges, we assert the default ranges */
     1260      }
     1261#endif /* VBOX_WITH_HGSMI */
    12311262      rc = VideoPortVerifyAccessRanges(HwDeviceExtension, 1, AccessRanges);
    12321263      dprintf(("VBoxVideo::VBoxVideoFindAdapter: VideoPortVerifyAccessRanges returned 0x%x\n", rc));
     
    17771808                VideoPortWritePortUlong((PULONG)VBE_DISPI_IOPORT_DATA, VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE + pDevExt->iDevice);
    17781809#else
    1779                 VBoxVideoHostWriteUlong(((PDEVICE_EXTENSION)HwDeviceExtension)->pPrimary, VBE_DISPI_INDEX_VBOX_VIDEO, VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE + pDevExt->iDevice);
     1810                VBoxVideoVBEWriteUlong(((PDEVICE_EXTENSION)HwDeviceExtension)->pPrimary, VBE_DISPI_INDEX_VBOX_VIDEO, VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE + pDevExt->iDevice);
    17801811#endif
    17811812            }
     
    20442075    VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_DISABLED);
    20452076#else
    2046     VBoxVideoHostWriteUshort(((PDEVICE_EXTENSION)HwDeviceExtension)->pPrimary, VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED);
     2077    VBoxVideoVBEWriteUshort(((PDEVICE_EXTENSION)HwDeviceExtension)->pPrimary, VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED);
    20472078#endif
    20482079
     
    21592190    /** @todo read from the port to see if the mode switch was successful */
    21602191#else
    2161     VBoxVideoHostWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_XRES, (USHORT)ModeInfo->VisScreenWidth);
    2162     VBoxVideoHostWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_YRES, (USHORT)ModeInfo->VisScreenHeight);
    2163     VBoxVideoHostWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_BPP, (USHORT)ModeInfo->BitsPerPlane);
    2164     VBoxVideoHostWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);
     2192    VBoxVideoVBEWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_XRES, (USHORT)ModeInfo->VisScreenWidth);
     2193    VBoxVideoVBEWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_YRES, (USHORT)ModeInfo->VisScreenHeight);
     2194    VBoxVideoVBEWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_BPP, (USHORT)ModeInfo->BitsPerPlane);
     2195    VBoxVideoVBEWriteUshort(DeviceExtension->pPrimary, VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);
    21652196#endif
    21662197
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h

    r22136 r22444  
    5151#define VBE_DISPI_INDEX_VIRT_HEIGHT     0x7
    5252#define VBE_DISPI_INDEX_VBOX_VIDEO      0xa
    53 #ifdef VBOX_WITH_HGSMI
    54 #define VBE_DISPI_INDEX_VBVA_HOST       0xb
    55 #define VBE_DISPI_INDEX_VBVA_GUEST      0xc
    56 #endif /* VBOX_WITH_HGSMI */
    5753
    5854#define VBE_DISPI_ID2                   0xB0C2
     
    7066#define VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES      (VBE_DISPI_TOTAL_VIDEO_MEMORY_KB * 1024)
    7167
     68#ifdef VBOX_WITH_HGSMI
     69#define VGA_PORT_OFF_HGSMI_HOST  0
     70#define VGA_PORT_OFF_HGSMI_GUEST 4
     71#endif /* VBOX_WITH_HGSMI */
     72
    7273typedef struct _DEVICE_EXTENSION
    7374{
     
    142143
    143144           PSPIN_LOCK pGHRWLock; /* lock for making guest->host read/writes atomic */
     145
     146           /* The IO Port Number for host commands. */
     147           RTIOPORT IOPortHost;
     148
     149           /* The IO Port Number for guest commands. */
     150           RTIOPORT IOPortGuest;
    144151#endif /* VBOX_WITH_HGSMI */
    145152       } primary;
     
    256263#ifdef VBOX_WITH_HGSMI
    257264
    258 DECLINLINE(void) VBoxVideoHostWriteUlongLocked(USHORT dataType, ULONG data)
     265DECLINLINE(void) VBoxVideoVBEWriteUlongLocked(USHORT dataType, ULONG data)
    259266{
    260267    VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, dataType);
     
    262269}
    263270
    264 DECLINLINE(void) VBoxVideoHostWriteUshortLocked(USHORT dataType, USHORT data)
     271DECLINLINE(void) VBoxVideoVBEWriteUshortLocked(USHORT dataType, USHORT data)
    265272{
    266273    VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, dataType);
     
    268275}
    269276
    270 DECLINLINE(ULONG) VBoxVideoHostReadUlongLocked (USHORT dataType)
     277DECLINLINE(ULONG) VBoxVideoVBEReadUlongLocked (USHORT dataType)
    271278{
    272279    VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, dataType);
     
    274281}
    275282
    276 DECLINLINE(void) VBoxVideoHostWriteUlong(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType, ULONG data)
     283DECLINLINE(void) VBoxVideoVBEWriteUlong(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType, ULONG data)
    277284{
    278285    UCHAR oldIrql;
     
    280287                PrimaryExtension->u.primary.pGHRWLock,
    281288            &oldIrql);
    282     VBoxVideoHostWriteUlongLocked(dataType, data);
     289    VBoxVideoVBEWriteUlongLocked(dataType, data);
    283290    VideoPortReleaseSpinLock(PrimaryExtension,
    284291                PrimaryExtension->u.primary.pGHRWLock,
     
    286293}
    287294
    288 DECLINLINE(void) VBoxVideoHostWriteUshort(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType, USHORT data)
     295DECLINLINE(void) VBoxVideoVBEWriteUshort(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType, USHORT data)
    289296{
    290297    UCHAR oldIrql;
     
    292299                PrimaryExtension->u.primary.pGHRWLock,
    293300            &oldIrql);
    294     VBoxVideoHostWriteUshortLocked(dataType, data);
     301    VBoxVideoVBEWriteUshortLocked(dataType, data);
    295302    VideoPortReleaseSpinLock(PrimaryExtension,
    296303                PrimaryExtension->u.primary.pGHRWLock,
     
    298305}
    299306
    300 DECLINLINE(ULONG) VBoxVideoHostReadUlong(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType)
    301 {
    302         ULONG data;
     307DECLINLINE(ULONG) VBoxVideoVBEReadUlong(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType)
     308{
     309    ULONG data;
    303310    UCHAR oldIrql;
    304311    VideoPortAcquireSpinLock(PrimaryExtension,
    305312                PrimaryExtension->u.primary.pGHRWLock,
    306313            &oldIrql);
    307         data = VBoxVideoHostReadUlongLocked(dataType);
     314    data = VBoxVideoVBEReadUlongLocked(dataType);
    308315    VideoPortReleaseSpinLock(PrimaryExtension,
    309316                PrimaryExtension->u.primary.pGHRWLock,
    310317            oldIrql);
    311318    return data;
     319}
     320
     321/*
     322 * Host and Guest port IO helpers.
     323 */
     324DECLINLINE(void) VBoxHGSMIHostWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
     325{
     326    VideoPortWritePortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost, data);
     327}
     328
     329DECLINLINE(ULONG) VBoxHGSMIHostRead(PDEVICE_EXTENSION PrimaryExtension)
     330{
     331    return VideoPortReadPortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost);
     332}
     333
     334DECLINLINE(void) VBoxHGSMIGuestWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
     335{
     336    VideoPortWritePortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest, data);
     337}
     338
     339DECLINLINE(ULONG) VBoxHGSMIGuestRead(PDEVICE_EXTENSION PrimaryExtension)
     340{
     341    return VideoPortReadPortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest);
    312342}
    313343
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