Changeset b04967a in mainline for uspace/drv/usbhub/ports.h


Ignore:
Timestamp:
2011-04-07T15:53:46Z (13 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c156c2d
Parents:
64dbc83 (diff), a82889e (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:

development merge

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhub/ports.h

    r64dbc83 rb04967a  
    11/*
    2  * Copyright (c) 2010 Matus Dekanek
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829/** @addtogroup drvusbhub
    2930 * @{
    3031 */
    3132/** @file
    32  * @brief usblist implementation
     33 * Hub ports related functions.
    3334 */
    34 #include <sys/types.h>
     35#ifndef DRV_USBHUB_PORTS_H
     36#define DRV_USBHUB_PORTS_H
    3537
    36 #include "usbhub_private.h"
     38#include <ipc/devman.h>
     39#include <usb/usb.h>
     40#include <ddf/driver.h>
     41#include <fibril_synch.h>
     42
     43#include <usb/hub.h>
     44
     45#include <usb/pipes.h>
     46#include <usb/devdrv.h>
     47
     48/** Information about single port on a hub. */
     49typedef struct {
     50        /** Mutex needed by CV for checking port reset. */
     51        fibril_mutex_t reset_mutex;
     52        /** CV for waiting to port reset completion. */
     53        fibril_condvar_t reset_cv;
     54        /** Whether port reset is completed.
     55         * Guarded by @c reset_mutex.
     56         */
     57        bool reset_completed;
     58
     59        /** Information about attached device. */
     60        usb_hc_attached_device_t attached_device;
     61} usb_hub_port_t;
     62
     63/** Initialize hub port information.
     64 *
     65 * @param port Port to be initialized.
     66 */
     67static inline void usb_hub_port_init(usb_hub_port_t *port) {
     68        port->attached_device.address = -1;
     69        port->attached_device.handle = 0;
     70        fibril_mutex_initialize(&port->reset_mutex);
     71        fibril_condvar_initialize(&port->reset_cv);
     72}
     73
     74bool hub_port_changes_callback(usb_device_t *, uint8_t *, size_t, void *);
    3775
    3876
    39 usb_general_list_t * usb_lst_create(void) {
    40         usb_general_list_t* result = usb_new(usb_general_list_t);
    41         usb_lst_init(result);
    42         return result;
    43 }
    44 
    45 void usb_lst_init(usb_general_list_t * lst) {
    46         lst->prev = lst;
    47         lst->next = lst;
    48         lst->data = NULL;
    49 }
    50 
    51 void usb_lst_prepend(usb_general_list_t* item, void* data) {
    52         usb_general_list_t* appended = usb_new(usb_general_list_t);
    53         appended->data = data;
    54         appended->next = item;
    55         appended->prev = item->prev;
    56         item->prev->next = appended;
    57         item->prev = appended;
    58 }
    59 
    60 void usb_lst_append(usb_general_list_t* item, void* data) {
    61         usb_general_list_t* appended = usb_new(usb_general_list_t);
    62         appended->data = data;
    63         appended->next = item->next;
    64         appended->prev = item;
    65         item->next->prev = appended;
    66         item->next = appended;
    67 }
    68 
    69 void usb_lst_remove(usb_general_list_t* item) {
    70         item->next->prev = item->prev;
    71         item->prev->next = item->next;
    72 }
    73 
    74 
    75 
     77#endif
    7678/**
    7779 * @}
    7880 */
    79 
    80 
Note: See TracChangeset for help on using the changeset viewer.