Changeset 80632 in vbox
- Timestamp:
- Sep 6, 2019 4:35:14 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/hgcmsvc.h
r80396 r80632 37 37 #include <iprt/err.h> 38 38 #ifdef IN_RING3 39 # include <iprt/mem.h> 40 # include <VBox/err.h> 39 41 # include <VBox/vmm/stam.h> 40 42 # include <VBox/vmm/dbgf.h> 43 # include <VBox/vmm/ssm.h> 41 44 #endif 42 45 #ifdef VBOX_TEST_HGCM_PARMS … … 453 456 #endif 454 457 458 #ifdef IN_RING3 459 /** 460 * Puts (serializes) a VBOXHGCMSVCPARM struct into SSM. 461 * 462 * @returns VBox status code. 463 * @param pParm VBOXHGCMSVCPARM to serialize. 464 * @param pSSM SSM handle to serialize to. 465 */ 466 DECLINLINE(int) HGCMSvcSSMR3Put(VBOXHGCMSVCPARM *pParm, PSSMHANDLE pSSM) 467 { 468 AssertPtrReturn(pParm, VERR_INVALID_POINTER); 469 AssertPtrReturn(pSSM, VERR_INVALID_POINTER); 470 471 int rc = SSMR3PutU32(pSSM, sizeof(VBOXHGCMSVCPARM)); 472 AssertRCReturn(rc, rc); 473 rc = SSMR3PutU32(pSSM, pParm->type); 474 AssertRCReturn(rc, rc); 475 476 switch (pParm->type) 477 { 478 case VBOX_HGCM_SVC_PARM_32BIT: 479 rc = SSMR3PutU32(pSSM, pParm->u.uint32); 480 break; 481 case VBOX_HGCM_SVC_PARM_64BIT: 482 rc = SSMR3PutU32(pSSM, pParm->u.uint64); 483 break; 484 case VBOX_HGCM_SVC_PARM_PTR: 485 rc = SSMR3PutU32(pSSM, pParm->u.pointer.size); 486 if (RT_SUCCESS(rc)) 487 rc = SSMR3PutMem(pSSM, pParm->u.pointer.addr, pParm->u.pointer.size); 488 break; 489 default: 490 AssertMsgFailed(("Paramter type %RU32 not implemented yet\n", pParm->type)); 491 rc = VERR_NOT_IMPLEMENTED; 492 break; 493 } 494 495 return rc; 496 } 497 498 /** 499 * Gets (loads) a VBOXHGCMSVCPARM struct from SSM. 500 * 501 * @returns VBox status code. 502 * @param pParm VBOXHGCMSVCPARM to load into. Must be initialied (zero-ed) properly. 503 * @param pSSM SSM handle to load from. 504 */ 505 DECLINLINE(int) HGCMSvcSSMR3Get(VBOXHGCMSVCPARM *pParm, PSSMHANDLE pSSM) 506 { 507 AssertPtrReturn(pParm, VERR_INVALID_POINTER); 508 AssertPtrReturn(pSSM, VERR_INVALID_POINTER); 509 510 uint32_t cbParm; 511 int rc = SSMR3GetU32(pSSM, &cbParm); 512 AssertRCReturn(rc, rc); 513 AssertReturn(cbParm == sizeof(VBOXHGCMSVCPARM), VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 514 515 rc = SSMR3GetU32(pSSM, &pParm->type); 516 AssertRCReturn(rc, rc); 517 518 switch (pParm->type) 519 { 520 case VBOX_HGCM_SVC_PARM_32BIT: 521 { 522 rc = SSMR3GetU32(pSSM, &pParm->u.uint32); 523 AssertRCReturn(rc, rc); 524 break; 525 } 526 527 case VBOX_HGCM_SVC_PARM_64BIT: 528 { 529 rc = SSMR3GetU64(pSSM, &pParm->u.uint64); 530 AssertRCReturn(rc, rc); 531 break; 532 } 533 534 case VBOX_HGCM_SVC_PARM_PTR: 535 { 536 AssertMsgReturn(pParm->u.pointer.size == 0, 537 ("Pointer size parameter already in use (or not initialized)\n"), VERR_INVALID_PARAMETER); 538 539 rc = SSMR3GetU32(pSSM, &pParm->u.pointer.size); 540 AssertRCReturn(rc, rc); 541 542 AssertMsgReturn(pParm->u.pointer.addr == NULL, 543 ("Pointer parameter already in use (or not initialized)\n"), VERR_INVALID_PARAMETER); 544 545 pParm->u.pointer.addr = RTMemAlloc(pParm->u.pointer.size); 546 AssertPtrReturn(pParm->u.pointer.addr, VERR_NO_MEMORY); 547 rc = SSMR3GetMem(pSSM, pParm->u.pointer.addr, pParm->u.pointer.size); 548 549 AssertRCReturn(rc, rc); 550 break; 551 } 552 553 default: 554 AssertMsgFailed(("Paramter type %RU32 not implemented yet\n", pParm->type)); 555 rc = VERR_NOT_IMPLEMENTED; 556 break; 557 } 558 559 return VINF_SUCCESS; 560 } 561 #endif /* IN_RING3 */ 562 455 563 typedef VBOXHGCMSVCPARM *PVBOXHGCMSVCPARM; 456 564
Note:
See TracChangeset
for help on using the changeset viewer.