Changeset 68848 in vbox for trunk/src/VBox/Additions/common/VBoxVideo
- Timestamp:
- Sep 24, 2017 4:58:46 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 118102
- Location:
- trunk/src/VBox/Additions/common/VBoxVideo
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxVideo/HGSMIBase.cpp
r67145 r68848 26 26 */ 27 27 28 #include <HGSMIBase.h> 29 #include <VBoxVideoIPRT.h> 28 30 #include <VBoxVideoGuest.h> 29 31 #include <VBoxVideoVBE.h> 30 #include <VBoxVideoIPRT.h> 32 #include <HGSMIChannels.h> 33 #include <HGSMIChSetup.h> 31 34 32 35 /** Detect whether HGSMI is supported by the host. */ … … 45 48 46 49 /** 47 * Inform the host of the location of the host flags in VRAM via an HGSMI 48 * command. 50 * Inform the host of the location of the host flags in VRAM via an HGSMI command. 49 51 * @returns IPRT status value. 50 52 * @returns VERR_NOT_IMPLEMENTED if the host does not support the command. 51 53 * @returns VERR_NO_MEMORY if a heap allocation fails. 52 54 * @param pCtx the context of the guest heap to use. 53 * @param offLocation the offset chosen for the flags withing guest 54 * VRAM. 55 */ 56 DECLHIDDEN(int) VBoxHGSMIReportFlagsLocation(PHGSMIGUESTCOMMANDCONTEXT pCtx, 57 HGSMIOFFSET offLocation) 55 * @param offLocation the offset chosen for the flags withing guest VRAM. 56 */ 57 DECLHIDDEN(int) VBoxHGSMIReportFlagsLocation(PHGSMIGUESTCOMMANDCONTEXT pCtx, HGSMIOFFSET offLocation) 58 58 { 59 59 HGSMIBUFFERLOCATION *p; 60 int rc = VINF_SUCCESS; 61 62 /* Allocate the IO buffer. */ 63 p = (HGSMIBUFFERLOCATION *)VBoxHGSMIBufferAlloc(pCtx, 64 sizeof(HGSMIBUFFERLOCATION), 65 HGSMI_CH_HGSMI, 66 HGSMI_CC_HOST_FLAGS_LOCATION); 67 if (p) 68 { 69 /* Prepare data to be sent to the host. */ 70 p->offLocation = offLocation; 71 p->cbLocation = sizeof(HGSMIHOSTFLAGS); 72 rc = VBoxHGSMIBufferSubmit(pCtx, p); 73 /* Free the IO buffer. */ 74 VBoxHGSMIBufferFree(pCtx, p); 75 } 76 else 77 rc = VERR_NO_MEMORY; 78 return rc; 60 61 /* Allocate the IO buffer. */ 62 p = (HGSMIBUFFERLOCATION *)VBoxHGSMIBufferAlloc(pCtx, sizeof(*p), HGSMI_CH_HGSMI, 63 HGSMI_CC_HOST_FLAGS_LOCATION); 64 if (!p) 65 return VERR_NO_MEMORY; 66 67 /* Prepare data to be sent to the host. */ 68 p->offLocation = offLocation; 69 p->cbLocation = sizeof(HGSMIHOSTFLAGS); 70 /* No need to check that the buffer is valid as we have just allocated it. */ 71 VBoxHGSMIBufferSubmit(pCtx, p); 72 /* Free the IO buffer. */ 73 VBoxHGSMIBufferFree(pCtx, p); 74 75 return VINF_SUCCESS; 79 76 } 80 77 … … 88 85 * @param fCaps the capabilities to report, see VBVACAPS. 89 86 */ 90 DECLHIDDEN(int) VBoxHGSMISendCapsInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx, 91 uint32_t fCaps) 92 { 93 VBVACAPS *pCaps; 94 int rc = VINF_SUCCESS; 95 96 /* Allocate the IO buffer. */ 97 pCaps = (VBVACAPS *)VBoxHGSMIBufferAlloc(pCtx, 98 sizeof(VBVACAPS), HGSMI_CH_VBVA, 99 VBVA_INFO_CAPS); 100 101 if (pCaps) 102 { 103 /* Prepare data to be sent to the host. */ 104 pCaps->rc = VERR_NOT_IMPLEMENTED; 105 pCaps->fCaps = fCaps; 106 rc = VBoxHGSMIBufferSubmit(pCtx, pCaps); 107 if (RT_SUCCESS(rc)) 108 { 109 AssertRC(pCaps->rc); 110 rc = pCaps->rc; 111 } 112 /* Free the IO buffer. */ 113 VBoxHGSMIBufferFree(pCtx, pCaps); 114 } 115 else 116 rc = VERR_NO_MEMORY; 117 return rc; 87 DECLHIDDEN(int) VBoxHGSMISendCapsInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx, uint32_t fCaps) 88 { 89 VBVACAPS *p; 90 91 /* Allocate the IO buffer. */ 92 p = (VBVACAPS *)VBoxHGSMIBufferAlloc(pCtx, sizeof(*p), HGSMI_CH_VBVA, VBVA_INFO_CAPS); 93 94 if (!p) 95 return VERR_NO_MEMORY; 96 97 /* Prepare data to be sent to the host. */ 98 p->rc = VERR_NOT_IMPLEMENTED; 99 p->fCaps = fCaps; 100 /* No need to check that the buffer is valid as we have just allocated it. */ 101 VBoxHGSMIBufferSubmit(pCtx, p); 102 103 AssertRC(p->rc); 104 /* Free the IO buffer. */ 105 VBoxHGSMIBufferFree(pCtx, p); 106 return p->rc; 118 107 } 119 108 … … 160 149 } 161 150 162 163 /** Sanity test on first call. We do not worry about concurrency issues. */164 static int testQueryConf(PHGSMIGUESTCOMMANDCONTEXT pCtx)165 {166 static bool cOnce = false;167 uint32_t ulValue = 0;168 int rc;169 170 if (cOnce)171 return VINF_SUCCESS;172 cOnce = true;173 rc = VBoxQueryConfHGSMI(pCtx, UINT32_MAX, &ulValue);174 if (RT_SUCCESS(rc) && ulValue == UINT32_MAX)175 return VINF_SUCCESS;176 cOnce = false;177 if (RT_FAILURE(rc))178 return rc;179 return VERR_INTERNAL_ERROR;180 }181 182 183 151 /** 184 152 * Query the host for an HGSMI configuration parameter via an HGSMI command. … … 187 155 * @param u32Index the index of the parameter to query, 188 156 * @see VBVACONF32::u32Index 189 * @param u32DefValue defaut value190 157 * @param pulValue where to store the value of the parameter on success 191 158 */ 192 DECLHIDDEN(int) VBoxQueryConfHGSMIDef(PHGSMIGUESTCOMMANDCONTEXT pCtx, 193 uint32_t u32Index, uint32_t u32DefValue, uint32_t *pulValue) 194 { 195 int rc = VINF_SUCCESS; 159 DECLHIDDEN(int) VBoxQueryConfHGSMI(PHGSMIGUESTCOMMANDCONTEXT pCtx, uint32_t u32Index, uint32_t *pulValue) 160 { 196 161 VBVACONF32 *p; 197 // LogFunc(("u32Index = %d\n", u32Index)); 198 199 rc = testQueryConf(pCtx); 200 if (RT_FAILURE(rc)) 201 return rc; 202 /* Allocate the IO buffer. */ 203 p = (VBVACONF32 *)VBoxHGSMIBufferAlloc(pCtx, 204 sizeof(VBVACONF32), HGSMI_CH_VBVA, 205 VBVA_QUERY_CONF32); 206 if (p) 207 { 208 /* Prepare data to be sent to the host. */ 209 p->u32Index = u32Index; 210 p->u32Value = u32DefValue; 211 rc = VBoxHGSMIBufferSubmit(pCtx, p); 212 if (RT_SUCCESS(rc)) 213 { 214 *pulValue = p->u32Value; 215 // LogFunc(("u32Value = %d\n", p->u32Value)); 216 } 217 /* Free the IO buffer. */ 218 VBoxHGSMIBufferFree(pCtx, p); 219 } 220 else 221 rc = VERR_NO_MEMORY; 222 // LogFunc(("rc = %d\n", rc)); 223 return rc; 224 } 225 226 DECLHIDDEN(int) VBoxQueryConfHGSMI(PHGSMIGUESTCOMMANDCONTEXT pCtx, 227 uint32_t u32Index, uint32_t *pulValue) 228 { 229 return VBoxQueryConfHGSMIDef(pCtx, u32Index, UINT32_MAX, pulValue); 162 163 /* Allocate the IO buffer. */ 164 p = (VBVACONF32 *)VBoxHGSMIBufferAlloc(pCtx, sizeof(*p), HGSMI_CH_VBVA, 165 VBVA_QUERY_CONF32); 166 if (!p) 167 return VERR_NO_MEMORY; 168 169 /* Prepare data to be sent to the host. */ 170 p->u32Index = u32Index; 171 p->u32Value = UINT32_MAX; 172 /* No need to check that the buffer is valid as we have just allocated it. */ 173 VBoxHGSMIBufferSubmit(pCtx, p); 174 *pulValue = p->u32Value; 175 /* Free the IO buffer. */ 176 VBoxHGSMIBufferFree(pCtx, p); 177 return VINF_SUCCESS; 230 178 } 231 179 … … 243 191 * @param cbLength size in bytes of the pixel data 244 192 */ 245 DECLHIDDEN(int) VBoxHGSMIUpdatePointerShape(PHGSMIGUESTCOMMANDCONTEXT pCtx, 246 uint32_t fFlags, 247 uint32_t cHotX, 248 uint32_t cHotY, 249 uint32_t cWidth, 250 uint32_t cHeight, 251 uint8_t *pPixels, 252 uint32_t cbLength) 193 DECLHIDDEN(int) VBoxHGSMIUpdatePointerShape(PHGSMIGUESTCOMMANDCONTEXT pCtx, uint32_t fFlags, 194 uint32_t cHotX, uint32_t cHotY, uint32_t cWidth, uint32_t cHeight, 195 uint8_t *pPixels, uint32_t cbLength) 253 196 { 254 197 VBVAMOUSEPOINTERSHAPE *p; 255 uint32_t cb Data= 0;256 int rc = VINF_SUCCESS;198 uint32_t cbPixels = 0; 199 int rc; 257 200 258 201 if (fFlags & VBOX_MOUSE_POINTER_SHAPE) 259 202 { 260 /* Size of the pointer data: sizeof (AND mask) + sizeof (XOR_MASK) */ 261 cbData = ((((cWidth + 7) / 8) * cHeight + 3) & ~3) 203 /* 204 * Size of the pointer data: 205 * sizeof (AND mask) + sizeof (XOR_MASK) 206 */ 207 cbPixels = ((((cWidth + 7) / 8) * cHeight + 3) & ~3) 262 208 + cWidth * 4 * cHeight; 263 /* If shape is supplied, then always create the pointer visible. 209 if (cbPixels > cbLength) 210 return VERR_INVALID_PARAMETER; 211 /* 212 * If shape is supplied, then always create the pointer visible. 264 213 * See comments in 'vboxUpdatePointerShape' 265 214 */ 266 215 fFlags |= VBOX_MOUSE_POINTER_VISIBLE; 267 216 } 268 // LogFlowFunc(("cbData %d, %dx%d\n", cbData, cWidth, cHeight)); 269 if (cbData > cbLength) 270 { 271 // LogFunc(("calculated pointer data size is too big (%d bytes, limit %d)\n", 272 // cbData, cbLength)); 273 return VERR_INVALID_PARAMETER; 274 } 275 /* Allocate the IO buffer. */ 276 p = (VBVAMOUSEPOINTERSHAPE *)VBoxHGSMIBufferAlloc(pCtx, 277 sizeof(VBVAMOUSEPOINTERSHAPE) 278 + cbData, 279 HGSMI_CH_VBVA, 280 VBVA_MOUSE_POINTER_SHAPE); 281 if (p) 282 { 283 /* Prepare data to be sent to the host. */ 284 /* Will be updated by the host. */ 285 p->i32Result = VINF_SUCCESS; 286 /* We have our custom flags in the field */ 287 p->fu32Flags = fFlags; 288 p->u32HotX = cHotX; 289 p->u32HotY = cHotY; 290 p->u32Width = cWidth; 291 p->u32Height = cHeight; 292 if (p->fu32Flags & VBOX_MOUSE_POINTER_SHAPE) 293 /* Copy the actual pointer data. */ 294 memcpy (p->au8Data, pPixels, cbData); 295 rc = VBoxHGSMIBufferSubmit(pCtx, p); 296 if (RT_SUCCESS(rc)) 297 rc = p->i32Result; 298 /* Free the IO buffer. */ 299 VBoxHGSMIBufferFree(pCtx, p); 300 } 301 else 302 rc = VERR_NO_MEMORY; 303 // LogFlowFunc(("rc %d\n", rc)); 217 /* Allocate the IO buffer. */ 218 p = (VBVAMOUSEPOINTERSHAPE *)VBoxHGSMIBufferAlloc(pCtx, sizeof(*p) + cbPixels, HGSMI_CH_VBVA, 219 VBVA_MOUSE_POINTER_SHAPE); 220 if (!p) 221 return VERR_NO_MEMORY; 222 /* Prepare data to be sent to the host. */ 223 /* Will be updated by the host. */ 224 p->i32Result = VINF_SUCCESS; 225 /* We have our custom flags in the field */ 226 p->fu32Flags = fFlags; 227 p->u32HotX = cHotX; 228 p->u32HotY = cHotY; 229 p->u32Width = cWidth; 230 p->u32Height = cHeight; 231 if (cbPixels) 232 /* Copy the actual pointer data. */ 233 memcpy (p->au8Data, pPixels, cbPixels); 234 /* No need to check that the buffer is valid as we have just allocated it. */ 235 VBoxHGSMIBufferSubmit(pCtx, p); 236 rc = p->i32Result; 237 /* Free the IO buffer. */ 238 VBoxHGSMIBufferFree(pCtx, p); 304 239 return rc; 305 240 } … … 319 254 * @returns VERR_NO_MEMORY HGSMI heap allocation failed. 320 255 */ 321 DECLHIDDEN(int) VBoxHGSMICursorPosition(PHGSMIGUESTCOMMANDCONTEXT pCtx, bool fReportPosition, uint32_t x, uint32_t y, 322 uint32_t *pxHost, uint32_t *pyHost) 323 { 324 int rc = VINF_SUCCESS; 256 DECLHIDDEN(int) VBoxHGSMICursorPosition(PHGSMIGUESTCOMMANDCONTEXT pCtx, bool fReportPosition, 257 uint32_t x, uint32_t y, uint32_t *pxHost, uint32_t *pyHost) 258 { 325 259 VBVACURSORPOSITION *p; 326 // Log(("%s: x=%u, y=%u\n", __PRETTY_FUNCTION__, (unsigned)x, (unsigned)y)); 327 328 /* Allocate the IO buffer. */ 329 p = (VBVACURSORPOSITION *)VBoxHGSMIBufferAlloc(pCtx, sizeof(VBVACURSORPOSITION), HGSMI_CH_VBVA, VBVA_CURSOR_POSITION); 330 if (p) 331 { 332 /* Prepare data to be sent to the host. */ 333 p->fReportPosition = fReportPosition ? 1 : 0; 334 p->x = x; 335 p->y = y; 336 rc = VBoxHGSMIBufferSubmit(pCtx, p); 337 if (RT_SUCCESS(rc)) 338 { 339 if (pxHost) 340 *pxHost = p->x; 341 if (pyHost) 342 *pyHost = p->y; 343 // Log(("%s: return: x=%u, y=%u\n", __PRETTY_FUNCTION__, (unsigned)p->x, (unsigned)p->y)); 344 } 345 /* Free the IO buffer. */ 346 VBoxHGSMIBufferFree(pCtx, p); 347 } 348 else 349 rc = VERR_NO_MEMORY; 350 // LogFunc(("rc = %d\n", rc)); 351 return rc; 352 } 353 354 355 /** @todo Mouse pointer position to be read from VMMDev memory, address of the memory region 356 * can be queried from VMMDev via an IOCTL. This VMMDev memory region will contain 357 * host information which is needed by the guest. 260 261 /* Allocate the IO buffer. */ 262 p = (VBVACURSORPOSITION *)VBoxHGSMIBufferAlloc(pCtx, sizeof(*p), HGSMI_CH_VBVA, 263 VBVA_CURSOR_POSITION); 264 if (!p) 265 return VERR_NO_MEMORY; 266 /* Prepare data to be sent to the host. */ 267 p->fReportPosition = fReportPosition; 268 p->x = x; 269 p->y = y; 270 /* No need to check that the buffer is valid as we have just allocated it. */ 271 VBoxHGSMIBufferSubmit(pCtx, p); 272 if (pxHost) 273 *pxHost = p->x; 274 if (pyHost) 275 *pyHost = p->y; 276 /* Free the IO buffer. */ 277 VBoxHGSMIBufferFree(pCtx, p); 278 return VINF_SUCCESS; 279 } 280 281 282 /** 283 * @todo Mouse pointer position to be read from VMMDev memory, address of the 284 * memory region can be queried from VMMDev via an IOCTL. This VMMDev memory 285 * region will contain host information which is needed by the guest. 358 286 * 359 287 * Reading will not cause a switch to the host. … … 366 294 * the page readonly for the guest. 367 295 * * the information should be available only for additions drivers. 368 * * VMMDev additions driver will inform the host which version of the info it expects, 369 * host must support all versions. 370 * 371 */ 296 * * VMMDev additions driver will inform the host which version of the info 297 * it expects, host must support all versions. 298 */ -
trunk/src/VBox/Additions/common/VBoxVideo/Modesetting.cpp
r67268 r68848 29 29 #include <VBoxVideoGuest.h> 30 30 #include <VBoxVideoVBE.h> 31 #include <HGSMIChannels.h> 31 32 32 33 #ifndef VBOX_GUESTR3XF86MOD … … 384 385 { 385 386 uint32_t u32Flags = 0; 386 int rc = VBoxQueryConfHGSMI Def(pCtx, VBOX_VBVA_CONF32_SCREEN_FLAGS, 0, &u32Flags);387 int rc = VBoxQueryConfHGSMI(pCtx, VBOX_VBVA_CONF32_SCREEN_FLAGS, &u32Flags); 387 388 // LogFunc(("u32Flags = 0x%x rc %Rrc\n", u32Flags, rc)); 388 if (RT_FAILURE(rc) )389 if (RT_FAILURE(rc) || u32Flags > UINT16_MAX) 389 390 u32Flags = 0; 390 391 return (uint16_t)u32Flags; -
trunk/src/VBox/Additions/common/VBoxVideo/VBVABase.cpp
r66544 r68848 29 29 #include <VBoxVideoGuest.h> 30 30 #include <VBoxVideoIPRT.h> 31 #include <HGSMIChannels.h> 31 32 32 33 /*
Note:
See TracChangeset
for help on using the changeset viewer.