diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-09-13 14:14:18 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-09-13 14:14:18 +0000 |
commit | f6ca2227e38d4b076cf44ce50b0fefeed22d4fab (patch) | |
tree | e60b015f4c47e705a04ef8f95e46d5ddd6465d4a /nuttx/include | |
parent | a033a25dbf92d2a6048c76b245d9ea6da7498c20 (diff) | |
download | px4-firmware-f6ca2227e38d4b076cf44ce50b0fefeed22d4fab.tar.gz px4-firmware-f6ca2227e38d4b076cf44ce50b0fefeed22d4fab.tar.bz2 px4-firmware-f6ca2227e38d4b076cf44ce50b0fefeed22d4fab.zip |
USB device drivers: Add hooks to to use common, external DMA buffer allocation implementation..
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5142 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/include')
-rw-r--r-- | nuttx/include/nuttx/fs/fat.h | 10 | ||||
-rw-r--r-- | nuttx/include/nuttx/usb/usbdev.h | 35 |
2 files changed, 41 insertions, 4 deletions
diff --git a/nuttx/include/nuttx/fs/fat.h b/nuttx/include/nuttx/fs/fat.h index 680aefbe9..ac85c502f 100644 --- a/nuttx/include/nuttx/fs/fat.h +++ b/nuttx/include/nuttx/fs/fat.h @@ -40,6 +40,7 @@ * Included Files ****************************************************************************/ +#include <nuttx/config.h> #include <stdint.h> /**************************************************************************** @@ -98,15 +99,20 @@ EXTERN int fat_setattrib(const char *path, fat_attrib_t setbits, fat_attrib_t cl * Some hardware, however, may require special DMA-capable memory in * order to perform the the transfers. If CONFIG_FAT_DMAMEMORY is defined * then the architecture-specific hardware must provide the funtions - * fat_dma_alloc() and fat_dma_free() as prototyped below: fat_dmalloc() - * will allocate DMA-capable memory of the specified size; fat_dmafree() + * fat_dma_alloc() and fat_dma_free() as prototyped below: fat_dma_alloc() + * will allocate DMA-capable memory of the specified size; fat_dma_free() * is the corresponding function that will be called to free the DMA- * capable memory. * + * This functions may be simple wrappers around gran_alloc() and gran_free() + * (See nuttx/gran.h). + * ****************************************************************************/ +#ifdef CONFIG_FAT_DMAMEMORY EXTERN FAR void *fat_dma_alloc(size_t size); EXTERN void fat_dma_free(FAR void *memory, size_t size); +#endif #undef EXTERN #ifdef __cplusplus diff --git a/nuttx/include/nuttx/usb/usbdev.h b/nuttx/include/nuttx/usb/usbdev.h index 89813cac9..1270fe13a 100644 --- a/nuttx/include/nuttx/usb/usbdev.h +++ b/nuttx/include/nuttx/usb/usbdev.h @@ -85,7 +85,7 @@ /* Allocate/free an I/O buffer. Should not be called from interrupt processing! */ -#ifdef CONFIG_ARCH_USBDEV_DMA +#ifdef CONFIG_USBDEV_DMA # define EP_ALLOCBUFFER(ep,nb) (ep)->ops->alloc(ep,nb) # define EP_FREEBUFFER(ep,buff) (ep)->ops->free(ep,buf) #else @@ -234,7 +234,7 @@ struct usbdev_epops_s /* Allocate and free I/O buffers */ -#ifdef CONFIG_ARCH_USBDEV_DMA +#ifdef CONFIG_USBDEV_DMA FAR void *(*allocbuffer)(FAR struct usbdev_ep_s *ep, uint16_t nbytes); void (*freebuffer)(FAR struct usbdev_ep_s *ep, FAR void *buf); #endif @@ -354,6 +354,37 @@ EXTERN int usbdev_register(FAR struct usbdevclass_driver_s *driver); EXTERN int usbdev_unregister(FAR struct usbdevclass_driver_s *driver); +/**************************************************************************** + * Name: usbdev_dma_alloc and usbdev_dma_free + * + * Description: + * The USB class driver allocates packet I/O buffers for data transfer by + * calling the driver allocbuffer() and freebuffer() methods. Those + * methods are only available if CONFIG_USBDEV_DMA is defined in the + * system configuration. + * + * If CONFIG_USBDEV_DMAMEMORY is also defined in the NuttX configuration, + * then the driver implementations of the allocbuffer() and freebuffer() + * methods may use board-specific usbdev_dma_alloc() and usbdev_dma_free(). + * If CONFIG_USBDEV_DMA and CONFIG_USBDEV_DMAMEMORY are both defined, + * then the board-specific logic must provide the functions + * usbdev_dma_alloc() and usbdev_dma_free() as prototyped below: + * usbdev_dma_alloc() will allocate DMA-capable memory of the specified + * size; usbdev_dma_free() is the corresponding function that will be + * called to free the DMA-capable memory. + * + * This functions may be simple wrappers around gran_alloc() and + * gran_free() (See nuttx/gran.h). Note that the gran_free() function + * does require the size of the allocation to be freed; that would need + * to be managed in the board-specific logic. + * + ****************************************************************************/ + +#if defined(CONFIG_USBDEV_DMA) && defined(CONFIG_USBDEV_DMAMEMORY) +EXTERN FAR void *usbdev_dma_alloc(size_t size); +EXTERN void usbdev_dma_free(FAR void *memory); +#endif + #undef EXTERN #if defined(__cplusplus) } |