Lines Matching refs:command

287 	usb_raw_command command;
288 if (length < sizeof(command.version.status))
291 || user_memcpy(&command, buffer, min_c(length, sizeof(command)))
296 command.version.status = B_USB_RAW_STATUS_ABORTED;
302 command.version.status = B_USB_RAW_PROTOCOL_VERSION;
309 if (length < sizeof(command.device))
318 if (!IS_USER_ADDRESS(command.device.descriptor)
319 || user_memcpy(command.device.descriptor, deviceDescriptor,
324 command.device.status = B_USB_RAW_STATUS_SUCCESS;
332 && length < sizeof(command.config_etc))
335 if (length < sizeof(command.config))
340 usb_raw_get_configuration(device, command.config.config_index,
341 &command.config.status);
347 sizeToCopy = std::min(command.config_etc.length,
351 if (!IS_USER_ADDRESS(command.config.descriptor)
352 || user_memcpy(command.config.descriptor,
357 command.config.status = B_USB_RAW_STATUS_SUCCESS;
364 if (length < sizeof(command.alternate))
370 command.alternate.config_index,
371 &command.alternate.status);
375 if (command.alternate.interface_index
377 command.alternate.status = B_USB_RAW_STATUS_INVALID_INTERFACE;
383 command.alternate.interface_index];
385 command.alternate.alternate_info = interfaceList->alt_count;
389 command.alternate.alternate_info = i;
395 command.alternate.status = B_USB_RAW_STATUS_SUCCESS;
405 if (length < sizeof(command.interface))
409 command.interface.config_index,
410 command.interface.interface_index,
412 &command.interface.status);
414 if (length < sizeof(command.interface_etc))
418 command.interface_etc.config_index,
419 command.interface_etc.interface_index,
420 command.interface_etc.alternate_index,
421 &command.interface_etc.status);
427 if (!IS_USER_ADDRESS(command.interface.descriptor)
428 || user_memcpy(command.interface.descriptor, interfaceInfo->descr,
433 command.interface.status = B_USB_RAW_STATUS_SUCCESS;
444 if (length < sizeof(command.endpoint))
448 command.endpoint.config_index,
449 command.endpoint.interface_index,
451 &command.endpoint.status);
452 endpointIndex = command.endpoint.endpoint_index;
454 if (length < sizeof(command.endpoint_etc))
458 command.endpoint_etc.config_index,
459 command.endpoint_etc.interface_index,
460 command.endpoint_etc.alternate_index,
461 &command.endpoint_etc.status);
462 endpointIndex = command.endpoint_etc.endpoint_index;
469 command.endpoint.status = B_USB_RAW_STATUS_INVALID_ENDPOINT;
473 if (!IS_USER_ADDRESS(command.endpoint.descriptor)
474 || user_memcpy(command.endpoint.descriptor,
480 command.endpoint.status = B_USB_RAW_STATUS_SUCCESS;
492 if (length < sizeof(command.generic))
496 command.generic.config_index,
497 command.generic.interface_index,
499 &command.generic.status);
500 genericIndex = command.generic.generic_index;
501 genericLength = command.generic.length;
503 if (length < sizeof(command.generic_etc))
507 command.generic_etc.config_index,
508 command.generic_etc.interface_index,
509 command.generic_etc.alternate_index,
510 &command.generic_etc.status);
511 genericIndex = command.generic_etc.generic_index;
512 genericLength = command.generic_etc.length;
519 command.endpoint.status = B_USB_RAW_STATUS_INVALID_ENDPOINT;
527 if (!IS_USER_ADDRESS(command.generic.descriptor)
528 || user_memcpy(command.generic.descriptor, descriptor,
534 command.generic.status = B_USB_RAW_STATUS_NO_MEMORY;
536 command.generic.status = B_USB_RAW_STATUS_SUCCESS;
542 if (length < sizeof(command.string))
555 command.string.status = B_USB_RAW_STATUS_ABORTED;
556 command.string.length = 0;
563 USB_DESCRIPTOR_STRING, command.string.string_index, langid,
567 command.string.status = B_USB_RAW_STATUS_ABORTED;
568 command.string.length = 0;
572 uint8 stringLength = MIN(temp[0], command.string.length);
575 command.string.status = B_USB_RAW_STATUS_ABORTED;
576 command.string.length = 0;
582 USB_DESCRIPTOR_STRING, command.string.string_index, langid,
585 command.string.status = B_USB_RAW_STATUS_ABORTED;
586 command.string.length = 0;
591 if (!IS_USER_ADDRESS(command.string.descriptor)
592 || user_memcpy(command.string.descriptor, string,
598 command.string.status = B_USB_RAW_STATUS_SUCCESS;
599 command.string.length = stringLength;
606 if (length < sizeof(command.descriptor))
614 command.descriptor.type, command.descriptor.index,
615 command.descriptor.language_id, firstTwoBytes, 2,
618 || firstTwoBytes[1] != command.descriptor.type) {
619 command.descriptor.status = B_USB_RAW_STATUS_ABORTED;
620 command.descriptor.length = 0;
625 command.descriptor.length);
628 command.descriptor.status = B_USB_RAW_STATUS_ABORTED;
629 command.descriptor.length = 0;
635 command.descriptor.type, command.descriptor.index,
636 command.descriptor.language_id, descriptorBuffer,
639 command.descriptor.status = B_USB_RAW_STATUS_ABORTED;
640 command.descriptor.length = 0;
645 if (!IS_USER_ADDRESS(command.descriptor.data)
646 || user_memcpy(command.descriptor.data, descriptorBuffer,
652 command.descriptor.status = B_USB_RAW_STATUS_SUCCESS;
653 command.descriptor.length = descriptorLength;
660 if (length < sizeof(command.config))
665 usb_raw_get_configuration(device, command.config.config_index,
666 &command.config.status);
672 command.config.status = B_USB_RAW_STATUS_FAILED;
676 command.config.status = B_USB_RAW_STATUS_SUCCESS;
682 if (length < sizeof(command.alternate))
688 command.alternate.config_index,
689 &command.alternate.status);
693 if (command.alternate.interface_index
695 command.alternate.status = B_USB_RAW_STATUS_INVALID_INTERFACE;
700 &configurationInfo->interface[command.alternate.interface_index];
701 if (command.alternate.alternate_info >= interfaceList->alt_count) {
702 command.alternate.status = B_USB_RAW_STATUS_INVALID_INTERFACE;
707 &interfaceList->alt[command.alternate.alternate_info]) < B_OK) {
708 command.alternate.status = B_USB_RAW_STATUS_FAILED;
712 command.alternate.status = B_USB_RAW_STATUS_SUCCESS;
718 if (length < sizeof(command.control))
721 void *controlData = malloc(command.control.length);
726 bool inTransfer = (command.control.request_type
728 if (!IS_USER_ADDRESS(command.control.data)
730 command.control.data, command.control.length) != B_OK)) {
736 command.control.request_type, command.control.request,
737 command.control.value, command.control.index,
738 command.control.length, controlData,
740 command.control.status = B_USB_RAW_STATUS_FAILED;
741 command.control.length = 0;
752 command.control.status = device->status;
753 command.control.length = device->actual_length;
756 if (command.control.status == B_OK)
758 if (inTransfer && user_memcpy(command.control.data, controlData,
759 command.control.length) != B_OK) {
769 if (length < sizeof(command.transfer))
776 command.transfer.status = B_USB_RAW_STATUS_INVALID_CONFIGURATION;
780 if (command.transfer.interface >= configurationInfo->interface_count) {
781 command.transfer.status = B_USB_RAW_STATUS_INVALID_INTERFACE;
786 configurationInfo->interface[command.transfer.interface].active;
788 command.transfer.status = B_USB_RAW_STATUS_ABORTED;
792 if (command.transfer.endpoint >= interfaceInfo->endpoint_count) {
793 command.transfer.status = B_USB_RAW_STATUS_INVALID_ENDPOINT;
798 &interfaceInfo->endpoint[command.transfer.endpoint];
800 command.transfer.status = B_USB_RAW_STATUS_INVALID_ENDPOINT;
812 if (length < sizeof(command.isochronous))
816 * command.isochronous.packet_count;
820 command.transfer.status = B_USB_RAW_STATUS_NO_MEMORY;
821 command.transfer.length = 0;
826 if (!IS_USER_ADDRESS(command.isochronous.data)
827 || !IS_USER_ADDRESS(command.isochronous.packet_descriptors)
829 command.isochronous.packet_descriptors,
834 transferData = malloc(command.transfer.length);
836 command.transfer.status = B_USB_RAW_STATUS_NO_MEMORY;
837 command.transfer.length = 0;
842 if (!IS_USER_ADDRESS(command.transfer.data) || (!inTransfer
843 && user_memcpy(transferData, command.transfer.data,
844 command.transfer.length) != B_OK)) {
853 transferData, command.transfer.length,
857 transferData, command.transfer.length,
861 command.isochronous.data, command.isochronous.length,
862 packetDescriptors, command.isochronous.packet_count, NULL,
867 command.transfer.status = B_USB_RAW_STATUS_FAILED;
868 command.transfer.length = 0;
879 command.transfer.status = device->status;
880 command.transfer.length = device->actual_length;
883 if (command.transfer.status == B_OK)
886 if (user_memcpy(command.isochronous.packet_descriptors,
891 if (inTransfer && user_memcpy(command.transfer.data,
892 transferData, command.transfer.length) != B_OK) {
901 if (user_memcpy(buffer, &command, min_c(length, sizeof(command))) != B_OK)