Changeset 41528 in vbox for trunk/src/VBox/Main/src-server/os2
- Timestamp:
- May 31, 2012 4:48:33 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 78291
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/os2/USBProxyServiceOs2.cpp
r31892 r41528 5 5 6 6 /* 7 * Copyright (C) 200 6-2010Oracle Corporation7 * Copyright (C) 2005-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 38 38 * Initialize data members. 39 39 */ 40 USBProxyServiceOs2::USBProxyServiceOs2 41 : USBProxyService (aHost), mhev (NULLHANDLE), mhmod(NULLHANDLE),42 mpfnUsbRegisterChangeNotification (NULL), mpfnUsbDeregisterNotification(NULL),43 mpfnUsbQueryNumberDevices (NULL), mpfnUsbQueryDeviceReport(NULL)40 USBProxyServiceOs2::USBProxyServiceOs2(Host *aHost) 41 : USBProxyService(aHost), mhev(NULLHANDLE), mhmod(NULLHANDLE), 42 mpfnUsbRegisterChangeNotification(NULL), mpfnUsbDeregisterNotification(NULL), 43 mpfnUsbQueryNumberDevices(NULL), mpfnUsbQueryDeviceReport(NULL) 44 44 { 45 45 LogFlowThisFunc(("aHost=%p\n", aHost)); … … 48 48 * Try initialize the usbcalls stuff. 49 49 */ 50 int rc = DosCreateEventSem 51 rc = RTErrConvertFromOS2 50 int rc = DosCreateEventSem(NULL, &mhev, 0, FALSE); 51 rc = RTErrConvertFromOS2(rc); 52 52 if (RT_SUCCESS(rc)) 53 53 { 54 rc = DosLoadModule 55 rc = RTErrConvertFromOS2 54 rc = DosLoadModule(NULL, 0, (PCSZ)"usbcalls", &mhmod); 55 rc = RTErrConvertFromOS2(rc); 56 56 if (RT_SUCCESS(rc)) 57 57 { 58 if ( (rc = DosQueryProcAddr (mhmod, 0, (PCSZ)"UsbQueryNumberDevices",(PPFN)&mpfnUsbQueryNumberDevices)) == NO_ERROR59 && (rc = DosQueryProcAddr (mhmod, 0, (PCSZ)"UsbQueryDeviceReport",(PPFN)&mpfnUsbQueryDeviceReport)) == NO_ERROR60 && (rc = DosQueryProcAddr (mhmod, 0, (PCSZ)"UsbRegisterChangeNotification",(PPFN)&mpfnUsbRegisterChangeNotification)) == NO_ERROR61 && (rc = DosQueryProcAddr (mhmod, 0, (PCSZ)"UsbDeregisterNotification",(PPFN)&mpfnUsbDeregisterNotification)) == NO_ERROR58 if ( (rc = DosQueryProcAddr(mhmod, 0, (PCSZ)"UsbQueryNumberDevices", (PPFN)&mpfnUsbQueryNumberDevices)) == NO_ERROR 59 && (rc = DosQueryProcAddr(mhmod, 0, (PCSZ)"UsbQueryDeviceReport", (PPFN)&mpfnUsbQueryDeviceReport)) == NO_ERROR 60 && (rc = DosQueryProcAddr(mhmod, 0, (PCSZ)"UsbRegisterChangeNotification", (PPFN)&mpfnUsbRegisterChangeNotification)) == NO_ERROR 61 && (rc = DosQueryProcAddr(mhmod, 0, (PCSZ)"UsbDeregisterNotification", (PPFN)&mpfnUsbDeregisterNotification)) == NO_ERROR 62 62 ) 63 63 { 64 rc = mpfnUsbRegisterChangeNotification 64 rc = mpfnUsbRegisterChangeNotification(&mNotifyId, mhev, mhev); 65 65 if (!rc) 66 66 { … … 77 77 } 78 78 79 LogRel 79 LogRel(("USBProxyServiceOs2: failed to register change notification, rc=%d\n", rc)); 80 80 } 81 81 else 82 LogRel 83 84 DosFreeModule 82 LogRel(("USBProxyServiceOs2: failed to load usbcalls\n")); 83 84 DosFreeModule(mhmod); 85 85 } 86 86 else 87 LogRel 87 LogRel(("USBProxyServiceOs2: failed to load usbcalls, rc=%d\n", rc)); 88 88 mhmod = NULLHANDLE; 89 89 } … … 115 115 { 116 116 if (mpfnUsbDeregisterNotification) 117 mpfnUsbDeregisterNotification 117 mpfnUsbDeregisterNotification(mNotifyId); 118 118 119 119 mpfnUsbRegisterChangeNotification = NULL; … … 122 122 mpfnUsbQueryDeviceReport = NULL; 123 123 124 DosFreeModule 124 DosFreeModule(mhmod); 125 125 mhmod = NULLHANDLE; 126 126 } … … 128 128 129 129 130 int USBProxyServiceOs2::captureDevice (HostUSBDevice *aDevice) 131 { 132 Log (("USBProxyServiceOs2::captureDevice: %p\n", aDevice)); 130 int USBProxyServiceOs2::captureDevice(HostUSBDevice *aDevice) 131 { 133 132 AssertReturn(aDevice, VERR_GENERAL_FAILURE); 134 AssertReturn(aDevice->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE); 133 AssertReturn(!aDevice->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE); 134 135 AutoReadLock devLock(aDevice COMMA_LOCKVAL_SRC_POS); 136 LogFlowThisFunc(("aDevice=%s\n", aDevice->getName().c_str())); 135 137 136 138 /* … … 138 140 */ 139 141 Assert(aDevice->isStatePending()); 142 devLock.release(); 140 143 interruptWait(); 141 144 … … 144 147 145 148 146 int USBProxyServiceOs2::releaseDevice (HostUSBDevice *aDevice) 147 { 148 Log (("USBProxyServiceOs2::releaseDevice: %p\n", aDevice)); 149 int USBProxyServiceOs2::releaseDevice(HostUSBDevice *aDevice) 150 { 149 151 AssertReturn(aDevice, VERR_GENERAL_FAILURE); 150 AssertReturn(aDevice->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE); 152 AssertReturn(!aDevice->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE); 153 154 AutoReadLock devLock(aDevice COMMA_LOCKVAL_SRC_POS); 155 LogFlowThisFunc(("aDevice=%s\n", aDevice->getName().c_str())); 151 156 152 157 /* … … 154 159 */ 155 160 Assert(aDevice->isStatePending()); 161 devLock.release(); 156 162 interruptWait(); 157 163 … … 162 168 bool USBProxyServiceOs2::updateDeviceState(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters, SessionMachine **aIgnoreMachine) 163 169 { 170 AssertReturn(aDevice, false); 171 AssertReturn(!aDevice->isWriteLockOnCurrentThread(), false); 164 172 return updateDeviceStateFake(aDevice, aUSBDevice, aRunFilters, aIgnoreMachine); 165 173 } … … 174 182 175 183 176 int USBProxyServiceOs2::interruptWait 177 { 178 int rc = DosPostEventSem 184 int USBProxyServiceOs2::interruptWait(void) 185 { 186 int rc = DosPostEventSem(mhev); 179 187 return rc == NO_ERROR || rc == ERROR_ALREADY_POSTED 180 188 ? VINF_SUCCESS 181 : RTErrConvertFromOS2 189 : RTErrConvertFromOS2(rc); 182 190 } 183 191 184 192 #include <stdio.h> 185 193 186 PUSBDEVICE USBProxyServiceOs2::getDevices 194 PUSBDEVICE USBProxyServiceOs2::getDevices(void) 187 195 { 188 196 /* … … 190 198 */ 191 199 ULONG cDevices = 0; 192 int rc = mpfnUsbQueryNumberDevices 200 int rc = mpfnUsbQueryNumberDevices((PULONG)&cDevices); /* Thanks to com/xpcom, PULONG and ULONG * aren't the same. */ 193 201 if (rc) 194 202 return NULL;
Note:
See TracChangeset
for help on using the changeset viewer.