Changeset 0edf7c7 in mainline for uspace/lib/usb/src/hc.c


Ignore:
Timestamp:
2011-05-20T20:01:25Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
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.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • 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 * @}
Note: See TracChangeset for help on using the changeset viewer.