Changeset 4053 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
- Timestamp:
- Aug 7, 2007 8:40:02 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
r4027 r4053 740 740 741 741 dprintf(("VBoxVideo::vboxComputeFrameBufferSizes: [%d] ulFrameBufferOffset 0x%08X\n", 742 ulFrameBufferOffset));742 Extension->iDevice, ulFrameBufferOffset)); 743 743 744 744 ulFrameBufferOffset += PrimaryExtension->u.primary.ulMaxFrameBufferSize … … 749 749 } 750 750 751 static int vboxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension )752 { 753 dprintf(("VBoxVideo::vboxMapAdapterMemory \n"));751 static int vboxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension, void **ppv, ULONG ulOffset, ULONG ulSize) 752 { 753 dprintf(("VBoxVideo::vboxMapAdapterMemory 0x%08X[0x%X]\n", ulOffset, ulSize)); 754 754 755 755 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; 760 757 761 758 PVOID VideoRamBase = NULL; 762 759 ULONG inIoSpace = 0; 763 ULONG VideoRamLength = PrimaryExtension->u.primary.cbMiniportHeap 764 + VBOX_VIDEO_ADAPTER_INFORMATION_SIZE; 760 ULONG VideoRamLength = ulSize; 765 761 766 762 VP_STATUS Status = VideoPortMapMemory (PrimaryExtension, FrameBuffer, … … 770 766 if (Status == NO_ERROR) 771 767 { 772 PrimaryExtension->u.primary.pvMiniportHeap = VideoRamBase; 773 PrimaryExtension->u.primary.pvAdapterInformation = (uint8_t *)VideoRamBase 774 + PrimaryExtension->u.primary.cbMiniportHeap; 768 *ppv = VideoRamBase; 775 769 } 776 770 … … 780 774 } 781 775 782 static void vboxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension )776 static void vboxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension, void **ppv) 783 777 { 784 778 dprintf(("VBoxVideo::vboxMapAdapterMemory\n")); 785 779 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 788 static 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)); 793 819 } 794 820 … … 883 909 PrimaryExtension->u.primary.ulDisplayInformationSize = 0; 884 910 885 886 911 /* Verify whether the HW supports VirtualBox extensions. */ 887 912 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID); … … 896 921 PrimaryExtension->u.primary.bVBoxVideoSupported)); 897 922 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 898 940 /* Setup the non-volatile heap and the adapter memory. */ 899 941 if (PrimaryExtension->u.primary.bVBoxVideoSupported) 900 942 { 901 943 /* 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); 906 946 907 947 /* Do not allow too big heap. 50% of VRAM should be enough. */ … … 927 967 * 928 968 */ 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 ); 930 976 931 977 if (rc != NO_ERROR) … … 954 1000 { 955 1001 /* 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 959 1005 dprintf(("VBoxVideo::VBoxSetupDisplays: cDisplays = %d\n", 960 1006 cDisplays)); … … 968 1014 PDEVICE_EXTENSION pPrev = PrimaryExtension; 969 1015 970 intiDisplay;1016 ULONG iDisplay; 971 1017 for (iDisplay = 1; iDisplay < cDisplays; iDisplay++) 972 1018 { … … 1011 1057 /* Setup the information for the host. */ 1012 1058 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); 1013 1065 } 1014 1066 … … 1667 1719 VbglTerminate (); 1668 1720 1669 vboxUnmapAdapterMemory (pDevExt); 1721 vboxUnmapAdapterMemory (pDevExt, &pDevExt->u.primary.pvMiniportHeap); 1722 vboxUnmapAdapterMemory (pDevExt, &pDevExt->u.primary.pvAdapterInformation); 1670 1723 1671 1724 return TRUE;
Note:
See TracChangeset
for help on using the changeset viewer.