- Timestamp:
- Mar 20, 2012 1:46:33 PM (13 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxGuest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris-streams.c
r40533 r40550 222 222 * absolute mouse position reporting. 223 223 */ 224 unsignedcMaxScreenX;224 int cMaxScreenX; 225 225 /* The current greatest vertical pixel offset on the screen, used for 226 226 * absolute mouse position reporting. 227 227 */ 228 unsignedcMaxScreenY;228 int cMaxScreenY; 229 229 } VBGR0STATE, *PVBGR0STATE; 230 230 … … 541 541 542 542 #ifdef TESTCASE 543 /* Constants, definitions and test functions for testWPut. */ 544 static const int g_ccTestWPutFirmEvent = VUID_FIRM_EVENT; 545 # define PVGFORMAT (&g_ccTestWPutFirmEvent) 546 # define CBGFORMAT (sizeof(g_ccTestWPutFirmEvent)) 547 static const Ms_screen_resolution g_TestResolution = { 640, 480 }; 548 # define PMSIOSRES (&g_TestResolution) 549 # define CBMSIOSRES (sizeof(g_TestResolution)) 550 551 static inline void testSetResolution(RTTEST hTest, queue_t *pWriteQueue, 552 struct msgb *pMBlk) 553 { 554 PVBGR0STATE pState = (PVBGR0STATE)pWriteQueue->q_ptr; 555 RTTEST_CHECK_MSG(hTest, pState->cMaxScreenX 556 == g_TestResolution.width - 1, 557 (hTest, "pState->cMaxScreenX=%d\n", pState->cMaxScreenX)); 558 RTTEST_CHECK_MSG(hTest, pState->cMaxScreenY 559 == g_TestResolution.height - 1, 560 (hTest, "pState->cMaxScreenY=%d\n", pState->cMaxScreenY)); 561 } 562 563 /** Data table for testWPut. */ 564 static struct 565 { 566 unsigned char iDBType; 567 int iIOCCmd; 568 size_t cbData; 569 const void *pvDataIn; 570 size_t cbDataIn; 571 const void *pvDataOut; 572 size_t cbDataOut; 573 int rcExp; 574 void (*pfnExtra)(RTTEST hTest, queue_t *pWriteQueue, struct msgb *pMBlk); 575 } g_asTestWPut[] = 576 { 577 /* iDBType iIOCCmd cbData pvDataIn cbDataIn 578 pvDataOut cbDataOut rcExp pfnExtra */ 579 { M_IOCTL, VUIDGFORMAT, sizeof(int), NULL, 0, 580 PVGFORMAT, CBGFORMAT, 0, NULL }, 581 { M_IOCTL, VUIDSFORMAT, sizeof(int), PVGFORMAT, CBGFORMAT, 582 NULL, 0, 0, NULL }, 583 { M_IOCTL, MSIOSRESOLUTION, CBMSIOSRES, PMSIOSRES, CBMSIOSRES, 584 NULL, 0, 0, testSetResolution } 585 }; 586 587 # undef PVGFORMAT 588 # undef CBGFORMAT 589 # undef PMSIOSRES 590 # undef CBMSIOSRES 591 543 592 /** Test WPut's handling of different IOCtls, which is bulk of the logic in 544 593 * this file. */ … … 551 600 struct iocblk IOCBlk; 552 601 int rc, cFormat = 0; 602 unsigned i; 553 603 554 604 /* Single simple test to start with. We can try to make it more systematic 555 605 * next. */ 556 606 RTTestSub(hTest, "Testing vbgr0WPut"); 557 RT_ZERO(aQueues); 558 doInitQueues(&aQueues[0]); 559 rc = vbgr0SolOpen(RD(&aQueues[0]), &device, 0, 0, NULL); 560 RTTEST_CHECK(hTest, rc == 0); 561 RTTEST_CHECK(hTest, g_aOpenNodeStates[1].pWriteQueue == WR(&aQueues[0])); 562 RT_ZERO(MBlk); 563 RT_ZERO(DBlk); 564 RT_ZERO(IOCBlk); 565 RT_ZERO(MBlkCont); 566 DBlk.db_type = M_IOCTL; 567 IOCBlk.ioc_cmd = VUIDSFORMAT; 568 IOCBlk.ioc_count = sizeof(int); 569 MBlkCont.b_rptr = (unsigned char *)&cFormat; 570 MBlkCont.b_rptr = (unsigned char *)&cFormat + sizeof(cFormat); 571 MBlk.b_cont = &MBlkCont; 572 MBlk.b_rptr = (unsigned char *)&IOCBlk; 573 MBlkCont.b_rptr = (unsigned char *)&IOCBlk + sizeof(IOCBlk); 574 MBlk.b_datap = &DBlk; 575 rc = vbgr0SolWPut(WR(&aQueues[0]), &MBlk); 576 RTTEST_CHECK(hTest, rc == 0); 577 vbgr0SolClose(RD(&aQueues[1]), 0, NULL); 607 for (i = 0; i < RT_ELEMENTS(g_asTestWPut); ++i) 608 { 609 unsigned char acData[1024]; 610 611 RT_ZERO(aQueues); 612 doInitQueues(&aQueues[0]); 613 rc = vbgr0SolOpen(RD(&aQueues[0]), &device, 0, 0, NULL); 614 RTTEST_CHECK_MSG(hTest, rc == 0, (hTest, "i=%u, rc=%d\n", i, rc)); 615 RTTEST_CHECK_MSG(hTest, g_aOpenNodeStates[1].pWriteQueue 616 == WR(&aQueues[0]), (hTest, "i=%u\n", i)); 617 RT_ZERO(MBlk); 618 RT_ZERO(DBlk); 619 RT_ZERO(IOCBlk); 620 RT_ZERO(MBlkCont); 621 DBlk.db_type = g_asTestWPut[i].iDBType; 622 IOCBlk.ioc_cmd = g_asTestWPut[i].iIOCCmd; 623 IOCBlk.ioc_count = g_asTestWPut[i].cbData; 624 AssertReturnVoid(g_asTestWPut[i].cbDataIn <= sizeof(acData)); 625 memcpy(acData, g_asTestWPut[i].pvDataIn, g_asTestWPut[i].cbDataIn); 626 MBlkCont.b_rptr = acData; 627 MBlkCont.b_wptr = acData + g_asTestWPut[i].cbDataIn; 628 MBlk.b_cont = &MBlkCont; 629 MBlk.b_rptr = (unsigned char *)&IOCBlk; 630 MBlk.b_wptr = (unsigned char *)&IOCBlk + sizeof(IOCBlk); 631 MBlk.b_datap = &DBlk; 632 rc = vbgr0SolWPut(WR(&aQueues[0]), &MBlk); 633 RTTEST_CHECK_MSG(hTest, rc == g_asTestWPut[i].rcExp, 634 (hTest, "i=%u, rc=%d\n", i, rc)); 635 RTTEST_CHECK_MSG(hTest, IOCBlk.ioc_count == g_asTestWPut[i].cbDataOut, 636 (hTest, "i=%u, ioc_count=%u\n", i, IOCBlk.ioc_count)); 637 RTTEST_CHECK_MSG(hTest, !memcmp(acData, g_asTestWPut[i].pvDataOut, 638 g_asTestWPut[i].cbDataOut), 639 (hTest, "i=%u\n", i)); 640 if (g_asTestWPut[i].pfnExtra) 641 g_asTestWPut[i].pfnExtra(hTest, WR(&aQueues[0]), &MBlk); 642 vbgr0SolClose(RD(&aQueues[1]), 0, NULL); 643 } 578 644 } 579 645 #endif … … 599 665 * IOCtl handler function. 600 666 * @returns 0 on success, error code on failure. 601 * @param cCmd The IOCtl command number.667 * @param iCmd The IOCtl command number. 602 668 * @param pvData Buffer for the user data. 603 669 * @param cbBuffer Size of the buffer in @a pvData or zero. … … 608 674 * implemention. 609 675 */ 610 typedef int FNVBGR0SOLIOCTL(PVBGR0STATE pState, int cCmd, void *pvData,676 typedef int FNVBGR0SOLIOCTL(PVBGR0STATE pState, int iCmd, void *pvData, 611 677 size_t cbBuffer, size_t *pcbData, int *prc); 612 678 typedef FNVBGR0SOLIOCTL *PFNVBGR0SOLIOCTL; … … 615 681 static int vbgr0SolHandleIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 616 682 PFNVBGR0SOLIOCTL pfnHandler, 617 int cCmd, size_t cbTransparent,683 int iCmd, size_t cbTransparent, 618 684 enum IOCTLDIRECTION enmDirection); 619 static int vbgr0SolVUIDIOCtl(PVBGR0STATE pState, int cCmd, void *pvData,685 static int vbgr0SolVUIDIOCtl(PVBGR0STATE pState, int iCmd, void *pvData, 620 686 size_t cbBuffer, size_t *pcbData, int *prc); 621 static int vbgr0SolGuestIOCtl(PVBGR0STATE pState, int cCmd, void *pvData,687 static int vbgr0SolGuestIOCtl(PVBGR0STATE pState, int iCmd, void *pvData, 622 688 size_t cbBuffer, size_t *pcbData, int *prc); 623 689 … … 626 692 { 627 693 /** The IOCtl number. */ 628 int cCmd;694 int iCmd; 629 695 /** The size of the buffer which needs to be copied between user and kernel 630 696 * space, or zero if unknown (must be known for tranparent IOCtls). */ … … 660 726 { 661 727 struct iocblk *pIOCBlk = (struct iocblk *)pMBlk->b_rptr; 662 int cCmd = pIOCBlk->ioc_cmd, cCmdType = (cCmd >> 8)& ~0xff;728 int iCmd = pIOCBlk->ioc_cmd, iCmdType = iCmd & ~0xff; 663 729 size_t cbBuffer; 664 730 enum IOCTLDIRECTION enmDirection; 665 731 666 LogFlowFunc((DEVICE_NAME ":: cCmdType=%c, cCmd=%d\n", cCmdType, cCmd));667 switch ( cCmdType)732 LogFlowFunc((DEVICE_NAME "::iCmdType=%c, iCmd=%d\n", iCmdType, iCmd)); 733 switch (iCmdType) 668 734 { 669 735 case MSIOC: … … 673 739 674 740 for (i = 0; i < RT_ELEMENTS(g_aVUIDIOCtlDescriptions); ++i) 675 if (g_aVUIDIOCtlDescriptions[i]. cCmd == cCmd)741 if (g_aVUIDIOCtlDescriptions[i].iCmd == iCmd) 676 742 { 677 743 cbBuffer = g_aVUIDIOCtlDescriptions[i].cbBuffer; 678 744 enmDirection = g_aVUIDIOCtlDescriptions[i].enmDirection; 679 745 return vbgr0SolHandleIOCtl(pWriteQueue, pMBlk, 680 vbgr0SolVUIDIOCtl, cCmd,746 vbgr0SolVUIDIOCtl, iCmd, 681 747 cbBuffer, enmDirection); 682 748 } 683 749 return EINVAL; 684 750 } 685 case 'V' :751 case 'V' << 8: 686 752 return vbgr0SolHandleIOCtl(pWriteQueue, pMBlk, vbgr0SolGuestIOCtl, 687 cCmd, 0, UNSPECIFIED);753 iCmd, 0, UNSPECIFIED); 688 754 default: 689 755 return ENOTTY; … … 694 760 /* Helpers for vbgr0SolHandleIOCtl. */ 695 761 static int vbgr0SolHandleIOCtlData(queue_t *pWriteQueue, mblk_t *pMBlk, 696 PFNVBGR0SOLIOCTL pfnHandler, int cCmd,762 PFNVBGR0SOLIOCTL pfnHandler, int iCmd, 697 763 size_t cbTransparent, 698 764 enum IOCTLDIRECTION enmDirection); … … 700 766 static int vbgr0SolHandleTransparentIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 701 767 PFNVBGR0SOLIOCTL pfnHandler, 702 int cCmd, size_t cbTransparent,768 int iCmd, size_t cbTransparent, 703 769 enum IOCTLDIRECTION enmDirection); 704 770 705 771 static int vbgr0SolHandleIStrIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 706 PFNVBGR0SOLIOCTL pfnHandler, int cCmd);772 PFNVBGR0SOLIOCTL pfnHandler, int iCmd); 707 773 708 774 /** … … 719 785 * @param pfnHandler pointer to the right IOCtl handler function for this 720 786 * IOCtl number. 721 * @param cCmd IOCtl command number.787 * @param iCmd IOCtl command number. 722 788 * @param cbTransparent size of the user space buffer for this IOCtl number, 723 789 * used for processing transparent IOCtls. Pass zero … … 728 794 */ 729 795 static int vbgr0SolHandleIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 730 PFNVBGR0SOLIOCTL pfnHandler, int cCmd,796 PFNVBGR0SOLIOCTL pfnHandler, int iCmd, 731 797 size_t cbTransparent, 732 798 enum IOCTLDIRECTION enmDirection) … … 736 802 737 803 if (pMBlk->b_datap->db_type == M_IOCDATA) 738 return vbgr0SolHandleIOCtlData(pWriteQueue, pMBlk, pfnHandler, cCmd,804 return vbgr0SolHandleIOCtlData(pWriteQueue, pMBlk, pfnHandler, iCmd, 739 805 cbTransparent, enmDirection); 740 806 else if ( pMBlk->b_datap->db_type == M_IOCTL 741 807 && pIOCBlk->ioc_count == TRANSPARENT) 742 808 return vbgr0SolHandleTransparentIOCtl(pWriteQueue, pMBlk, pfnHandler, 743 cCmd, cbTransparent,809 iCmd, cbTransparent, 744 810 enmDirection); 745 811 else if (pMBlk->b_datap->db_type == M_IOCTL) 746 return vbgr0SolHandleIStrIOCtl(pWriteQueue, pMBlk, pfnHandler, cCmd);812 return vbgr0SolHandleIStrIOCtl(pWriteQueue, pMBlk, pfnHandler, iCmd); 747 813 return EINVAL; 748 814 } … … 756 822 */ 757 823 static int vbgr0SolHandleIOCtlData(queue_t *pWriteQueue, mblk_t *pMBlk, 758 PFNVBGR0SOLIOCTL pfnHandler, int cCmd,824 PFNVBGR0SOLIOCTL pfnHandler, int iCmd, 759 825 size_t cbTransparent, 760 826 enum IOCTLDIRECTION enmDirection) … … 781 847 return EINVAL; 782 848 pvData = pMBlk->b_cont->b_rptr; 783 err = pfnHandler(pState, cCmd, pvData, cbTransparent, &cbData, NULL);849 err = pfnHandler(pState, iCmd, pvData, cbTransparent, &cbData, NULL); 784 850 if (!err && enmDirection == BOTH) 785 851 mcopyout(pMBlk, NULL, cbData, pCopyResp->cp_private, NULL); … … 803 869 */ 804 870 int vbgr0SolHandleTransparentIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 805 PFNVBGR0SOLIOCTL pfnHandler, int cCmd,871 PFNVBGR0SOLIOCTL pfnHandler, int iCmd, 806 872 size_t cbTransparent, 807 873 enum IOCTLDIRECTION enmDirection) … … 830 896 return EAGAIN; 831 897 pvData = pMBlkOut->b_rptr; 832 err = pfnHandler(pState, cCmd, pvData, cbTransparent, &cbData, NULL);898 err = pfnHandler(pState, iCmd, pvData, cbTransparent, &cbData, NULL); 833 899 if (!err) 834 900 mcopyout(pMBlk, NULL, cbData, NULL, pMBlkOut); … … 839 905 { 840 906 AssertReturn(enmDirection == NONE, EINVAL); 841 err = pfnHandler(pState, cCmd, NULL, 0, NULL, &rc);907 err = pfnHandler(pState, iCmd, NULL, 0, NULL, &rc); 842 908 if (!err) 843 909 miocack(pWriteQueue, pMBlk, 0, rc); … … 852 918 */ 853 919 static int vbgr0SolHandleIStrIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 854 PFNVBGR0SOLIOCTL pfnHandler, int cCmd)920 PFNVBGR0SOLIOCTL pfnHandler, int iCmd) 855 921 { 856 922 struct iocblk *pIOCBlk = (struct iocblk *)pMBlk->b_rptr; … … 871 937 pvData = pMBlk->b_cont->b_rptr; 872 938 } 873 err = pfnHandler(pState, cCmd, pvData, cbBuffer, &cbData, &rc);939 err = pfnHandler(pState, iCmd, pvData, cbBuffer, &cbData, &rc); 874 940 if (!err) 875 941 miocack(pWriteQueue, pMBlk, cbData, rc); … … 882 948 * @copydoc FNVBGR0SOLIOCTL 883 949 */ 884 static int vbgr0SolVUIDIOCtl(PVBGR0STATE pState, int cCmd, void *pvData,950 static int vbgr0SolVUIDIOCtl(PVBGR0STATE pState, int iCmd, void *pvData, 885 951 size_t cbBuffer, size_t *pcbData, int *prc) 886 952 { 887 953 LogFlowFunc((DEVICE_NAME ":: " /* no '\n' */)); 888 switch ( cCmd)954 switch (iCmd) 889 955 { 890 956 case VUIDGFORMAT: … … 960 1026 return EINVAL; 961 1027 default: 962 LogFlowFunc(("Invalid IOCtl command %x\n", cCmd));1028 LogFlowFunc(("Invalid IOCtl command %x\n", iCmd)); 963 1029 return EINVAL; 964 1030 } … … 970 1036 * @copydoc FNVBGR0SOLIOCTL 971 1037 */ 972 static int vbgr0SolGuestIOCtl(PVBGR0STATE pState, int cCmd, void *pvData,1038 static int vbgr0SolGuestIOCtl(PVBGR0STATE pState, int iCmd, void *pvData, 973 1039 size_t cbBuffer, size_t *pcbData, int *prc) 974 1040 { 975 int rc = VBoxGuestCommonIOCtl( cCmd, &g_DevExt, pState->pSession, pvData, cbBuffer, pcbData);1041 int rc = VBoxGuestCommonIOCtl(iCmd, &g_DevExt, pState->pSession, pvData, cbBuffer, pcbData); 976 1042 if (RT_SUCCESS(rc)) 977 1043 { … … 986 1052 * which are not really failures that require logging. 987 1053 */ 988 Log((DEVICE_NAME "::IOCtl: VBoxGuestCommonIOCtl failed. Cmd=%#x rc=%d\n", cCmd, rc));1054 Log((DEVICE_NAME "::IOCtl: VBoxGuestCommonIOCtl failed. Cmd=%#x rc=%d\n", iCmd, rc)); 989 1055 rc = RTErrConvertToErrno(rc); 990 1056 return rc; -
trunk/src/VBox/Additions/common/VBoxGuest/testcase/solaris.h
r40533 r40550 322 322 #define flushq(...) do {} while(0) 323 323 #define qreply(...) do {} while(0) 324 #define miocack(...) do {} while(0)325 #define miocnak(...) do {} while(0)326 324 #define mcopyin(...) do {} while(0) 327 325 #define mcopyout(...) do {} while(0) … … 388 386 } 389 387 388 static inline void miocack(queue_t *pWriteQueue, mblk_t *pMBlk, int cbData, 389 int rc) 390 { 391 struct iocblk *pIOCBlk = (struct iocblk *)pMBlk->b_rptr; 392 393 pMBlk->b_datap->db_type = M_IOCACK; 394 pIOCBlk->ioc_count = cbData; 395 pIOCBlk->ioc_error = 0; 396 pIOCBlk->ioc_rval = rc; 397 qreply(pWriteQueue, pMBlk); 398 } 399 400 static inline void miocnak(queue_t *pWriteQueue, mblk_t *pMBlk, int cbData, 401 int iErr) 402 { 403 struct iocblk *pIOCBlk = (struct iocblk *)pMBlk->b_rptr; 404 405 pMBlk->b_datap->db_type = M_IOCNAK; 406 pIOCBlk->ioc_count = cbData; 407 pIOCBlk->ioc_error = iErr; 408 qreply(pWriteQueue, pMBlk); 409 } 410 390 411 /* API stubs with controllable logic */ 391 412
Note:
See TracChangeset
for help on using the changeset viewer.