Changeset b7068da in mainline for uspace/lib/usb/include/usb/hc.h


Ignore:
Timestamp:
2012-02-09T20:35:12Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
591762c6
Parents:
7cede12c (diff), 3d4750f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/hc.h

    r7cede12c rb7068da  
    11/*
    22 * Copyright (c) 2011 Vojtech Horky
     3 * Copyright (c) 2011 Jan Vesely
    34 * All rights reserved.
    45 *
     
    2627 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2728 */
    28 
    2929/** @addtogroup libusb
    3030 * @{
    3131 */
    3232/** @file
    33  * General communication with host controller driver.
     33 * General communication with host controller.
    3434 */
    3535#ifndef LIBUSB_HC_H_
    3636#define LIBUSB_HC_H_
    3737
    38 #include <sys/types.h>
    39 #include <ipc/devman.h>
    40 #include <ipc/loc.h>
     38#include <async.h>
     39#include <devman.h>
    4140#include <ddf/driver.h>
    4241#include <bool.h>
    43 #include <async.h>
     42#include <fibril_synch.h>
    4443#include <usb/usb.h>
    4544
    46 /** Connection to the host controller driver. */
     45/** Connection to the host controller driver.
     46 *
     47 * This is a high level IPC communication wrapper. After the structure has been
     48 * initialized using devman handle of an USB host controller, it
     49 * will manage all communication to that host controller, including session
     50 * creation/destruction and proper IPC protocol.
     51 */
    4752typedef struct {
    4853        /** Devman handle of the host controller. */
     
    5055        /** Session to the host controller. */
    5156        async_sess_t *hc_sess;
     57        /** Session guard. */
     58        fibril_mutex_t guard;
     59        /** Use counter. */
     60        unsigned ref_count;
    5261} usb_hc_connection_t;
     62
     63/** Initialize connection to USB host controller.
     64 *
     65 * @param connection Connection to be initialized.
     66 * @param hc_handle Devman handle of the host controller.
     67 * @return Error code.
     68 */
     69static inline void usb_hc_connection_initialize(usb_hc_connection_t *connection,
     70    devman_handle_t hc_handle)
     71{
     72        assert(connection);
     73        connection->hc_handle = hc_handle;
     74        connection->hc_sess = NULL;
     75        connection->ref_count = 0;
     76        fibril_mutex_initialize(&connection->guard);
     77}
    5378
    5479int usb_hc_connection_initialize_from_device(usb_hc_connection_t *,
    5580    const ddf_dev_t *);
    56 int usb_hc_connection_initialize(usb_hc_connection_t *, devman_handle_t);
     81
     82void usb_hc_connection_deinitialize(usb_hc_connection_t *);
    5783
    5884int usb_hc_connection_open(usb_hc_connection_t *);
    59 bool usb_hc_connection_is_opened(const usb_hc_connection_t *);
    6085int usb_hc_connection_close(usb_hc_connection_t *);
     86
     87usb_address_t usb_hc_request_address(usb_hc_connection_t *, usb_address_t, bool,
     88    usb_speed_t);
     89int usb_hc_bind_address(usb_hc_connection_t *, usb_address_t, devman_handle_t);
    6190int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t,
    6291    devman_handle_t *);
     92int usb_hc_release_address(usb_hc_connection_t *, usb_address_t);
    6393
    64 usb_address_t usb_get_address_by_handle(devman_handle_t);
     94int usb_hc_register_endpoint(usb_hc_connection_t *, usb_address_t,
     95    usb_endpoint_t, usb_transfer_type_t, usb_direction_t, size_t, unsigned int);
     96int usb_hc_unregister_endpoint(usb_hc_connection_t *, usb_address_t,
     97    usb_endpoint_t, usb_direction_t);
    6598
    66 int usb_hc_find(devman_handle_t, devman_handle_t *);
     99int usb_hc_read(usb_hc_connection_t *, usb_address_t, usb_endpoint_t,
     100    uint64_t, void *, size_t, size_t *);
     101int usb_hc_write(usb_hc_connection_t *, usb_address_t, usb_endpoint_t,
     102    uint64_t, const void *, size_t);
    67103
    68 int usb_resolve_device_handle(const char *, devman_handle_t *, usb_address_t *,
    69     devman_handle_t *);
    70 
    71 int usb_ddf_get_hc_handle_by_sid(service_id_t, devman_handle_t *);
    72 
     104/** Get host controller handle by its class index.
     105 *
     106 * @param sid Service ID of the HC function.
     107 * @param hc_handle Where to store the HC handle
     108 *      (can be NULL for existence test only).
     109 * @return Error code.
     110 */
     111static inline int usb_ddf_get_hc_handle_by_sid(
     112    service_id_t sid, devman_handle_t *handle)
     113{
     114        devman_handle_t h;
     115        return devman_fun_sid_to_handle(sid, handle ? handle : &h);
     116}
    73117
    74118#endif
Note: See TracChangeset for help on using the changeset viewer.