Changeset 12741 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
- Timestamp:
- Sep 25, 2008 2:26:02 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
r12215 r12741 33 33 #define _INC_SWPRINTF_INL_ 34 34 extern "C" int __cdecl swprintf(wchar_t *, const wchar_t *, ...); 35 #endif 35 #endif 36 36 #include <wchar.h> 37 37 … … 737 737 738 738 /* Size of a framebuffer. */ 739 739 740 740 ULONG ulSize = ulAvailable / PrimaryExtension->u.primary.cDisplays; 741 741 742 742 /* Align down to 4096 bytes. */ 743 743 ulSize &= ~0xFFF; 744 744 745 745 dprintf(("VBoxVideo::vboxComputeFrameBufferSizes: cbVRAM = 0x%08X, cDisplays = %d, ulSize = 0x%08X, ulSize * cDisplays = 0x%08X, slack = 0x%08X\n", 746 746 PrimaryExtension->u.primary.cbVRAM, PrimaryExtension->u.primary.cDisplays, 747 747 ulSize, ulSize * PrimaryExtension->u.primary.cDisplays, 748 748 ulAvailable - ulSize * PrimaryExtension->u.primary.cDisplays)); 749 749 750 750 if (ulSize > VBOX_VIDEO_DISPLAY_INFORMATION_SIZE) 751 751 { … … 758 758 ulSize = 0; 759 759 } 760 760 761 761 /* Update the primary info. */ 762 762 PrimaryExtension->u.primary.ulMaxFrameBufferSize = ulSize; 763 763 PrimaryExtension->u.primary.ulDisplayInformationSize = VBOX_VIDEO_DISPLAY_INFORMATION_SIZE; 764 764 765 765 /* Update the per extension info. */ 766 766 PDEVICE_EXTENSION Extension = PrimaryExtension; … … 771 771 /* That is assigned when a video mode is set. */ 772 772 Extension->ulFrameBufferSize = 0; 773 773 774 774 dprintf(("VBoxVideo::vboxComputeFrameBufferSizes: [%d] ulFrameBufferOffset 0x%08X\n", 775 775 Extension->iDevice, ulFrameBufferOffset)); 776 776 777 777 ulFrameBufferOffset += PrimaryExtension->u.primary.ulMaxFrameBufferSize 778 778 + PrimaryExtension->u.primary.ulDisplayInformationSize; 779 779 780 780 Extension = Extension->pNext; 781 781 } … … 807 807 *ppv = VideoRamBase; 808 808 } 809 809 810 810 dprintf(("VBoxVideo::vboxMapAdapterMemory rc = %d\n", Status)); 811 811 812 812 return Status; 813 813 } … … 816 816 { 817 817 dprintf(("VBoxVideo::vboxMapAdapterMemory\n")); 818 818 819 819 if (*ppv) 820 820 { 821 821 VideoPortUnmapMemory(PrimaryExtension, *ppv, NULL); 822 822 } 823 823 824 824 *ppv = NULL; 825 825 } … … 828 828 { 829 829 dprintf(("VBoxVideo::vboxQueryConf: u32Index = %d\n", u32Index)); 830 830 831 831 typedef struct _VBOXVIDEOQCONF32 832 832 { … … 841 841 p->hdrQuery.u8Reserved = 0; 842 842 p->hdrQuery.u16Length = sizeof (VBOXVIDEOINFOQUERYCONF32); 843 843 844 844 p->query.u32Index = u32Index; 845 845 p->query.u32Value = 0; 846 846 847 847 p->hdrEnd.u8Type = VBOX_VIDEO_INFO_TYPE_END; 848 848 p->hdrEnd.u8Reserved = 0; 849 849 p->hdrEnd.u16Length = 0; 850 850 851 851 /* Let the host to process the commands. */ 852 852 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VBOX_VIDEO); 853 853 VideoPortWritePortUlong((PULONG)VBE_DISPI_IOPORT_DATA, VBOX_VIDEO_INTERPRET_ADAPTER_MEMORY); 854 854 855 855 *pulValue = (ULONG)p->query.u32Value; 856 856 857 857 dprintf(("VBoxVideo::vboxQueryConf: u32Value = %d\n", p->query.u32Value)); 858 858 } … … 861 861 { 862 862 dprintf(("VBoxVideo::vboxSetupAdapterInfo\n")); 863 863 864 864 VBOXVIDEOINFOHDR *pHdr; 865 865 … … 887 887 } 888 888 889 889 890 890 /* The heap description. */ 891 891 pHdr = (VBOXVIDEOINFOHDR *)pu8; … … 899 899 pu8 += sizeof (VBOXVIDEOINFONVHEAP); 900 900 901 pHeap->u32HeapOffset = PrimaryExtension->u.primary.cbVRAM 901 pHeap->u32HeapOffset = PrimaryExtension->u.primary.cbVRAM 902 902 - PrimaryExtension->u.primary.cbMiniportHeap 903 903 - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE; 904 904 pHeap->u32HeapSize = PrimaryExtension->u.primary.cbMiniportHeap; 905 906 905 906 907 907 /* The END marker. */ 908 908 pHdr = (VBOXVIDEOINFOHDR *)pu8; … … 916 916 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VBOX_VIDEO); 917 917 VideoPortWritePortUlong((PULONG)VBE_DISPI_IOPORT_DATA, VBOX_VIDEO_INTERPRET_ADAPTER_MEMORY); 918 918 919 919 dprintf(("VBoxVideo::vboxSetupAdapterInfo finished\n")); 920 920 } … … 956 956 PrimaryExtension->u.primary.bVBoxVideoSupported = TRUE; 957 957 } 958 958 959 959 dprintf(("VBoxVideo::VBoxSetupDisplays: bVBoxVideoSupported = %d\n", 960 960 PrimaryExtension->u.primary.bVBoxVideoSupported)); 961 961 962 962 if (PrimaryExtension->u.primary.bVBoxVideoSupported) 963 963 { … … 972 972 dprintf(("VBoxVideo::VBoxSetupDisplays: vboxMapAdapterMemory pvAdapterInfoirrmation failed rc = %d\n", 973 973 rc)); 974 974 975 975 PrimaryExtension->u.primary.bVBoxVideoSupported = FALSE; 976 976 } 977 977 } 978 978 979 979 /* Setup the non-volatile heap and the adapter memory. */ 980 980 if (PrimaryExtension->u.primary.bVBoxVideoSupported) … … 983 983 ULONG cbMiniportHeap = 0; 984 984 vboxQueryConf (PrimaryExtension, VBOX_VIDEO_QCI32_OFFSCREEN_HEAP_SIZE, &cbMiniportHeap); 985 985 986 986 /* Do not allow too big heap. 50% of VRAM should be enough. */ 987 987 ULONG cbMiniportHeapMaxSize = AdapterMemorySize / 2 - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE; 988 988 989 989 if (cbMiniportHeap > cbMiniportHeapMaxSize) 990 990 { 991 991 cbMiniportHeap = cbMiniportHeapMaxSize; 992 992 } 993 993 994 994 /* Round up to 4096. */ 995 995 PrimaryExtension->u.primary.cbMiniportHeap = (cbMiniportHeap + 0xFFF) & ~0xFFF; 996 996 997 997 dprintf(("VBoxVideo::VBoxSetupDisplays: cbMiniportHeap = 0x%08X, PrimaryExtension->u.primary.cbMiniportHeap = 0x%08X, cbMiniportHeapMaxSize = 0x%08X\n", 998 998 cbMiniportHeap, PrimaryExtension->u.primary.cbMiniportHeap, cbMiniportHeapMaxSize)); 999 999 1000 1000 /* Map the heap region and the adapter information area. 1001 1001 * … … 1004 1004 * It is assumed that all display drivers and the miniport has the SAME 1005 1005 * virtual address space. 1006 * 1006 * 1007 1007 */ 1008 1008 rc = vboxMapAdapterMemory (PrimaryExtension, … … 1013 1013 PrimaryExtension->u.primary.cbMiniportHeap 1014 1014 ); 1015 1015 1016 1016 if (rc != NO_ERROR) 1017 1017 { … … 1026 1026 typedef VP_STATUS (*PFNCREATESECONDARYDISPLAY)(PVOID, PVOID *, ULONG); 1027 1027 PFNCREATESECONDARYDISPLAY pfnCreateSecondaryDisplay = NULL; 1028 1028 1029 1029 /* Dynamically query the VideoPort import to be binary compatible across Windows versions */ 1030 if (vboxQueryWinVersion() > WINNT4) 1030 if (vboxQueryWinVersion() > WINNT4) 1031 1031 { 1032 1032 /* This bluescreens on NT4, hence the above version check */ … … 1041 1041 ULONG cDisplays = 0; 1042 1042 vboxQueryConf (PrimaryExtension, VBOX_VIDEO_QCI32_MONITOR_COUNT, &cDisplays); 1043 1043 1044 1044 dprintf(("VBoxVideo::VBoxSetupDisplays: cDisplays = %d\n", 1045 1045 cDisplays)); 1046 1046 1047 1047 if (cDisplays == 0 || cDisplays > VBOX_VIDEO_MAX_SCREENS) 1048 1048 { … … 1052 1052 1053 1053 PDEVICE_EXTENSION pPrev = PrimaryExtension; 1054 1054 1055 1055 ULONG iDisplay; 1056 1056 for (iDisplay = 1; iDisplay < cDisplays; iDisplay++) … … 1058 1058 PDEVICE_EXTENSION SecondaryExtension = NULL; 1059 1059 rc = pfnCreateSecondaryDisplay (PrimaryExtension, (PVOID*)&SecondaryExtension, VIDEO_DUALVIEW_REMOVABLE); 1060 1060 1061 1061 dprintf(("VBoxVideo::VBoxSetupDisplays: VideoPortCreateSecondaryDisplay returned %#x, SecondaryExtension = %p\n", 1062 1062 rc, SecondaryExtension)); 1063 1063 1064 1064 if (rc != NO_ERROR) 1065 1065 { … … 1073 1073 SecondaryExtension->ulFrameBufferSize = 0; 1074 1074 SecondaryExtension->u.secondary.bEnabled = FALSE; 1075 1075 1076 1076 /* Update the list pointers. */ 1077 1077 pPrev->pNext = SecondaryExtension; 1078 1078 pPrev = SecondaryExtension; 1079 1079 1080 1080 /* Take the successfully created display into account. */ 1081 1081 PrimaryExtension->u.primary.cDisplays++; 1082 1082 } 1083 1083 1084 1084 /* Failure to create secondary displays is not fatal */ 1085 1085 rc = NO_ERROR; 1086 1086 } 1087 1087 } 1088 1088 1089 1089 /* Now when the number of monitors is known and extensions are created, 1090 1090 * calculate the layout of framebuffers. … … 1103 1103 vboxUnmapAdapterMemory (PrimaryExtension, &PrimaryExtension->u.primary.pvAdapterInformation); 1104 1104 } 1105 1105 1106 1106 dprintf(("VBoxVideo::VBoxSetupDisplays: finished\n")); 1107 1107 } … … 1260 1260 BOOLEAN Result; 1261 1261 1262 // dprintf(("VBoxVideo::VBoxVideoStartIO: code %08X\n", RequestPacket->IoControlCode));1262 // dprintf(("VBoxVideo::VBoxVideoStartIO: Code %08X\n", RequestPacket->IoControlCode)); 1263 1263 1264 1264 RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION; … … 1324 1324 VP_STATUS status; 1325 1325 1326 dprintf((" IOCTL_VIDEO_SHARE_VIDEO_MEMORY\n"));1327 1328 if ( (RequestPacket->OutputBufferLength < sizeof(VIDEO_SHARE_MEMORY_INFORMATION)) 1326 dprintf(("VBoxVideo::VBoxVideoStartIO: IOCTL_VIDEO_SHARE_VIDEO_MEMORY\n")); 1327 1328 if ( (RequestPacket->OutputBufferLength < sizeof(VIDEO_SHARE_MEMORY_INFORMATION)) 1329 1329 || (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY)) ) { 1330 1330 1331 dprintf((" IOCTL_VIDEO_SHARE_VIDEO_MEMORY: ERROR_INSUFFICIENT_BUFFER\n"));1331 dprintf(("VBoxVideo::VBoxVideoStartIO: IOCTL_VIDEO_SHARE_VIDEO_MEMORY: ERROR_INSUFFICIENT_BUFFER\n")); 1332 1332 RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER; 1333 1333 Result = FALSE; … … 1337 1337 pShareMemory = (PVIDEO_SHARE_MEMORY)RequestPacket->InputBuffer; 1338 1338 1339 if ( (pShareMemory->ViewOffset > pDevExt->pPrimary->u.primary.ulMaxFrameBufferSize) 1339 if ( (pShareMemory->ViewOffset > pDevExt->pPrimary->u.primary.ulMaxFrameBufferSize) 1340 1340 || ((pShareMemory->ViewOffset + pShareMemory->ViewSize) > pDevExt->pPrimary->u.primary.ulMaxFrameBufferSize) ) { 1341 1341 1342 dprintf((" IOCTL_VIDEO_SHARE_VIDEO_MEMORY - ERROR_INVALID_PARAMETER %x:%x size %x\n", pShareMemory->ViewOffset, pShareMemory->ViewSize, pDevExt->pPrimary->u.primary.ulMaxFrameBufferSize));1342 dprintf(("VBoxVideo::VBoxVideoStartIO: IOCTL_VIDEO_SHARE_VIDEO_MEMORY - ERROR_INVALID_PARAMETER %x:%x size %x\n", pShareMemory->ViewOffset, pShareMemory->ViewSize, pDevExt->pPrimary->u.primary.ulMaxFrameBufferSize)); 1343 1343 RequestPacket->StatusBlock->Status = ERROR_INVALID_PARAMETER; 1344 1344 Result = FALSE; … … 1355 1355 status = VideoPortMapMemory(HwDeviceExtension, shareAddress, &sharedViewSize, &inIoSpace, &virtualAddress); 1356 1356 if (status != NO_ERROR) 1357 dprintf(("V ideoPortMapMemory failed with %x\n", status));1357 dprintf(("VBoxVideo::VBoxVideoStartIO: VideoPortMapMemory failed with %x\n", status)); 1358 1358 Result = (status == NO_ERROR); 1359 1359 … … 1370 1370 VP_STATUS status; 1371 1371 1372 dprintf((" IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY\n"));1373 1374 if (RequestPacket->InputBufferLength < sizeof(VIDEO_SHARE_MEMORY)) 1375 { 1376 dprintf((" IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY: ERROR_INSUFFICIENT_BUFFER\n"));1372 dprintf(("VBoxVideo::VBoxVideoStartIO: IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY\n")); 1373 1374 if (RequestPacket->InputBufferLength < sizeof(VIDEO_SHARE_MEMORY)) 1375 { 1376 dprintf(("VBoxVideo::VBoxVideoStartIO: IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY: ERROR_INSUFFICIENT_BUFFER\n")); 1377 1377 RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER; 1378 1378 Result = FALSE; … … 1384 1384 status = VideoPortUnmapMemory(HwDeviceExtension, pShareMemory->RequestedVirtualAddress, pShareMemory->ProcessHandle); 1385 1385 if (status != NO_ERROR) 1386 dprintf(("V ideoPortUnmapMemory failed with %x\n", status));1386 dprintf(("VBoxVideo::VBoxVideoStartIO: VideoPortUnmapMemory failed with %x\n", status)); 1387 1387 Result = (status == NO_ERROR); 1388 1388 break; … … 1471 1471 1472 1472 if (!Result) 1473 dprintf(("VBoxVideo::VBoxVideoStartIO: could not hide hardware pointer -> fallback\n"));1473 dprintf(("VBoxVideo::VBoxVideoStartIO: Could not hide hardware pointer -> fallback\n")); 1474 1474 } else 1475 1475 { … … 1499 1499 1500 1500 if (!Result) 1501 dprintf(("VBoxVideo::VBoxVideoStartIO: could not hide hardware pointer -> fallback\n"));1501 dprintf(("VBoxVideo::VBoxVideoStartIO: Could not hide hardware pointer -> fallback\n")); 1502 1502 } else 1503 1503 { … … 1541 1541 Result = vboxUpdatePointerShape(pPointerAttributes, RequestPacket->InputBufferLength); 1542 1542 if (!Result) 1543 dprintf(("VBoxVideo::VBoxVideoStartIO: could not set hardware pointer -> fallback\n"));1543 dprintf(("VBoxVideo::VBoxVideoStartIO: Could not set hardware pointer -> fallback\n")); 1544 1544 } else 1545 1545 { 1546 dprintf(("VBoxVideo::VBoxVideoStartIO: fallback to software pointer\n"));1546 dprintf(("VBoxVideo::VBoxVideoStartIO: Fallback to software pointer\n")); 1547 1547 // fallback to software pointer 1548 1548 RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION; … … 1590 1590 if (RequestPacket->OutputBufferLength < sizeof(VIDEO_POINTER_POSITION)) 1591 1591 { 1592 dprintf(("VBoxVideo::VBoxVideoStartIO: output buffer too small!\n"));1592 dprintf(("VBoxVideo::VBoxVideoStartIO: Output buffer too small!\n")); 1593 1593 RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER; 1594 1594 return TRUE; … … 1625 1625 if (RequestPacket->OutputBufferLength < sizeof(VIDEO_POINTER_CAPABILITIES)) 1626 1626 { 1627 dprintf(("VBoxVideo::VBoxVideoStartIO: output buffer too small!\n"));1627 dprintf(("VBoxVideo::VBoxVideoStartIO: Output buffer too small!\n")); 1628 1628 RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER; 1629 1629 return TRUE; … … 1684 1684 if (RequestPacket->OutputBufferLength < sizeof(QUERYDISPLAYINFORESULT)) 1685 1685 { 1686 dprintf(("VBoxVideo::VBoxVideoStartIO: output buffer too small: %d needed: %d!!!\n",1686 dprintf(("VBoxVideo::VBoxVideoStartIO: Output buffer too small: %d needed: %d!!!\n", 1687 1687 RequestPacket->OutputBufferLength, sizeof(QUERYDISPLAYINFORESULT))); 1688 1688 RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER; … … 1691 1691 1692 1692 QUERYDISPLAYINFORESULT *pDispInfo = (QUERYDISPLAYINFORESULT *)RequestPacket->OutputBuffer; 1693 1693 1694 1694 pDispInfo->iDevice = pDevExt->iDevice; 1695 1695 pDispInfo->u32DisplayInfoSize = pDevExt->pPrimary->u.primary.ulDisplayInformationSize; … … 1710 1710 if (RequestPacket->InputBufferLength < sizeof(ULONG)) 1711 1711 { 1712 dprintf(("VBoxVideo::VBoxVideoStartIO: input buffer too small: %d needed: %d!!!\n",1712 dprintf(("VBoxVideo::VBoxVideoStartIO: Input buffer too small: %d needed: %d!!!\n", 1713 1713 RequestPacket->InputBufferLength, sizeof(ULONG))); 1714 1714 RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER; … … 1718 1718 if (RequestPacket->OutputBufferLength < sizeof(VBVAENABLERESULT)) 1719 1719 { 1720 dprintf(("VBoxVideo::VBoxVideoStartIO: output buffer too small: %d needed: %d!!!\n",1720 dprintf(("VBoxVideo::VBoxVideoStartIO: Output buffer too small: %d needed: %d!!!\n", 1721 1721 RequestPacket->OutputBufferLength, sizeof(VBVAENABLERESULT))); 1722 1722 RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER; … … 1753 1753 || RequestPacket->InputBufferLength != cRect*sizeof(RTRECT)) 1754 1754 { 1755 dprintf(("VBoxVideo::IOCTL_VIDEO_VBOX_SETVISIBLEREGION: output buffer too small: %d needed: %d!!!\n",1755 dprintf(("VBoxVideo::IOCTL_VIDEO_VBOX_SETVISIBLEREGION: Output buffer too small: %d needed: %d!!!\n", 1756 1756 RequestPacket->OutputBufferLength, sizeof(RTRECT))); 1757 1757 RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER; … … 1780 1780 } 1781 1781 } 1782 dprintf(("VBoxVideo: failed with rc=%x (hdr.rc=%x)\n", rc, (req) ? req->header.rc : -1));1782 dprintf(("VBoxVideo::VBoxVideoStartIO: Failed with rc=%x (hdr.rc=%x)\n", rc, (req) ? req->header.rc : -1)); 1783 1783 RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION; 1784 1784 return FALSE; … … 1786 1786 1787 1787 default: 1788 dprintf(("VBoxVideo::VBoxVideoStartIO: unsupported %p, fn %d(0x%x)\n",1788 dprintf(("VBoxVideo::VBoxVideoStartIO: Unsupported %p, fn %d(0x%x)\n", 1789 1789 RequestPacket->IoControlCode, 1790 1790 (RequestPacket->IoControlCode >> 2) & 0xFFF, … … 1799 1799 RequestPacket->StatusBlock->Information = 0; 1800 1800 1801 // dprintf(("VBoxVideo::VBoxVideoStartIO: completed\n"));1801 // dprintf(("VBoxVideo::VBoxVideoStartIO: Completed\n")); 1802 1802 1803 1803 return TRUE; … … 1832 1832 1833 1833 VbglTerminate (); 1834 1834 1835 1835 vboxUnmapAdapterMemory (pDevExt, &pDevExt->u.primary.pvMiniportHeap); 1836 1836 vboxUnmapAdapterMemory (pDevExt, &pDevExt->u.primary.pvAdapterInformation); … … 1865 1865 /** 1866 1866 * VBoxVideoSetGraphicsCap 1867 * 1867 * 1868 1868 * Tells the host whether or not we currently support graphics in the 1869 1869 * additions … … 1884 1884 req->u32OrMask = isEnabled ? VMMDEV_GUEST_SUPPORTS_GRAPHICS : 0; 1885 1885 req->u32NotMask = isEnabled ? 0 : VMMDEV_GUEST_SUPPORTS_GRAPHICS; 1886 1886 1887 1887 rc = VbglGRPerform (&req->header); 1888 1888 if (!RT_SUCCESS(rc) || !RT_SUCCESS(req->header.rc)) … … 2194 2194 2195 2195 dprintf(("VBoxVideo::vboxVbvaEnable: VbglQueryVMMDevMemory rc = %d, pVMMDevMemory = %p\n", rc, pVMMDevMemory)); 2196 2196 2197 2197 if (pDevExt->iDevice > 0) 2198 2198 { … … 2201 2201 dprintf(("VBoxVideo::vboxVbvaEnable: Skipping for non-primary display %d\n", 2202 2202 pDevExt->iDevice)); 2203 2203 2204 2204 if ( ulEnable 2205 2205 && pPrimaryDevExt->u.primary.ulVbvaEnabled)
Note:
See TracChangeset
for help on using the changeset viewer.