VirtualBox

Ignore:
Timestamp:
Mar 13, 2009 7:29:11 PM (16 years ago)
Author:
vboxsync
Message:

Additions/linux/vboxadd: added vboxuser device to kernel module for use by OpenGL guest additions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/module/vboxmod.c

    r17853 r17857  
    666666
    667667/**
    668  * IOCTL handler
    669  *
     668 * IOCTL handler for vboxadd
    670669 */
    671670static int vboxadd_ioctl(struct inode *inode, struct file *filp,
     
    852851
    853852/**
     853 * IOCTL handler for vboxuser
     854 */
     855static int vboxuser_ioctl(struct inode *inode, struct file *filp,
     856                          unsigned int cmd, unsigned long arg)
     857{
     858        int rc = 0;
     859
     860        /* Deal with variable size ioctls first. */
     861        if (   VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL(0))
     862                 == VBOXGUEST_IOCTL_STRIP_SIZE(cmd))
     863        {
     864        /* Do the HGCM call using the Vbgl bits */
     865                IOCTL_ENTRY("VBOXGUEST_IOCTL_HGCM_CALL", arg);
     866                rc = vboxadd_hgcm_call(arg, _IOC_SIZE(cmd));
     867                IOCTL_EXIT("VBOXGUEST_IOCTL_HGCM_CALL", arg);
     868        }
     869        else if (   VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL_TIMED(0))
     870                 == VBOXGUEST_IOCTL_STRIP_SIZE(cmd))
     871        {
     872        /* Do the HGCM call using the Vbgl bits */
     873                IOCTL_ENTRY("VBOXGUEST_IOCTL_HGCM_CALL_TIMED", arg);
     874                rc = vboxadd_hgcm_call_timed(arg, _IOC_SIZE(cmd));
     875                IOCTL_EXIT("VBOXGUEST_IOCTL_HGCM_CALL_TIMED", arg);
     876        }
     877        else
     878        {
     879            switch (cmd) {
     880            case VBOXGUEST_IOCTL_HGCM_CONNECT:
     881                    IOCTL_ENTRY("VBOXGUEST_IOCTL_HGCM_CONNECT", arg);
     882                    rc = vboxadd_hgcm_connect(filp, arg);
     883                    IOCTL_EXIT("VBOXGUEST_IOCTL_HGCM_CONNECT", arg);
     884                    break;
     885            case VBOXGUEST_IOCTL_HGCM_DISCONNECT:
     886                    IOCTL_ENTRY("VBOXGUEST_IOCTL_HGCM_DISCONNECT", arg);
     887                    vboxadd_hgcm_disconnect(filp, arg);
     888                    IOCTL_EXIT("VBOXGUEST_IOCTL_HGCM_DISCONNECT", arg);
     889                    break;
     890            default:
     891                    LogRelFunc(("unknown command: %x\n", cmd));
     892                    rc = -EINVAL;
     893                    break;
     894            }
     895        }
     896        return rc;
     897}
     898
     899/**
    854900 * Poll function.  This returns "ready to read" if the guest is in absolute
    855901 * mouse pointer mode and the pointer position has changed since the last
     
    890936
    891937/**
    892  * File close handler.  Clean up any HGCM connections associated with the open file
    893  * which might still be open.
     938 * File close handler for vboxadd.  Clean up any HGCM connections associated
     939 * with the open file which might still be open.
    894940 */
    895941static int vboxadd_release(struct inode *inode, struct file * filp)
     
    898944        /* Deactivate our asynchronous queue. */
    899945        vboxadd_fasync(-1, filp, 0);
     946        return 0;
     947}
     948
     949/**
     950 * File close handler for vboxuser.  Clean up any HGCM connections associated
     951 * with the open file which might still be open.
     952 */
     953static int vboxuser_release(struct inode *inode, struct file * filp)
     954{
     955        vboxadd_unregister_all_hgcm_connections(filp);
    900956        return 0;
    901957}
     
    920976    name:       VBOXADD_NAME,
    921977    fops:       &vboxadd_fops
     978};
     979
     980/** file operations for the vboxuser device */
     981static struct file_operations vboxuser_fops =
     982{
     983    .owner   = THIS_MODULE,
     984    .open    = vboxadd_open,
     985    .ioctl   = vboxuser_ioctl,
     986    .release = vboxuser_release,
     987    .llseek  = no_llseek
     988};
     989
     990/** Miscellaneous device allocation for vboxuser */
     991static struct miscdevice gMiscVBoxUser =
     992{
     993    minor:      MISC_DYNAMIC_MINOR,
     994    name:       VBOXUSER_NAME,
     995    fops:       &vboxuser_fops
    922996};
    923997
     
    11711245{
    11721246    int rc = 0, rcVBox = VINF_SUCCESS;
    1173     bool haveVBoxAdd = false, haveGuestLib = false;
     1247    bool haveVBoxAdd = false, haveVBoxUser = false, haveGuestLib = false;
    11741248    struct pci_dev *pcidev = NULL;
    11751249
     
    12191293    if (!rc)
    12201294        haveVBoxAdd = true;
     1295
     1296    /* Register our user session device */
     1297    if (!rc) {
     1298        rc = misc_register(&gMiscVBoxUser);
     1299        if (rc)
     1300            LogRel(("vboxadd: misc_register failed for %s (rc=%d)\n",
     1301                    VBOXUSER_NAME, rc));
     1302    }
     1303    if (!rc)
     1304        haveVBoxUser = true;
    12211305
    12221306    /* allocate and initialize device extension */
     
    14281512        if (vboxDev)
    14291513            free_resources();
     1514        if (haveVBoxUser)
     1515            misc_deregister(&gMiscVBoxUser);
    14301516        if (haveVBoxAdd && vbox_major > 0)
    14311517            unregister_chrdev(vbox_major, VBOXADD_NAME);
     
    14461532static __exit void fini(void)
    14471533{
     1534    misc_deregister(&gMiscVBoxUser);
    14481535    if (vbox_major > 0)
    14491536        unregister_chrdev(vbox_major, VBOXADD_NAME);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette