- Timestamp:
- Sep 22, 2012 6:12:17 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxDev-haiku.c
r43369 r43409 45 45 */ 46 46 47 48 #define LOG_GROUP LOG_GROUP_SUP_DRV 49 //#undef LOG_DISABLED 50 //#define LOG_ENABLED 51 //#define LOG_ENABLE_FLOW 52 //#define DO_LOG 47 /******************************************************************************* 48 * Header Files * 49 *******************************************************************************/ 53 50 #include <sys/param.h> 54 51 #include <sys/types.h> … … 72 69 #define MODULE_NAME "generic/vboxguest" 73 70 71 /******************************************************************************* 72 * Internal Functions * 73 *******************************************************************************/ 74 74 static status_t VBoxGuestHaikuOpen(const char *name, uint32 flags, void **cookie); 75 75 static status_t VBoxGuestHaikuClose(void *cookie); … … 95 95 96 96 /** 97 * File open handler 98 * 97 * Driver open hook. 98 * 99 * @param name The name of the device as returned by publish_devices. 100 * @param flags Open flags. 101 * @param cookie Where to store the session pointer. 102 * 103 * @return Haiku status code. 99 104 */ 100 105 static status_t VBoxGuestHaikuOpen(const char *name, uint32 flags, void **cookie) … … 114 119 ASMAtomicIncU32(&cUsers); 115 120 *cookie = pSession; 116 return 0;121 return B_OK; 117 122 } 118 123 … … 123 128 124 129 /** 125 * File close handler 126 * 130 * Driver close hook. 131 * @param cookie The session. 132 * 133 * @return Haiku status code. 127 134 */ 128 135 static status_t VBoxGuestHaikuClose(void *cookie) … … 134 141 RTSpinlockAcquire(g_DevExt.SessionSpinlock); 135 142 136 / /XXX: we don't know if it belongs to this session !143 /* @todo we don't know if it belongs to this session!! */ 137 144 if (sState.selectSync) 138 145 { … … 145 152 146 153 RTSpinlockRelease(g_DevExt.SessionSpinlock); 147 148 return 0; 149 } 150 151 152 /** 153 * File free handler 154 * 154 return B_OK; 155 } 156 157 158 /** 159 * Driver free hook. 160 * @param cookie The session. 161 * 162 * @return Haiku status code. 155 163 */ 156 164 static status_t VBoxGuestHaikuFree(void *cookie) … … 169 177 else 170 178 Log(("VBoxGuestHaikuFree: si_drv1=%p!\n", pSession)); 171 return 0; 172 } 173 174 175 /** 176 * IOCTL handler 177 * 179 return B_OK; 180 } 181 182 183 /** 184 * Driver IOCtl entry. 185 * @param cookie The session. 186 * @param op The operation to perform. 187 * @param data The data associated with the operation. 188 * @param len Size of the data in bytes. 189 * 190 * @return Haiku status code. 178 191 */ 179 192 static status_t VBoxGuestHaikuIOCtl(void *cookie, uint32 op, void *data, size_t len) 180 193 { 181 194 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie; 182 //Log(("VBoxGuestHaikuFree: pSession=%p\n", pSession)); 183 //LogFlow((DRIVER_NAME ":VBoxGuestHaikuIOCtl(, 0x%08x, %p, %d)\n", op, data, len)); 184 Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl(, 0x%08x, %p, %d)\n", op, data, len)); 185 186 int rc = 0; 195 Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl cookie=%p op=0x%08x data=%p len=%lu)\n", cookie, op, data, len)); 196 197 int rc = B_OK; 187 198 188 199 /* … … 198 209 if (IOCPARM_LEN(ulCmd) != sizeof(VBGLBIGREQ)) 199 210 { 200 Log((DRIVER_NAME ": VBoxGuestHaikuIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd), sizeof(VBGLBIGREQ))); 211 Log((DRIVER_NAME ": VBoxGuestHaikuIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd), 212 sizeof(VBGLBIGREQ))); 201 213 return ENOTTY; 202 214 } … … 222 234 } 223 235 236 /** @todo r=ramshankar: replace with RTR0MemUserCopyFrom() */ 224 237 rc = user_memcpy(pvBuf, data, len); 225 238 if (RT_UNLIKELY(rc < 0)) … … 268 281 RTMemTmpFree(pvBuf); 269 282 return rc; 270 #if 0 271 #endif 272 } 273 274 283 } 284 285 286 /** 287 * Driver select hook. 288 * 289 * @param cookie The session. 290 * @param event The event. 291 * @param ref ??? 292 * @param sync ??? 293 * 294 * @return Haiku status code. 295 */ 275 296 static status_t VBoxGuestHaikuSelect(void *cookie, uint8 event, uint32 ref, selectsync *sync) 276 297 { 277 298 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie; 278 299 status_t err = B_OK; 279 //dprintf(DRIVER_NAME "select(,%d,%p)\n", event, sync);280 281 300 282 301 switch (event) 283 302 { 284 303 case B_SELECT_READ: 285 //case B_SELECT_ERROR:286 304 break; 287 305 default: … … 294 312 if (pSession->u32MousePosChangedSeq != u32CurSeq) 295 313 { 296 //dprintf(DRIVER_NAME "select: notifying now: %p %x\n", sync, event);297 314 pSession->u32MousePosChangedSeq = u32CurSeq; 298 315 notify_select_event(sync, event); … … 300 317 else if (sState.selectSync == NULL) 301 318 { 302 //dprintf(DRIVER_NAME "select: caching: %p %x\n", sync, event);303 319 sState.selectEvent = (uint8_t)event; 304 320 sState.selectRef = (uint32_t)ref; … … 306 322 } 307 323 else 308 {309 //dprintf(DRIVER_NAME "select: dropping: %p %x\n", sync, event);310 324 err = B_WOULD_BLOCK; 311 }312 325 313 326 RTSpinlockRelease(g_DevExt.SessionSpinlock); 314 327 315 328 return err; 316 #if 0 317 int fEventsProcessed; 318 319 LogFlow((DRIVER_NAME "::Poll: fEvents=%d\n", fEvents)); 320 321 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1; 322 if (RT_UNLIKELY(!VALID_PTR(pSession))) 323 { 324 Log((DRIVER_NAME "::Poll: no state data for %s\n", devtoname(pDev))); 325 return (fEvents & (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM)); 326 } 327 328 uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq); 329 if (pSession->u32MousePosChangedSeq != u32CurSeq) 330 { 331 fEventsProcessed = fEvents & (POLLIN | POLLRDNORM); 332 pSession->u32MousePosChangedSeq = u32CurSeq; 333 } 334 else 335 { 336 fEventsProcessed = 0; 337 338 selrecord(td, &g_SelInfo); 339 } 340 341 return fEventsProcessed; 342 #endif 343 } 344 345 329 } 330 331 332 /** 333 * Driver deselect hook. 334 * @param cookie The session. 335 * @param event The event. 336 * @param sync ??? 337 * 338 * @return Haiku status code. 339 */ 346 340 static status_t VBoxGuestHaikuDeselect(void *cookie, uint8 event, selectsync *sync) 347 341 { … … 367 361 368 362 363 /** 364 * Driver write hook. 365 * @param cookie The session. 366 * @param position The offset. 367 * @param data Pointer to the data. 368 * @param numBytes Where to store the number of bytes written. 369 * 370 * @return Haiku status code. 371 */ 369 372 static status_t VBoxGuestHaikuWrite(void *cookie, off_t position, const void *data, size_t *numBytes) 370 373 { 371 374 *numBytes = 0; 372 return 0; 373 } 374 375 375 return B_OK; 376 } 377 378 379 /** 380 * Driver read hook. 381 * @param cookie The session. 382 * @param position The offset. 383 * @param data Pointer to the data. 384 * @param numBytes Where to store the number of bytes read. 385 * 386 * @return Haiku status code. 387 */ 376 388 static status_t VBoxGuestHaikuRead(void *cookie, off_t position, void *data, size_t *numBytes) 377 389 { 378 390 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie; 379 391 380 //dprintf(DRIVER_NAME "read(,,%d)\n", *numBytes);381 382 392 if (*numBytes == 0) 383 return 0;393 return B_OK; 384 394 385 395 uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq); … … 387 397 { 388 398 pSession->u32MousePosChangedSeq = u32CurSeq; 389 //dprintf(DRIVER_NAME "read: giving 1 byte\n");390 399 *numBytes = 1; 391 return 0;400 return B_OK; 392 401 } 393 402 394 403 *numBytes = 0; 395 return 0;404 return B_OK; 396 405 } 397 406
Note:
See TracChangeset
for help on using the changeset viewer.

