Changeset 54d71e1 in mainline for uspace/drv/vhc/hub/virthubops.c
- Timestamp:
- 2011-04-29T07:05:30Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 361fcec
- Parents:
- 9014dcd (diff), cd4ae1e (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/hub/virthubops.c
r9014dcd r54d71e1 35 35 #include <errno.h> 36 36 #include <usb/classes/hub.h> 37 #include <usbvirt/device.h> 37 38 #include "virthub.h" 38 39 #include "hub.h" 39 40 40 41 /** Callback when device changes states. */ 41 static void on_state_change( struct usbvirt_device*dev,42 static void on_state_change(usbvirt_device_t *dev, 42 43 usbvirt_device_state_t old_state, usbvirt_device_state_t new_state) 43 44 { … … 61 62 62 63 /** Callback for data request. */ 63 static int req_on_ data(struct usbvirt_device*dev,64 usb_endpoint_t endpoint, 65 void *buffer, size_t size, size_t *actual_size)64 static int req_on_status_change_pipe(usbvirt_device_t *dev, 65 usb_endpoint_t endpoint, usb_transfer_type_t tr_type, 66 void *buffer, size_t buffer_size, size_t *actual_size) 66 67 { 67 68 if (endpoint != HUB_STATUS_CHANGE_PIPE) { 68 return EINVAL; 69 return ESTALL; 70 } 71 if (tr_type != USB_TRANSFER_INTERRUPT) { 72 return ESTALL; 69 73 } 70 74 71 hub_t *hub = (hub_t *)dev->device_data;75 hub_t *hub = dev->device_data; 72 76 73 77 hub_acquire(hub); 74 78 79 if (!hub->signal_changes) { 80 hub_release(hub); 81 82 return ENAK; 83 } 84 85 75 86 uint8_t change_map = hub_get_status_change_bitmap(hub); 76 87 77 88 uint8_t *b = (uint8_t *) buffer; 78 if ( size > 0) {89 if (buffer_size > 0) { 79 90 *b = change_map; 80 91 *actual_size = 1; 92 } else { 93 *actual_size = 0; 81 94 } 82 95 96 hub->signal_changes = false; 97 83 98 hub_release(hub); 84 99 … … 94 109 */ 95 110 static int req_clear_hub_feature(usbvirt_device_t *dev, 96 usb_device_request_setup_packet_t *request,97 uint8_t *data)111 const usb_device_request_setup_packet_t *request, uint8_t *data, 112 size_t *act_size) 98 113 { 99 114 return ENOTSUP; … … 108 123 */ 109 124 static int req_clear_port_feature(usbvirt_device_t *dev, 110 usb_device_request_setup_packet_t *request,111 uint8_t *data)125 const usb_device_request_setup_packet_t *request, uint8_t *data, 126 size_t *act_size) 112 127 { 113 128 int rc; … … 188 203 */ 189 204 static int req_get_bus_state(usbvirt_device_t *dev, 190 usb_device_request_setup_packet_t *request,191 uint8_t *data)205 const usb_device_request_setup_packet_t *request, uint8_t *data, 206 size_t *act_size) 192 207 { 193 208 return ENOTSUP; … … 202 217 */ 203 218 static int req_get_descriptor(usbvirt_device_t *dev, 204 usb_device_request_setup_packet_t *request,205 uint8_t *data)219 const usb_device_request_setup_packet_t *request, uint8_t *data, 220 size_t *act_size) 206 221 { 207 222 if (request->value_high == USB_DESCTYPE_HUB) { 208 int rc = dev->control_transfer_reply(dev, 0,223 usbvirt_control_reply_helper(request, data, act_size, 209 224 &hub_descriptor, hub_descriptor.length); 210 225 211 return rc;226 return EOK; 212 227 } 213 228 /* Let the framework handle all the rest. */ … … 223 238 */ 224 239 static int req_get_hub_status(usbvirt_device_t *dev, 225 usb_device_request_setup_packet_t *request,226 uint8_t *data)240 const usb_device_request_setup_packet_t *request, uint8_t *data, 241 size_t *act_size) 227 242 { 228 243 uint32_t hub_status = 0; 229 244 230 return dev->control_transfer_reply(dev, 0,245 usbvirt_control_reply_helper(request, data, act_size, 231 246 &hub_status, sizeof(hub_status)); 247 248 return EOK; 232 249 } 233 250 … … 240 257 */ 241 258 static int req_get_port_status(usbvirt_device_t *dev, 242 usb_device_request_setup_packet_t *request,243 uint8_t *data)259 const usb_device_request_setup_packet_t *request, uint8_t *data, 260 size_t *act_size) 244 261 { 245 262 hub_t *hub = (hub_t *) dev->device_data; … … 251 268 hub_release(hub); 252 269 253 return dev->control_transfer_reply(dev, 0, &status, 4); 270 usbvirt_control_reply_helper(request, data, act_size, 271 &status, sizeof(status)); 272 273 return EOK; 254 274 } 255 275 … … 262 282 */ 263 283 static int req_set_hub_feature(usbvirt_device_t *dev, 264 usb_device_request_setup_packet_t *request,265 uint8_t *data)284 const usb_device_request_setup_packet_t *request, uint8_t *data, 285 size_t *act_size) 266 286 { 267 287 return ENOTSUP; … … 276 296 */ 277 297 static int req_set_port_feature(usbvirt_device_t *dev, 278 usb_device_request_setup_packet_t *request,279 uint8_t *data)298 const usb_device_request_setup_packet_t *request, uint8_t *data, 299 size_t *act_size) 280 300 { 281 301 int rc; … … 330 350 331 351 /** Recipient: other. */ 332 #define REC_OTHER USB VIRT_REQUEST_RECIPIENT_OTHER352 #define REC_OTHER USB_REQUEST_RECIPIENT_OTHER 333 353 /** Recipient: device. */ 334 #define REC_DEVICE USB VIRT_REQUEST_RECIPIENT_DEVICE354 #define REC_DEVICE USB_REQUEST_RECIPIENT_DEVICE 335 355 /** Direction: in. */ 336 356 #define DIR_IN USB_DIRECTION_IN … … 338 358 #define DIR_OUT USB_DIRECTION_OUT 339 359 360 340 361 /** Create a class request. 341 362 * … … 345 366 */ 346 367 #define CLASS_REQ(direction, recipient, req) \ 347 .request_type = USBVIRT_MAKE_CONTROL_REQUEST_TYPE(direction, \ 348 USBVIRT_REQUEST_TYPE_CLASS, recipient), \ 368 .req_direction = direction, \ 369 .req_recipient = recipient, \ 370 .req_type = USB_REQUEST_TYPE_CLASS, \ 349 371 .request = req 350 372 … … 356 378 */ 357 379 #define STD_REQ(direction, recipient, req) \ 358 .request_type = USBVIRT_MAKE_CONTROL_REQUEST_TYPE(direction, \ 359 USBVIRT_REQUEST_TYPE_STANDARD, recipient), \ 380 .req_direction = direction, \ 381 .req_recipient = recipient, \ 382 .req_type = USB_REQUEST_TYPE_STANDARD, \ 360 383 .request = req 361 384 362 385 /** Hub operations on control endpoint zero. */ 363 static usbvirt_control_ transfer_handler_t endpoint_zero_handlers[] = {386 static usbvirt_control_request_handler_t endpoint_zero_handlers[] = { 364 387 { 365 388 STD_REQ(DIR_IN, REC_DEVICE, USB_DEVREQ_GET_DESCRIPTOR), … … 417 440 .callback = req_set_port_feature 418 441 }, 419 USBVIRT_CONTROL_TRANSFER_HANDLER_LAST 442 { 443 .callback = NULL 444 } 420 445 }; 421 446 … … 423 448 /** Hub operations. */ 424 449 usbvirt_device_ops_t hub_ops = { 425 .control_transfer_handlers = endpoint_zero_handlers, 426 .on_data = NULL, 427 .on_data_request = req_on_data, 428 .on_state_change = on_state_change, 450 .control = endpoint_zero_handlers, 451 .data_in[HUB_STATUS_CHANGE_PIPE] = req_on_status_change_pipe, 452 .state_changed = on_state_change, 429 453 }; 430 454
Note:
See TracChangeset
for help on using the changeset viewer.