Changeset 49591 in vbox for trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
- Timestamp:
- Nov 20, 2013 5:53:55 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
r49476 r49591 3056 3056 * NOTE: it is ALWAYS responsibility of the crVBoxServerCrHgsmiCmd to complete the command! 3057 3057 * */ 3058 static int32_t crVBoxServerC rHgsmiCmdProcess(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, bool fCompleteNeeded)3058 static int32_t crVBoxServerCmdVbvaCrCmdProcess(struct VBOXCMDVBVA_CRCMD_CMD *pCmd) 3059 3059 { 3060 3060 int32_t rc; … … 3070 3070 { 3071 3071 crWarning("g_pvVRamBase is not initialized"); 3072 if (!fCompleteNeeded) 3073 return VERR_INVALID_STATE; 3074 3075 crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_STATE); 3076 return VINF_SUCCESS; 3072 return VERR_INVALID_STATE; 3077 3073 } 3078 3074 … … 3080 3076 { 3081 3077 crWarning("zero buffers passed in!"); 3082 if (!fCompleteNeeded) 3083 return VERR_INVALID_PARAMETER; 3084 3085 crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER); 3086 return VINF_SUCCESS; 3078 return VERR_INVALID_PARAMETER; 3087 3079 } 3088 3080 … … 3094 3086 { 3095 3087 crWarning("invalid header buffer!"); 3096 if (!fCompleteNeeded) 3097 return VERR_INVALID_PARAMETER; 3098 3099 crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER); 3100 return VINF_SUCCESS; 3088 return VERR_INVALID_PARAMETER; 3101 3089 } 3102 3090 … … 3104 3092 { 3105 3093 crWarning("invalid header buffer size!"); 3106 if (!fCompleteNeeded) 3107 return VERR_INVALID_PARAMETER; 3108 3109 crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER); 3110 return VINF_SUCCESS; 3094 return VERR_INVALID_PARAMETER; 3111 3095 } 3112 3096 … … 3124 3108 { 3125 3109 CRVBOXHGSMIWRITE* pFnCmd = (CRVBOXHGSMIWRITE*)pHdr; 3126 VBOX VDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];3110 VBOXCMDVBVA_CRCMD_BUFFER *pBuf = &pCmd->aBuffers[1]; 3127 3111 /* Fetch parameters. */ 3128 3112 uint32_t cbBuffer = pBuf->cbBuffer; … … 3156 3140 pClient->conn->pBuffer = pBuffer; 3157 3141 pClient->conn->cbBuffer = cbBuffer; 3158 CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, f CompleteNeeded);3142 CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, false); 3159 3143 rc = crVBoxServerInternalClientWriteRead(pClient); 3160 3144 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData); … … 3180 3164 /* Fetch parameters. */ 3181 3165 uint32_t u32InjectClientID = pFnCmd->u32ClientID; 3182 VBOX VDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];3166 VBOXCMDVBVA_CRCMD_BUFFER *pBuf = &pCmd->aBuffers[1]; 3183 3167 uint32_t cbBuffer = pBuf->cbBuffer; 3184 3168 uint8_t *pBuffer = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t); … … 3211 3195 pClient->conn->pBuffer = pBuffer; 3212 3196 pClient->conn->cbBuffer = cbBuffer; 3213 CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, fCompleteNeeded); 3197 CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, false); 3198 rc = crVBoxServerInternalClientWriteRead(pClient); 3199 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData); 3200 return rc; 3201 } 3202 3203 crWarning("invalid number of args"); 3204 rc = VERR_INVALID_PARAMETER; 3205 break; 3206 } 3207 3208 case SHCRGL_GUEST_FN_READ: 3209 { 3210 Log(("svcCall: SHCRGL_GUEST_FN_READ\n")); 3211 3212 /* @todo: Verify */ 3213 if (cParams == 1) 3214 { 3215 CRVBOXHGSMIREAD *pFnCmd = (CRVBOXHGSMIREAD*)pHdr; 3216 VBOXCMDVBVA_CRCMD_BUFFER *pBuf = &pCmd->aBuffers[1]; 3217 /* Fetch parameters. */ 3218 uint32_t cbBuffer = pBuf->cbBuffer; 3219 uint8_t *pBuffer = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t); 3220 3221 if (cbHdr < sizeof (*pFnCmd)) 3222 { 3223 crWarning("invalid read cmd buffer size!"); 3224 rc = VERR_INVALID_PARAMETER; 3225 break; 3226 } 3227 3228 3229 if (!pBuffer) 3230 { 3231 crWarning("invalid buffer data received from guest!"); 3232 rc = VERR_INVALID_PARAMETER; 3233 break; 3234 } 3235 3236 rc = crVBoxServerClientGet(u32ClientID, &pClient); 3237 if (RT_FAILURE(rc)) 3238 { 3239 break; 3240 } 3241 3242 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData); 3243 3244 rc = crVBoxServerInternalClientRead(pClient, pBuffer, &cbBuffer); 3245 3246 /* Return the required buffer size always */ 3247 pFnCmd->cbBuffer = cbBuffer; 3248 3249 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData); 3250 3251 /* the read command is never pended, complete it right away */ 3252 pHdr->result = rc; 3253 3254 return VINF_SUCCESS; 3255 } 3256 3257 crWarning("invalid number of args"); 3258 rc = VERR_INVALID_PARAMETER; 3259 break; 3260 } 3261 3262 case SHCRGL_GUEST_FN_WRITE_READ: 3263 { 3264 Log(("svcCall: SHCRGL_GUEST_FN_WRITE_READ\n")); 3265 3266 /* @todo: Verify */ 3267 if (cParams == 2) 3268 { 3269 CRVBOXHGSMIWRITEREAD *pFnCmd = (CRVBOXHGSMIWRITEREAD*)pHdr; 3270 VBOXCMDVBVA_CRCMD_BUFFER *pBuf = &pCmd->aBuffers[1]; 3271 VBOXCMDVBVA_CRCMD_BUFFER *pWbBuf = &pCmd->aBuffers[2]; 3272 3273 /* Fetch parameters. */ 3274 uint32_t cbBuffer = pBuf->cbBuffer; 3275 uint8_t *pBuffer = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t); 3276 3277 uint32_t cbWriteback = pWbBuf->cbBuffer; 3278 char *pWriteback = VBOXCRHGSMI_PTR_SAFE(pWbBuf->offBuffer, cbWriteback, char); 3279 3280 if (cbHdr < sizeof (*pFnCmd)) 3281 { 3282 crWarning("invalid write_read cmd buffer size!"); 3283 rc = VERR_INVALID_PARAMETER; 3284 break; 3285 } 3286 3287 3288 CRASSERT(cbBuffer); 3289 if (!pBuffer) 3290 { 3291 crWarning("invalid write buffer data received from guest!"); 3292 rc = VERR_INVALID_PARAMETER; 3293 break; 3294 } 3295 3296 CRASSERT(cbWriteback); 3297 if (!pWriteback) 3298 { 3299 crWarning("invalid writeback buffer data received from guest!"); 3300 rc = VERR_INVALID_PARAMETER; 3301 break; 3302 } 3303 rc = crVBoxServerClientGet(u32ClientID, &pClient); 3304 if (RT_FAILURE(rc)) 3305 { 3306 pHdr->result = rc; 3307 return VINF_SUCCESS; 3308 } 3309 3310 /* This should never fire unless we start to multithread */ 3311 CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0); 3312 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData); 3313 3314 pClient->conn->pBuffer = pBuffer; 3315 pClient->conn->cbBuffer = cbBuffer; 3316 CRVBOXHGSMI_CMDDATA_SETWB(&pClient->conn->CmdData, pCmd, pHdr, pWriteback, cbWriteback, &pFnCmd->cbWriteback, false); 3317 rc = crVBoxServerInternalClientWriteRead(pClient); 3318 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData); 3319 return rc; 3320 } 3321 3322 crWarning("invalid number of args"); 3323 rc = VERR_INVALID_PARAMETER; 3324 break; 3325 } 3326 3327 case SHCRGL_GUEST_FN_SET_VERSION: 3328 { 3329 crWarning("invalid function"); 3330 rc = VERR_NOT_IMPLEMENTED; 3331 break; 3332 } 3333 3334 case SHCRGL_GUEST_FN_SET_PID: 3335 { 3336 crWarning("invalid function"); 3337 rc = VERR_NOT_IMPLEMENTED; 3338 break; 3339 } 3340 3341 default: 3342 { 3343 crWarning("invalid function"); 3344 rc = VERR_NOT_IMPLEMENTED; 3345 break; 3346 } 3347 3348 } 3349 3350 /* we can be on fail only here */ 3351 CRASSERT(RT_FAILURE(rc)); 3352 pHdr->result = rc; 3353 3354 return rc; 3355 } 3356 3357 3358 int32_t crVBoxServerCrHgsmiCmd(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, uint32_t cbCmd) 3359 { 3360 3361 int32_t rc; 3362 uint32_t cBuffers = pCmd->cBuffers; 3363 uint32_t cParams; 3364 uint32_t cbHdr; 3365 CRVBOXHGSMIHDR *pHdr; 3366 uint32_t u32Function; 3367 uint32_t u32ClientID; 3368 CRClient *pClient; 3369 3370 if (!g_pvVRamBase) 3371 { 3372 crWarning("g_pvVRamBase is not initialized"); 3373 3374 crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_STATE); 3375 return VINF_SUCCESS; 3376 } 3377 3378 if (!cBuffers) 3379 { 3380 crWarning("zero buffers passed in!"); 3381 3382 crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER); 3383 return VINF_SUCCESS; 3384 } 3385 3386 cParams = cBuffers-1; 3387 3388 cbHdr = pCmd->aBuffers[0].cbBuffer; 3389 pHdr = VBOXCRHGSMI_PTR_SAFE(pCmd->aBuffers[0].offBuffer, cbHdr, CRVBOXHGSMIHDR); 3390 if (!pHdr) 3391 { 3392 crWarning("invalid header buffer!"); 3393 3394 crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER); 3395 return VINF_SUCCESS; 3396 } 3397 3398 if (cbHdr < sizeof (*pHdr)) 3399 { 3400 crWarning("invalid header buffer size!"); 3401 3402 crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER); 3403 return VINF_SUCCESS; 3404 } 3405 3406 u32Function = pHdr->u32Function; 3407 u32ClientID = pHdr->u32ClientID; 3408 3409 switch (u32Function) 3410 { 3411 case SHCRGL_GUEST_FN_WRITE: 3412 { 3413 Log(("svcCall: SHCRGL_GUEST_FN_WRITE\n")); 3414 3415 /* @todo: Verify */ 3416 if (cParams == 1) 3417 { 3418 CRVBOXHGSMIWRITE* pFnCmd = (CRVBOXHGSMIWRITE*)pHdr; 3419 VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1]; 3420 /* Fetch parameters. */ 3421 uint32_t cbBuffer = pBuf->cbBuffer; 3422 uint8_t *pBuffer = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t); 3423 3424 if (cbHdr < sizeof (*pFnCmd)) 3425 { 3426 crWarning("invalid write cmd buffer size!"); 3427 rc = VERR_INVALID_PARAMETER; 3428 break; 3429 } 3430 3431 CRASSERT(cbBuffer); 3432 if (!pBuffer) 3433 { 3434 crWarning("invalid buffer data received from guest!"); 3435 rc = VERR_INVALID_PARAMETER; 3436 break; 3437 } 3438 3439 rc = crVBoxServerClientGet(u32ClientID, &pClient); 3440 if (RT_FAILURE(rc)) 3441 { 3442 break; 3443 } 3444 3445 /* This should never fire unless we start to multithread */ 3446 CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0); 3447 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData); 3448 3449 pClient->conn->pBuffer = pBuffer; 3450 pClient->conn->cbBuffer = cbBuffer; 3451 CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, true); 3452 rc = crVBoxServerInternalClientWriteRead(pClient); 3453 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData); 3454 return rc; 3455 } 3456 else 3457 { 3458 crWarning("invalid number of args"); 3459 rc = VERR_INVALID_PARAMETER; 3460 break; 3461 } 3462 break; 3463 } 3464 3465 case SHCRGL_GUEST_FN_INJECT: 3466 { 3467 Log(("svcCall: SHCRGL_GUEST_FN_INJECT\n")); 3468 3469 /* @todo: Verify */ 3470 if (cParams == 1) 3471 { 3472 CRVBOXHGSMIINJECT *pFnCmd = (CRVBOXHGSMIINJECT*)pHdr; 3473 /* Fetch parameters. */ 3474 uint32_t u32InjectClientID = pFnCmd->u32ClientID; 3475 VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1]; 3476 uint32_t cbBuffer = pBuf->cbBuffer; 3477 uint8_t *pBuffer = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t); 3478 3479 if (cbHdr < sizeof (*pFnCmd)) 3480 { 3481 crWarning("invalid inject cmd buffer size!"); 3482 rc = VERR_INVALID_PARAMETER; 3483 break; 3484 } 3485 3486 CRASSERT(cbBuffer); 3487 if (!pBuffer) 3488 { 3489 crWarning("invalid buffer data received from guest!"); 3490 rc = VERR_INVALID_PARAMETER; 3491 break; 3492 } 3493 3494 rc = crVBoxServerClientGet(u32InjectClientID, &pClient); 3495 if (RT_FAILURE(rc)) 3496 { 3497 break; 3498 } 3499 3500 /* This should never fire unless we start to multithread */ 3501 CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0); 3502 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData); 3503 3504 pClient->conn->pBuffer = pBuffer; 3505 pClient->conn->cbBuffer = cbBuffer; 3506 CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, true); 3214 3507 rc = crVBoxServerInternalClientWriteRead(pClient); 3215 3508 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData); … … 3267 3560 /* the read command is never pended, complete it right away */ 3268 3561 pHdr->result = rc; 3269 3270 if (!fCompleteNeeded)3271 return VINF_SUCCESS;3272 3562 3273 3563 crServerCrHgsmiCmdComplete(pCmd, VINF_SUCCESS); … … 3335 3625 pClient->conn->pBuffer = pBuffer; 3336 3626 pClient->conn->cbBuffer = cbBuffer; 3337 CRVBOXHGSMI_CMDDATA_SETWB(&pClient->conn->CmdData, pCmd, pHdr, pWriteback, cbWriteback, &pFnCmd->cbWriteback, fCompleteNeeded);3627 CRVBOXHGSMI_CMDDATA_SETWB(&pClient->conn->CmdData, pCmd, pHdr, pWriteback, cbWriteback, &pFnCmd->cbWriteback, true); 3338 3628 rc = crVBoxServerInternalClientWriteRead(pClient); 3339 3629 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData); … … 3373 3663 pHdr->result = rc; 3374 3664 3375 if (!fCompleteNeeded)3376 return rc;3377 3378 3665 crServerCrHgsmiCmdComplete(pCmd, VINF_SUCCESS); 3379 3666 return rc; 3380 } 3381 3382 int32_t crVBoxServerCrHgsmiCmd(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, uint32_t cbCmd) 3383 { 3384 return crVBoxServerCrHgsmiCmdProcess(pCmd, true); 3667 3385 3668 } 3386 3669 … … 3433 3716 { 3434 3717 VBOXCMDVBVA_CRCMD *pCrCmdDr = (VBOXCMDVBVA_CRCMD*)pCmd; 3435 VBOXCMDVBVAOFFSET offCmd = pCrCmdDr->offCmd; 3436 if (offCmd < g_cbVRam && offCmd + cbCmd < g_cbVRam) 3718 VBOXCMDVBVA_CRCMD_CMD *pCrCmd = &pCrCmdDr->Cmd; 3719 int rc = crVBoxServerCmdVbvaCrCmdProcess(pCrCmd); 3720 if (RT_SUCCESS(rc)) 3437 3721 { 3438 VBOXVDMACMD_CHROMIUM_CMD *pCrCmd = (VBOXVDMACMD_CHROMIUM_CMD*)(g_pvVRamBase + offCmd); 3439 crVBoxServerCrHgsmiCmdProcess(pCrCmd, false); 3440 /* success */ 3722 /* success */ 3441 3723 pCmd->i8Result = 0; 3442 3724 } 3443 3725 else 3444 3726 { 3445 crWarning(" incorrect command info!");3727 crWarning("crVBoxServerCmdVbvaCrCmdProcess failed, rc %d", rc); 3446 3728 pCmd->i8Result = -1; 3447 3729 }
Note:
See TracChangeset
for help on using the changeset viewer.