Changeset 40488 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Mar 15, 2012 4:57:11 PM (13 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxGuest
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris-streams.c
r40325 r40488 51 51 #ifdef TESTCASE /* Include this last as we . */ 52 52 # include "testcase/solaris.h" 53 # include <iprt/test.h>53 # include "testcase/tstVBoxGuest-solaris.h" 54 54 #endif /* TESTCASE */ 55 55 … … 63 63 /** The module description as seen in 'modinfo'. */ 64 64 #define DEVICE_DESC "VirtualBox GstDrv" 65 /** The maximum number of open device nodes we support. */ 66 #define MAX_OPEN_NODES 4096 65 67 66 68 … … 69 71 ******************************************************************************/ 70 72 71 static int vb oxGuestSolarisOpen(queue_t *pReadQueue, dev_t *pDev, int fFlag,73 static int vbgr0SolOpen(queue_t *pReadQueue, dev_t *pDev, int fFlag, 72 74 int fMode, cred_t *pCred); 73 static int vb oxGuestSolarisClose(queue_t *pReadQueue, int fFlag, cred_t *pCred);74 static int vb oxGuestSolarisWPut(queue_t *pWriteQueue, mblk_t *pMBlk);75 76 static int vb oxGuestSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pArg, void **ppResult);77 static int vb oxGuestSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd);78 static int vb oxGuestSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd);75 static int vbgr0SolClose(queue_t *pReadQueue, int fFlag, cred_t *pCred); 76 static int vbgr0SolWPut(queue_t *pWriteQueue, mblk_t *pMBlk); 77 78 static int vbgr0SolGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pArg, void **ppResult); 79 static int vbgr0SolAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd); 80 static int vbgr0SolDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd); 79 81 80 82 … … 83 85 ******************************************************************************/ 84 86 85 #ifndef TESTCASE /* I see no value in including these . */87 #ifndef TESTCASE /* I see no value in including these in the test. */ 86 88 87 89 /* 88 90 * mod_info: STREAMS module information. 89 91 */ 90 static struct module_info g_ VBoxGuestSolarisModInfo =92 static struct module_info g_vbgr0SolModInfo = 91 93 { 92 94 0x0ffff, /* module id number */ … … 103 105 * the put and service procedures. 104 106 */ 105 static struct qinit g_ VBoxGuestSolarisRInit =107 static struct qinit g_vbgr0SolRInit = 106 108 { 107 109 NULL, /* put */ 108 110 NULL, /* service thread procedure */ 109 vb oxGuestSolarisOpen,110 vb oxGuestSolarisClose,111 vbgr0SolOpen, 112 vbgr0SolClose, 111 113 NULL, /* reserved */ 112 &g_ VBoxGuestSolarisModInfo,114 &g_vbgr0SolModInfo, 113 115 NULL /* module statistics structure */ 114 116 }; … … 121 123 * hardware pointer drivers to a single virtual pointer. 122 124 */ 123 static struct qinit g_ VBoxGuestSolarisWInit =124 { 125 vb oxGuestSolarisWPut,125 static struct qinit g_vbgr0SolWInit = 126 { 127 vbgr0SolWPut, 126 128 NULL, /* service thread procedure */ 127 129 NULL, /* open */ 128 130 NULL, /* close */ 129 131 NULL, /* reserved */ 130 &g_ VBoxGuestSolarisModInfo,132 &g_vbgr0SolModInfo, 131 133 NULL /* module statistics structure */ 132 134 }; … … 135 137 * streamtab: for drivers that support char/block entry points. 136 138 */ 137 static struct streamtab g_ VBoxGuestSolarisStreamTab =138 { 139 &g_ VBoxGuestSolarisRInit,140 &g_ VBoxGuestSolarisWInit,139 static struct streamtab g_vbgr0SolStreamTab = 140 { 141 &g_vbgr0SolRInit, 142 &g_vbgr0SolWInit, 141 143 NULL, /* MUX rinit */ 142 144 NULL /* MUX winit */ … … 146 148 * cb_ops: for drivers that support char/block entry points. 147 149 */ 148 static struct cb_ops g_ VBoxGuestSolarisCbOps =150 static struct cb_ops g_vbgr0SolCbOps = 149 151 { 150 152 nulldev, /* open */ … … 161 163 nochpoll, /* c poll */ 162 164 ddi_prop_op, /* property ops */ 163 g_ VBoxGuestSolarisStreamTab,165 g_vbgr0SolStreamTab, 164 166 D_NEW | D_MP, /* compat. flag */ 165 167 }; … … 168 170 * dev_ops: for driver device operations. 169 171 */ 170 static struct dev_ops g_ VBoxGuestSolarisDevOps =172 static struct dev_ops g_vbgr0SolDevOps = 171 173 { 172 174 DEVO_REV, /* driver build revision */ 173 175 0, /* ref count */ 174 vb oxGuestSolarisGetInfo,176 vbgr0SolGetInfo, 175 177 nulldev, /* identify */ 176 178 nulldev, /* probe */ 177 vb oxGuestSolarisAttach,178 vb oxGuestSolarisDetach,179 vbgr0SolAttach, 180 vbgr0SolDetach, 179 181 nodev, /* reset */ 180 &g_ VBoxGuestSolarisCbOps,182 &g_vbgr0SolCbOps, 181 183 (struct bus_ops *)0, 182 184 nodev /* power */ … … 186 188 * modldrv: export driver specifics to the kernel. 187 189 */ 188 static struct modldrv g_ VBoxGuestSolarisModule =190 static struct modldrv g_vbgr0SolModule = 189 191 { 190 192 &mod_driverops, /* extern from kernel */ 191 193 DEVICE_DESC " " VBOX_VERSION_STRING "r" RT_XSTR(VBOX_SVN_REV), 192 &g_ VBoxGuestSolarisDevOps194 &g_vbgr0SolDevOps 193 195 }; 194 196 … … 196 198 * modlinkage: export install/remove/info to the kernel. 197 199 */ 198 static struct modlinkage g_ VBoxGuestSolarisModLinkage =200 static struct modlinkage g_vbgr0SolModLinkage = 199 201 { 200 202 MODREV_1, /* loadable module system revision */ 201 &g_ VBoxGuestSolarisModule,203 &g_vbgr0SolModule, 202 204 NULL /* terminate array of linkage structures */ 203 205 }; 204 206 205 207 #else /* TESTCASE */ 206 static void *g_ VBoxGuestSolarisModLinkage;208 static void *g_vbgr0SolModLinkage; 207 209 #endif /* TESTCASE */ 208 210 … … 217 219 * user-space. */ 218 220 queue_t *pWriteQueue; 219 /** Our minor number. */220 unsigned cMinor;221 221 /* The current greatest horizontal pixel offset on the screen, used for 222 222 * absolute mouse position reporting. … … 227 227 */ 228 228 unsigned cMaxScreenY; 229 } vboxguest_state_t;229 } VBGR0STATE, *PVBGR0STATE; 230 230 231 231 … … 236 236 /** Device handle (we support only one instance). */ 237 237 static dev_info_t *g_pDip = NULL; 238 /** Opaque pointer to file-descriptor states */ 239 static void *g_pVBoxGuestSolarisState = NULL; 238 /** Array of state structures for open device nodes. I don't care about 239 * wasting a few K of memory. */ 240 static VBGR0STATE g_aOpenNodeStates[MAX_OPEN_NODES] /* = { 0 } */; 241 /** Mutex to protect the queue pointers in the node states from being unset 242 * during an IRQ. */ 243 static kmutex_t g_StateMutex; 240 244 /** Device extention & session data association structure. */ 241 245 static VBOXGUESTDEVEXT g_DevExt; … … 255 259 static size_t g_cIntrAllocated; 256 260 /** The IRQ Mutex */ 257 static kmutex_t g_IrqMtx; 258 /** Our global state. 259 * @todo Make this into an opaque pointer in the device extension structure. 260 * @todo Can't we make do without all these globals anyway? 261 */ 262 static vboxguest_state_t *g_pState; 261 static kmutex_t g_IrqMutex; 263 262 264 263 … … 291 290 * Prevent module autounloading. 292 291 */ 293 pModCtl = mod_getctl(&g_ VBoxGuestSolarisModLinkage);292 pModCtl = mod_getctl(&g_vbgr0SolModLinkage); 294 293 if (pModCtl) 295 294 pModCtl->mod_loadflags |= MOD_NOAUTOUNLOAD; 296 295 else 297 296 LogRel((DEVICE_NAME ":failed to disable autounloading!\n")); 298 299 rc = ddi_soft_state_init(&g_pVBoxGuestSolarisState, sizeof(vboxguest_state_t), 1); 300 if (!rc) 301 { 302 rc = mod_install(&g_VBoxGuestSolarisModLinkage); 303 if (rc) 304 ddi_soft_state_fini(&g_pVBoxGuestSolarisState); 305 } 297 /* Initialise the node state mutex. This will be taken in the ISR. */ 298 mutex_init(&g_StateMutex, NULL, MUTEX_DRIVER, 299 DDI_INTR_PRI(uIntrPriority)); 300 rc = mod_install(&g_vbgr0SolModLinkage); 306 301 } 307 302 else … … 316 311 317 312 #ifdef TESTCASE 318 /* Nothing in these three really worth testing, plus we would have to stub 319 * around the IPRT log functions. */ 313 /** Simple test of the flow through _init. */ 314 void test_init(RTTEST hTest) 315 { 316 RTTestSub(hTest, "Testing _init"); 317 RTTEST_CHECK(hTest, _init() == 0); 318 } 320 319 #endif 321 320 … … 327 326 328 327 LogFlow((DEVICE_NAME ":_fini\n")); 329 rc = mod_remove(&g_VBoxGuestSolarisModLinkage); 330 if (!rc) 331 ddi_soft_state_fini(&g_pVBoxGuestSolarisState); 328 rc = mod_remove(&g_vbgr0SolModLinkage); 329 mutex_destroy(&g_StateMutex); 332 330 333 331 RTLogDestroy(RTLogRelSetDefaultInstance(NULL)); … … 343 341 { 344 342 LogFlow((DEVICE_NAME ":_info\n")); 345 return mod_info(&g_VBoxGuestSolarisModLinkage, pModInfo); 346 } 347 343 return mod_info(&g_vbgr0SolModLinkage, pModInfo); 344 } 345 346 347 /****************************************************************************** 348 * Helper routines * 349 ******************************************************************************/ 350 351 /** Calls the kernel IOCtl to report mouse status to the host on behalf of 352 * an open session. */ 353 static int vbgr0SolSetMouseStatus(PVBOXGUESTSESSION pSession, uint32_t fStatus) 354 { 355 return VBoxGuestCommonIOCtl(VBOXGUEST_IOCTL_SET_MOUSE_STATUS, &g_DevExt, 356 pSession, &fStatus, sizeof(fStatus), NULL); 357 } 358 359 static void vbgr0SolResetSoftState(PVBGR0STATE pState) 360 { 361 mutex_enter(&g_StateMutex); 362 RT_ZERO(*pState); 363 mutex_exit(&g_StateMutex); 364 } 348 365 349 366 /****************************************************************************** … … 355 372 * handler. 356 373 */ 357 int vb oxGuestSolarisOpen(queue_t *pReadQueue, dev_t *pDev, int fFlag, int fMode,358 374 int vbgr0SolOpen(queue_t *pReadQueue, dev_t *pDev, int fFlag, int fMode, 375 cred_t *pCred) 359 376 { 360 377 int rc; 361 378 PVBOXGUESTSESSION pSession = NULL; 362 vboxguest_state_t *pState = NULL;379 PVBGR0STATE pState = NULL; 363 380 unsigned cInstance; 364 381 … … 368 385 369 386 /* 370 * Sanity check on the mode parameter. 387 * Sanity check on the mode parameter - only open as a driver, not a 388 * module, and we do cloning ourselves. Note that we start at 1, as minor 389 * zero was allocated to the file system device node in vbgr0SolAttach 390 * (see https://blogs.oracle.com/timatworkhomeandinbetween/entry/using_makedevice_in_a_drivers). 371 391 */ 372 392 if (fMode) 373 393 return EINVAL; 374 394 375 for (cInstance = 0; cInstance < 4096; cInstance++)376 { 377 if ( !ddi_get_soft_state(g_pVBoxGuestSolarisState, cInstance) /* faster */378 && ddi_soft_state_zalloc(g_pVBoxGuestSolarisState, cInstance) == DDI_SUCCESS)379 { 380 pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, cInstance);395 for (cInstance = 1; cInstance < MAX_OPEN_NODES; cInstance++) 396 { 397 if (ASMAtomicCmpXchgPtr(&g_aOpenNodeStates[cInstance].pWriteQueue, 398 WR(pReadQueue), NULL)) 399 { 400 pState = &g_aOpenNodeStates[cInstance]; 381 401 break; 382 402 } … … 399 419 WR(pReadQueue)->q_ptr = (char *)pState; 400 420 pReadQueue->q_ptr = (char *)pState; 401 pState->pWriteQueue = WR(pReadQueue);402 pState->cMinor = cInstance;403 g_pState = pState;404 421 qprocson(pState->pWriteQueue); 405 422 Log((DEVICE_NAME "::Open: pSession=%p pState=%p pid=%d\n", pSession, pState, (int)RTProcSelf())); … … 408 425 409 426 /* Failed, clean up. */ 410 ddi_soft_state_free(g_pVBoxGuestSolarisState, cInstance);427 vbgr0SolResetSoftState(pState); 411 428 412 429 LogRel((DEVICE_NAME "::Open: VBoxGuestCreateUserSession failed. rc=%d\n", rc)); … … 419 436 * handler. 420 437 */ 421 int vb oxGuestSolarisClose(queue_t *pReadQueue, int fFlag, cred_t *pCred)438 int vbgr0SolClose(queue_t *pReadQueue, int fFlag, cred_t *pCred) 422 439 { 423 440 PVBOXGUESTSESSION pSession = NULL; 424 vboxguest_state_t *pState = (vboxguest_state_t *)pReadQueue->q_ptr;441 PVBGR0STATE pState = (PVBGR0STATE)pReadQueue->q_ptr; 425 442 426 443 LogFlow((DEVICE_NAME "::Close pid=%d\n", (int)RTProcSelf())); … … 435 452 qprocsoff(pState->pWriteQueue); 436 453 pState->pWriteQueue = NULL; 437 g_pState = NULL;438 454 pReadQueue->q_ptr = NULL; 439 455 … … 441 457 pState->pSession = NULL; 442 458 Log((DEVICE_NAME "::Close: pSession=%p pState=%p\n", pSession, pState)); 443 ddi_soft_state_free(g_pVBoxGuestSolarisState, pState->cMinor);459 vbgr0SolResetSoftState(pState); 444 460 if (!pSession) 445 461 { … … 456 472 457 473 458 /* Helper for vb oxGuestSolarisWPut. */459 static int vb oxGuestSolarisDispatchIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk);474 /* Helper for vbgr0SolWPut. */ 475 static int vbgr0SolDispatchIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk); 460 476 461 477 /** … … 463 479 * land in our write queue. 464 480 */ 465 int vb oxGuestSolarisWPut(queue_t *pWriteQueue, mblk_t *pMBlk)466 { 467 vboxguest_state_t *pState = (vboxguest_state_t *)pWriteQueue->q_ptr;481 int vbgr0SolWPut(queue_t *pWriteQueue, mblk_t *pMBlk) 482 { 483 PVBGR0STATE pState = (PVBGR0STATE)pWriteQueue->q_ptr; 468 484 469 LogFlowFunc(( "\n"));485 LogFlowFunc((DEVICE_NAME "::\n")); 470 486 switch (pMBlk->b_datap->db_type) 471 487 { … … 487 503 case M_IOCDATA: 488 504 { 489 int err = vb oxGuestSolarisDispatchIOCtl(pWriteQueue, pMBlk);505 int err = vbgr0SolDispatchIOCtl(pWriteQueue, pMBlk); 490 506 if (!err) 491 507 qreply(pWriteQueue, pMBlk); … … 527 543 * implemention. 528 544 */ 529 typedef int FNVBOXGUESTSOLARISIOCTL(vboxguest_state_t *pState, int cCmd, 530 void *pvData, size_t cbBuffer, 531 size_t *pcbData, int *prc); 532 typedef FNVBOXGUESTSOLARISIOCTL *PFNVBOXGUESTSOLARISIOCTL; 533 534 /* Helpers for vboxGuestSolarisDispatchIOCtl. */ 535 static int vboxGuestSolarisHandleIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 536 PFNVBOXGUESTSOLARISIOCTL pfnHandler, 537 int cCmd, size_t cbTransparent, 538 enum IOCTLDIRECTION enmDirection); 539 static int vboxGuestSolarisVUIDIOCtl(vboxguest_state_t *pState, int cCmd, 540 void *pvData, size_t cbBuffer, 541 size_t *pcbData, int *prc); 542 static int vboxGuestSolarisGuestIOCtl(vboxguest_state_t *pState, int cCmd, 543 void *pvData, size_t cbBuffer, 544 size_t *pcbData, int *prc); 545 typedef int FNVBGR0SOLIOCTL(PVBGR0STATE pState, int cCmd, void *pvData, 546 size_t cbBuffer, size_t *pcbData, int *prc); 547 typedef FNVBGR0SOLIOCTL *PFNVBGR0SOLIOCTL; 548 549 /* Helpers for vbgr0SolDispatchIOCtl. */ 550 static int vbgr0SolHandleIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 551 PFNVBGR0SOLIOCTL pfnHandler, 552 int cCmd, size_t cbTransparent, 553 enum IOCTLDIRECTION enmDirection); 554 static int vbgr0SolVUIDIOCtl(PVBGR0STATE pState, int cCmd, void *pvData, 555 size_t cbBuffer, size_t *pcbData, int *prc); 556 static int vbgr0SolGuestIOCtl(PVBGR0STATE pState, int cCmd, void *pvData, 557 size_t cbBuffer, size_t *pcbData, int *prc); 545 558 546 559 /** Table of supported VUID IOCtls. */ … … 555 568 * specified for transparent IOCtls. */ 556 569 enum IOCTLDIRECTION enmDirection; 557 } s_aVUIDIOCtlDescriptions[] =570 } g_aVUIDIOCtlDescriptions[] = 558 571 { 559 572 { VUIDGFORMAT, sizeof(int), OUT }, … … 579 592 * @param pMBlk pointer to the STREAMS message block structure. 580 593 */ 581 static int vb oxGuestSolarisDispatchIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk)594 static int vbgr0SolDispatchIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk) 582 595 { 583 596 struct iocblk *pIOCBlk = (struct iocblk *)pMBlk->b_rptr; … … 586 599 enum IOCTLDIRECTION enmDirection; 587 600 588 LogFlowFunc(( "cCmdType=%c, cCmd=%d\n", cCmdType, cCmd));601 LogFlowFunc((DEVICE_NAME "::cCmdType=%c, cCmd=%d\n", cCmdType, cCmd)); 589 602 switch (cCmdType) 590 603 { … … 594 607 unsigned i; 595 608 596 for (i = 0; i < RT_ELEMENTS( s_aVUIDIOCtlDescriptions); ++i)597 if ( s_aVUIDIOCtlDescriptions[i].cCmd == cCmd)609 for (i = 0; i < RT_ELEMENTS(g_aVUIDIOCtlDescriptions); ++i) 610 if (g_aVUIDIOCtlDescriptions[i].cCmd == cCmd) 598 611 { 599 cbBuffer = s_aVUIDIOCtlDescriptions[i].cbBuffer; 600 enmDirection = s_aVUIDIOCtlDescriptions[i].enmDirection; 601 return vboxGuestSolarisHandleIOCtl(pWriteQueue, pMBlk, 602 vboxGuestSolarisVUIDIOCtl, 603 cCmd, cbBuffer, 604 enmDirection); 612 cbBuffer = g_aVUIDIOCtlDescriptions[i].cbBuffer; 613 enmDirection = g_aVUIDIOCtlDescriptions[i].enmDirection; 614 return vbgr0SolHandleIOCtl(pWriteQueue, pMBlk, 615 vbgr0SolVUIDIOCtl, cCmd, 616 cbBuffer, enmDirection); 605 617 } 606 618 return EINVAL; 607 619 } 608 620 case 'V': 609 return vboxGuestSolarisHandleIOCtl(pWriteQueue, pMBlk, 610 vboxGuestSolarisGuestIOCtl, 611 cCmd, 0, UNSPECIFIED); 621 return vbgr0SolHandleIOCtl(pWriteQueue, pMBlk, vbgr0SolGuestIOCtl, 622 cCmd, 0, UNSPECIFIED); 612 623 default: 613 624 return ENOTTY; … … 616 627 617 628 618 /* Helpers for vboxGuestSolarisHandleIOCtl. */ 619 static int vboxGuestSolarisHandleIOCtlData 620 (queue_t *pWriteQueue, mblk_t *pMBlk, 621 PFNVBOXGUESTSOLARISIOCTL pfnHandler, int cCmd, 622 size_t cbTransparent, enum IOCTLDIRECTION enmDirection); 623 624 static int vboxGuestSolarisHandleTransparentIOCtl 625 (queue_t *pWriteQueue, mblk_t *pMBlk, 626 PFNVBOXGUESTSOLARISIOCTL pfnHandler, int cCmd, 627 size_t cbTransparent, enum IOCTLDIRECTION enmDirection); 628 629 static int vboxGuestSolarisHandleIStrIOCtl 630 (queue_t *pWriteQueue, mblk_t *pMBlk, 631 PFNVBOXGUESTSOLARISIOCTL pfnHandler, int cCmd); 629 /* Helpers for vbgr0SolHandleIOCtl. */ 630 static int vbgr0SolHandleIOCtlData(queue_t *pWriteQueue, mblk_t *pMBlk, 631 PFNVBGR0SOLIOCTL pfnHandler, int cCmd, 632 size_t cbTransparent, 633 enum IOCTLDIRECTION enmDirection); 634 635 static int vbgr0SolHandleTransparentIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 636 PFNVBGR0SOLIOCTL pfnHandler, 637 int cCmd, size_t cbTransparent, 638 enum IOCTLDIRECTION enmDirection); 639 640 static int vbgr0SolHandleIStrIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 641 PFNVBGR0SOLIOCTL pfnHandler, int cCmd); 632 642 633 643 /** … … 652 662 * @param enmDirection data transfer direction of the IOCtl. 653 663 */ 654 static int vb oxGuestSolarisHandleIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk,655 PFNVBOXGUESTSOLARISIOCTL pfnHandler,656 int cCmd,size_t cbTransparent,657 664 static int vbgr0SolHandleIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 665 PFNVBGR0SOLIOCTL pfnHandler, int cCmd, 666 size_t cbTransparent, 667 enum IOCTLDIRECTION enmDirection) 658 668 { 659 669 struct iocblk *pIOCBlk = (struct iocblk *)pMBlk->b_rptr; 660 vboxguest_state_t *pState = (vboxguest_state_t *)pWriteQueue->q_ptr;670 PVBGR0STATE pState = (PVBGR0STATE)pWriteQueue->q_ptr; 661 671 662 672 if (pMBlk->b_datap->db_type == M_IOCDATA) 663 return vboxGuestSolarisHandleIOCtlData(pWriteQueue, pMBlk, pfnHandler, 664 cCmd, cbTransparent, 665 enmDirection); 673 return vbgr0SolHandleIOCtlData(pWriteQueue, pMBlk, pfnHandler, cCmd, 674 cbTransparent, enmDirection); 666 675 else if (pIOCBlk->ioc_count == TRANSPARENT) 667 return vboxGuestSolarisHandleTransparentIOCtl(pWriteQueue, pMBlk, 668 pfnHandler, cCmd, 669 cbTransparent, 670 enmDirection); 676 return vbgr0SolHandleTransparentIOCtl(pWriteQueue, pMBlk, pfnHandler, 677 cCmd, cbTransparent, 678 enmDirection); 671 679 else 672 return vboxGuestSolarisHandleIStrIOCtl(pWriteQueue, pMBlk, pfnHandler, 673 cCmd); 674 } 675 676 677 /** 678 * Helper for vboxGuestSolarisHandleIOCtl. This rather complicated-looking 680 return vbgr0SolHandleIStrIOCtl(pWriteQueue, pMBlk, pfnHandler, cCmd); 681 } 682 683 684 /** 685 * Helper for vbgr0SolHandleIOCtl. This rather complicated-looking 679 686 * code is basically the standard boilerplate for handling any streams IOCtl 680 687 * additional data, which we currently only use for transparent IOCtls. 681 * @copydoc vb oxGuestSolarisHandleIOCtl682 */ 683 static int vb oxGuestSolarisHandleIOCtlData(queue_t *pWriteQueue, mblk_t *pMBlk,684 PFNVBOXGUESTSOLARISIOCTL pfnHandler,685 int cCmd,size_t cbTransparent,686 688 * @copydoc vbgr0SolHandleIOCtl 689 */ 690 static int vbgr0SolHandleIOCtlData(queue_t *pWriteQueue, mblk_t *pMBlk, 691 PFNVBGR0SOLIOCTL pfnHandler, int cCmd, 692 size_t cbTransparent, 693 enum IOCTLDIRECTION enmDirection) 687 694 { 688 695 struct copyresp *pCopyResp = (struct copyresp *)pMBlk->b_rptr; 689 696 struct iocblk *pIOCBlk = (struct iocblk *)pMBlk->b_rptr; 690 vboxguest_state_t *pState = (vboxguest_state_t *)pWriteQueue->q_ptr;697 PVBGR0STATE pState = (PVBGR0STATE)pWriteQueue->q_ptr; 691 698 692 699 if (pCopyResp->cp_rval) … … 724 731 725 732 /** 726 * Helper for vb oxGuestSolarisHandleIOCtl. This rather complicated-looking733 * Helper for vbgr0SolHandleIOCtl. This rather complicated-looking 727 734 * code is basically the standard boilerplate for handling transparent IOCtls, 728 735 * that is, IOCtls which are not re-packed inside STREAMS IOCtls. 729 * @copydoc vb oxGuestSolarisHandleIOCtl730 */ 731 int vb oxGuestSolarisHandleTransparentIOCtl732 (queue_t *pWriteQueue, mblk_t *pMBlk,733 PFNVBOXGUESTSOLARISIOCTL pfnHandler, int cCmd,734 size_t cbTransparent,enum IOCTLDIRECTION enmDirection)736 * @copydoc vbgr0SolHandleIOCtl 737 */ 738 int vbgr0SolHandleTransparentIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 739 PFNVBGR0SOLIOCTL pfnHandler, int cCmd, 740 size_t cbTransparent, 741 enum IOCTLDIRECTION enmDirection) 735 742 { 736 743 int err = 0, rc = 0; 737 744 size_t cbData = 0; 738 vboxguest_state_t *pState = (vboxguest_state_t *)pWriteQueue->q_ptr;745 PVBGR0STATE pState = (PVBGR0STATE)pWriteQueue->q_ptr; 739 746 740 747 if ( (enmDirection != NONE && !pMBlk->b_cont) … … 774 781 775 782 /** 776 * Helper for vb oxGuestSolarisHandleIOCtl. This rather complicated-looking783 * Helper for vbgr0SolHandleIOCtl. This rather complicated-looking 777 784 * code is basically the standard boilerplate for handling any streams IOCtl. 778 * @copydoc vboxGuestSolarisHandleIOCtl 779 */ 780 static int vboxGuestSolarisHandleIStrIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 781 PFNVBOXGUESTSOLARISIOCTL pfnHandler, 782 int cCmd) 785 * @copydoc vbgr0SolHandleIOCtl 786 */ 787 static int vbgr0SolHandleIStrIOCtl(queue_t *pWriteQueue, mblk_t *pMBlk, 788 PFNVBGR0SOLIOCTL pfnHandler, int cCmd) 783 789 { 784 790 struct iocblk *pIOCBlk = (struct iocblk *)pMBlk->b_rptr; 785 vboxguest_state_t *pState = (vboxguest_state_t *)pWriteQueue->q_ptr;791 PVBGR0STATE pState = (PVBGR0STATE)pWriteQueue->q_ptr; 786 792 uint_t cbBuffer = pIOCBlk->ioc_count; 787 793 void *pvData = NULL; … … 808 814 /** 809 815 * Handle a VUID input device IOCtl. 810 * @copydoc FNVBOXGUESTSOLARISIOCTL 811 */ 812 static int vboxGuestSolarisVUIDIOCtl(vboxguest_state_t *pState, int cCmd, 813 void *pvData, size_t cbBuffer, 814 size_t *pcbData, int *prc) 815 { 816 LogFlowFunc((": " /* no '\n' */)); 816 * @copydoc FNVBGR0SOLIOCTL 817 */ 818 static int vbgr0SolVUIDIOCtl(PVBGR0STATE pState, int cCmd, void *pvData, 819 size_t cbBuffer, size_t *pcbData, int *prc) 820 { 821 LogFlowFunc((DEVICE_NAME ":: " /* no '\n' */)); 817 822 switch (cCmd) 818 823 { … … 851 856 { 852 857 Ms_screen_resolution *pResolution = (Ms_screen_resolution *)pvData; 858 int rc; 859 853 860 LogFlowFunc(("MSIOSRESOLUTION\n")); 854 861 AssertReturn(cbBuffer >= sizeof(Ms_screen_resolution), EINVAL); 855 862 pState->cMaxScreenX = pResolution->width - 1; 856 863 pState->cMaxScreenY = pResolution->height - 1; 857 return 0; 864 /* Note: we don't disable this again until session close. */ 865 rc = vbgr0SolSetMouseStatus(pState->pSession, 866 VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE 867 | VMMDEV_MOUSE_NEW_PROTOCOL); 868 if (RT_SUCCESS(rc)) 869 return 0; 870 pState->cMaxScreenX = 0; 871 pState->cMaxScreenY = 0; 872 return ENODEV; 858 873 } 859 874 case MSIOBUTTONS: … … 887 902 /** 888 903 * Handle a VBoxGuest IOCtl. 889 * @copydoc FNVBOXGUESTSOLARISIOCTL 890 */ 891 static int vboxGuestSolarisGuestIOCtl(vboxguest_state_t *pState, int cCmd, 892 void *pvData, size_t cbBuffer, 893 size_t *pcbData, int *prc) 904 * @copydoc FNVBGR0SOLIOCTL 905 */ 906 static int vbgr0SolGuestIOCtl(PVBGR0STATE pState, int cCmd, void *pvData, 907 size_t cbBuffer, size_t *pcbData, int *prc) 894 908 { 895 909 int rc = VBoxGuestCommonIOCtl(cCmd, &g_DevExt, pState->pSession, pvData, cbBuffer, pcbData); … … 923 937 * @return corresponding solaris error code. 924 938 */ 925 int vb oxGuestSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd,926 void *pvArg,void **ppvResult)939 int vbgr0SolGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pvArg, 940 void **ppvResult) 927 941 { 928 942 int rc = DDI_SUCCESS; … … 949 963 950 964 951 /* Helpers for vb oxGuestSolarisAttach and vboxGuestSolarisDetach. */952 static int vb oxGuestSolarisAddIRQ(dev_info_t *pDip);953 static void vb oxGuestSolarisRemoveIRQ(dev_info_t *pDip);965 /* Helpers for vbgr0SolAttach and vbgr0SolDetach. */ 966 static int vbgr0SolAddIRQ(dev_info_t *pDip); 967 static void vbgr0SolRemoveIRQ(dev_info_t *pDip); 954 968 955 969 /** … … 961 975 * @return corresponding solaris error code. 962 976 */ 963 int vb oxGuestSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd)977 int vbgr0SolAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd) 964 978 { 965 979 LogFlow((DEVICE_NAME "::Attach\n")); … … 1010 1024 * Add IRQ of VMMDev. 1011 1025 */ 1012 rc = vb oxGuestSolarisAddIRQ(pDip);1026 rc = vbgr0SolAddIRQ(pDip); 1013 1027 if (rc == DDI_SUCCESS) 1014 1028 { … … 1042 1056 else 1043 1057 LogRel((DEVICE_NAME "::Attach: VBoxGuestInitDevExt failed.\n")); 1044 vb oxGuestSolarisRemoveIRQ(pDip);1058 vbgr0SolRemoveIRQ(pDip); 1045 1059 } 1046 1060 else 1047 LogRel((DEVICE_NAME "::Attach: vb oxGuestSolarisAddIRQ failed.\n"));1061 LogRel((DEVICE_NAME "::Attach: vbgr0SolAddIRQ failed.\n")); 1048 1062 ddi_regs_map_free(&g_PciMMIOHandle); 1049 1063 } … … 1084 1098 * @return corresponding solaris error code. 1085 1099 */ 1086 int vb oxGuestSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd)1100 int vbgr0SolDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd) 1087 1101 { 1088 1102 LogFlow((DEVICE_NAME "::Detach\n")); … … 1091 1105 case DDI_DETACH: 1092 1106 { 1093 vb oxGuestSolarisRemoveIRQ(pDip);1107 vbgr0SolRemoveIRQ(pDip); 1094 1108 ddi_regs_map_free(&g_PciIOHandle); 1095 1109 ddi_regs_map_free(&g_PciMMIOHandle); … … 1112 1126 1113 1127 1114 /* Interrupt service routine installed by vb oxGuestSolarisAddIRQ. */1115 static uint_t vb oxGuestSolarisISR(char *Arg /* Actually caddr_t. */);1128 /* Interrupt service routine installed by vbgr0SolAddIRQ. */ 1129 static uint_t vbgr0SolISR(char *Arg /* Actually caddr_t. */); 1116 1130 1117 1131 /** … … 1121 1135 * @param pDip Pointer to the device info structure. 1122 1136 */ 1123 static int vb oxGuestSolarisAddIRQ(dev_info_t *pDip)1137 static int vbgr0SolAddIRQ(dev_info_t *pDip) 1124 1138 { 1125 1139 int IntrType = 0, rc; … … 1158 1172 { 1159 1173 /* Initialize the mutex. */ 1160 mutex_init(&g_IrqM tx, NULL, MUTEX_DRIVER, DDI_INTR_PRI(uIntrPriority));1174 mutex_init(&g_IrqMutex, NULL, MUTEX_DRIVER, DDI_INTR_PRI(uIntrPriority)); 1161 1175 1162 1176 /* Assign interrupt handler functions and enable interrupts. */ 1163 1177 for (i = 0; i < IntrAllocated; i++) 1164 1178 { 1165 rc = ddi_intr_add_handler(g_pIntr[i], (ddi_intr_handler_t *)vb oxGuestSolarisISR,1179 rc = ddi_intr_add_handler(g_pIntr[i], (ddi_intr_handler_t *)vbgr0SolISR, 1166 1180 NULL /* No Private Data */, NULL); 1167 1181 if (rc == DDI_SUCCESS) … … 1216 1230 * @param pDip Pointer to the device info structure. 1217 1231 */ 1218 static void vb oxGuestSolarisRemoveIRQ(dev_info_t *pDip)1232 static void vbgr0SolRemoveIRQ(dev_info_t *pDip) 1219 1233 { 1220 1234 unsigned i; … … 1232 1246 } 1233 1247 RTMemFree(g_pIntr); 1234 mutex_destroy(&g_IrqM tx);1248 mutex_destroy(&g_IrqMutex); 1235 1249 } 1236 1250 … … 1242 1256 * @returns DDI_INTR_CLAIMED if it's our interrupt, DDI_INTR_UNCLAIMED if it isn't. 1243 1257 */ 1244 static uint_t vb oxGuestSolarisISR(char *Arg /* Actually caddr_t. */)1258 static uint_t vbgr0SolISR(char *Arg /* Actually caddr_t. */) 1245 1259 { 1246 1260 bool fOurIRQ; 1247 1261 1248 1262 LogFlow((DEVICE_NAME "::ISR:\n")); 1249 mutex_enter(&g_IrqM tx);1263 mutex_enter(&g_IrqMutex); 1250 1264 fOurIRQ = VBoxGuestCommonISR(&g_DevExt); 1251 mutex_exit(&g_IrqM tx);1265 mutex_exit(&g_IrqMutex); 1252 1266 return fOurIRQ ? DDI_INTR_CLAIMED : DDI_INTR_UNCLAIMED; 1253 1267 } … … 1255 1269 1256 1270 /* Helper for VBoxGuestNativeISRMousePollEvent. */ 1257 static void VBoxGuestVUIDPutAbsEvent(ushort_t cEvent, int cValue); 1271 static void vbgr0SolVUIDPutAbsEvent(PVBGR0STATE pState, ushort_t cEvent, 1272 int cValue); 1258 1273 1259 1274 /** … … 1277 1292 if (RT_SUCCESS(rc)) 1278 1293 { 1279 int cMaxScreenX = g_pState->cMaxScreenX; 1280 int cMaxScreenY = g_pState->cMaxScreenY; 1281 1282 VBoxGuestVUIDPutAbsEvent(LOC_X_ABSOLUTE, 1283 pReq->pointerXPos * cMaxScreenX 1284 / VMMDEV_MOUSE_RANGE_MAX); 1285 VBoxGuestVUIDPutAbsEvent(LOC_Y_ABSOLUTE, 1286 pReq->pointerYPos * cMaxScreenY 1287 / VMMDEV_MOUSE_RANGE_MAX); 1294 unsigned i; 1295 1296 mutex_enter(&g_StateMutex); 1297 for (i = 1; i < MAX_OPEN_NODES; ++i) 1298 { 1299 int cMaxScreenX = g_aOpenNodeStates[i].cMaxScreenX; 1300 int cMaxScreenY = g_aOpenNodeStates[i].cMaxScreenY; 1301 1302 if (!cMaxScreenX || !cMaxScreenY) 1303 continue; 1304 vbgr0SolVUIDPutAbsEvent(&g_aOpenNodeStates[i], LOC_X_ABSOLUTE, 1305 pReq->pointerXPos * cMaxScreenX 1306 / VMMDEV_MOUSE_RANGE_MAX); 1307 vbgr0SolVUIDPutAbsEvent(&g_aOpenNodeStates[i], LOC_Y_ABSOLUTE, 1308 pReq->pointerYPos * cMaxScreenY 1309 / VMMDEV_MOUSE_RANGE_MAX); 1310 } 1311 mutex_exit(&g_StateMutex); 1288 1312 } 1289 1313 VbglGRFree(&pReq->header); … … 1291 1315 1292 1316 1293 void VBoxGuestVUIDPutAbsEvent(ushort_t cEvent, int cValue) 1294 { 1295 queue_t *pReadQueue = RD(g_pState->pWriteQueue); 1317 void vbgr0SolVUIDPutAbsEvent(PVBGR0STATE pState, ushort_t cEvent, 1318 int cValue) 1319 { 1320 queue_t *pReadQueue = RD(pState->pWriteQueue); 1296 1321 mblk_t *pMBlk = allocb(sizeof(Firm_event, BPRI_HI)); 1297 1322 Firm_event *pEvent; -
trunk/src/VBox/Additions/common/VBoxGuest/testcase/solaris.h
r40430 r40488 298 298 #define cmn_err(...) do {} while(0) 299 299 #define allocb(...) NULL 300 #define ddi_soft_state_init(...) 0301 #define ddi_soft_state_fini(...) do {} while(0)302 #define mod_install(...) 0303 300 #define mod_remove(...) 0 304 301 #define mod_info(...) 0 … … 307 304 #define RTR0Init(...) VINF_SUCCESS 308 305 #define RTR0Term(...) do {} while(0) 306 #define RTLogCreate(...) VINF_SUCCESS 307 #define RTLogRelSetDefaultInstance(...) do {} while(0) 308 #define RTLogDestroy(...) do {} while(0) 309 309 #define VBoxGuestCreateKernelSession(...) VINF_SUCCESS 310 310 #define VBoxGuestCreateUserSession(...) VINF_SUCCESS … … 357 357 358 358 static modctl_t s_ModCtl; 359 360 #define mod_getctl(...) (&s_ModCtl) 359 static void **s_pvLinkage; 360 361 static inline modctl_t *mod_getctl(void **linkage) 362 { 363 s_pvLinkage = linkage; 364 return s_pvLinkage ? &s_ModCtl : NULL; 365 } 366 367 #define mod_install(linkage) (s_pvLinkage && ((linkage) == s_pvLinkage) ? 0 : EINVAL) 361 368 362 369 #define QREADR 0x00000010 … … 366 373 /* API stubs with controllable logic */ 367 374 368 void *s_pSoftState[256];369 void *s_pInstSoftState;370 371 static void testSetInstSoftState(void *pInst, unsigned cAllocated)372 {373 unsigned i;374 Assert(cAllocated < RT_ELEMENTS(s_pSoftState));375 s_pInstSoftState = pInst;376 RT_ZERO(s_pSoftState);377 for (i = 0; i < cAllocated; ++i)378 s_pSoftState[i] = (void *)1;379 }380 381 #define ddi_get_soft_state(a, c) \382 (c < RT_ELEMENTS(s_pSoftState) ? s_pSoftState[c] : NULL)383 #define ddi_soft_state_zalloc(a, c) \384 ( c < RT_ELEMENTS(s_pSoftState) && (s_pSoftState[c] = s_pInstSoftState) \385 ? DDI_SUCCESS : DDI_FAILURE)386 #define ddi_soft_state_free(a, c) \387 (c < RT_ELEMENTS(s_pSoftState) ? s_pSoftState[c] = NULL : NULL)388 389 375 #endif /* ___VBoxGuestTestCaseSolaris_h */ -
trunk/src/VBox/Additions/common/VBoxGuest/testcase/tstVBoxGuest-solaris.cpp
r40311 r40488 17 17 */ 18 18 19 #include <iprt/test.h>19 #include "tstVBoxGuest-solaris.h" 20 20 21 21 int main() … … 26 26 return rc; 27 27 RTTestBanner(hTest); 28 test_init(hTest); 28 29 29 30 /*
Note:
See TracChangeset
for help on using the changeset viewer.