Changeset 75732da in mainline for uspace/drv/vhc
- Timestamp:
- 2010-12-13T07:20:20Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 309dea52
- Parents:
- 84439d7 (diff), 37f7cfe (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. - Location:
- uspace/drv/vhc
- Files:
-
- 1 deleted
- 12 edited
-
Makefile (modified) (1 diff)
-
addrmgm.c (deleted)
-
conn.h (modified) (1 diff)
-
connhost.c (modified) (6 diffs)
-
debug.c (modified) (1 diff)
-
devices.c (modified) (1 diff)
-
hc.c (modified) (5 diffs)
-
hcd.c (modified) (2 diffs)
-
hub.c (modified) (6 diffs)
-
hub.h (modified) (2 diffs)
-
hubintern.h (modified) (3 diffs)
-
hubops.c (modified) (13 diffs)
-
vhcd.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/Makefile
r84439d7 r75732da 39 39 40 40 SOURCES = \ 41 addrmgm.c \42 41 conndev.c \ 43 42 connhost.c \ -
uspace/drv/vhc/conn.h
r84439d7 r75732da 48 48 49 49 void address_init(void); 50 int reserve_default_address(device_t *);51 int release_default_address(device_t *);52 int request_address(device_t *, usb_address_t *);53 int release_address(device_t *, usb_address_t);54 int bind_address(device_t *, usb_address_t, devman_handle_t);55 50 56 int tell_address(device_t *, devman_handle_t, usb_address_t *);57 51 58 52 void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *); -
uspace/drv/vhc/connhost.c
r84439d7 r75732da 36 36 #include <errno.h> 37 37 #include <usb/usb.h> 38 #include <usb/hcd.h> 38 39 39 40 #include "vhcd.h" … … 57 58 case USB_DIRECTION_IN: 58 59 transfer->in_callback(transfer->dev, 59 size, outcome,60 outcome, size, 60 61 transfer->arg); 61 62 break; … … 92 93 usbhc_iface_transfer_out_callback_t callback, void *arg) 93 94 { 94 printf(NAME ": transfer OUT [%d.%d (%s); %u]\n",95 dprintf(3, "transfer OUT [%d.%d (%s); %zu]", 95 96 target.address, target.endpoint, 96 97 usb_str_transfer_type(transfer_type), … … 112 113 usbhc_iface_transfer_out_callback_t callback, void *arg) 113 114 { 114 printf(NAME ": transfer SETUP [%d.%d (%s); %u]\n",115 dprintf(3, "transfer SETUP [%d.%d (%s); %zu]", 115 116 target.address, target.endpoint, 116 117 usb_str_transfer_type(transfer_type), … … 132 133 usbhc_iface_transfer_in_callback_t callback, void *arg) 133 134 { 134 printf(NAME ": transfer IN [%d.%d (%s); %u]\n",135 dprintf(3, "transfer IN [%d.%d (%s); %zu]", 135 136 target.address, target.endpoint, 136 137 usb_str_transfer_type(transfer_type), … … 218 219 } 219 220 221 static usb_address_keeping_t addresses; 222 223 224 static int reserve_default_address(device_t *dev) 225 { 226 usb_address_keeping_reserve_default(&addresses); 227 return EOK; 228 } 229 230 static int release_default_address(device_t *dev) 231 { 232 usb_address_keeping_release_default(&addresses); 233 return EOK; 234 } 235 236 static int request_address(device_t *dev, usb_address_t *address) 237 { 238 usb_address_t addr = usb_address_keeping_request(&addresses); 239 if (addr < 0) { 240 return (int)addr; 241 } 242 243 *address = addr; 244 return EOK; 245 } 246 247 static int release_address(device_t *dev, usb_address_t address) 248 { 249 return usb_address_keeping_release(&addresses, address); 250 } 251 252 static int bind_address(device_t *dev, usb_address_t address, 253 devman_handle_t handle) 254 { 255 usb_address_keeping_devman_bind(&addresses, address, handle); 256 return EOK; 257 } 258 259 static int tell_address(device_t *dev, devman_handle_t handle, 260 usb_address_t *address) 261 { 262 usb_address_t addr = usb_address_keeping_find(&addresses, handle); 263 if (addr < 0) { 264 return addr; 265 } 266 267 *address = addr; 268 return EOK; 269 } 270 271 void address_init(void) 272 { 273 usb_address_keeping_init(&addresses, 50); 274 } 220 275 221 276 usbhc_iface_t vhc_iface = { -
uspace/drv/vhc/debug.c
r84439d7 r75732da 35 35 #include <stdio.h> 36 36 #include <ipc/ipc.h> 37 #include <usb/debug.h> 37 38 38 39 #include "vhcd.h" 39 40 40 /** Current debug level. */41 int debug_level = 0;42 43 /** Debugging printf.44 * This function is intended for single-line messages as it45 * automatically prints debugging prefix at the beginning of the46 * line.47 *48 * @see printf49 * @param level Debugging level.50 */51 void dprintf(int level, const char *format, ...)52 {53 if (level > debug_level) {54 return;55 }56 57 printf("%s(%d): ", NAME, level);58 va_list args;59 va_start(args, format);60 vprintf(format, args);61 va_end(args);62 printf("\n");63 }64 41 65 42 /** Debug print informing of invalid call. -
uspace/drv/vhc/devices.c
r84439d7 r75732da 147 147 if (virthub_dev.address == transaction->target.address) { 148 148 size_t tmp; 149 dprintf( 3, "sending `%s' transaction to hub",149 dprintf(1, "sending `%s' transaction to hub", 150 150 usbvirt_str_transaction_type(transaction->type)); 151 151 switch (transaction->type) { -
uspace/drv/vhc/hc.c
r84439d7 r75732da 50 50 #include "hub.h" 51 51 52 #define USLEEP_BASE ( 500* 1000)52 #define USLEEP_BASE (0 * 5 * 1000) 53 53 54 #define USLEEP_VAR 50 0054 #define USLEEP_VAR 50 55 55 56 56 #define SHORTENING_VAR 15 … … 89 89 usb_transaction_outcome_t outcome) 90 90 { 91 dprintf(3, " processing transaction " TRANSACTION_FORMAT ", outcome: %s",91 dprintf(3, "transaction " TRANSACTION_FORMAT " done, outcome: %s", 92 92 TRANSACTION_PRINTF(*transaction), 93 93 usb_str_transaction_outcome(outcome)); … … 116 116 char ports[HUB_PORT_COUNT + 2]; 117 117 hub_get_port_statuses(ports, HUB_PORT_COUNT + 1); 118 dprintf( 3, "virtual hub: addr=%d ports=%s",118 dprintf(4, "virtual hub: addr=%d ports=%s", 119 119 virthub_dev.address, ports); 120 120 … … 124 124 list_remove(first_transaction_link); 125 125 126 127 dprintf(0, "about to process " TRANSACTION_FORMAT " (vhub:%s)", 128 TRANSACTION_PRINTF(*transaction), ports); 129 126 130 dprintf(3, "processing transaction " TRANSACTION_FORMAT "", 127 131 TRANSACTION_PRINTF(*transaction)); … … 153 157 transaction->callback_arg = arg; 154 158 155 dprintf( 1, "creating transaction " TRANSACTION_FORMAT,159 dprintf(3, "creating transaction " TRANSACTION_FORMAT, 156 160 TRANSACTION_PRINTF(*transaction)); 157 161 -
uspace/drv/vhc/hcd.c
r84439d7 r75732da 79 79 * Initialize our hub and announce its presence. 80 80 */ 81 hub_init(); 82 usb_hcd_add_root_hub(dev); 81 hub_init(dev); 83 82 84 83 printf("%s: virtual USB host controller ready.\n", NAME); … … 111 110 printf("%s: virtual USB host controller driver.\n", NAME); 112 111 113 debug_level = 10;112 usb_dprintf_enable(NAME, 0); 114 113 115 114 fid_t fid = fibril_create(hc_manager_fibril, NULL); -
uspace/drv/vhc/hub.c
r84439d7 r75732da 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 } -
uspace/drv/vhc/hub.h
r84439d7 r75732da 37 37 38 38 #include <usbvirt/device.h> 39 #include <driver.h> 39 40 40 41 #include "devices.h" 41 42 42 #define HUB_PORT_COUNT 643 #define HUB_PORT_COUNT 2 43 44 44 45 #define BITS2BYTES(bits) \ … … 47 48 extern usbvirt_device_t virthub_dev; 48 49 49 void hub_init( void);50 void hub_init(device_t *); 50 51 size_t hub_add_device(virtdev_connection_t *); 51 52 void hub_remove_device(virtdev_connection_t *); -
uspace/drv/vhc/hubintern.h
r84439d7 r75732da 37 37 38 38 #include "hub.h" 39 #include <fibril_synch.h> 39 40 40 41 /** Endpoint number for status change pipe. */ … … 121 122 typedef struct { 122 123 virtdev_connection_t *device; 124 int index; 123 125 hub_port_state_t state; 124 126 uint16_t status_change; 127 fibril_mutex_t guard; 125 128 } hub_port_t; 126 129 … … 138 141 void clear_port_status_change(hub_port_t *, uint16_t); 139 142 void set_port_status_change(hub_port_t *, uint16_t); 143 void set_port_status_change_nl(hub_port_t *, uint16_t); 140 144 141 145 -
uspace/drv/vhc/hubops.c
r84439d7 r75732da 59 59 static int on_get_descriptor(struct usbvirt_device *dev, 60 60 usb_device_request_setup_packet_t *request, uint8_t *data); 61 static int on_set_configuration(struct usbvirt_device *dev, 62 usb_device_request_setup_packet_t *request, uint8_t *data); 61 63 static int on_class_request(struct usbvirt_device *dev, 62 64 usb_device_request_setup_packet_t *request, uint8_t *data); … … 64 66 usb_endpoint_t endpoint, 65 67 void *buffer, size_t size, size_t *actual_size); 68 static void set_port_state(hub_port_t *, hub_port_state_t); 69 static void clear_port_status_change_nl(hub_port_t *, uint16_t); 70 static void set_port_state_nl(hub_port_t *, hub_port_state_t); 66 71 67 72 /** Hub operations. */ 68 73 usbvirt_device_ops_t hub_ops = { 69 74 .on_standard_request[USB_DEVREQ_GET_DESCRIPTOR] = on_get_descriptor, 75 .on_standard_request[USB_DEVREQ_SET_CONFIGURATION] = on_set_configuration, 70 76 .on_class_device_request = on_class_request, 71 77 .on_data = NULL, … … 87 93 } 88 94 95 /** Callback for SET_CONFIGURATION request. */ 96 int on_set_configuration(struct usbvirt_device *dev, 97 usb_device_request_setup_packet_t *request, uint8_t *data) 98 { 99 /* We must suspend power source to all ports. */ 100 size_t i; 101 for (i = 0; i < HUB_PORT_COUNT; i++) { 102 hub_port_t *port = &hub_dev.ports[i]; 103 104 set_port_state(port, HUB_PORT_STATE_POWERED_OFF); 105 } 106 107 /* Let the framework handle the rest of the job. */ 108 return EFORWARD; 109 } 110 111 struct delay_port_state_change { 112 suseconds_t delay; 113 hub_port_state_t old_state; 114 hub_port_state_t new_state; 115 hub_port_t *port; 116 }; 117 118 static int set_port_state_delayed_fibril(void *arg) 119 { 120 struct delay_port_state_change *change 121 = (struct delay_port_state_change *) arg; 122 123 async_usleep(change->delay); 124 125 fibril_mutex_lock(&change->port->guard); 126 if (change->port->state == change->old_state) { 127 set_port_state_nl(change->port, change->new_state); 128 } 129 fibril_mutex_unlock(&change->port->guard); 130 131 free(change); 132 133 return EOK; 134 } 135 136 static void set_port_state_delayed(hub_port_t *port, 137 suseconds_t delay_time, 138 hub_port_state_t old_state, hub_port_state_t new_state) 139 { 140 struct delay_port_state_change *change 141 = malloc(sizeof(struct delay_port_state_change)); 142 change->port = port; 143 change->delay = delay_time; 144 change->old_state = old_state; 145 change->new_state = new_state; 146 fid_t fibril = fibril_create(set_port_state_delayed_fibril, change); 147 if (fibril == 0) { 148 printf("Failed to create fibril\n"); 149 return; 150 } 151 fibril_add_ready(fibril); 152 } 153 89 154 /** Change port status and updates status change status fields. 90 155 */ 91 static void set_port_state(hub_port_t *port, hub_port_state_t state) 92 { 156 void set_port_state(hub_port_t *port, hub_port_state_t state) 157 { 158 fibril_mutex_lock(&port->guard); 159 set_port_state_nl(port, state); 160 fibril_mutex_unlock(&port->guard); 161 } 162 163 void set_port_state_nl(hub_port_t *port, hub_port_state_t state) 164 { 165 166 dprintf(2, "setting port %d state to %d (%c) from %c (change=%u)", 167 port->index, 168 state, hub_port_state_as_char(state), 169 hub_port_state_as_char(port->state), 170 (unsigned int) port->status_change); 171 172 if (state == HUB_PORT_STATE_POWERED_OFF) { 173 clear_port_status_change_nl(port, HUB_STATUS_C_PORT_CONNECTION); 174 clear_port_status_change_nl(port, HUB_STATUS_C_PORT_ENABLE); 175 clear_port_status_change_nl(port, HUB_STATUS_C_PORT_RESET); 176 } 177 if (state == HUB_PORT_STATE_RESUMING) { 178 set_port_state_delayed(port, 10*1000, 179 HUB_PORT_STATE_RESUMING, HUB_PORT_STATE_ENABLED); 180 } 181 if (state == HUB_PORT_STATE_RESETTING) { 182 set_port_state_delayed(port, 10*1000, 183 HUB_PORT_STATE_RESETTING, HUB_PORT_STATE_ENABLED); 184 } 185 if ((port->state == HUB_PORT_STATE_RESETTING) 186 && (state == HUB_PORT_STATE_ENABLED)) { 187 set_port_status_change_nl(port, HUB_STATUS_C_PORT_RESET); 188 } 189 93 190 port->state = state; 94 if (state == HUB_PORT_STATE_POWERED_OFF) {95 clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);96 clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE);97 clear_port_status_change(port, HUB_STATUS_C_PORT_RESET);98 }99 if (state == HUB_PORT_STATE_RESUMING) {100 async_usleep(10*1000);101 if (port->state == state) {102 set_port_state(port, HUB_PORT_STATE_ENABLED);103 }104 }105 if (state == HUB_PORT_STATE_RESETTING) {106 async_usleep(10*1000);107 if (port->state == state) {108 set_port_status_change(port, HUB_STATUS_C_PORT_RESET);109 set_port_state(port, HUB_PORT_STATE_ENABLED);110 }111 }112 191 } 113 192 … … 122 201 } \ 123 202 } while (false); \ 124 hub_port_t *portvar = &hub_dev.ports[index ]203 hub_port_t *portvar = &hub_dev.ports[index-1] 125 204 126 205 … … 134 213 _GET_PORT(port, portindex); 135 214 215 fibril_mutex_lock(&port->guard); 216 int rc = ENOTSUP; 217 136 218 switch (feature) { 137 219 case USB_HUB_FEATURE_PORT_ENABLE: 138 220 if ((port->state != HUB_PORT_STATE_NOT_CONFIGURED) 139 221 && (port->state != HUB_PORT_STATE_POWERED_OFF)) { 140 set_port_state(port, HUB_PORT_STATE_DISABLED); 141 } 142 return EOK; 222 set_port_state_nl(port, HUB_PORT_STATE_DISABLED); 223 } 224 rc = EOK; 225 break; 143 226 144 227 case USB_HUB_FEATURE_PORT_SUSPEND: 145 228 if (port->state != HUB_PORT_STATE_SUSPENDED) { 146 return EOK; 147 } 148 set_port_state(port, HUB_PORT_STATE_RESUMING); 149 return EOK; 229 rc = EOK; 230 break; 231 } 232 set_port_state_nl(port, HUB_PORT_STATE_RESUMING); 233 rc = EOK; 234 break; 150 235 151 236 case USB_HUB_FEATURE_PORT_POWER: 152 237 if (port->state != HUB_PORT_STATE_NOT_CONFIGURED) { 153 set_port_state(port, HUB_PORT_STATE_POWERED_OFF); 154 } 155 return EOK; 238 set_port_state_nl(port, HUB_PORT_STATE_POWERED_OFF); 239 } 240 rc = EOK; 241 break; 156 242 157 243 case USB_HUB_FEATURE_C_PORT_CONNECTION: 158 clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION); 159 return EOK; 244 clear_port_status_change_nl(port, HUB_STATUS_C_PORT_CONNECTION); 245 rc = EOK; 246 break; 160 247 161 248 case USB_HUB_FEATURE_C_PORT_ENABLE: 162 clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE); 163 return EOK; 249 clear_port_status_change_nl(port, HUB_STATUS_C_PORT_ENABLE); 250 rc = EOK; 251 break; 164 252 165 253 case USB_HUB_FEATURE_C_PORT_SUSPEND: 166 clear_port_status_change(port, HUB_STATUS_C_PORT_SUSPEND); 167 return EOK; 254 clear_port_status_change_nl(port, HUB_STATUS_C_PORT_SUSPEND); 255 rc = EOK; 256 break; 168 257 169 258 case USB_HUB_FEATURE_C_PORT_OVER_CURRENT: 170 clear_port_status_change(port, HUB_STATUS_C_PORT_OVER_CURRENT); 171 return EOK; 172 } 173 259 clear_port_status_change_nl(port, HUB_STATUS_C_PORT_OVER_CURRENT); 260 rc = EOK; 261 break; 262 263 case USB_HUB_FEATURE_C_PORT_RESET: 264 clear_port_status_change_nl(port, HUB_STATUS_C_PORT_RESET); 265 rc = EOK; 266 break; 267 } 268 269 fibril_mutex_unlock(&port->guard); 270 271 return rc; 272 } 273 274 static int get_bus_state(uint16_t portindex) 275 { 174 276 return ENOTSUP; 175 277 } 176 278 177 static int get_bus_state(uint16_t portindex) 178 { 179 return ENOTSUP; 180 } 181 182 static int get_hub_descriptor(uint8_t descriptor_type, 183 uint8_t descriptor_index, uint16_t length) 184 { 279 static int get_hub_descriptor(struct usbvirt_device *dev, 280 uint8_t descriptor_index, 281 uint8_t descriptor_type, uint16_t length) 282 { 283 if (descriptor_type == USB_DESCTYPE_HUB) { 284 int rc = dev->control_transfer_reply(dev, 0, 285 &hub_descriptor, hub_descriptor.length); 286 287 return rc; 288 289 } 290 185 291 return ENOTSUP; 186 292 } … … 198 304 _GET_PORT(port, portindex); 199 305 306 fibril_mutex_lock(&port->guard); 307 200 308 uint32_t status; 201 309 status = MAKE_BYTE( … … 225 333 status |= (port->status_change << 16); 226 334 335 fibril_mutex_unlock(&port->guard); 336 337 dprintf(2, "GetPortStatus(port=%d, status=%u)\n", (int)portindex, 338 (unsigned int) status); 227 339 return virthub_dev.control_transfer_reply(&virthub_dev, 0, &status, 4); 228 340 } … … 238 350 _GET_PORT(port, portindex); 239 351 352 fibril_mutex_lock(&port->guard); 353 354 int rc = ENOTSUP; 355 240 356 switch (feature) { 241 357 case USB_HUB_FEATURE_PORT_RESET: 242 358 if (port->state != HUB_PORT_STATE_POWERED_OFF) { 243 set_port_state(port, HUB_PORT_STATE_RESETTING); 244 } 245 return EOK; 359 set_port_state_nl(port, HUB_PORT_STATE_RESETTING); 360 } 361 rc = EOK; 362 break; 246 363 247 364 case USB_HUB_FEATURE_PORT_SUSPEND: 248 365 if (port->state == HUB_PORT_STATE_ENABLED) { 249 set_port_state(port, HUB_PORT_STATE_SUSPENDED); 250 } 251 return EOK; 366 set_port_state_nl(port, HUB_PORT_STATE_SUSPENDED); 367 } 368 rc = EOK; 369 break; 252 370 253 371 case USB_HUB_FEATURE_PORT_POWER: 254 372 if (port->state == HUB_PORT_STATE_POWERED_OFF) { 255 set_port_state(port, HUB_PORT_STATE_DISCONNECTED); 256 } 257 return EOK; 258 } 259 return ENOTSUP; 373 set_port_state_nl(port, HUB_PORT_STATE_DISCONNECTED); 374 } 375 rc = EOK; 376 break; 377 } 378 379 fibril_mutex_unlock(&port->guard); 380 return rc; 260 381 } 261 382 … … 267 388 usb_device_request_setup_packet_t *request, uint8_t *data) 268 389 { 269 dprintf(2, "hub class request (%d) \n", (int) request->request);390 dprintf(2, "hub class request (%d)", (int) request->request); 270 391 271 392 uint8_t recipient = request->request_type & 31; … … 298 419 299 420 case USB_HUB_REQUEST_GET_DESCRIPTOR: 300 return get_hub_descriptor( request->value_low,421 return get_hub_descriptor(dev, request->value_low, 301 422 request->value_high, request->length); 302 423 … … 316 437 317 438 default: 439 dprintf(0, "WARN: unknown request (%d)!\n", 440 request->request); 318 441 break; 319 442 } … … 325 448 } 326 449 450 void clear_port_status_change_nl(hub_port_t *port, uint16_t change) 451 { 452 port->status_change &= (~change); 453 dprintf(2, "cleared port %d status change %d (%u)", port->index, 454 (int)change, (unsigned int) port->status_change); 455 } 456 457 void set_port_status_change_nl(hub_port_t *port, uint16_t change) 458 { 459 port->status_change |= change; 460 dprintf(2, "set port %d status change %d (%u)", port->index, 461 (int)change, (unsigned int) port->status_change); 462 463 } 464 327 465 void clear_port_status_change(hub_port_t *port, uint16_t change) 328 466 { 329 port->status_change &= (~change); 467 fibril_mutex_lock(&port->guard); 468 clear_port_status_change_nl(port, change); 469 fibril_mutex_unlock(&port->guard); 330 470 } 331 471 332 472 void set_port_status_change(hub_port_t *port, uint16_t change) 333 473 { 334 port->status_change |= change; 474 fibril_mutex_lock(&port->guard); 475 set_port_status_change_nl(port, change); 476 fibril_mutex_unlock(&port->guard); 335 477 } 336 478 … … 350 492 hub_port_t *port = &hub_dev.ports[i]; 351 493 494 fibril_mutex_lock(&port->guard); 352 495 if (port->status_change != 0) { 353 496 change_map |= (1 << (i + 1)); 354 497 } 498 fibril_mutex_unlock(&port->guard); 355 499 } 356 500 -
uspace/drv/vhc/vhcd.h
r84439d7 r75732da 36 36 #define VHCD_VHCD_H_ 37 37 38 #include <usb/debug.h> 39 38 40 #define NAME "vhc" 39 41 #define NAME_DEV "hcd-virt-dev" … … 43 45 #define DEVMAP_PATH_DEV NAMESPACE "/" NAME_DEV 44 46 45 extern int debug_level; 46 void dprintf(int, const char *, ...); 47 #define dprintf(level, format, ...) \ 48 usb_dprintf(NAME, (level), format "\n", ##__VA_ARGS__) 47 49 void dprintf_inval_call(int, ipc_call_t, ipcarg_t); 48 50
Note:
See TracChangeset
for help on using the changeset viewer.
