Changeset b4b534ac in mainline for uspace/lib/usbvirt/src/stdreq.c
- Timestamp:
- 2016-07-22T08:24:47Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f76d2c2
- Parents:
- 5b18137 (diff), 8351f9a4 (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/lib/usbvirt/src/stdreq.c
r5b18137 rb4b534ac 51 51 void usbvirt_control_reply_helper(const usb_device_request_setup_packet_t *setup_packet, 52 52 uint8_t *data, size_t *act_size, 53 void *actual_data, size_t actual_data_size)53 const void *actual_data, size_t actual_data_size) 54 54 { 55 55 size_t expected_size = setup_packet->length; … … 63 63 *act_size = actual_data_size; 64 64 } 65 } 66 67 /** NOP handler */ 68 int req_nop(usbvirt_device_t *device, 69 const usb_device_request_setup_packet_t *setup_packet, 70 uint8_t *data, size_t *act_size) 71 { 72 return EOK; 65 73 } 66 74 … … 98 106 } 99 107 /* Copy the data. */ 100 usbvirt_device_configuration_t *config = &device->descriptors101 ->configuration[index];108 const usbvirt_device_configuration_t *config = 109 &device->descriptors->configuration[index]; 102 110 uint8_t *all_data = malloc(config->descriptor->total_length); 103 111 if (all_data == NULL) { … … 110 118 size_t i; 111 119 for (i = 0; i < config->extra_count; i++) { 112 usbvirt_device_configuration_extras_t *extra120 const usbvirt_device_configuration_extras_t *extra 113 121 = &config->extra[i]; 114 122 memcpy(ptr, extra->data, extra->length); … … 189 197 } 190 198 199 static int req_get_dev_status(usbvirt_device_t *device, 200 const usb_device_request_setup_packet_t *setup_packet, uint8_t *data, size_t *act_size) 201 { 202 if (setup_packet->length != 2) 203 return ESTALL; 204 data[0] = (device->self_powered ? 1 : 0) | (device->remote_wakeup ? 2 : 0); 205 data[1] = 0; 206 *act_size = 2; 207 return EOK; 208 } 209 static int req_get_iface_ep_status(usbvirt_device_t *device, 210 const usb_device_request_setup_packet_t *setup_packet, uint8_t *data, size_t *act_size) 211 { 212 if (setup_packet->length != 2) 213 return ESTALL; 214 data[0] = 0; 215 data[1] = 0; 216 *act_size = 2; 217 return EOK; 218 } 219 191 220 /** Standard request handlers. */ 192 221 usbvirt_control_request_handler_t library_handlers[] = { 193 222 { 194 .req_direction = USB_DIRECTION_OUT, 195 .req_recipient = USB_REQUEST_RECIPIENT_DEVICE, 196 .req_type = USB_REQUEST_TYPE_STANDARD, 197 .request = USB_DEVREQ_SET_ADDRESS, 223 STD_REQ_OUT(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_SET_ADDRESS), 198 224 .name = "SetAddress", 199 225 .callback = req_set_address 200 226 }, 201 227 { 202 .req_direction = USB_DIRECTION_IN, 203 .req_recipient = USB_REQUEST_RECIPIENT_DEVICE, 204 .req_type = USB_REQUEST_TYPE_STANDARD, 205 .request = USB_DEVREQ_GET_DESCRIPTOR, 206 .name = "GetDescriptor", 228 STD_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_GET_DESCRIPTOR), 229 .name = "GetStdDescriptor", 207 230 .callback = req_get_descriptor 208 231 }, 209 232 { 210 .req_direction = USB_DIRECTION_OUT, 211 .req_recipient = USB_REQUEST_RECIPIENT_DEVICE, 212 .req_type = USB_REQUEST_TYPE_STANDARD, 213 .request = USB_DEVREQ_SET_CONFIGURATION, 233 STD_REQ_OUT(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_SET_CONFIGURATION), 214 234 .name = "SetConfiguration", 215 235 .callback = req_set_configuration 216 236 }, 217 237 { 238 STD_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_GET_STATUS), 239 .name = "GetDeviceStatus", 240 .callback = req_get_dev_status, 241 }, 242 { 243 STD_REQ_IN(USB_REQUEST_RECIPIENT_INTERFACE, USB_DEVREQ_GET_STATUS), 244 .name = "GetInterfaceStatus", 245 .callback = req_get_iface_ep_status, 246 }, 247 { 248 /* virtual EPs by default cannot be stalled */ 249 STD_REQ_IN(USB_REQUEST_RECIPIENT_ENDPOINT, USB_DEVREQ_GET_STATUS), 250 .name = "GetEndpointStatus", 251 .callback = req_get_iface_ep_status, 252 }, 218 253 { .callback = NULL } 219 254 };
Note:
See TracChangeset
for help on using the changeset viewer.