- Timestamp:
- Jun 30, 2009 6:54:01 PM (16 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxGuest
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c
r21069 r21095 41 41 #include "the-linux-kernel.h" 42 42 #include <linux/miscdevice.h> 43 #include <linux/poll.h> 43 44 #include "version-generated.h" 44 45 45 46 #include <iprt/assert.h> 47 #include <iprt/asm.h> 48 #include <iprt/err.h> 49 #include <iprt/initterm.h> 50 #include <iprt/mem.h> 51 #include <iprt/mp.h> 52 #include <iprt/process.h> 46 53 #include <iprt/spinlock.h> 47 54 #include <iprt/semaphore.h> 48 #include <iprt/initterm.h>49 #include <iprt/process.h>50 #include <iprt/err.h>51 #include <iprt/mem.h>52 55 #include <VBox/log.h> 53 #include <iprt/mp.h> 54 #include <iprt/mem.h> 55 56 57 #define xstr(s) str(s) 58 #define str(s) #s 59 56 57 58 /******************************************************************************* 59 * Defined Constants And Macros * 60 *******************************************************************************/ 60 61 /** The device name. */ 61 62 #define DEVICE_NAME "vboxguest" … … 91 92 static int vboxguestLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 92 93 #endif 94 static int vboxguestFAsync(int fd, struct file *pFile, int fOn); 95 static unsigned int vboxguestPoll(struct file *pFile, poll_table *pPt); 96 static ssize_t vboxguestRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff); 93 97 94 98 … … 110 114 /** The pointer to the mapping of the MMIO range. */ 111 115 static void *g_pvMMIOBase; 116 /** Wait queue used by polling. */ 117 static wait_queue_head_t g_PollEventQueue; 118 /** Asynchronous notification stuff. */ 119 static struct fasync_struct *g_pFAsyncQueue; 112 120 113 121 /** Our file node major id. … … 118 126 static unsigned int g_iModuleMajor = 0; 119 127 #endif 120 121 128 122 129 /** The file_operations structure. */ … … 131 138 ioctl: vboxguestLinuxIOCtl, 132 139 #endif 140 read: vboxguestRead, 141 poll: vboxguestPoll, 142 fasync: vboxguestFAsync, 133 143 }; 134 144 … … 442 452 if (RT_FAILURE(rc)) 443 453 { 444 Log((DEVICE_NAME ": RTR0Init failed.\n"));454 printk(KERN_ERR DEVICE_NAME ": RTR0Init failed, rc=%d.\n", rc); 445 455 return -EINVAL; 446 456 } … … 487 497 { 488 498 /* some useful information for the user but don't show this on the console */ 489 LogRel(( "VirtualBox device settings: major %d, IRQ %d, I/O port 0x%x, MMIO at 0x%x (size 0x%x)\n",499 LogRel((DEVICE_NAME ": major %d, IRQ %d, I/O port 0x%x, MMIO at 0x%x (size 0x%x)\n", 490 500 g_iModuleMajor, g_pPciDev->irq, g_IOPortBase, g_MMIOPhysAddr, g_cbMMIO)); 491 501 printk(KERN_DEBUG DEVICE_NAME ": Successfully loaded version " 492 VBOX_VERSION_STRING " (interface " xstr(VMMDEV_VERSION) ")\n");502 VBOX_VERSION_STRING " (interface " RT_XSTR(VMMDEV_VERSION) ")\n"); 493 503 return rc; 494 504 } … … 499 509 else 500 510 { 501 LogRel(( 511 LogRel((DEVICE_NAME ": VBoxGuestInitDevExt failed with rc=%Rrc\n", rc)); 502 512 rc = RTErrConvertFromErrno(rc); 503 513 } … … 657 667 } 658 668 669 670 /** 671 * Poll function. 672 * 673 * This returns ready to read if the mouse pointer mode or the pointer position 674 * has changed since last call to read. 675 * 676 * @returns 0 if no changes, POLLIN | POLLRDNORM if there are unseen changes. 677 * 678 * @param pFile The file structure. 679 * @param pPt The poll table. 680 */ 681 static unsigned int vboxguestPoll(struct file *pFile, poll_table *pPt) 682 { 683 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pFile->private_data; 684 uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq); 685 unsigned int fMask = pSession->u32MousePosChangedSeq != u32CurSeq 686 ? POLLIN | POLLRDNORM 687 : 0; 688 #if 1 /** @todo this isn't quite right... but it's what we used to do. */ 689 pSession->u32MousePosChangedSeq = u32CurSeq; 690 #endif 691 poll_wait(pFile, &g_PollEventQueue, pPt); 692 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 } 709 710 711 /** 712 * Read to go with our poll/fasync response. 713 * 714 * @returns 1 or -EINVAL. 715 * 716 * @param pFile The file structure. 717 * @param pbBuf The buffer to read into. 718 * @param cbRead The max number of bytes to read. 719 * @param poff The current file position. 720 */ 721 static ssize_t vboxguestRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff) 722 { 723 if (*poff != 0) 724 return -EINVAL; 725 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); 731 pSession->u32MousePosChangedSeq = u32CurSeq; 732 733 pbBuf[0] = 0; 734 return 1; 735 } 736 737 #if 1 /** @todo This is wrong, see man 2 read. Does it server any purpose? */ 738 return -EINVAL; 739 #else 740 return 0; 741 #endif 742 } 743 744 745 void VBoxGuestNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt) 746 { 747 NOREF(pDevExt); 748 749 /* 750 * Wake up everyone that's in a poll() and post anyone that has 751 * subscribed to async notifications. 752 */ 753 wake_up_all(&g_PollEventQueue); 754 kill_fasync(&g_pFAsyncQueue, SIGIO, POLL_IN); 755 } 756 757 659 758 /* Common code that depend on g_DevExt. */ 660 759 #include "VBoxGuestIDC-unix.c.h" … … 671 770 MODULE_LICENSE("GPL"); 672 771 #ifdef MODULE_VERSION 673 MODULE_VERSION(VBOX_VERSION_STRING " (" xstr(SUPDRV_IOC_VERSION) ")");674 #endif 675 772 MODULE_VERSION(VBOX_VERSION_STRING " (" RT_XSTR(SUPDRV_IOC_VERSION) ")"); 773 #endif 774 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r21071 r21095 1 1 /* $Id$ */ 2 2 /** @file 3 * VBoxGuest - Guest Additions Driver .3 * VBoxGuest - Guest Additions Driver, Common Code. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2007 Sun Microsystems, Inc.7 * Copyright (C) 2007-2009 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 1411 1411 RTSpinlockAcquireNoInts(pDevExt->WaitSpinlock, &Tmp); 1412 1412 1413 /** @todo This looks wrong: Seems like VMMDEV_EVENT_HGCM will always be set in 1414 * f32PendingEvents... */ 1413 1415 #ifdef VBOX_WITH_HGCM 1414 1416 /* The HGCM event/list is kind of different in that we evaluate all entries. */ … … 1423 1425 #endif 1424 1426 1427 /* VMMDEV_EVENT_MOUSE_POSITION_CHANGED can only be polled for. */ 1428 #if defined(RT_OS_LINUX) 1429 if (fEvents & VMMDEV_EVENT_MOUSE_POSITION_CHANGED) 1430 { 1431 pDevExt->u32MousePosChangedSeq++; 1432 VBoxGuestNativeISRMousePollEvent(pDevExt); 1433 } 1434 #endif 1435 fEvents &= ~VMMDEV_EVENT_MOUSE_POSITION_CHANGED; 1436 1425 1437 /* Normal FIFO evaluation. */ 1426 1438 fEvents |= pDevExt->f32PendingEvents; -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h
r21069 r21095 97 97 /** Mask of pending events. */ 98 98 uint32_t volatile f32PendingEvents; 99 /** Current VMMDEV_EVENT_MOUSE_POSITION_CHANGED sequence number. 100 * Used to implement polling. */ 101 uint32_t volatile u32MousePosChangedSeq; 99 102 100 103 /** Spinlock various items in the VBOXGUESTSESSION. */ … … 144 147 uint32_t volatile aHGCMClientIds[8]; 145 148 #endif 149 150 /** The last consumed VMMDEV_EVENT_MOUSE_POSITION_CHANGED sequence number. 151 * Used to implement polling. */ 152 uint32_t volatile u32MousePosChangedSeq; 146 153 } VBOXGUESTSESSION; 147 154 … … 170 177 #endif 171 178 179 /** 180 * ISR callback for notifying threads polling for mouse events. 181 * 182 * @param pDevExt The device extension. 183 */ 184 void VBoxGuestNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt); 185 172 186 RT_C_DECLS_END 173 187
Note:
See TracChangeset
for help on using the changeset viewer.