- Timestamp:
- Jul 2, 2009 2:45:00 PM (16 years ago)
- Location:
- trunk/src/VBox/Additions
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-freebsd.c
r21069 r21170 493 493 */ 494 494 rc = VBoxGuestInitDevExt(&g_DevExt, pState->uIOPortBase, pState->pMMIOBase, 495 pState->VMMDevMemSize, VBOXOSTYPE_FreeBSD );495 pState->VMMDevMemSize, VBOXOSTYPE_FreeBSD, 0); 496 496 if (RT_SUCCESS(rc)) 497 497 { -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c
r21155 r21170 498 498 g_pvMMIOBase, 499 499 g_cbMMIO, 500 enmOSType); 500 enmOSType, 501 VMMDEV_EVENT_MOUSE_POSITION_CHANGED); 501 502 if (RT_SUCCESS(rc)) 502 503 { -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-os2.cpp
r20374 r21170 159 159 RTR0MemObjAddress(g_MemMapMMIO), 160 160 RTR0MemObjSize(g_MemMapMMIO), 161 vboxGuestOS2DetectVersion()); 161 vboxGuestOS2DetectVersion(), 162 0); 162 163 else 163 164 rc = VBoxGuestInitDevExt(&g_DevExt, g_IOPortBase, NULL, 0, 164 vboxGuestOS2DetectVersion()); 165 vboxGuestOS2DetectVersion(), 166 0); 165 167 if (RT_SUCCESS(rc)) 166 168 { -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c
r21069 r21170 42 42 #include <iprt/process.h> 43 43 #include <iprt/mem.h> 44 #include <iprt/cdefs.h> 45 #include <iprt/asm.h> 44 46 45 47 … … 47 49 * Defined Constants And Macros * 48 50 *******************************************************************************/ 49 #define VBOXSOLQUOTE2(x) #x50 #define VBOXSOLQUOTE(x) VBOXSOLQUOTE2(x)51 51 /** The module name. */ 52 52 #define DEVICE_NAME "vboxguest" … … 63 63 static int VBoxGuestSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred); 64 64 static int VBoxGuestSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArg, int Mode, cred_t *pCred, int *pVal); 65 static int VBoxGuestSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead); 65 66 66 67 static int VBoxGuestSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pArg, void **ppResult); … … 68 69 static int VBoxGuestSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd); 69 70 70 static int VBoxGuestSolarisAddIRQ(dev_info_t *pDip , void *pvState);71 static void VBoxGuestSolarisRemoveIRQ(dev_info_t *pDip , void *pvState);71 static int VBoxGuestSolarisAddIRQ(dev_info_t *pDip); 72 static void VBoxGuestSolarisRemoveIRQ(dev_info_t *pDip); 72 73 static uint_t VBoxGuestSolarisISR(caddr_t Arg); 73 74 … … 92 93 nodev, /* c mmap */ 93 94 nodev, /* c segmap */ 94 nochpoll, /* c poll */95 VBoxGuestSolarisPoll, 95 96 ddi_prop_op, /* property ops */ 96 97 NULL, /* streamtab */ … … 123 124 { 124 125 &mod_driverops, /* extern from kernel */ 125 DEVICE_DESC " " VBOX_VERSION_STRING "r" VBOXSOLQUOTE(VBOX_SVN_REV),126 DEVICE_DESC " " VBOX_VERSION_STRING "r" RT_XSTR(VBOX_SVN_REV), 126 127 &g_VBoxGuestSolarisDevOps 127 128 }; … … 142 143 typedef struct 143 144 { 144 /** IO port handle. */145 ddi_acc_handle_t PciIOHandle;146 /** MMIO handle. */147 ddi_acc_handle_t PciMMIOHandle;148 #if 0149 /** Interrupt block cookie. */150 ddi_iblock_cookie_t BlockCookie;151 #endif152 /** Driver Mutex. */153 kmutex_t Mtx;154 /** IO Port. */155 uint16_t uIOPortBase;156 /** Address of the MMIO region.*/157 caddr_t pMMIOBase;158 /** Size of the MMIO region. */159 off_t cbMMIO;160 /** VMMDev Version. */161 uint32_t u32Version;162 /** Pointer to the interrupt handle vector */163 ddi_intr_handle_t *pIntr;164 /** Number of actually allocated interrupt handles */165 size_t cIntrAllocated;166 #ifndef USE_SESSION_HASH167 145 /** Pointer to the session handle. */ 168 146 PVBOXGUESTSESSION pSession; 169 #endif 147 /** The process reference for posting signals */ 148 void *pvProcRef; 170 149 } vboxguest_state_t; 171 150 … … 175 154 *******************************************************************************/ 176 155 /** Device handle (we support only one instance). */ 177 static dev_info_t *g_pDip; 178 179 /** Opaque pointer to state */ 180 static void *g_pVBoxGuestSolarisState; 181 156 static dev_info_t *g_pDip = NULL; 157 /** Opaque pointer to file-descriptor states */ 158 static void *g_pVBoxGuestSolarisState = NULL; 182 159 /** Device extention & session data association structure. */ 183 160 static VBOXGUESTDEVEXT g_DevExt; 184 /** Spinlock protecting g_apSessionHashTab. */ 185 static RTSPINLOCK g_Spinlock = NIL_RTSPINLOCK; 186 #ifdef USE_SESSION_HASH 187 /** Hash table */ 188 static PVBOXGUESTSESSION g_apSessionHashTab[19]; 189 /** Calculates the index into g_apSessionHashTab.*/ 190 #define SESSION_HASH(sfn) ((sfn) % RT_ELEMENTS(g_apSessionHashTab)) 191 #endif /* USE_SESSION_HASH */ 192 193 #if 0/** @todo This shouldn't be needed. if it is, that means exceptions hasn't been disabled correctly. */ 194 /** GCC C++ hack. */ 195 unsigned __gxx_personality_v0 = 0xdecea5ed; 196 #endif 161 /** IO port handle. */ 162 static ddi_acc_handle_t g_PciIOHandle; 163 /** MMIO handle. */ 164 static ddi_acc_handle_t g_PciMMIOHandle; 165 /** IO Port. */ 166 static uint16_t g_uIOPortBase; 167 /** Address of the MMIO region.*/ 168 static caddr_t g_pMMIOBase; 169 /** Size of the MMIO region. */ 170 static off_t g_cbMMIO; 171 /** VMMDev Version. */ 172 static uint32_t g_u32Version; 173 /** Pointer to the interrupt handle vector */ 174 static ddi_intr_handle_t *g_pIntr; 175 /** Number of actually allocated interrupt handles */ 176 static size_t g_cIntrAllocated; 177 /** The pollhead structure */ 178 static pollhead_t g_PollHead; 179 /** The IRQ Mutex */ 180 static kmutex_t g_IrqMtx; 197 181 198 182 /** … … 245 229 case DDI_ATTACH: 246 230 { 231 if (g_pDip) 232 { 233 LogRel((DEVICE_NAME "::Attach: Only one instance supported.\n")); 234 return DDI_FAILURE; 235 } 236 247 237 int rc; 248 238 int instance; 249 vboxguest_state_t *pState;250 239 251 240 instance = ddi_get_instance(pDip); 252 #ifdef USE_SESSION_HASH253 rc = ddi_soft_state_zalloc(g_pVBoxGuestSolarisState, instance);254 if (rc != DDI_SUCCESS)255 {256 Log((DEVICE_NAME ":ddi_soft_state_zalloc failed.\n"));257 return DDI_FAILURE;258 }259 260 pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, instance);261 if (!pState)262 {263 ddi_soft_state_free(g_pVBoxGuestSolarisState, instance);264 Log((DEVICE_NAME ":ddi_get_soft_state for instance %d failed\n", instance));265 return DDI_FAILURE;266 }267 #else268 pState = RTMemAllocZ(sizeof(vboxguest_state_t));269 if (!pState)270 {271 Log((DEVICE_NAME ":RTMemAllocZ failed to allocate %d bytes\n", sizeof(vboxguest_state_t)));272 return DDI_FAILURE;273 }274 #endif275 241 276 242 /* … … 280 246 if (RT_FAILURE(rc)) 281 247 { 282 Log((DEVICE_NAME ": RTR0Init failed.\n"));248 Log((DEVICE_NAME "::Attach: RTR0Init failed.\n")); 283 249 return DDI_FAILURE; 284 250 } 285 251 286 252 /* 287 * Initialize the session hash table.253 * Enable resources for PCI access. 288 254 */ 289 rc = RTSpinlockCreate(&g_Spinlock); 290 if (RT_SUCCESS(rc)) 255 ddi_acc_handle_t PciHandle; 256 rc = pci_config_setup(pDip, &PciHandle); 257 if (rc == DDI_SUCCESS) 291 258 { 292 259 /* 293 * Enable resources for PCI access.260 * Map the register address space. 294 261 */ 295 ddi_acc_handle_t PciHandle; 296 rc = pci_config_setup(pDip, &PciHandle); 262 caddr_t baseAddr; 263 ddi_device_acc_attr_t deviceAttr; 264 deviceAttr.devacc_attr_version = DDI_DEVICE_ATTR_V0; 265 deviceAttr.devacc_attr_endian_flags = DDI_NEVERSWAP_ACC; 266 deviceAttr.devacc_attr_dataorder = DDI_STRICTORDER_ACC; 267 deviceAttr.devacc_attr_access = DDI_DEFAULT_ACC; 268 rc = ddi_regs_map_setup(pDip, 1, &baseAddr, 0, 0, &deviceAttr, &g_PciIOHandle); 297 269 if (rc == DDI_SUCCESS) 298 270 { 299 271 /* 300 * Map the register address space.272 * Read size of the MMIO region. 301 273 */ 302 caddr_t baseAddr; 303 ddi_device_acc_attr_t deviceAttr; 304 deviceAttr.devacc_attr_version = DDI_DEVICE_ATTR_V0; 305 deviceAttr.devacc_attr_endian_flags = DDI_NEVERSWAP_ACC; 306 deviceAttr.devacc_attr_dataorder = DDI_STRICTORDER_ACC; 307 deviceAttr.devacc_attr_access = DDI_DEFAULT_ACC; 308 rc = ddi_regs_map_setup(pDip, 1, &baseAddr, 0, 0, &deviceAttr, &pState->PciIOHandle); 274 g_uIOPortBase = (uintptr_t)baseAddr; 275 rc = ddi_dev_regsize(pDip, 2, &g_cbMMIO); 309 276 if (rc == DDI_SUCCESS) 310 277 { 311 /* 312 * Read size of the MMIO region. 313 */ 314 pState->uIOPortBase = (uintptr_t)baseAddr; 315 rc = ddi_dev_regsize(pDip, 2, &pState->cbMMIO); 278 rc = ddi_regs_map_setup(pDip, 2, &g_pMMIOBase, 0, g_cbMMIO, &deviceAttr, 279 &g_PciMMIOHandle); 316 280 if (rc == DDI_SUCCESS) 317 281 { 318 rc = ddi_regs_map_setup(pDip, 2, &pState->pMMIOBase, 0, pState->cbMMIO, &deviceAttr, 319 &pState->PciMMIOHandle); 282 /* 283 * Add IRQ of VMMDev. 284 */ 285 rc = VBoxGuestSolarisAddIRQ(pDip); 320 286 if (rc == DDI_SUCCESS) 321 287 { 322 288 /* 323 * Add IRQ of VMMDev.289 * Call the common device extension initializer. 324 290 */ 325 rc = VBoxGuestSolarisAddIRQ(pDip, pState); 326 if (rc == DDI_SUCCESS) 291 rc = VBoxGuestInitDevExt(&g_DevExt, g_uIOPortBase, g_pMMIOBase, 292 g_cbMMIO, VBOXOSTYPE_Solaris, 293 VMMDEV_EVENT_MOUSE_POSITION_CHANGED); 294 if (RT_SUCCESS(rc)) 327 295 { 328 /* 329 * Call the common device extension initializer. 330 */ 331 rc = VBoxGuestInitDevExt(&g_DevExt, pState->uIOPortBase, pState->pMMIOBase, 332 pState->cbMMIO, VBOXOSTYPE_Solaris); 333 if (RT_SUCCESS(rc)) 296 rc = ddi_create_minor_node(pDip, DEVICE_NAME, S_IFCHR, instance, DDI_PSEUDO, 0); 297 if (rc == DDI_SUCCESS) 334 298 { 335 rc = ddi_create_minor_node(pDip, DEVICE_NAME, S_IFCHR, instance, DDI_PSEUDO, 0); 336 if (rc == DDI_SUCCESS) 337 { 338 g_pDip = pDip; 339 ddi_set_driver_private(pDip, pState); 340 pci_config_teardown(&PciHandle); 341 ddi_report_dev(pDip); 342 return DDI_SUCCESS; 343 } 344 345 LogRel((DEVICE_NAME ": ddi_create_minor_node failed.\n")); 346 VBoxGuestDeleteDevExt(&g_DevExt); 299 g_pDip = pDip; 300 pci_config_teardown(&PciHandle); 301 return DDI_SUCCESS; 347 302 } 348 else 349 LogRel((DEVICE_NAME ": VBoxGuestInitDevExtfailed.\n"));350 VBoxGuest SolarisRemoveIRQ(pDip, pState);303 304 LogRel((DEVICE_NAME "::Attach: ddi_create_minor_node failed.\n")); 305 VBoxGuestDeleteDevExt(&g_DevExt); 351 306 } 352 307 else 353 LogRel((DEVICE_NAME ": VBoxGuestSolarisAddIRQfailed.\n"));354 ddi_regs_map_free(&pState->PciMMIOHandle);308 LogRel((DEVICE_NAME "::Attach: VBoxGuestInitDevExt failed.\n")); 309 VBoxGuestSolarisRemoveIRQ(pDip); 355 310 } 356 311 else 357 LogRel((DEVICE_NAME ": ddi_regs_map_setup for MMIO region failed.\n")); 312 LogRel((DEVICE_NAME "::Attach: VBoxGuestSolarisAddIRQ failed.\n")); 313 ddi_regs_map_free(&g_PciMMIOHandle); 358 314 } 359 315 else 360 LogRel((DEVICE_NAME ": ddi_dev_regsize for MMIO region failed.\n")); 361 ddi_regs_map_free(&pState->PciIOHandle); 316 LogRel((DEVICE_NAME "::Attach: ddi_regs_map_setup for MMIO region failed.\n")); 362 317 } 363 318 else 364 LogRel((DEVICE_NAME ": ddi_regs_map_setup for IOportfailed.\n"));365 pci_config_teardown(&PciHandle);319 LogRel((DEVICE_NAME "::Attach: ddi_dev_regsize for MMIO region failed.\n")); 320 ddi_regs_map_free(&g_PciIOHandle); 366 321 } 367 322 else 368 LogRel((DEVICE_NAME ": pci_config_setup failed rc=%d.\n", rc)); 369 RTSpinlockDestroy(g_Spinlock); 370 g_Spinlock = NIL_RTSPINLOCK; 323 LogRel((DEVICE_NAME "::Attach: ddi_regs_map_setup for IOport failed.\n")); 324 pci_config_teardown(&PciHandle); 371 325 } 372 326 else 373 LogRel((DEVICE_NAME ": RTSpinlockCreate failed.\n"));327 LogRel((DEVICE_NAME "::Attach: pci_config_setup failed rc=%d.\n", rc)); 374 328 375 329 RTR0Term(); … … 404 358 case DDI_DETACH: 405 359 { 406 int rc; 407 int instance = ddi_get_instance(pDip); 408 #ifdef USE_SESSION_HASH 409 vboxguest_state_t *pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, instance); 410 #else 411 vboxguest_state_t *pState = ddi_get_driver_private(g_pDip); 412 #endif 413 if (pState) 414 { 415 VBoxGuestSolarisRemoveIRQ(pDip, pState); 416 ddi_regs_map_free(&pState->PciIOHandle); 417 ddi_regs_map_free(&pState->PciMMIOHandle); 418 ddi_remove_minor_node(pDip, NULL); 419 #ifdef USE_SESSION_HASH 420 ddi_soft_state_free(g_pVBoxGuestSolarisState, instance); 421 #else 422 RTMemFree(pState); 423 #endif 424 425 rc = RTSpinlockDestroy(g_Spinlock); 426 AssertRC(rc); 427 g_Spinlock = NIL_RTSPINLOCK; 428 429 RTR0Term(); 430 return DDI_SUCCESS; 431 } 432 Log((DEVICE_NAME ":ddi_get_soft_state failed. Cannot detach instance %d\n", instance)); 433 return DDI_FAILURE; 360 VBoxGuestSolarisRemoveIRQ(pDip); 361 ddi_regs_map_free(&g_PciIOHandle); 362 ddi_regs_map_free(&g_PciMMIOHandle); 363 ddi_remove_minor_node(pDip, NULL); 364 365 RTR0Term(); 366 return DDI_SUCCESS; 434 367 } 435 368 … … 497 430 return EINVAL; 498 431 499 #ifndef USE_SESSION_HASH500 432 vboxguest_state_t *pState = NULL; 501 433 unsigned iOpenInstance; … … 521 453 if (RT_SUCCESS(rc)) 522 454 { 455 pState->pvProcRef = proc_ref(); 523 456 pState->pSession = pSession; 524 457 *pDev = makedevice(getmajor(*pDev), iOpenInstance); … … 529 462 /* Failed, clean up. */ 530 463 ddi_soft_state_free(g_pVBoxGuestSolarisState, iOpenInstance); 531 #else 532 /* 533 * Create a new session. 534 */ 535 rc = VBoxGuestCreateUserSession(&g_DevExt, &pSession); 536 if (RT_SUCCESS(rc)) 537 { 538 /* 539 * Insert it into the hash table. 540 */ 541 unsigned iHash = SESSION_HASH(pSession->Process); 542 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 543 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 544 pSession->pNextHash = g_apSessionHashTab[iHash]; 545 g_apSessionHashTab[iHash] = pSession; 546 RTSpinlockReleaseNoInts(g_Spinlock, &Tmp); 547 548 int instance; 549 for (instance = 0; instance < 4096; instance++) 550 { 551 vboxguest_state_t *pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, instance); 552 if (pState) 553 break; 554 } 555 if (instance >= 4096) 556 { 557 Log((DEVICE_NAME "::Open: All instances exhausted\n")); 558 return ENXIO; 559 } 560 *pDev = makedevice(getmajor(*pDev), instance); 561 Log((DEVICE_NAME "::Open success: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf())); 562 return 0; 563 } 564 #endif 464 565 465 LogRel((DEVICE_NAME "::Open: VBoxGuestCreateUserSession failed. rc=%d\n", rc)); 566 466 return EFAULT; … … 572 472 LogFlow((DEVICE_NAME "::Close pid=%d\n", (int)RTProcSelf())); 573 473 574 #ifndef USE_SESSION_HASH575 474 PVBOXGUESTSESSION pSession; 576 475 vboxguest_state_t *pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, getminor(Dev)); … … 581 480 } 582 481 482 proc_unref(pState->pvProcRef); 583 483 pSession = pState->pSession; 584 484 pState->pSession = NULL; … … 591 491 } 592 492 593 #else /* USE_SESSION_HASH */594 /*595 * Remove from the hash table.596 */597 PVBOXGUESTSESSION pSession;598 const RTPROCESS Process = RTProcSelf();599 const unsigned iHash = SESSION_HASH(Process);600 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;601 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);602 603 pSession = g_apSessionHashTab[iHash];604 if (pSession)605 {606 if (pSession->Process == Process)607 {608 g_apSessionHashTab[iHash] = pSession->pNextHash;609 pSession->pNextHash = NULL;610 }611 else612 {613 PVBOXGUESTSESSION pPrev = pSession;614 pSession = pSession->pNextHash;615 while (pSession)616 {617 if (pSession->Process == Process)618 {619 pPrev->pNextHash = pSession->pNextHash;620 pSession->pNextHash = NULL;621 break;622 }623 624 /* next */625 pPrev = pSession;626 pSession = pSession->pNextHash;627 }628 }629 }630 RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);631 if (!pSession)632 {633 Log((DEVICE_NAME "::Close: WHUT?!? pSession == NULL! This must be a mistake... pid=%d", (int)Process));634 return EFAULT;635 }636 Log((DEVICE_NAME "::Close: pid=%d\n", (int)Process));637 #endif /* USE_SESSION_HASH */638 639 493 /* 640 494 * Close the session. … … 648 502 { 649 503 LogFlow((DEVICE_NAME "::Read\n")); 504 505 PVBOXGUESTSESSION pSession; 506 vboxguest_state_t *pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, getminor(Dev)); 507 if (!pState) 508 { 509 Log((DEVICE_NAME "::Close: failed to get pState.\n")); 510 return EFAULT; 511 } 512 513 uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq); 514 if (pSession->u32MousePosChangedSeq != u32CurSeq) 515 pSession->u32MousePosChangedSeq = u32CurSeq; 516 650 517 return 0; 651 518 } … … 684 551 LogFlow((DEVICE_NAME ":VBoxGuestSolarisIOCtl\n")); 685 552 686 #ifndef USE_SESSION_HASH687 553 /* 688 554 * Get the session from the soft state item. … … 701 567 return EINVAL; 702 568 } 703 704 #else /* USE_SESSION_HASH */705 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;706 const RTPROCESS Process = RTProcSelf();707 const unsigned iHash = SESSION_HASH(Process);708 PVBOXGUESTSESSION pSession;709 710 /*711 * Find the session.712 */713 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);714 pSession = g_apSessionHashTab[iHash];715 if (pSession && pSession->Process != Process)716 {717 do pSession = pSession->pNextHash;718 while (pSession && pSession->Process != Process);719 }720 RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);721 if (!pSession)722 {723 Log((DEVICE_NAME "::IOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#x\n", (int)Process, Cmd));724 return EINVAL;725 }726 #endif /* USE_SESSION_HASH */727 569 728 570 /* … … 816 658 817 659 660 static int VBoxGuestSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead) 661 { 662 LogFlow((DEVICE_NAME "::Poll: fEvents=%d fAnyYet=%d\n", fEvents, fAnyYet)); 663 664 vboxguest_state_t *pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, getminor(Dev)); 665 if (RT_LIKELY(pState)) 666 { 667 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pState->pSession; 668 uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq); 669 if (pSession->u32MousePosChangedSeq != u32CurSeq) 670 { 671 *pReqEvents |= (POLLIN | POLLRDNORM); 672 pSession->u32MousePosChangedSeq = u32CurSeq; 673 } 674 else 675 { 676 *pReqEvents = 0; 677 if (!fAnyYet) 678 *ppPollHead = &g_PollHead; 679 } 680 681 return 0; 682 } 683 else 684 { 685 Log((DEVICE_NAME "::Poll: no state data for %d\n", getminor(Dev))); 686 return EINVAL; 687 } 688 } 689 690 818 691 /** 819 692 * Sets IRQ for VMMDev. … … 821 694 * @returns Solaris error code. 822 695 * @param pDip Pointer to the device info structure. 823 * @param pvState Pointer to the state info structure. 824 */ 825 static int VBoxGuestSolarisAddIRQ(dev_info_t *pDip, void *pvState) 826 { 827 LogFlow((DEVICE_NAME "::AddIRQ: %p\n", pvState)); 828 829 vboxguest_state_t *pState = (vboxguest_state_t *)pvState; 830 #if 0 831 /* 832 * These calls are supposedly deprecated. But Sun seems to use them all over 833 * the place. Anyway, once this works we will switch to the highly elaborate 834 * and non-obsolete way of setting up IRQs. 835 */ 836 int rc = ddi_get_iblock_cookie(pDip, 0, &pState->BlockCookie); 837 if (rc == DDI_SUCCESS) 838 { 839 mutex_init(&pState->Mtx, "VBoxGuest Driver Mutex", MUTEX_DRIVER, (void *)pState->BlockCookie); 840 rc = ddi_add_intr(pDip, 0, &pState->BlockCookie, NULL, VBoxGuestSolarisISR, (caddr_t)pState); 841 if (rc != DDI_SUCCESS) 842 Log((DEVICE_NAME ":ddi_add_intr failed. Cannot set IRQ for VMMDev.\n")); 843 } 844 else 845 Log((DEVICE_NAME ":ddi_get_iblock_cookie failed. Cannot set IRQ for VMMDev.\n")); 846 return rc; 847 #else 696 */ 697 static int VBoxGuestSolarisAddIRQ(dev_info_t *pDip) 698 { 699 LogFlow((DEVICE_NAME "::AddIRQ: pDip=%p\n", pDip)); 700 848 701 int IntrType = 0; 849 702 int rc = ddi_intr_get_supported_types(pDip, &IntrType); … … 864 717 { 865 718 /* Allocated kernel memory for the interrupt handles. The allocation size is stored internally. */ 866 pState->pIntr = RTMemAlloc(IntrCount * sizeof(ddi_intr_handle_t));867 if ( pState->pIntr)719 g_pIntr = RTMemAlloc(IntrCount * sizeof(ddi_intr_handle_t)); 720 if (g_pIntr) 868 721 { 869 722 int IntrAllocated; 870 rc = ddi_intr_alloc(pDip, pState->pIntr, IntrType, 0, IntrCount, &IntrAllocated, DDI_INTR_ALLOC_NORMAL);723 rc = ddi_intr_alloc(pDip, g_pIntr, IntrType, 0, IntrCount, &IntrAllocated, DDI_INTR_ALLOC_NORMAL); 871 724 if ( rc == DDI_SUCCESS 872 725 && IntrAllocated > 0) 873 726 { 874 pState->cIntrAllocated = IntrAllocated;727 g_cIntrAllocated = IntrAllocated; 875 728 uint_t uIntrPriority; 876 rc = ddi_intr_get_pri( pState->pIntr[0], &uIntrPriority);729 rc = ddi_intr_get_pri(g_pIntr[0], &uIntrPriority); 877 730 if (rc == DDI_SUCCESS) 878 731 { 879 732 /* Initialize the mutex. */ 880 mutex_init(& pState->Mtx, "VBoxGuestMtx", MUTEX_DRIVER, DDI_INTR_PRI(uIntrPriority));733 mutex_init(&g_IrqMtx, NULL, MUTEX_DRIVER, DDI_INTR_PRI(uIntrPriority)); 881 734 882 735 /* Assign interrupt handler functions and enable interrupts. */ 883 736 for (int i = 0; i < IntrAllocated; i++) 884 737 { 885 rc = ddi_intr_add_handler( pState->pIntr[i], (ddi_intr_handler_t *)VBoxGuestSolarisISR,886 (caddr_t)pState, NULL);738 rc = ddi_intr_add_handler(g_pIntr[i], (ddi_intr_handler_t *)VBoxGuestSolarisISR, 739 NULL /* No Private Data */, NULL); 887 740 if (rc == DDI_SUCCESS) 888 rc = ddi_intr_enable( pState->pIntr[i]);741 rc = ddi_intr_enable(g_pIntr[i]); 889 742 if (rc != DDI_SUCCESS) 890 743 { … … 900 753 LogRel((DEVICE_NAME ":failed to assign IRQs allocated=%d\n", IntrAllocated)); 901 754 for (int x = 0; x < IntrAllocated; x++) 902 ddi_intr_remove_handler( pState->pIntr[x]);755 ddi_intr_remove_handler(g_pIntr[x]); 903 756 } 904 757 else … … 906 759 907 760 /* Remove allocated IRQs, too bad we can free only one handle at a time. */ 908 for (int k = 0; k < pState->cIntrAllocated; k++)909 ddi_intr_free( pState->pIntr[k]);761 for (int k = 0; k < g_cIntrAllocated; k++) 762 ddi_intr_free(g_pIntr[k]); 910 763 } 911 764 else 912 765 LogRel((DEVICE_NAME "::AddIRQ: failed to allocated IRQs. count=%d\n", IntrCount)); 913 RTMemFree( pState->pIntr);766 RTMemFree(g_pIntr); 914 767 } 915 768 else … … 928 781 LogRel((DEVICE_NAME "::AddIRQ: failed to get supported interrupt types\n")); 929 782 return rc; 930 #endif931 783 } 932 784 … … 936 788 * 937 789 * @param pDip Pointer to the device info structure. 938 * @param pvState Opaque pointer to the state info structure. 939 */ 940 static void VBoxGuestSolarisRemoveIRQ(dev_info_t *pDip, void *pvState) 941 { 942 vboxguest_state_t *pState = (vboxguest_state_t *)pvState; 943 LogFlow((DEVICE_NAME "::RemoveIRQ: pvState=%p\n")); 944 945 #if 0 946 ddi_remove_intr(pDip, 0, pState->BlockCookie); 947 mutex_destroy(&pState->Mtx); 948 #else 949 for (int i = 0; i < pState->cIntrAllocated; i++) 950 { 951 int rc = ddi_intr_disable(pState->pIntr[i]); 790 */ 791 static void VBoxGuestSolarisRemoveIRQ(dev_info_t *pDip) 792 { 793 LogFlow((DEVICE_NAME "::RemoveIRQ:\n")); 794 795 for (int i = 0; i < g_cIntrAllocated; i++) 796 { 797 int rc = ddi_intr_disable(g_pIntr[i]); 952 798 if (rc == DDI_SUCCESS) 953 799 { 954 rc = ddi_intr_remove_handler( pState->pIntr[i]);800 rc = ddi_intr_remove_handler(g_pIntr[i]); 955 801 if (rc == DDI_SUCCESS) 956 ddi_intr_free(pState->pIntr[i]); 957 } 958 } 959 RTMemFree(pState->pIntr); 960 mutex_destroy(&pState->Mtx); 961 #endif 802 ddi_intr_free(g_pIntr[i]); 803 } 804 } 805 RTMemFree(g_pIntr); 806 mutex_destroy(&g_IrqMtx); 962 807 } 963 808 … … 966 811 * Interrupt Service Routine for VMMDev. 967 812 * 813 * @param Arg Private data (unused, will be NULL). 968 814 * @returns DDI_INTR_CLAIMED if it's our interrupt, DDI_INTR_UNCLAIMED if it isn't. 969 815 */ 970 816 static uint_t VBoxGuestSolarisISR(caddr_t Arg) 971 817 { 972 LogFlow((DEVICE_NAME "::ISR: Arg=%p\n", Arg)); 973 974 vboxguest_state_t *pState = (vboxguest_state_t *)Arg; 975 mutex_enter(&pState->Mtx); 818 LogFlow((DEVICE_NAME "::ISR:\n")); 819 820 mutex_enter(&g_IrqMtx); 976 821 bool fOurIRQ = VBoxGuestCommonISR(&g_DevExt); 977 mutex_exit(& pState->Mtx);822 mutex_exit(&g_IrqMtx); 978 823 979 824 return fOurIRQ ? DDI_INTR_CLAIMED : DDI_INTR_UNCLAIMED; 825 } 826 827 828 void VBoxGuestNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt) 829 { 830 LogFlow((DEVICE_NAME "::NativeISRMousePollEvent:\n")); 831 832 /* 833 * Wake up poll waiters. 834 */ 835 pollwakeup(&g_PollHead, POLLIN | POLLRDNORM); 980 836 } 981 837 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r21118 r21170 142 142 * This is optional, pass 0 if not present. 143 143 * @param enmOSType The guest OS type to report to the VMMDev. 144 * @param fEvents Additional requested events (like Mouse events). 144 145 */ 145 146 int VBoxGuestInitDevExt(PVBOXGUESTDEVEXT pDevExt, uint16_t IOPortBase, 146 void *pvMMIOBase, uint32_t cbMMIO, VBOXOSTYPE enmOSType )147 void *pvMMIOBase, uint32_t cbMMIO, VBOXOSTYPE enmOSType, uint32_t fEvents) 147 148 { 148 149 int rc, rc2; … … 215 216 { 216 217 #ifdef VBOX_WITH_HGCM 217 rc = vboxGuestInitFilterMask(pDevExt, VMMDEV_EVENT_HGCM );218 rc = vboxGuestInitFilterMask(pDevExt, VMMDEV_EVENT_HGCM | fEvents); 218 219 #else 219 rc = vboxGuestInitFilterMask(pDevExt, 0);220 rc = vboxGuestInitFilterMask(pDevExt, fEvents); 220 221 #endif 221 222 if (RT_SUCCESS(rc)) … … 1434 1435 1435 1436 /* VMMDEV_EVENT_MOUSE_POSITION_CHANGED can only be polled for. */ 1436 #if defined(RT_OS_LINUX) 1437 #if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) 1437 1438 if (fEvents & VMMDEV_EVENT_MOUSE_POSITION_CHANGED) 1438 1439 { -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h
r21095 r21170 147 147 uint32_t volatile aHGCMClientIds[8]; 148 148 #endif 149 150 149 /** The last consumed VMMDEV_EVENT_MOUSE_POSITION_CHANGED sequence number. 151 150 * Used to implement polling. */ … … 153 152 } VBOXGUESTSESSION; 154 153 155 156 154 RT_C_DECLS_BEGIN 157 155 158 int VBoxGuestInitDevExt(PVBOXGUESTDEVEXT pDevExt, uint16_t IOPortBase, void *pvMMIOBase, uint32_t cbMMIO, VBOXOSTYPE enmOSType );156 int VBoxGuestInitDevExt(PVBOXGUESTDEVEXT pDevExt, uint16_t IOPortBase, void *pvMMIOBase, uint32_t cbMMIO, VBOXOSTYPE enmOSType, uint32_t fEvents); 159 157 void VBoxGuestDeleteDevExt(PVBOXGUESTDEVEXT pDevExt); 160 158 bool VBoxGuestCommonISR(PVBOXGUESTDEVEXT pDevExt); -
trunk/src/VBox/Additions/x11/Installer/x11config15sol.pl
r18907 r21170 77 77 } 78 78 79 # Solaris specific: /dev/kdmouse for PS/2 and not /dev/mouse79 # Solaris specific: Use /dev/vboxguest for Xorg 1.5.3+ 80 80 if ($os_type =~ 'SunOS') 81 81 { 82 82 if ($line =~ /^\s*option\s+\"(?:device)\"\s+\"(?:\/dev\/kdmouse)\"/i) 83 83 { 84 $line = " Option \"Device\" \"\/dev\/mouse\"\n" 84 $line = " Option \"Device\" \"\/dev\/vboxguest\"\n" 85 } 86 87 if ($line =~ /^\s*option\s+\"(?:device)\"\s+\"(?:\/dev\/mouse)\"/i) 88 { 89 $line = " Option \"Device\" \"\/dev\/vboxguest\"\n" 85 90 } 86 91 }
Note:
See TracChangeset
for help on using the changeset viewer.