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

Changeset 11658b64 in mainline for uspace/drv/vhc/hub/virthub.h


Ignore:
Timestamp:
2010-12-16T11:54:53Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
557c7d0, 5863a95, 82122f3, a8b7dfd, f2962621
Parents:
a9b6bec (diff), 70e5ad5 (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:

Merged vojtechhorky/ - libusbvirt clean-up

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/vhc/hub/virthub.h

    ra9b6bec r11658b64  
    3131 */
    3232/** @file
    33  * @brief
     33 * @brief USB hub as a virtual USB device.
    3434 */
    35 #ifndef VHCD_HUBINTERN_H_
    36 #define VHCD_HUBINTERN_H_
     35#ifndef VHC_HUB_VIRTHUB_H_
     36#define VHC_HUB_VIRTHUB_H_
    3737
     38#include <usbvirt/device.h>
     39#include "../devices.h"
    3840#include "hub.h"
    39 #include <fibril_synch.h>
    4041
    4142/** Endpoint number for status change pipe. */
     
    4344/** Configuration value for hub configuration. */
    4445#define HUB_CONFIGURATION_ID 1
     46
    4547
    4648/** Hub descriptor.
     
    6971} __attribute__ ((packed)) hub_descriptor_t;
    7072
    71 /** Hub port internal state.
    72  * Some states (e.g. port over current) are not covered as they are not
    73  * simulated at all.
    74  */
    75 typedef enum {
    76         HUB_PORT_STATE_NOT_CONFIGURED,
    77         HUB_PORT_STATE_POWERED_OFF,
    78         HUB_PORT_STATE_DISCONNECTED,
    79         HUB_PORT_STATE_DISABLED,
    80         HUB_PORT_STATE_RESETTING,
    81         HUB_PORT_STATE_ENABLED,
    82         HUB_PORT_STATE_SUSPENDED,
    83         HUB_PORT_STATE_RESUMING,
    84         /* HUB_PORT_STATE_, */
    85 } hub_port_state_t;
    86 
    87 /** Convert hub port state to a char. */
    88 static inline char hub_port_state_as_char(hub_port_state_t state) {
    89         switch (state) {
    90                 case HUB_PORT_STATE_NOT_CONFIGURED:
    91                         return '-';
    92                 case HUB_PORT_STATE_POWERED_OFF:
    93                         return 'O';
    94                 case HUB_PORT_STATE_DISCONNECTED:
    95                         return 'X';
    96                 case HUB_PORT_STATE_DISABLED:
    97                         return 'D';
    98                 case HUB_PORT_STATE_RESETTING:
    99                         return 'R';
    100                 case HUB_PORT_STATE_ENABLED:
    101                         return 'E';
    102                 case HUB_PORT_STATE_SUSPENDED:
    103                         return 'S';
    104                 case HUB_PORT_STATE_RESUMING:
    105                         return 'F';
    106                 default:
    107                         return '?';
    108         }
    109 }
    110 
    111 /** Hub status change mask bits. */
    112 typedef enum {
    113         HUB_STATUS_C_PORT_CONNECTION = (1 << 0),
    114         HUB_STATUS_C_PORT_ENABLE = (1 << 1),
    115         HUB_STATUS_C_PORT_SUSPEND = (1 << 2),
    116         HUB_STATUS_C_PORT_OVER_CURRENT = (1 << 3),
    117         HUB_STATUS_C_PORT_RESET = (1 << 4),
    118         /* HUB_STATUS_C_ = (1 << ), */
    119 } hub_status_change_t;
    120 
    121 /** Hub port information. */
    122 typedef struct {
    123         virtdev_connection_t *device;
    124         int index;
    125         hub_port_state_t state;
    126         uint16_t status_change;
    127         fibril_mutex_t guard;
    128 } hub_port_t;
    129 
    130 /** Hub device type. */
    131 typedef struct {
    132         hub_port_t ports[HUB_PORT_COUNT];
    133 } hub_device_t;
    134 
    135 extern hub_device_t hub_dev;
    136 
     73extern usbvirt_device_ops_t hub_ops;
    13774extern hub_descriptor_t hub_descriptor;
    13875
    139 extern usbvirt_device_ops_t hub_ops;
    140 
    141 void clear_port_status_change(hub_port_t *, uint16_t);
    142 void set_port_status_change(hub_port_t *, uint16_t);
    143 void set_port_status_change_nl(hub_port_t *, uint16_t);
    144 
     76int virthub_init(usbvirt_device_t *);
     77int virthub_connect_device(usbvirt_device_t *, virtdev_connection_t *);
     78int virthub_disconnect_device(usbvirt_device_t *, virtdev_connection_t *);
     79bool virthub_is_device_enabled(usbvirt_device_t *, virtdev_connection_t *);
     80void virthub_get_status(usbvirt_device_t *, char *, size_t);
    14581
    14682#endif
Note: See TracChangeset for help on using the changeset viewer.