Changeset 21102 in vbox
- Timestamp:
- Jun 30, 2009 7:38:12 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 49365
- Location:
- trunk/src/VBox/Additions/common/VBoxGuest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c
r21095 r21102 669 669 670 670 /** 671 * Asynchronous notification activation method. 672 * 673 * @returns 0 on success, negative errno on failure. 674 * 675 * @param fd The file descriptor. 676 * @param pFile The file structure. 677 * @param fOn On/off indicator. 678 */ 679 static int vboxguestFAsync(int fd, struct file *pFile, int fOn) 680 { 681 return fasync_helper(fd, pFile, fOn, &g_pFAsyncQueue); 682 } 683 684 685 /** 671 686 * Poll function. 672 687 * … … 678 693 * @param pFile The file structure. 679 694 * @param pPt The poll table. 695 * 696 * @remarks This is probably not really used, X11 is said to use the fasync 697 * interface instead. 680 698 */ 681 699 static unsigned int vboxguestPoll(struct file *pFile, poll_table *pPt) … … 686 704 ? POLLIN | POLLRDNORM 687 705 : 0; 688 #if 1 /** @todo this isn't quite right... but it's what we used to do. */689 pSession->u32MousePosChangedSeq = u32CurSeq;690 #endif691 706 poll_wait(pFile, &g_PollEventQueue, pPt); 692 707 return fMask; 693 }694 695 696 /**697 * Asynchronous notification activation method.698 *699 * @returns 0 on success, negative errno on failure.700 *701 * @param fd The file descriptor.702 * @param pFile The file structure.703 * @param fOn On/off indicator.704 */705 static int vboxguestFAsync(int fd, struct file *pFile, int fOn)706 {707 return fasync_helper(fd, pFile, fOn, &g_pFAsyncQueue);708 708 } 709 709 … … 718 718 * @param cbRead The max number of bytes to read. 719 719 * @param poff The current file position. 720 * 721 * @remarks This is probably not really used as X11 lets the driver do its own 722 * event reading. The poll condition is therefore also cleared when we 723 * see VMMDevReq_GetMouseStatus in VBoxGuestCommonIOCtl_VMMRequest. 720 724 */ 721 725 static ssize_t vboxguestRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff) 722 726 { 727 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pFile->private_data; 728 uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq); 729 723 730 if (*poff != 0) 724 731 return -EINVAL; 725 732 726 if (cbRead > 0) 727 { 728 /* Indicate that we're up to speed. */ 729 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pFile->private_data; 730 uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq); 733 /* 734 * Fake a single byte read if we're not up to date with the current mouse position. 735 */ 736 if ( pSession->u32MousePosChangedSeq != u32CurSeq 737 && cbRead > 0) 738 { 731 739 pSession->u32MousePosChangedSeq = u32CurSeq; 732 733 740 pbBuf[0] = 0; 734 741 return 1; 735 742 } 736 737 #if 1 /** @todo This is wrong, see man 2 read. Does it server any purpose? */738 return -EINVAL;739 #else740 743 return 0; 741 #endif742 744 } 743 745 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r21095 r21102 747 747 748 748 749 static int VBoxGuestCommonIOCtl_VMMRequest(PVBOXGUESTDEVEXT pDevExt, VMMDevRequestHeader *pReqHdr,750 size_t cbData, size_t *pcbDataReturned)749 static int VBoxGuestCommonIOCtl_VMMRequest(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, 750 VMMDevRequestHeader *pReqHdr, size_t cbData, size_t *pcbDataReturned) 751 751 { 752 752 Log(("VBoxGuestCommonIOCtl: VMMREQUEST type %d\n", pReqHdr->requestType)); … … 755 755 * Validate the header and request size. 756 756 */ 757 const uint32_t cbReq = pReqHdr->size; 758 const uint32_t cbMinSize = vmmdevGetRequestSize(pReqHdr->requestType); 757 const VMMDevRequestType enmType = pReqHdr->requestType; 758 const uint32_t cbReq = pReqHdr->size; 759 const uint32_t cbMinSize = vmmdevGetRequestSize(enmType); 759 760 if (cbReq < cbMinSize) 760 761 { 761 762 Log(("VBoxGuestCommonIOCtl: VMMREQUEST: invalid hdr size %#x, expected >= %#x; type=%#x!!\n", 762 cbReq, cbMinSize, pReqHdr->requestType));763 cbReq, cbMinSize, enmType)); 763 764 return VERR_INVALID_PARAMETER; 764 765 } … … 766 767 { 767 768 Log(("VBoxGuestCommonIOCtl: VMMREQUEST: invalid size %#x, expected >= %#x (hdr); type=%#x!!\n", 768 cbData, cbReq, pReqHdr->requestType));769 cbData, cbReq, enmType)); 769 770 return VERR_INVALID_PARAMETER; 770 771 } … … 778 779 */ 779 780 VMMDevRequestHeader *pReqCopy; 780 int rc = VbglGRAlloc(&pReqCopy, cbReq, pReqHdr->requestType);781 int rc = VbglGRAlloc(&pReqCopy, cbReq, enmType); 781 782 if (RT_FAILURE(rc)) 782 783 { … … 785 786 return rc; 786 787 } 787 788 788 memcpy(pReqCopy, pReqHdr, cbReq); 789 790 if (enmType == VMMDevReq_GetMouseStatus) /* clear poll condition. */ 791 pSession->u32MousePosChangedSeq = ASMAtomicUoReadU32(&pDevExt->u32MousePosChangedSeq); 792 789 793 rc = VbglGRPerform(pReqCopy); 790 794 if ( RT_SUCCESS(rc) … … 1269 1273 { 1270 1274 CHECKRET_MIN_SIZE("VMMREQUEST", sizeof(VMMDevRequestHeader)); 1271 rc = VBoxGuestCommonIOCtl_VMMRequest(pDevExt, (VMMDevRequestHeader *)pvData, cbData, pcbDataReturned);1275 rc = VBoxGuestCommonIOCtl_VMMRequest(pDevExt, pSession, (VMMDevRequestHeader *)pvData, cbData, pcbDataReturned); 1272 1276 } 1273 1277 #ifdef VBOX_WITH_HGCM
Note:
See TracChangeset
for help on using the changeset viewer.