Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 0edf7c7 in mainline


Ignore:
Timestamp:
2011-05-20T20:01:25Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
04028225
Parents:
a60afd0
Message:

HC communication moved into libusb

Although communication with HC looked like a thing common only
to devices, any utility wanting to communicate with the device may
try to get some information about it from the HC.

Thus the usb_hc_connection* and some other generic functions were
moved into libusb.

Also merged dev/hc.h and host.h into hc.h.

Location:
uspace
Files:
2 deleted
9 edited
2 moved

Legend:

Unmodified
Added
Removed
  • uspace/app/lsusb/main.c

    ra60afd0 r0edf7c7  
    4545#include <devmap.h>
    4646#include <usb/dev/hub.h>
    47 #include <usb/host.h>
     47#include <usb/hc.h>
    4848
    4949#define NAME "lsusb"
  • uspace/app/mkbd/main.c

    ra60afd0 r0edf7c7  
    4545#include <devmap.h>
    4646#include <usb/dev/hub.h>
    47 #include <usb/host.h>
     47#include <usb/hc.h>
    4848#include <usb/driver.h>
    4949#include <usb/dev/pipes.h>
  • uspace/app/usbinfo/main.c

    ra60afd0 r0edf7c7  
    4343#include <devman.h>
    4444#include <devmap.h>
    45 #include <usb/dev/hc.h>
     45#include <usb/hc.h>
    4646#include <usb/dev/pipes.h>
    47 #include <usb/host.h>
    4847#include <usb/driver.h>
    4948#include "usbinfo.h"
  • uspace/drv/uhci-rhd/port.h

    ra60afd0 r0edf7c7  
    3838#include <fibril.h>
    3939#include <ddf/driver.h>
    40 #include <usb/dev/hc.h> /* usb_hc_connection_t */
     40#include <usb/hc.h> /* usb_hc_connection_t */
    4141
    4242typedef uint16_t port_status_t;
  • uspace/lib/usb/Makefile

    ra60afd0 r0edf7c7  
    3939        src/driver.c \
    4040        src/dump.c \
    41         src/host.c \
     41        src/hc.c \
    4242        src/usb.c
    4343
  • uspace/lib/usb/include/usb/hc.h

    ra60afd0 r0edf7c7  
    2727 */
    2828
    29 /** @addtogroup libusbdev
     29/** @addtogroup libusb
    3030 * @{
    3131 */
    3232/** @file
    33  * General communication between device drivers and host controller driver.
     33 * General communication with host controller driver.
    3434 */
    35 #ifndef LIBUSBDEV_HC_H_
    36 #define LIBUSBDEV_HC_H_
     35#ifndef LIBUSB_HC_H_
     36#define LIBUSB_HC_H_
    3737
    3838#include <sys/types.h>
     
    5757bool usb_hc_connection_is_opened(const usb_hc_connection_t *);
    5858int usb_hc_connection_close(usb_hc_connection_t *);
     59int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t,
     60    devman_handle_t *);
    5961
     62int usb_ddf_get_hc_handle_by_class(size_t, devman_handle_t *);
    6063
    6164
  • uspace/lib/usb/src/hc.c

    ra60afd0 r0edf7c7  
    2727 */
    2828
    29 /** @addtogroup libusbdev
     29/** @addtogroup libusb
    3030 * @{
    3131 */
    3232/** @file
    33  * General communication between device drivers and host controller driver.
     33 * General communication with host controller driver (implementation).
    3434 */
    3535#include <devman.h>
    3636#include <async.h>
     37#include <dev_iface.h>
    3738#include <usb_iface.h>
    38 #include <usb/dev/hc.h>
     39#include <usbhc_iface.h>
     40#include <usb/hc.h>
    3941#include <usb/driver.h>
    4042#include <usb/debug.h>
     
    143145}
    144146
     147/** Get handle of USB device with given address.
     148 *
     149 * @param[in] connection Opened connection to host controller.
     150 * @param[in] address Address of device in question.
     151 * @param[out] handle Where to write the device handle.
     152 * @return Error code.
     153 */
     154int usb_hc_get_handle_by_address(usb_hc_connection_t *connection,
     155    usb_address_t address, devman_handle_t *handle)
     156{
     157        if (!usb_hc_connection_is_opened(connection)) {
     158                return ENOENT;
     159        }
     160
     161        sysarg_t tmp;
     162        int rc = async_req_2_1(connection->hc_phone,
     163            DEV_IFACE_ID(USBHC_DEV_IFACE),
     164            IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
     165            address, &tmp);
     166        if ((rc == EOK) && (handle != NULL)) {
     167                *handle = tmp;
     168        }
     169
     170        return rc;
     171}
     172
     173
     174/** Get host controller handle by its class index.
     175 *
     176 * @param class_index Class index for the host controller.
     177 * @param hc_handle Where to store the HC handle
     178 *      (can be NULL for existence test only).
     179 * @return Error code.
     180 */
     181int usb_ddf_get_hc_handle_by_class(size_t class_index,
     182    devman_handle_t *hc_handle)
     183{
     184        char *class_index_str;
     185        devman_handle_t hc_handle_tmp;
     186        int rc;
     187
     188        rc = asprintf(&class_index_str, "%zu", class_index);
     189        if (rc < 0) {
     190                return ENOMEM;
     191        }
     192        rc = devman_device_get_handle_by_class("usbhc", class_index_str,
     193            &hc_handle_tmp, 0);
     194        free(class_index_str);
     195        if (rc != EOK) {
     196                return rc;
     197        }
     198
     199        if (hc_handle != NULL) {
     200                *hc_handle = hc_handle_tmp;
     201        }
     202
     203        return EOK;
     204}
     205
    145206/**
    146207 * @}
  • uspace/lib/usbdev/Makefile

    ra60afd0 r0edf7c7  
    4646        src/pipesio.c \
    4747        src/recognise.c \
    48         src/request.c \
    49         src/usbdevice.c
     48        src/request.c
    5049
    5150include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/usbdev/include/usb/dev/hub.h

    ra60afd0 r0edf7c7  
    3939
    4040#include <sys/types.h>
    41 #include <usb/dev/hc.h>
     41#include <usb/hc.h>
    4242
    4343int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t,
     
    6363    const usb_hc_attached_device_t *);
    6464int usb_hc_unregister_device(usb_hc_connection_t *, usb_address_t);
    65 int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t,
    66     devman_handle_t *);
    6765
    6866#endif
  • uspace/lib/usbdev/include/usb/dev/pipes.h

    ra60afd0 r0edf7c7  
    3838#include <sys/types.h>
    3939#include <usb/usb.h>
    40 #include <usb/dev/hc.h>
     40#include <usb/hc.h>
    4141#include <usb/descriptor.h>
    4242#include <ipc/devman.h>
  • uspace/lib/usbdev/src/hub.c

    ra60afd0 r0edf7c7  
    120120}
    121121
    122 /** Get handle of USB device with given address.
    123  *
    124  * @param[in] connection Opened connection to host controller.
    125  * @param[in] address Address of device in question.
    126  * @param[out] handle Where to write the device handle.
    127  * @return Error code.
    128  */
    129 int usb_hc_get_handle_by_address(usb_hc_connection_t *connection,
    130     usb_address_t address, devman_handle_t *handle)
    131 {
    132         CHECK_CONNECTION(connection);
    133 
    134         sysarg_t tmp;
    135         int rc = async_req_2_1(connection->hc_phone,
    136             DEV_IFACE_ID(USBHC_DEV_IFACE),
    137             IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
    138             address, &tmp);
    139         if ((rc == EOK) && (handle != NULL)) {
    140                 *handle = tmp;
    141         }
    142 
    143         return rc;
    144 }
    145122
    146123static void unregister_control_endpoint_on_default_address(
Note: See TracChangeset for help on using the changeset viewer.