Changeset 34429 in vbox
- Timestamp:
- Nov 27, 2010 1:56:46 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxVideoGuest.h
r34346 r34429 32 32 #include <VBox/HGSMI/HGSMI.h> 33 33 #include <VBox/HGSMI/HGSMIChSetup.h> 34 35 #ifdef VBOX_XPDM_MINIPORT 36 RT_C_DECLS_BEGIN 37 # include "miniport.h" 38 # include "ntddvdeo.h" 39 # include <Video.h> 40 RT_C_DECLS_END 41 #else 42 # include <iprt/asm-amd64-x86.h> 43 #endif 44 45 RT_C_DECLS_BEGIN 34 46 35 47 /** … … 74 86 } HGSMIHOSTCOMMANDCONTEXT, *PHGSMIHOSTCOMMANDCONTEXT; 75 87 88 /** @name Helper functions 89 * @{ */ 90 /** Write an 8-bit value to an I/O port. */ 91 DECLINLINE(void) VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value) 92 { 93 #ifdef VBOX_XPDM_MINIPORT 94 VideoPortWritePortUchar((PUCHAR)Port, Value); 95 #else /** @todo make these explicit */ 96 ASMOutU8(Port, Value); 97 #endif 98 } 99 100 /** Write a 16-bit value to an I/O port. */ 101 DECLINLINE(void) VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value) 102 { 103 #ifdef VBOX_XPDM_MINIPORT 104 VideoPortWritePortUshort((PUSHORT)Port,Value); 105 #else 106 ASMOutU16(Port, Value); 107 #endif 108 } 109 110 /** Write a 32-bit value to an I/O port. */ 111 DECLINLINE(void) VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value) 112 { 113 #ifdef VBOX_XPDM_MINIPORT 114 VideoPortWritePortUlong((PULONG)Port,Value); 115 #else 116 ASMOutU32(Port, Value); 117 #endif 118 } 119 120 /** Read an 8-bit value from an I/O port. */ 121 DECLINLINE(uint8_t) VBoxVideoCmnPortReadUchar(RTIOPORT Port) 122 { 123 #ifdef VBOX_XPDM_MINIPORT 124 return VideoPortReadPortUchar((PUCHAR)Port); 125 #else 126 return ASMInU8(Port); 127 #endif 128 } 129 130 /** Read a 16-bit value from an I/O port. */ 131 DECLINLINE(uint16_t) VBoxVideoCmnPortReadUshort(RTIOPORT Port) 132 { 133 #ifdef VBOX_XPDM_MINIPORT 134 return VideoPortReadPortUshort((PUSHORT)Port); 135 #else 136 return ASMInU16(Port); 137 #endif 138 } 139 140 /** Read a 32-bit value from an I/O port. */ 141 DECLINLINE(uint32_t) VBoxVideoCmnPortReadUlong(RTIOPORT Port) 142 { 143 #ifdef VBOX_XPDM_MINIPORT 144 return VideoPortReadPortUlong((PULONG)Port); 145 #else 146 return ASMInU32(Port); 147 #endif 148 } 149 150 /** @} */ 151 152 /** @name Base HGSMI APIs 153 * @{ */ 154 155 /** Acknowlege an IRQ. */ 156 DECLINLINE(void) VBoxHGSMIClearIrq(PHGSMIHOSTCOMMANDCONTEXT pCtx) 157 { 158 VBoxVideoCmnPortWriteUlong(pCtx->port, HGSMIOFFSET_VOID); 159 } 160 161 RTDECL(void) VBoxHGSMIHostCmdComplete(PHGSMIHOSTCOMMANDCONTEXT pCtx, 162 void *pvMem); 163 RTDECL(void) VBoxHGSMIProcessHostQueue(PHGSMIHOSTCOMMANDCONTEXT pCtx); 164 RTDECL(bool) VBoxHGSMIIsSupported(void); 165 RTDECL(void *) VBoxHGSMIBufferAlloc(PHGSMIGUESTCOMMANDCONTEXT pCtx, 166 HGSMISIZE cbData, 167 uint8_t u8Ch, 168 uint16_t u16Op); 169 RTDECL(void) VBoxHGSMIBufferFree(PHGSMIGUESTCOMMANDCONTEXT pCtx, 170 void *pvBuffer); 171 RTDECL(int) VBoxHGSMIBufferSubmit(PHGSMIGUESTCOMMANDCONTEXT pCtx, 172 void *pvBuffer); 173 174 typedef struct VBVAINFOVIEW *PVBVAINFOVIEW; 175 /** 176 * Callback funtion called from @a VBoxHGSMISendViewInfo to initialise 177 * the @a VBVAINFOVIEW structure for each screen. 178 * 179 * @returns iprt status code 180 * @param pvData context data for the callback, passed to @a 181 * VBoxHGSMISendViewInfo along with the callback 182 * @param pInfo array of @a VBVAINFOVIEW structures to be filled in 183 * @todo explicitly pass the array size 184 */ 185 typedef DECLCALLBACK(int) FNHGSMIFILLVIEWINFO (void *pvData, 186 PVBVAINFOVIEW pInfo); 187 /** Pointer to a FNHGSMIFILLVIEWINFO callback */ 188 typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO; 189 190 RTDECL(int) VBoxHGSMISendViewInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx, 191 uint32_t u32Count, 192 PFNHGSMIFILLVIEWINFO pfnFill, 193 void *pvData); 194 RTDECL(void) VBoxHGSMIGetBaseMappingInfo(uint32_t cbVRAM, 195 uint32_t *poffVRAMBaseMapping, 196 uint32_t *pcbMapping, 197 uint32_t *poffGuestHeapMemory, 198 uint32_t *pcbGuestHeapMemory, 199 uint32_t *poffHostFlags); 200 /** @todo we should provide a cleanup function too as part of the API */ 201 RTDECL(int) VBoxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pCtx, 202 void *pvGuestHeapMemory, 203 uint32_t cbGuestHeapMemory, 204 uint32_t offVRAMGuestHeapMemory); 205 RTDECL(void) VBoxHGSMIGetHostAreaMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx, 206 uint32_t cbVRAM, 207 uint32_t offVRAMBaseMapping, 208 uint32_t *poffVRAMHostArea, 209 uint32_t *pcbHostArea); 210 RTDECL(void) VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx, 211 void *pvBaseMapping, 212 uint32_t offHostFlags, 213 void *pvHostAreaMapping, 214 uint32_t offVRAMHostArea, 215 uint32_t cbHostArea); 216 RTDECL(int) VBoxHGSMISendHostCtxInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx, 217 HGSMIOFFSET offVRAMFlagsLocation, 218 uint32_t fCaps, 219 uint32_t offVRAMHostArea, 220 uint32_t cbHostArea); 221 RTDECL(uint32_t) VBoxHGSMIGetMonitorCount(PHGSMIGUESTCOMMANDCONTEXT pCtx); 222 RTDECL(bool) VBoxHGSMIUpdatePointerShape(PHGSMIGUESTCOMMANDCONTEXT pCtx, 223 uint32_t fFlags, 224 uint32_t cHotX, 225 uint32_t cHotY, 226 uint32_t cWidth, 227 uint32_t cHeight, 228 uint8_t *pPixels, 229 uint32_t cbLength); 230 231 /** @} */ 232 233 RT_C_DECLS_END 76 234 77 235 #endif /* __HGSMI_GUEST_h__*/ -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Makefile.kmk
r34079 r34429 31 31 VBoxVideo_NOINST = true 32 32 endif 33 VBoxVideo_DEFS = LOG_TO_BACKDOOR VBOX_WITH_8BPP_MODES33 VBoxVideo_DEFS = VBOX_XPDM_MINIPORT LOG_TO_BACKDOOR VBOX_WITH_8BPP_MODES 34 34 ifdef VBOX_WITH_VIDEOHWACCEL 35 35 VBoxVideo_DEFS += VBOX_WITH_VIDEOHWACCEL … … 45 45 VBoxVideo.def \ 46 46 VBoxVideo.rc \ 47 VBoxVideoHGSMI.cpp 47 VBoxVideoHGSMI.cpp \ 48 $(PATH_ROOT)/src/VBox/Additions/common/VBoxVideo/HGSMIBase.cpp 48 49 VBoxVideo_LIBS.x86 = \ 49 50 $(PATH_SDK_W2K3DDK_LIB)/exsup.lib … … 99 100 VBoxVideoWddm_SOURCES = \ 100 101 VBoxVideoHGSMI.cpp \ 102 $(PATH_ROOT)/src/VBox/Additions/common/VBoxVideo/HGSMIBase.cpp \ 101 103 VBoxVideo.cpp \ 102 104 Helper.cpp \ -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo-win.h
r34349 r34429 261 261 uint32_t cbLength) 262 262 { 263 return vboxUpdatePointerShape(&pCommon->guestCtx, 264 pointerAttr->Enable & 0x0000FFFF, 265 (pointerAttr->Enable >> 16) & 0xFF, 266 (pointerAttr->Enable >> 24) & 0xFF, 267 pointerAttr->Width, 268 pointerAttr->Height, 269 pointerAttr->Pixels, 270 cbLength - sizeof(VIDEO_POINTER_ATTRIBUTES)); 263 return VBoxHGSMIUpdatePointerShape(&pCommon->guestCtx, 264 pointerAttr->Enable & 0x0000FFFF, 265 (pointerAttr->Enable >> 16) & 0xFF, 266 (pointerAttr->Enable >> 24) & 0xFF, 267 pointerAttr->Width, 268 pointerAttr->Height, 269 pointerAttr->Pixels, 270 cbLength 271 - sizeof(VIDEO_POINTER_ATTRIBUTES)); 271 272 } 272 273 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
r34349 r34429 2841 2841 #endif 2842 2842 2843 void VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value)2844 {2845 #ifndef VBOX_WITH_WDDM2846 VideoPortWritePortUchar((PUCHAR)Port,Value);2847 #else2848 WRITE_PORT_UCHAR((PUCHAR)Port,Value);2849 #endif2850 }2851 2852 void VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value)2853 {2854 #ifndef VBOX_WITH_WDDM2855 VideoPortWritePortUshort((PUSHORT)Port,Value);2856 #else2857 WRITE_PORT_USHORT((PUSHORT)Port,Value);2858 #endif2859 }2860 2861 void VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value)2862 {2863 #ifndef VBOX_WITH_WDDM2864 VideoPortWritePortUlong((PULONG)Port,Value);2865 #else2866 WRITE_PORT_ULONG((PULONG)Port,Value);2867 #endif2868 }2869 2870 uint8_t VBoxVideoCmnPortReadUchar(RTIOPORT Port)2871 {2872 #ifndef VBOX_WITH_WDDM2873 return VideoPortReadPortUchar((PUCHAR)Port);2874 #else2875 return READ_PORT_UCHAR((PUCHAR)Port);2876 #endif2877 }2878 2879 uint16_t VBoxVideoCmnPortReadUshort(RTIOPORT Port)2880 {2881 #ifndef VBOX_WITH_WDDM2882 return VideoPortReadPortUshort((PUSHORT)Port);2883 #else2884 return READ_PORT_USHORT((PUSHORT)Port);2885 #endif2886 }2887 2888 uint32_t VBoxVideoCmnPortReadUlong(RTIOPORT Port)2889 {2890 #ifndef VBOX_WITH_WDDM2891 return VideoPortReadPortUlong((PULONG)Port);2892 #else2893 return READ_PORT_ULONG((PULONG)Port);2894 #endif2895 }2896 2897 2843 int VBoxMapAdapterMemory (PVBOXVIDEO_COMMON pCommon, void **ppv, uint32_t ulOffset, uint32_t ulSize) 2898 2844 { … … 3087 3033 3088 3034 #ifndef VBOX_WITH_WDDM 3089 static int vbvaInitInfoDisplay (void *pvData, VBVAINFOVIEW *p)3035 DECLCALLBACK(int) vbvaInitInfoDisplay (void *pvData, PVBVAINFOVIEW p) 3090 3036 { 3091 3037 PDEVICE_EXTENSION PrimaryExtension = (PDEVICE_EXTENSION) pvData; … … 3382 3328 PDEVICE_EXTENSION PrimaryExtension = (PDEVICE_EXTENSION)HwDeviceExtension; 3383 3329 3384 hgsmiProcessHostCommandQueue(&commonFromDeviceExt(PrimaryExtension)->hostCtx);3330 VBoxHGSMIProcessHostQueue(&commonFromDeviceExt(PrimaryExtension)->hostCtx); 3385 3331 } 3386 3332 … … 3403 3349 } 3404 3350 /* clear the IRQ */ 3405 HGSMIClearIrq(&commonFromDeviceExt(PrimaryExtension)->hostCtx);3351 VBoxHGSMIClearIrq(&commonFromDeviceExt(PrimaryExtension)->hostCtx); 3406 3352 return TRUE; 3407 3353 } -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
r34399 r34429 70 70 void VBoxVideoCmnMemFreeDriver(PVBOXVIDEO_COMMON pCommon, void *pv); 71 71 72 /** Write an 8-bit value to an I/O port. */73 void VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value);74 75 /** Write a 16-bit value to an I/O port. */76 void VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value);77 78 /** Write a 32-bit value to an I/O port. */79 void VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value);80 81 /** Read an 8-bit value from an I/O port. */82 uint8_t VBoxVideoCmnPortReadUchar(RTIOPORT Port);83 84 /** Read a 16-bit value from an I/O port. */85 uint16_t VBoxVideoCmnPortReadUshort(RTIOPORT Port);86 87 /** Read a 32-bit value from an I/O port. */88 uint32_t VBoxVideoCmnPortReadUlong(RTIOPORT Port);89 90 void* vboxHGSMIBufferAlloc(PHGSMIGUESTCOMMANDCONTEXT pCtx,91 HGSMISIZE cbData,92 uint8_t u8Ch,93 uint16_t u16Op);94 void vboxHGSMIBufferFree(PHGSMIGUESTCOMMANDCONTEXT pCtx, void *pvBuffer);95 int vboxHGSMIBufferSubmit(PHGSMIGUESTCOMMANDCONTEXT pCtx, void *pvBuffer);96 97 72 int VBoxMapAdapterMemory (PVBOXVIDEO_COMMON pCommon, 98 73 void **ppv, … … 106 81 void *pvUser); 107 82 108 bool VBoxHGSMIIsSupported (void);109 110 typedef int FNHGSMIFILLVIEWINFO (void *pvData, VBVAINFOVIEW *pInfo);111 typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO;112 113 int VBoxHGSMISendViewInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx, uint32_t u32Count, PFNHGSMIFILLVIEWINFO pfnFill, void *pvData);114 115 83 void VBoxSetupDisplaysHGSMI (PVBOXVIDEO_COMMON pCommon, 116 84 uint32_t AdapterMemorySize, uint32_t fCaps); 117 118 bool vboxUpdatePointerShape (PHGSMIGUESTCOMMANDCONTEXT pCtx,119 uint32_t fFlags,120 uint32_t cHotX,121 uint32_t cHotY,122 uint32_t cWidth,123 uint32_t cHeight,124 uint8_t *pPixels,125 uint32_t cbLength);126 85 127 86 void VBoxFreeDisplaysHGSMI(PVBOXVIDEO_COMMON pCommon); … … 136 95 uint8_t u8Channel); 137 96 138 void hgsmiProcessHostCommandQueue(PHGSMIHOSTCOMMANDCONTEXT pCtx);139 140 void HGSMIClearIrq(PHGSMIHOSTCOMMANDCONTEXT pCtx);141 142 97 } /* extern "C" */ 143 98 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp
r34388 r34429 28 28 #include <VBox/VBoxVideo.h> 29 29 30 // #include <VBoxDisplay.h>31 32 // #include "vboxioctl.h"33 34 /** Send completion notification to the host for the command located at offset35 * @a offt into the host command buffer. */36 void HGSMINotifyHostCmdComplete(PHGSMIHOSTCOMMANDCONTEXT pCtx, HGSMIOFFSET offt)37 {38 VBoxVideoCmnPortWriteUlong(pCtx->port, offt);39 }40 41 /** Acknowlege an IRQ. */42 void HGSMIClearIrq(PHGSMIHOSTCOMMANDCONTEXT pCtx)43 {44 VBoxVideoCmnPortWriteUlong(pCtx->port, HGSMIOFFSET_VOID);45 }46 47 /** Inform the host that a command has been handled. */48 static void HGSMIHostCmdComplete(PHGSMIHOSTCOMMANDCONTEXT pCtx, void * pvMem)49 {50 HGSMIBUFFERHEADER *pHdr = HGSMIBufferHeaderFromData(pvMem);51 HGSMIOFFSET offMem = HGSMIPointerToOffset(&pCtx->areaCtx, pHdr);52 Assert(offMem != HGSMIOFFSET_VOID);53 if(offMem != HGSMIOFFSET_VOID)54 {55 HGSMINotifyHostCmdComplete(pCtx, offMem);56 }57 }58 59 /** Submit an incoming host command to the appropriate handler. */60 static void hgsmiHostCmdProcess(PHGSMIHOSTCOMMANDCONTEXT pCtx,61 HGSMIOFFSET offBuffer)62 {63 int rc = HGSMIBufferProcess(&pCtx->areaCtx, &pCtx->channels, offBuffer);64 Assert(!RT_FAILURE(rc));65 if(RT_FAILURE(rc))66 {67 /* failure means the command was not submitted to the handler for some reason68 * it's our responsibility to notify its completion in this case */69 HGSMINotifyHostCmdComplete(pCtx, offBuffer);70 }71 /* if the cmd succeeded it's responsibility of the callback to complete it */72 }73 74 /** Get the next command from the host. */75 static HGSMIOFFSET hgsmiGetHostBuffer(PHGSMIHOSTCOMMANDCONTEXT pCtx)76 {77 return VBoxVideoCmnPortReadUlong(pCtx->port);78 }79 80 /** Get and handle the next command from the host. */81 static void hgsmiHostCommandQueryProcess(PHGSMIHOSTCOMMANDCONTEXT pCtx)82 {83 HGSMIOFFSET offset = hgsmiGetHostBuffer(pCtx);84 AssertReturnVoid(offset != HGSMIOFFSET_VOID);85 hgsmiHostCmdProcess(pCtx, offset);86 }87 88 /** Drain the host command queue. */89 void hgsmiProcessHostCommandQueue(PHGSMIHOSTCOMMANDCONTEXT pCtx)90 {91 while (pCtx->pfHostFlags->u32HostFlags & HGSMIHOSTFLAGS_COMMANDS_PENDING)92 {93 if (!ASMAtomicCmpXchgBool(&pCtx->fHostCmdProcessing, true, false))94 return;95 hgsmiHostCommandQueryProcess(pCtx);96 ASMAtomicWriteBool(&pCtx->fHostCmdProcessing, false);97 }98 }99 100 /** Detect whether HGSMI is supported by the host. */101 bool VBoxHGSMIIsSupported (void)102 {103 uint16_t DispiId;104 105 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);106 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID_HGSMI);107 108 DispiId = VBoxVideoCmnPortReadUshort(VBE_DISPI_IOPORT_DATA);109 110 return (DispiId == VBE_DISPI_ID_HGSMI);111 }112 113 114 void* vboxHGSMIBufferAlloc(PHGSMIGUESTCOMMANDCONTEXT pCtx,115 HGSMISIZE cbData,116 uint8_t u8Ch,117 uint16_t u16Op)118 {119 #ifdef VBOX_WITH_WDDM120 /* @todo: add synchronization */121 #endif122 return HGSMIHeapAlloc (&pCtx->heapCtx, cbData, u8Ch, u16Op);123 }124 125 void vboxHGSMIBufferFree(PHGSMIGUESTCOMMANDCONTEXT pCtx, void *pvBuffer)126 {127 #ifdef VBOX_WITH_WDDM128 /* @todo: add synchronization */129 #endif130 HGSMIHeapFree (&pCtx->heapCtx, pvBuffer);131 }132 133 int vboxHGSMIBufferSubmit(PHGSMIGUESTCOMMANDCONTEXT pCtx, void *pvBuffer)134 {135 /* Initialize the buffer and get the offset for port IO. */136 HGSMIOFFSET offBuffer = HGSMIHeapBufferOffset (&pCtx->heapCtx, pvBuffer);137 138 Assert(offBuffer != HGSMIOFFSET_VOID);139 if (offBuffer != HGSMIOFFSET_VOID)140 {141 /* Submit the buffer to the host. */142 VBoxVideoCmnPortWriteUlong(pCtx->port, offBuffer);143 return VINF_SUCCESS;144 }145 146 return VERR_INVALID_PARAMETER;147 }148 149 150 static int vboxQueryConfHGSMI(PHGSMIGUESTCOMMANDCONTEXT pCtx, uint32_t u32Index,151 uint32_t *pulValue)152 {153 int rc = VINF_SUCCESS;154 VBVACONF32 *p;155 LogFunc(("u32Index = %d\n", u32Index));156 157 /* Allocate the IO buffer. */158 p = (VBVACONF32 *)HGSMIHeapAlloc(&pCtx->heapCtx,159 sizeof(VBVACONF32), HGSMI_CH_VBVA,160 VBVA_QUERY_CONF32);161 if (p)162 {163 /* Prepare data to be sent to the host. */164 p->u32Index = u32Index;165 p->u32Value = 0;166 rc = vboxHGSMIBufferSubmit(pCtx, p);167 if (RT_SUCCESS(rc))168 {169 *pulValue = p->u32Value;170 LogFunc(("u32Value = %d\n", p->u32Value));171 }172 /* Free the IO buffer. */173 HGSMIHeapFree(&pCtx->heapCtx, p);174 }175 else176 rc = VERR_NO_MEMORY;177 LogFunc(("rc = %d\n", rc));178 return rc;179 }180 181 182 static int vboxHGSMIBufferLocation(PHGSMIGUESTCOMMANDCONTEXT pCtx,183 HGSMIOFFSET offLocation)184 {185 HGSMIBUFFERLOCATION *p;186 int rc = VINF_SUCCESS;187 188 /* Allocate the IO buffer. */189 p = (HGSMIBUFFERLOCATION *)HGSMIHeapAlloc(&pCtx->heapCtx,190 sizeof(HGSMIBUFFERLOCATION),191 HGSMI_CH_HGSMI,192 HGSMI_CC_HOST_FLAGS_LOCATION);193 if (p)194 {195 /* Prepare data to be sent to the host. */196 p->offLocation = offLocation;197 p->cbLocation = sizeof(HGSMIHOSTFLAGS);198 rc = vboxHGSMIBufferSubmit(pCtx, p);199 /* Free the IO buffer. */200 HGSMIHeapFree (&pCtx->heapCtx, p);201 }202 else203 rc = VERR_NO_MEMORY;204 return rc;205 }206 207 208 static int vboxHGSMISendCapsInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,209 uint32_t fCaps)210 {211 VBVACAPS *pCaps;212 int rc = VINF_SUCCESS;213 214 /* Allocate the IO buffer. */215 pCaps = (VBVACAPS *)HGSMIHeapAlloc(&pCtx->heapCtx,216 sizeof(VBVACAPS), HGSMI_CH_VBVA,217 VBVA_INFO_CAPS);218 219 if (pCaps)220 {221 /* Prepare data to be sent to the host. */222 pCaps->rc = VERR_NOT_IMPLEMENTED;223 pCaps->fCaps = fCaps;224 rc = vboxHGSMIBufferSubmit(pCtx, pCaps);225 if (RT_SUCCESS(rc))226 {227 AssertRC(pCaps->rc);228 rc = pCaps->rc;229 }230 /* Free the IO buffer. */231 HGSMIHeapFree(&pCtx->heapCtx, pCaps);232 }233 else234 rc = VERR_NO_MEMORY;235 return rc;236 }237 238 239 static int vboxVBVAInitInfoHeap(PHGSMIGUESTCOMMANDCONTEXT pCtx,240 uint32_t u32HeapOffset, uint32_t u32HeapSize)241 {242 VBVAINFOHEAP *p;243 int rc = VINF_SUCCESS;244 245 /* Allocate the IO buffer. */246 p = (VBVAINFOHEAP *)HGSMIHeapAlloc(&pCtx->heapCtx,247 sizeof (VBVAINFOHEAP), HGSMI_CH_VBVA,248 VBVA_INFO_HEAP);249 if (p)250 {251 /* Prepare data to be sent to the host. */252 p->u32HeapOffset = u32HeapOffset;253 p->u32HeapSize = u32HeapSize;254 rc = vboxHGSMIBufferSubmit(pCtx, p);255 /* Free the IO buffer. */256 HGSMIHeapFree(&pCtx->heapCtx, p);257 }258 else259 rc = VERR_NO_MEMORY;260 return rc;261 }262 263 264 int VBoxHGSMISendViewInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx, uint32_t u32Count,265 PFNHGSMIFILLVIEWINFO pfnFill, void *pvData)266 {267 int rc;268 /* Issue the screen info command. */269 void *p = vboxHGSMIBufferAlloc(pCtx, sizeof(VBVAINFOVIEW) * u32Count,270 HGSMI_CH_VBVA, VBVA_INFO_VIEW);271 if (p)272 {273 VBVAINFOVIEW *pInfo = (VBVAINFOVIEW *)p;274 rc = pfnFill(pvData, pInfo);275 if (RT_SUCCESS(rc))276 vboxHGSMIBufferSubmit (pCtx, p);277 vboxHGSMIBufferFree(pCtx, p);278 }279 else280 rc = VERR_NO_MEMORY;281 return rc;282 }283 284 285 /**286 * Get the information needed to map the basic communication structures in287 * device memory into our address space.288 *289 * @param cbVRAM how much video RAM is allocated to the device290 * @param poffVRAMBaseMapping where to save the offset from the start of the291 * device VRAM of the whole area to map292 * @param pcbMapping where to save the mapping size293 * @param poffGuestHeapMemory where to save the offset into the mapped area294 * of the guest heap backing memory295 * @param pcbGuestHeapMemory where to save the size of the guest heap296 * backing memory297 * @param poffHostFlags where to save the offset into the mapped area298 * of the host flags299 */300 void vboxHGSMIGetBaseMappingInfo(uint32_t cbVRAM,301 uint32_t *poffVRAMBaseMapping,302 uint32_t *pcbMapping,303 uint32_t *poffGuestHeapMemory,304 uint32_t *pcbGuestHeapMemory,305 uint32_t *poffHostFlags)306 {307 AssertPtrReturnVoid(poffVRAMBaseMapping);308 AssertPtrReturnVoid(pcbMapping);309 AssertPtrReturnVoid(poffGuestHeapMemory);310 AssertPtrReturnVoid(pcbGuestHeapMemory);311 AssertPtrReturnVoid(poffHostFlags);312 *poffVRAMBaseMapping = cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE;313 *pcbMapping = VBVA_ADAPTER_INFORMATION_SIZE;314 *poffGuestHeapMemory = 0;315 *pcbGuestHeapMemory = VBVA_ADAPTER_INFORMATION_SIZE - sizeof(HGSMIHOSTFLAGS);316 *poffHostFlags = VBVA_ADAPTER_INFORMATION_SIZE - sizeof(HGSMIHOSTFLAGS);317 }318 319 320 /**321 * Set up the HGSMI guest-to-host command context.322 * @returns iprt status value323 * @param pCtx the context to set up324 * @param pvGuestHeapMemory a pointer to the mapped backing memory for325 * the guest heap326 * @param cbGuestHeapMemory the size of the backing memory area327 * @param offVRAMGuestHeapMemory the offset of the memory pointed to by328 * @a pvGuestHeapMemory within the video RAM329 */330 int vboxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pCtx,331 void *pvGuestHeapMemory,332 uint32_t cbGuestHeapMemory,333 uint32_t offVRAMGuestHeapMemory)334 {335 /** @todo should we be using a fixed ISA port value here? */336 pCtx->port = (RTIOPORT)VGA_PORT_HGSMI_GUEST;337 return HGSMIHeapSetup(&pCtx->heapCtx, pvGuestHeapMemory,338 cbGuestHeapMemory, offVRAMGuestHeapMemory,339 false /*fOffsetBased*/);340 }341 342 343 /**344 * Get the information needed to map the area used by the host to send back345 * requests.346 *347 * @param pCtx the guest context used to query the host348 * @param cbVRAM how much video RAM is allocated to the device349 * @param offVRAMBaseMapping the offset of the basic communication structures350 * into the guest's VRAM351 * @param poffVRAMHostArea where to store the offset of the host area into352 * the guest's VRAM353 * @param pcbHostArea where to store the size of the host area354 */355 void vboxHGSMIGetHostAreaMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx,356 uint32_t cbVRAM, uint32_t offVRAMBaseMapping,357 uint32_t *poffVRAMHostArea,358 uint32_t *pcbHostArea)359 {360 uint32_t offVRAMHostArea = offVRAMBaseMapping, cbHostArea = 0;361 362 AssertPtrReturnVoid(poffVRAMHostArea);363 AssertPtrReturnVoid(pcbHostArea);364 vboxQueryConfHGSMI(pCtx, VBOX_VBVA_CONF32_HOST_HEAP_SIZE, &cbHostArea);365 if (cbHostArea != 0)366 {367 uint32_t cbHostAreaMaxSize = cbVRAM / 4;368 /** @todo what is the idea of this? */369 if (cbHostAreaMaxSize >= VBVA_ADAPTER_INFORMATION_SIZE)370 {371 cbHostAreaMaxSize -= VBVA_ADAPTER_INFORMATION_SIZE;372 }373 if (cbHostArea > cbHostAreaMaxSize)374 {375 cbHostArea = cbHostAreaMaxSize;376 }377 /* Round up to 4096 bytes. */378 cbHostArea = (cbHostArea + 0xFFF) & ~0xFFF;379 offVRAMHostArea = offVRAMBaseMapping - cbHostArea;380 }381 382 *pcbHostArea = cbHostArea;383 *poffVRAMHostArea = offVRAMHostArea;384 LogFunc(("offVRAMHostArea = 0x%08X, cbHostArea = 0x%08X\n",385 offVRAMHostArea, cbHostArea));386 }387 388 389 /** Initialise the host context structure. */390 void vboxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx,391 void *pvBaseMapping, uint32_t offHostFlags,392 void *pvHostAreaMapping,393 uint32_t offVRAMHostArea, uint32_t cbHostArea)394 {395 uint8_t *pu8HostFlags = ((uint8_t *)pvBaseMapping) + offHostFlags;396 pCtx->pfHostFlags = (HGSMIHOSTFLAGS *)pu8HostFlags;397 /** @todo should we really be using a fixed ISA port value here? */398 pCtx->port = (RTIOPORT)VGA_PORT_HGSMI_HOST;399 HGSMIAreaInitialize(&pCtx->areaCtx, pvHostAreaMapping, cbHostArea,400 offVRAMHostArea);401 }402 403 404 /**405 * Mirror the information in the host context structure to the host.406 */407 static int vboxHGSMISendHostCtxInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,408 HGSMIOFFSET offBufferLocation,409 uint32_t fCaps, uint32_t u32HeapOffset,410 uint32_t u32HeapSize)411 {412 Log(("VBoxVideo::vboxSetupAdapterInfo\n"));413 414 /* setup the flags first to ensure they are initialized by the time the415 * host heap is ready */416 int rc = vboxHGSMIBufferLocation(pCtx, offBufferLocation);417 AssertRC(rc);418 if (RT_SUCCESS(rc) && fCaps)419 {420 /* Inform about caps */421 rc = vboxHGSMISendCapsInfo(pCtx, fCaps);422 AssertRC(rc);423 }424 if (RT_SUCCESS (rc))425 {426 /* Report the host heap location. */427 rc = vboxVBVAInitInfoHeap(pCtx, u32HeapOffset, u32HeapSize);428 AssertRC(rc);429 }430 Log(("VBoxVideo::vboxSetupAdapterInfo finished rc = %d\n", rc));431 return rc;432 }433 434 435 /**436 * Returns the count of virtual monitors attached to the guest. Returns437 * 1 on failure.438 */439 unsigned vboxHGSMIGetMonitorCount(PHGSMIGUESTCOMMANDCONTEXT pCtx)440 {441 /* Query the configured number of displays. */442 uint32_t cDisplays = 0;443 vboxQueryConfHGSMI(pCtx, VBOX_VBVA_CONF32_MONITOR_COUNT, &cDisplays);444 LogFunc(("cDisplays = %d\n", cDisplays));445 if (cDisplays == 0 || cDisplays > VBOX_VIDEO_MAX_SCREENS)446 /* Host reported some bad value. Continue in the 1 screen mode. */447 cDisplays = 1;448 return cDisplays;449 }450 451 30 452 31 /** … … 479 58 if (pCommon->bHGSMI) 480 59 { 481 vboxHGSMIGetBaseMappingInfo(pCommon->cbVRAM, &offVRAMBaseMapping,60 VBoxHGSMIGetBaseMappingInfo(pCommon->cbVRAM, &offVRAMBaseMapping, 482 61 &cbMapping, &offGuestHeapMemory, 483 62 &cbGuestHeapMemory, &offHostFlags); … … 498 77 { 499 78 /* Setup an HGSMI heap within the adapter information area. */ 500 rc = vboxHGSMISetupGuestContext(&pCommon->guestCtx,79 rc = VBoxHGSMISetupGuestContext(&pCommon->guestCtx, 501 80 pCommon->pvAdapterInformation, 502 81 cbGuestHeapMemory, … … 517 96 if (pCommon->bHGSMI) 518 97 { 519 vboxHGSMIGetHostAreaMapping(&pCommon->guestCtx, pCommon->cbVRAM,98 VBoxHGSMIGetHostAreaMapping(&pCommon->guestCtx, pCommon->cbVRAM, 520 99 offVRAMBaseMapping, &offVRAMHostArea, 521 100 &cbHostArea); … … 539 118 } 540 119 else 541 vboxHGSMISetupHostContext(&pCommon->hostCtx,120 VBoxHGSMISetupHostContext(&pCommon->hostCtx, 542 121 pCommon->pvAdapterInformation, 543 122 offHostFlags, … … 556 135 { 557 136 /* Setup the information for the host. */ 558 rc = vboxHGSMISendHostCtxInfo(&pCommon->guestCtx,137 rc = VBoxHGSMISendHostCtxInfo(&pCommon->guestCtx, 559 138 offVRAMBaseMapping + offHostFlags, 560 139 fCaps, offVRAMHostArea, … … 570 149 if (pCommon->bHGSMI) 571 150 /* Query the configured number of displays. */ 572 pCommon->cDisplays = vboxHGSMIGetMonitorCount(&pCommon->guestCtx);151 pCommon->cDisplays = VBoxHGSMIGetMonitorCount(&pCommon->guestCtx); 573 152 574 153 if (!pCommon->bHGSMI) … … 596 175 } 597 176 598 599 bool vboxUpdatePointerShape(PHGSMIGUESTCOMMANDCONTEXT pCtx,600 uint32_t fFlags,601 uint32_t cHotX,602 uint32_t cHotY,603 uint32_t cWidth,604 uint32_t cHeight,605 uint8_t *pPixels,606 uint32_t cbLength)607 {608 VBVAMOUSEPOINTERSHAPE *p;609 uint32_t cbData = 0;610 int rc = VINF_SUCCESS;611 612 if (fFlags & VBOX_MOUSE_POINTER_SHAPE)613 {614 /* Size of the pointer data: sizeof (AND mask) + sizeof (XOR_MASK) */615 cbData = ((((cWidth + 7) / 8) * cHeight + 3) & ~3)616 + cWidth * 4 * cHeight;617 /* If shape is supplied, then always create the pointer visible.618 * See comments in 'vboxUpdatePointerShape'619 */620 fFlags |= VBOX_MOUSE_POINTER_VISIBLE;621 }622 #ifndef DEBUG_misha623 LogFunc(("cbData %d, %dx%d\n", cbData, cWidth, cHeight));624 #endif625 if (cbData > cbLength)626 {627 LogFunc(("calculated pointer data size is too big (%d bytes, limit %d)\n",628 cbData, cbLength));629 return false;630 }631 /* Allocate the IO buffer. */632 p = (VBVAMOUSEPOINTERSHAPE *)HGSMIHeapAlloc(&pCtx->heapCtx,633 sizeof(VBVAMOUSEPOINTERSHAPE)634 + cbData,635 HGSMI_CH_VBVA,636 VBVA_MOUSE_POINTER_SHAPE);637 if (p)638 {639 /* Prepare data to be sent to the host. */640 /* Will be updated by the host. */641 p->i32Result = VINF_SUCCESS;642 /* We have our custom flags in the field */643 p->fu32Flags = fFlags;644 p->u32HotX = cHotX;645 p->u32HotY = cHotY;646 p->u32Width = cWidth;647 p->u32Height = cHeight;648 if (p->fu32Flags & VBOX_MOUSE_POINTER_SHAPE)649 /* Copy the actual pointer data. */650 memcpy (p->au8Data, pPixels, cbData);651 rc = vboxHGSMIBufferSubmit(pCtx, p);652 if (RT_SUCCESS(rc))653 rc = p->i32Result;654 /* Free the IO buffer. */655 HGSMIHeapFree(&pCtx->heapCtx, p);656 }657 else658 rc = VERR_NO_MEMORY;659 #ifndef DEBUG_misha660 LogFunc(("rc %d\n", rc));661 #endif662 return RT_SUCCESS(rc);663 }664 177 665 178 #ifndef VBOX_WITH_WDDM … … 726 239 { 727 240 PHGSMIHOSTCOMMANDCONTEXT pCtx = &((PVBOXVIDEO_COMMON)hHGSMI)->hostCtx; 728 HGSMIHostCmdComplete(pCtx, pCmd);241 VBoxHGSMIHostCmdComplete(pCtx, pCmd); 729 242 } 730 243 … … 753 266 754 267 /* pick up the host commands */ 755 hgsmiProcessHostCommandQueue(pCtx);268 VBoxHGSMIProcessHostQueue(pCtx); 756 269 757 270 HGSMICHANNEL *pChannel = HGSMIChannelFindById (&pCtx->channels, u8Channel); … … 846 359 Assert(!pCur->u.pNext); 847 360 #endif 848 HGSMIHostCmdComplete(&pCallbacks->pCommon->hostCtx, pCur);361 VBoxHGSMIHostCmdComplete(&pCallbacks->pCommon->hostCtx, pCur); 849 362 #if 0 /* pNext is NULL, and the other things have already been asserted */ 850 363 pCur = pNext; … … 898 411 } 899 412 /* no handlers were found, need to complete the command here */ 900 HGSMIHostCmdComplete(&pCallbacks->pCommon->hostCtx, pvBuffer);413 VBoxHGSMIHostCmdComplete(&pCallbacks->pCommon->hostCtx, pvBuffer); 901 414 return VINF_SUCCESS; 902 415 } -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVbva.cpp
r34346 r34429 22 22 { 23 23 int rc = VERR_NO_MEMORY; 24 void *p = vboxHGSMIBufferAlloc (&commonFromDeviceExt(pDevExt)->guestCtx,24 void *p = VBoxHGSMIBufferAlloc (&commonFromDeviceExt(pDevExt)->guestCtx, 25 25 sizeof (VBVAENABLE_EX), 26 26 HGSMI_CH_VBVA, … … 43 43 pEnable->i32Result = VERR_NOT_SUPPORTED; 44 44 45 vboxHGSMIBufferSubmit (&commonFromDeviceExt(pDevExt)->guestCtx, p);45 VBoxHGSMIBufferSubmit (&commonFromDeviceExt(pDevExt)->guestCtx, p); 46 46 47 47 if (bEnable) … … 53 53 rc = VINF_SUCCESS; 54 54 55 vboxHGSMIBufferFree (&commonFromDeviceExt(pDevExt)->guestCtx, p);55 VBoxHGSMIBufferFree (&commonFromDeviceExt(pDevExt)->guestCtx, p); 56 56 } 57 57 return rc; … … 143 143 { 144 144 /* Issue the flush command. */ 145 void *p = vboxHGSMIBufferAlloc (&commonFromDeviceExt(pDevExt)->guestCtx,145 void *p = VBoxHGSMIBufferAlloc (&commonFromDeviceExt(pDevExt)->guestCtx, 146 146 sizeof (VBVAFLUSH), 147 147 HGSMI_CH_VBVA, … … 158 158 pFlush->u32Reserved = 0; 159 159 160 vboxHGSMIBufferSubmit (&commonFromDeviceExt(pDevExt)->guestCtx, p);161 162 vboxHGSMIBufferFree (&commonFromDeviceExt(pDevExt)->guestCtx, p);160 VBoxHGSMIBufferSubmit (&commonFromDeviceExt(pDevExt)->guestCtx, p); 161 162 VBoxHGSMIBufferFree (&commonFromDeviceExt(pDevExt)->guestCtx, p); 163 163 } 164 164 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVhwa.cpp
r34383 r34429 45 45 if(!cRefs) 46 46 { 47 vboxHGSMIBufferFree(&commonFromDeviceExt(pDevExt)->guestCtx, pCmd);47 VBoxHGSMIBufferFree(&commonFromDeviceExt(pDevExt)->guestCtx, pCmd); 48 48 } 49 49 } … … 61 61 vbvaVhwaCommandRetain(pDevExt, pCmd); 62 62 63 vboxHGSMIBufferSubmit(&commonFromDeviceExt(pDevExt)->guestCtx, pCmd);63 VBoxHGSMIBufferSubmit(&commonFromDeviceExt(pDevExt)->guestCtx, pCmd); 64 64 65 65 if(!(pCmd->Flags & VBOXVHWACMD_FLAG_HG_ASYNCH) … … 100 100 VBVA_VHWA_CMD); 101 101 #else 102 VBOXVHWACMD* pHdr = (VBOXVHWACMD*) vboxHGSMIBufferAlloc(&commonFromDeviceExt(pDevExt)->guestCtx,102 VBOXVHWACMD* pHdr = (VBOXVHWACMD*)VBoxHGSMIBufferAlloc(&commonFromDeviceExt(pDevExt)->guestCtx, 103 103 cbCmd + VBOXVHWACMD_HEADSIZE(), 104 104 HGSMI_CH_VBVA, … … 108 108 if (!pHdr) 109 109 { 110 drprintf((__FUNCTION__": vboxHGSMIBufferAlloc failed\n"));110 drprintf((__FUNCTION__": VBoxHGSMIBufferAlloc failed\n")); 111 111 } 112 112 else -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r34387 r34429 120 120 NTSTATUS vboxWddmGhDisplayPostInfoScreenBySDesc (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SURFACE_DESC pDesc, POINT * pVScreenPos, uint16_t fFlags) 121 121 { 122 void *p = vboxHGSMIBufferAlloc (&commonFromDeviceExt(pDevExt)->guestCtx,122 void *p = VBoxHGSMIBufferAlloc (&commonFromDeviceExt(pDevExt)->guestCtx, 123 123 sizeof (VBVAINFOSCREEN), 124 124 HGSMI_CH_VBVA, … … 139 139 pScreen->u16Flags = fFlags; 140 140 141 vboxHGSMIBufferSubmit (&commonFromDeviceExt(pDevExt)->guestCtx, p);142 143 vboxHGSMIBufferFree (&commonFromDeviceExt(pDevExt)->guestCtx, p);141 VBoxHGSMIBufferSubmit (&commonFromDeviceExt(pDevExt)->guestCtx, p); 142 143 VBoxHGSMIBufferFree (&commonFromDeviceExt(pDevExt)->guestCtx, p); 144 144 } 145 145 … … 163 163 164 164 /* Issue the screen info command. */ 165 void *p = vboxHGSMIBufferAlloc (&commonFromDeviceExt(pDevExt)->guestCtx,165 void *p = VBoxHGSMIBufferAlloc (&commonFromDeviceExt(pDevExt)->guestCtx, 166 166 sizeof (VBVAINFOVIEW), 167 167 HGSMI_CH_VBVA, … … 178 178 pView->u32MaxScreenSize = pView->u32ViewSize; 179 179 180 vboxHGSMIBufferSubmit (&commonFromDeviceExt(pDevExt)->guestCtx, p);181 182 vboxHGSMIBufferFree (&commonFromDeviceExt(pDevExt)->guestCtx, p);180 VBoxHGSMIBufferSubmit (&commonFromDeviceExt(pDevExt)->guestCtx, p); 181 182 VBoxHGSMIBufferFree (&commonFromDeviceExt(pDevExt)->guestCtx, p); 183 183 } 184 184 … … 953 953 if (bOur) 954 954 { 955 HGSMIClearIrq(&commonFromDeviceExt(pDevExt)->hostCtx);955 VBoxHGSMIClearIrq(&commonFromDeviceExt(pDevExt)->hostCtx); 956 956 #ifdef DEBUG_misha 957 957 /* this is not entirely correct since host may concurrently complete some commands and raise a new IRQ while we are here,
Note:
See TracChangeset
for help on using the changeset viewer.