Changes in uspace/drv/vhc/hub.c [4b4c797:1e32a63] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/hub.c
r4b4c797 r1e32a63 37 37 #include <usbvirt/device.h> 38 38 #include <errno.h> 39 #include <str_error.h> 39 40 #include <stdlib.h> 41 #include <driver.h> 40 42 41 43 #include "vhcd.h" 42 44 #include "hub.h" 43 45 #include "hubintern.h" 46 #include "conn.h" 44 47 45 48 … … 141 144 .ops = &hub_ops, 142 145 .descriptors = &descriptors, 143 .lib_debug_level = 4,146 .lib_debug_level = 0, 144 147 .lib_debug_enabled_tags = USBVIRT_DEBUGTAG_ALL 145 148 }; … … 148 151 hub_device_t hub_dev; 149 152 153 static usb_address_t hub_set_address(usbvirt_device_t *hub) 154 { 155 usb_address_t new_address; 156 int rc = vhc_iface.request_address(NULL, &new_address); 157 if (rc != EOK) { 158 return rc; 159 } 160 161 usb_device_request_setup_packet_t setup_packet = { 162 .request_type = 0, 163 .request = USB_DEVREQ_SET_ADDRESS, 164 .index = 0, 165 .length = 0, 166 }; 167 setup_packet.value = new_address; 168 169 hub->transaction_setup(hub, 0, &setup_packet, sizeof(setup_packet)); 170 hub->transaction_in(hub, 0, NULL, 0, NULL); 171 172 return new_address; 173 } 174 150 175 /** Initialize virtual hub. */ 151 void hub_init(void) 152 { 153 size_t i; 176 void hub_init(device_t *hc_dev) 177 { 178 size_t i; 179 154 180 for (i = 0; i < HUB_PORT_COUNT; i++) { 155 181 hub_port_t *port = &hub_dev.ports[i]; 156 182 183 port->index = (int) i + 1; 157 184 port->device = NULL; 158 185 port->state = HUB_PORT_STATE_NOT_CONFIGURED; 159 186 port->status_change = 0; 187 fibril_mutex_initialize(&port->guard); 160 188 } 161 189 … … 163 191 164 192 dprintf(1, "virtual hub (%d ports) created", HUB_PORT_COUNT); 193 194 usb_address_t hub_address = hub_set_address(&virthub_dev); 195 if (hub_address < 0) { 196 dprintf(1, "problem changing hub address (%s)", 197 str_error(hub_address)); 198 } 199 200 dprintf(2, "virtual hub address changed to %d", hub_address); 201 202 char *id; 203 int rc = asprintf(&id, "usb&hub"); 204 if (rc <= 0) { 205 return; 206 } 207 devman_handle_t hub_handle; 208 rc = child_device_register_wrapper(hc_dev, "hub", id, 10, &hub_handle); 209 if (rc != EOK) { 210 free(id); 211 } 212 213 vhc_iface.bind_address(NULL, hub_address, hub_handle); 214 215 dprintf(2, "virtual hub has devman handle %d", (int) hub_handle); 165 216 } 166 217 … … 175 226 for (i = 0; i < HUB_PORT_COUNT; i++) { 176 227 hub_port_t *port = &hub_dev.ports[i]; 228 fibril_mutex_lock(&port->guard); 177 229 178 230 if (port->device != NULL) { 231 fibril_mutex_unlock(&port->guard); 179 232 continue; 180 233 } … … 191 244 //if (port->state == HUB_PORT_STATE_DISCONNECTED) { 192 245 port->state = HUB_PORT_STATE_DISABLED; 193 set_port_status_change (port, HUB_STATUS_C_PORT_CONNECTION);246 set_port_status_change_nl(port, HUB_STATUS_C_PORT_CONNECTION); 194 247 //} 195 248 249 fibril_mutex_unlock(&port->guard); 250 196 251 return i; 197 252 }
Note:
See TracChangeset
for help on using the changeset viewer.