- Timestamp:
- Aug 15, 2016 12:54:45 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-netbsd.c
r63454 r63455 149 149 150 150 static const struct fileops vboxguest_fileops = { 151 152 153 154 155 156 157 158 159 151 .fo_read = fbadop_read, 152 .fo_write = fbadop_write, 153 .fo_ioctl = VBoxGuestNetBSDIOCtl, 154 .fo_fcntl = fnullop_fcntl, 155 .fo_poll = VBoxGuestNetBSDPoll, 156 .fo_stat = fbadop_stat, 157 .fo_close = VBoxGuestNetBSDClose, 158 .fo_kqfilter = fnullop_kqfilter, 159 .fo_restart = fnullop_restart 160 160 }; 161 161 … … 184 184 LogFlow((DEVICE_NAME ": %s\n", __func__)); 185 185 186 if ((vboxguest = device_lookup_private(&vboxguest_cd, minor(device))) == NULL) { 186 if ((vboxguest = device_lookup_private(&vboxguest_cd, minor(device))) == NULL) 187 { 187 188 printf("device_lookup_private failed\n"); 188 189 return (ENXIO); 189 190 } 190 if ((vboxguest->vboxguest_state & VBOXGUEST_STATE_INITOK) == 0) { 191 192 if ((vboxguest->vboxguest_state & VBOXGUEST_STATE_INITOK) == 0) 193 { 191 194 aprint_error_dev(vboxguest->sc_dev, "device not configured\n"); 192 195 return (ENXIO); … … 194 197 195 198 session = kmem_alloc(sizeof(*session), KM_SLEEP); 196 if (session == NULL) { 199 if (session == NULL) 200 { 197 201 return (ENOMEM); 198 202 } … … 200 204 session->sc = vboxguest; 201 205 202 if ((error = fd_allocfile(&fp, &fd)) != 0) { 206 if ((error = fd_allocfile(&fp, &fd)) != 0) 207 { 203 208 kmem_free(session, sizeof(*session)); 204 209 return error; … … 257 262 * Validate the request wrapper. 258 263 */ 259 if (IOCPARM_LEN(command) != sizeof(VBGLBIGREQ)) { 264 if (IOCPARM_LEN(command) != sizeof(VBGLBIGREQ)) 265 { 260 266 Log((DEVICE_NAME ": %s: bad request %#lx size=%lu expected=%zu\n", 261 267 __func__, command, IOCPARM_LEN(command), sizeof(VBGLBIGREQ))); … … 312 318 size_t cbDataReturned; 313 319 rc = VGDrvCommonIoCtl(command, &g_DevExt, session->session, pvBuf, ReqWrap->cbData, &cbDataReturned); 314 if (RT_SUCCESS(rc)) { 320 if (RT_SUCCESS(rc)) 321 { 315 322 rc = 0; 316 323 if (RT_UNLIKELY(cbDataReturned > ReqWrap->cbData)) … … 351 358 352 359 u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq); 353 if (session->session->u32MousePosChangedSeq != u32CurSeq) { 360 if (session->session->u32MousePosChangedSeq != u32CurSeq) 361 { 354 362 events_processed = events & (POLLIN | POLLRDNORM); 355 363 session->session->u32MousePosChangedSeq = u32CurSeq; 356 } else { 364 } 365 else 366 { 357 367 events_processed = 0; 358 368 … … 373 383 return EBUSY; 374 384 375 if ((vboxguest->vboxguest_state & VBOXGUEST_STATE_INITOK) == 0) {385 if ((vboxguest->vboxguest_state & VBOXGUEST_STATE_INITOK) == 0) 376 386 return 0; 377 }378 387 379 388 /* … … 436 445 LogFlow((DEVICE_NAME ": %s\n", __func__)); 437 446 438 if (pci_intr_map(pa, &vboxguest->ih)) { 447 if (pci_intr_map(pa, &vboxguest->ih)) 448 { 439 449 aprint_error_dev(vboxguest->sc_dev, "couldn't map interrupt.\n"); 440 450 return VERR_DEV_IO_ERROR; 441 451 } 452 442 453 intrstr = pci_intr_string(vboxguest->pc, vboxguest->ih 443 454 #if __NetBSD_Prereq__(6, 99, 39) … … 446 457 ); 447 458 aprint_normal_dev(vboxguest->sc_dev, "interrupting at %s\n", intrstr); 459 448 460 vboxguest->pfnIrqHandler = pci_intr_establish(vboxguest->pc, vboxguest->ih, IPL_BIO, VBoxGuestNetBSDISR, vboxguest); 449 if (vboxguest->pfnIrqHandler == NULL) { 461 if (vboxguest->pfnIrqHandler == NULL) 462 { 450 463 aprint_error_dev(vboxguest->sc_dev, "couldn't establish interrupt\n"); 451 464 return VERR_DEV_IO_ERROR; … … 496 509 LogFunc(("RTR0Init failed.\n")); 497 510 aprint_error_dev(vboxguest->sc_dev, "RTR0Init failed\n"); 498 return 511 return; 499 512 } 500 513 … … 537 550 { 538 551 vboxguest->vboxguest_state |= VBOXGUEST_STATE_INITOK; 539 return 552 return; 540 553 } 541 554 VGDrvCommonDeleteDevExt(&g_DevExt); 542 } else { 555 } 556 else 557 { 543 558 aprint_error_dev(vboxguest->sc_dev, "init failed\n"); 544 559 } 545 560 bus_space_unmap(vboxguest->iVMMDevMemResId, vboxguest->VMMDevMemHandle, vboxguest->VMMDevMemSize); 546 } else { 561 } 562 else 563 { 547 564 aprint_error_dev(vboxguest->sc_dev, "MMIO mapping failed\n"); 548 565 } 549 566 bus_space_unmap(vboxguest->io_tag, vboxguest->io_handle, vboxguest->io_regsize); 550 } else { 567 } 568 else 569 { 551 570 aprint_error_dev(vboxguest->sc_dev, "IO mapping failed\n"); 552 571 } 553 572 554 573 RTR0Term(); 555 return 574 return; 556 575 } 557 576 … … 581 600 582 601 static const struct cfparent pspec = { 583 602 "pci", "pci", DVUNIT_ANY 584 603 }; 585 604 586 605 static struct cfdata vboxguest_cfdata[] = { 587 588 589 590 591 592 593 594 595 596 606 { 607 .cf_name = "vboxguest", 608 .cf_atname = "vboxguest", 609 .cf_unit = 0, /* Only unit 0 is ever used */ 610 .cf_fstate = FSTATE_STAR, 611 .cf_loc = loc, 612 .cf_flags = 0, 613 .cf_pspec = &pspec, 614 }, 615 { NULL, NULL, 0, 0, NULL, 0, NULL } 597 616 }; 598 617 … … 607 626 608 627 bmajor = cmajor = NODEVMAJOR; 609 switch (cmd) { 628 switch (cmd) 629 { 610 630 case MODULE_CMD_INIT: 611 error = config_cfdriver_attach(&vboxguest_cd); 612 if (error) { 613 printf("config_cfdriver_attach failed: %d", error); 614 break; 615 } 616 error = config_cfattach_attach(vboxguest_cd.cd_name, &vboxguest_ca); 617 if (error) { 618 config_cfdriver_detach(&vboxguest_cd); 619 printf("%s: unable to register cfattach\n", vboxguest_cd.cd_name); 620 break; 621 } 622 623 error = config_cfdata_attach(vboxguest_cfdata, 1); 624 if (error) { 625 printf("%s: unable to attach cfdata\n", vboxguest_cd.cd_name); 626 config_cfattach_detach(vboxguest_cd.cd_name, &vboxguest_ca); 627 config_cfdriver_detach(&vboxguest_cd); 628 break; 629 } 630 631 error = devsw_attach("vboxguest", NULL, &bmajor, &g_VBoxGuestNetBSDChrDevSW, &cmajor); 631 error = config_cfdriver_attach(&vboxguest_cd); 632 if (error) 633 { 634 printf("config_cfdriver_attach failed: %d", error); 635 break; 636 } 637 error = config_cfattach_attach(vboxguest_cd.cd_name, &vboxguest_ca); 638 if (error) 639 { 640 config_cfdriver_detach(&vboxguest_cd); 641 printf("%s: unable to register cfattach\n", vboxguest_cd.cd_name); 642 break; 643 } 644 error = config_cfdata_attach(vboxguest_cfdata, 1); 645 if (error) 646 { 647 printf("%s: unable to attach cfdata\n", vboxguest_cd.cd_name); 648 config_cfattach_detach(vboxguest_cd.cd_name, &vboxguest_ca); 649 config_cfdriver_detach(&vboxguest_cd); 650 break; 651 } 652 653 error = devsw_attach("vboxguest", NULL, &bmajor, &g_VBoxGuestNetBSDChrDevSW, &cmajor); 632 654 633 if (error == EEXIST) 634 error = 0; /* maybe built-in ... improve eventually */ 635 if (error) 636 break; 637 638 error = do_sys_mknod(curlwp, "/dev/vboxguest", 0666|S_IFCHR, makedev(cmajor, 0), &retval, UIO_SYSSPACE); 639 if (error == EEXIST) 640 error = 0; 655 if (error == EEXIST) 656 error = 0; /* maybe built-in ... improve eventually */ 657 658 if (error) 641 659 break; 660 661 error = do_sys_mknod(curlwp, "/dev/vboxguest", 0666|S_IFCHR, makedev(cmajor, 0), &retval, UIO_SYSSPACE); 662 if (error == EEXIST) 663 error = 0; 664 break; 665 642 666 case MODULE_CMD_FINI: 643 error = config_cfdata_detach(vboxguest_cfdata); 644 if (error) 645 break; 646 error = config_cfattach_detach(vboxguest_cd.cd_name, &vboxguest_ca); 647 if (error) 648 break; 649 config_cfdriver_detach(&vboxguest_cd); 650 error = devsw_detach(NULL, &g_VBoxGuestNetBSDChrDevSW); 667 error = config_cfdata_detach(vboxguest_cfdata); 668 if (error) 651 669 break; 670 error = config_cfattach_detach(vboxguest_cd.cd_name, &vboxguest_ca); 671 if (error) 672 break; 673 config_cfdriver_detach(&vboxguest_cd); 674 error = devsw_detach(NULL, &g_VBoxGuestNetBSDChrDevSW); 675 break; 676 652 677 default: 653 678 return ENOTTY; 654 679 } 655 680 return error;
Note:
See TracChangeset
for help on using the changeset viewer.