mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-11 14:10:34 +00:00
Add helper function to check if a USB page cache buffer is properly
aligned to reduce the use of bounce buffers in PIO mode. MFC after: 1 week
This commit is contained in:
parent
ddd208f7ad
commit
c6b6f54640
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=290489
@ -133,6 +133,35 @@ usbd_get_page(struct usb_page_cache *pc, usb_frlength_t offset,
|
||||
#endif
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* usb_pc_buffer_is_aligned - verify alignment
|
||||
*
|
||||
* This function is used to check if a page cache buffer is properly
|
||||
* aligned to reduce the use of bounce buffers in PIO mode.
|
||||
*------------------------------------------------------------------------*/
|
||||
uint8_t
|
||||
usb_pc_buffer_is_aligned(struct usb_page_cache *pc, usb_frlength_t offset,
|
||||
usb_frlength_t len, usb_frlength_t mask)
|
||||
{
|
||||
struct usb_page_search buf_res;
|
||||
|
||||
while (len != 0) {
|
||||
|
||||
usbd_get_page(pc, offset, &buf_res);
|
||||
|
||||
if (buf_res.length > len)
|
||||
buf_res.length = len;
|
||||
if (USB_P2U(buf_res.buffer) & mask)
|
||||
return (0);
|
||||
if (buf_res.length & mask)
|
||||
return (0);
|
||||
|
||||
offset += buf_res.length;
|
||||
len -= buf_res.length;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* usbd_copy_in - copy directly to DMA-able memory
|
||||
*------------------------------------------------------------------------*/
|
||||
|
@ -159,5 +159,8 @@ void usb_pc_cpu_flush(struct usb_page_cache *pc);
|
||||
void usb_pc_cpu_invalidate(struct usb_page_cache *pc);
|
||||
void usb_pc_dmamap_destroy(struct usb_page_cache *pc);
|
||||
void usb_pc_free_mem(struct usb_page_cache *pc);
|
||||
uint8_t usb_pc_buffer_is_aligned(struct usb_page_cache *pc,
|
||||
usb_frlength_t offset, usb_frlength_t len,
|
||||
usb_frlength_t mask);
|
||||
|
||||
#endif /* _USB_BUSDMA_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user