Changeset e27595b in mainline for uspace/lib/usbvirt/main.c


Ignore:
Timestamp:
2010-11-20T13:04:15Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0e126be7
Parents:
7034be15
Message:

Virtual USB devices can connect to VHC

Fixed and bypassed problems introduced by using DDF.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbvirt/main.c

    r7034be15 re27595b  
    3333 * @brief Device registration with virtual USB framework.
    3434 */
    35 #include <devmap.h>
    36 #include <fcntl.h>
    37 #include <vfs/vfs.h>
     35#include <devman.h>
    3836#include <errno.h>
    3937#include <stdlib.h>
     
    181179                return;
    182180        }
    183        
     181
    184182        device_callback_connection(dev->device, iid, icall);
    185183}
     
    187185/** Create necessary phones for comunication with virtual HCD.
    188186 * This function wraps following calls:
    189  * -# open <code>/dev/usb/<i>hcd_path</i></code> for reading
     187 * -# open <code>/dev/devices/\\vhc for reading
    190188 * -# access phone of file opened in previous step
    191189 * -# create callback through just opened phone
     
    202200 * @return EOK on success or error code from errno.h.
    203201 */
    204 int usbvirt_connect(usbvirt_device_t *dev, const char *hcd_path)
     202int usbvirt_connect(usbvirt_device_t *dev)
    205203{
    206204        virtual_device_t *virtual_device = find_device(dev);
     
    209207        }
    210208       
    211         char dev_path[DEVMAP_NAME_MAXLEN + 1];
    212         snprintf(dev_path, DEVMAP_NAME_MAXLEN,
    213             "/dev/%s/%s", NAMESPACE, hcd_path);
    214        
    215         int fd = open(dev_path, O_RDONLY);
    216         if (fd < 0) {
    217                 return fd;
    218         }
    219        
    220         int hcd_phone = fd_phone(fd);
     209        const char *vhc_path = "/vhc";
     210        int rc;
     211        devman_handle_t handle;
     212
     213        rc = devman_device_get_handle(vhc_path, &handle, 0);
     214        if (rc != EOK) {
     215                printf("devman_device_get_handle() failed\n");
     216                return rc;
     217        }
     218       
     219        int hcd_phone = devman_device_connect(handle, 0);
    221220       
    222221        if (hcd_phone < 0) {
     222                printf("devman_device_connect() failed\n");
    223223                return hcd_phone;
    224224        }
    225225       
    226226        ipcarg_t phonehash;
    227         int rc = ipc_connect_to_me(hcd_phone, 0, 0, 0, &phonehash);
     227        rc = ipc_connect_to_me(hcd_phone, 0, 0, 0, &phonehash);
    228228        if (rc != EOK) {
     229                printf("ipc_connect_to_me() failed\n");
    229230                return rc;
    230231        }
Note: See TracChangeset for help on using the changeset viewer.