Changeset 774afaae in mainline for uspace/drv/vhc/hub/virthub.h
- Timestamp:
- 2010-12-15T21:56:14Z (12 years ago)
- Branches:
- lfn, master, serial
- Children:
- e63a4e1
- Parents:
- 1840e0d
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/hub/virthub.h
r1840e0d r774afaae 33 33 * @brief 34 34 */ 35 #ifndef VHC D_HUBINTERN_H_36 #define VHC D_HUBINTERN_H_35 #ifndef VHC_HUB_VIRTHUB_H_ 36 #define VHC_HUB_VIRTHUB_H_ 37 37 38 #include <usbvirt/device.h> 39 #include "../devices.h" 38 40 #include "hub.h" 39 #include <fibril_synch.h>40 41 41 42 /** Endpoint number for status change pipe. */ … … 43 44 /** Configuration value for hub configuration. */ 44 45 #define HUB_CONFIGURATION_ID 1 46 45 47 46 48 /** Hub descriptor. … … 69 71 } __attribute__ ((packed)) hub_descriptor_t; 70 72 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 73 extern usbvirt_device_ops_t hub_ops; 137 74 extern hub_descriptor_t hub_descriptor; 138 75 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 76 int virthub_init(usbvirt_device_t *); 77 int virthub_connect_device(usbvirt_device_t *, virtdev_connection_t *); 78 int virthub_disconnect_device(usbvirt_device_t *, virtdev_connection_t *); 79 bool virthub_is_device_enabled(usbvirt_device_t *, virtdev_connection_t *); 80 void virthub_get_status(usbvirt_device_t *, char *, size_t); 145 81 146 82 #endif
Note: See TracChangeset
for help on using the changeset viewer.