Linux USB??????????
???????????? ???????[ 2014/12/25 11:11:48 ] ????????Linux ??????
????Linux USB????????????????
???????usb??????IO?????????ò??usb request block?????urb???????????????????????????usb??????????????·???????????????????????????豸?????????????urb???????????????????????USB?淶???????????????USB??endpoint??4??????????????????????????·????????????????????????????????????????????urb??????????????????????????????????????????????????????????????struct urb????????????????????????????????????λ????????????????????????????????μ????????include/linux/usb.h??
????????????????????????г????????????Σ?
????struct usb_device *dev
????urb???????????豸??
????unsigned int pipe
???????????????ù???????????豸?????????????????????????????????????????????????????豸???????????????????????????????????ù????????ù???????
????unsigned int usb_sndctrlpipe(struct usb_device *dev?? unsigned int endpoint)
?????????USB?豸????????????????????OUT???
????unsigned int usb_rcvctrlpipe(struct usb_device *dev?? unsigned int endpoint)
?????????USB?豸????????????????????IN???
????unsigned int usb_sndbulkpipe(struct usb_device *dev?? unsigned int endpoint)
?????????USB?豸????????????????????OUT???
????unsigned int usb_rcvbulkpipe(struct usb_device *dev?? unsigned int endpoint)
?????????USB?豸????????????????????OUT???
????unsigned int usb_sndintpipe(struct usb_device *dev?? unsigned int endpoint)
?????????USB?豸?????????????????ж?OUT???
????unsigned int usb_rcvintpipe(struct usb_device *dev?? unsigned int endpoint)
?????????USB?豸?????????????????ж?OUT???
????unsigned int usb_sndisocpipe(struct usb_device *dev?? unsigned int endpoint)
?????????USB?豸???????????????????OUT???
????unsigned int usb_rcvisocpipe(struct usb_device *dev?? unsigned int endpoint)
?????????USB?豸???????????????????OUT???
????unsigned int transfer_flags
???????????DMA??????transfer_flags |= URB_NO_TRANSFER_DMA_MAP??????????????????д????
????int status
?????????urb??????????豸??????urb??????????????????????????????????urb???????????????????status?????????????????й????????紫?????????????????0??
????????????????????г???????????????????urb??
????struct urb *usb_alloc_urb(int isoc_packets?? int mem_flags);
???????????????????????????????????????????????0?????????????kmalloc?????????
???????????urb???????
????void usb_free_urb(struct urb *urb);
?????????????????????????????????????????????????????????????????????????ж?urb????????
????void usb_fill_int_urb(struct urb *urb?? struct usb_device *dev?? unsigned int pipe??
????void *transfer_buffer?? int buffer_length??
????usb_complete_t complete?? void *context?? int interval);
???????????????£?transfer_buffer????????/??????????壬buffer_length??????????complete??urb???????????????context????????壬????????????????????????interval??urb??????????
????????????urb?????urb????????:
????void usb_fill_bulk_urb(struct urb *urb?? struct usb_device *dev?? unsigned int pipe??
????void *transfer_buffer?? int buffer_length?? usb_complete_t complete??
????void *context);
????void usb_fill_control_urb(struct urb *urb?? struct usb_device *dev?? unsigned int pipe??
????unsigned char* setup_packet??void *transfer_buffer??
????int buffer_length?? usb_complete_t complete??void *context);
?????????????????????setup_packet????????????????????????????????????
??????????urb???????????fill???????????urb???????????
?????????????????????????????????????????????????????????????urb
????int usb_submit_urb(struct urb *urb?? int mem_flags);
????mem_flags?м????GFP_ATOMIC??GFP_NOIO??GFP_KERNEL????????ж?????????????????GFP_ATOMIC??
?????????????????????????????????????????urb??????????????????????????????????????????????????????????????status??Σ????????????????????????????urb???????????????
????/* initialize the urb properly */
????usb_fill_bulk_urb(urb?? dev->udev??
????usb_sndbulkpipe(dev->udev?? dev->bulk_out_endpointAddr)??
????buf?? writesize?? skel_write_bulk_callback?? dev);
????urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
????/* send the data out the bulk port */
????retval = usb_submit_urb(urb?? GFP_KERNEL);
????????skel_write_bulk_callback?????????????????????????????????????????????????urb??
????dev = (struct usb_skel *)urb->context;
????/* sync/async unlink faults aren't errors */
????if (urb->status && !(urb->status = = -ENOENT || urb->status == -ECONNRESET || urb->status = = -ESHUTDOWN)) {
????dbg("%s - nonzero write bulk status received: %d"?? __FUNCTION__?? urb->status);
????}
????/* free up our allocated buffer */
????usb_buffer_free(urb->dev?? urb->transfer_buffer_length??
????urb->transfer_buffer?? urb->transfer_dma);
?????????????????????????????????????????????????????????????urb??????????usb-skeleton????????????????????????
????/* do a blocking bulk read to get data from the device */
????retval = usb_bulk_msg(dev->udev??
????usb_rcvbulkpipe(dev->udev?? dev->bulk_in_endpointAddr)??
????dev->bulk_in_buffer??
????min(dev->bulk_in_size?? count)??
????&bytes_read?? 10000);
????/* if the read was successful?? copy the data to userspace */
????if (!retval) {
????if (copy_to_user(buffer?? dev->bulk_in_buffer?? bytes_read))
????retval = -EFAULT;
????else
????retval = bytes_read;
????}
?????????????usb_bulk_msg?????????????????????£?
????int usb_bulk_msg(struct usb_device *usb_dev?? unsigned int pipe??void *data??
????int len?? int *actual length?? int timeout)
????????????????????????????????????????data??????/??????壬len???????С??actual length??????????????С??timeout???????????
?????????????????????????????????????????????
????Int usb_contrl_msg(struct usb_device *dev?? unsigned int pipe?? __u8 request??
????__u8 requesttype?? __u16 value?? __u16 index?? void *data??
????__u16 size?? int timeout);
????request??????????USB???????requesttype??????????USB?????????value??????????USB??????index??????????USB?????????????????????????????????????????????
?????????Linux?μ?USB????????????????????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
Linux??????DDR????????????Linux?????????????????豸??????????linux???в???????????м??????????????????????????Linux????Linux??DNS????????????γ???????????Linux?????????????Linux????(???)????????Linux ????????????????????????????????Windows???У?Linux???????Linux????????????????Linux iommu??vfio???????Linux????ε???TCP???????Linux?????????????СLinux?·???????????Linux???Jexus?й?Asp.Net Core??ó???Linux?????????Щ??
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????