diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-08-20 13:04:49 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-08-20 13:04:49 -0600 |
commit | 20174857959f8d35c17a780faf5871d62fb274ff (patch) | |
tree | a316c19f09b845e817b510f2a11586a2b3ab7b6f | |
parent | 19fc1af7daa365e9476cbe2d8fa4fcc9b177159e (diff) | |
download | px4-nuttx-20174857959f8d35c17a780faf5871d62fb274ff.tar.gz px4-nuttx-20174857959f8d35c17a780faf5871d62fb274ff.tar.bz2 px4-nuttx-20174857959f8d35c17a780faf5871d62fb274ff.zip |
Add kernel/user memalign functions. Not fully integrated
-rw-r--r-- | nuttx/arch/arm/src/sama5/sam_ohci.c | 8 | ||||
-rw-r--r-- | nuttx/include/nuttx/kmalloc.h | 5 | ||||
-rwxr-xr-x | nuttx/include/nuttx/usb/ehci.h | 2 | ||||
-rw-r--r-- | nuttx/include/nuttx/userspace.h | 4 | ||||
-rw-r--r-- | nuttx/mm/mm_kernel.c | 20 |
5 files changed, 33 insertions, 6 deletions
diff --git a/nuttx/arch/arm/src/sama5/sam_ohci.c b/nuttx/arch/arm/src/sama5/sam_ohci.c index 2c2fe6582..a8a10ebfa 100644 --- a/nuttx/arch/arm/src/sama5/sam_ohci.c +++ b/nuttx/arch/arm/src/sama5/sam_ohci.c @@ -215,8 +215,6 @@ struct sam_rhport_s struct sam_ohci_s { - /* Driver status */ - volatile bool rhswait; /* TRUE: Thread is waiting for Root Hub Status change */ #ifndef CONFIG_USBHOST_INT_DISABLE @@ -611,7 +609,7 @@ static void sam_putle16(uint8_t *dest, uint16_t val) * Name: sam_edalloc * * Description: - * Return an endpoint descriptor to the free list + * Allocate an endpoint descriptor by removing it from the free list * *******************************************************************************/ @@ -634,7 +632,7 @@ static struct sam_ed_s *sam_edalloc(void) * Name: sam_edfree * * Description: - * Return an endpoint descriptor to the free list + * Free an endpoint descriptor by returning to the free list * *******************************************************************************/ @@ -686,7 +684,7 @@ static struct sam_gtd_s *sam_tdalloc(void) * Name: sam_tdfree * * Description: - * Return an transfer descriptor to the free list + * Free a transfer descriptor by returning it to the free list * * Assumptions: * - Only called from the WDH interrupt handler (and during initialization). diff --git a/nuttx/include/nuttx/kmalloc.h b/nuttx/include/nuttx/kmalloc.h index 69ceb06bf..495fccc14 100644 --- a/nuttx/include/nuttx/kmalloc.h +++ b/nuttx/include/nuttx/kmalloc.h @@ -97,6 +97,7 @@ extern "C" # define kumalloc(s) malloc(s) # define kuzalloc(s) zalloc(s) # define kurealloc(p,s) realloc(p,s) +# define kumemalign(a,s) memalign(a,s) # define kufree(p) free(p) #else @@ -108,6 +109,7 @@ extern "C" # define kumalloc(s) umm_malloc(s) # define kuzalloc(s) umm_zalloc(s) # define kurealloc(p,s) umm_realloc(p,s) +# define kumemalign(a,s) umm_memalign(a,s) # define kufree(p) umm_free(p) #endif @@ -127,6 +129,7 @@ extern "C" # define kmalloc(s) malloc(s) # define kzalloc(s) zalloc(s) # define krealloc(p,s) realloc(p,s) +# define kmemalign(a,s) memalign(a,s) # define kfree(p) free(p) #elif !defined(CONFIG_MM_KERNEL_HEAP) @@ -143,6 +146,7 @@ extern "C" # define kmalloc(s) umm_malloc(s) # define kzalloc(s) umm_zalloc(s) # define krealloc(p,s) umm_realloc(p,s) +# define kmemalign(a,s) umm_memalign(a,s) # define kfree(p) umm_free(p) #else @@ -158,6 +162,7 @@ void kmm_givesemaphore(void); FAR void *kmalloc(size_t size); FAR void *kzalloc(size_t size); FAR void *krealloc(FAR void *oldmem, size_t newsize); +FAR void *kmemalign(size_t alignment, size_t size); void kfree(FAR void *mem); #ifdef CONFIG_DEBUG diff --git a/nuttx/include/nuttx/usb/ehci.h b/nuttx/include/nuttx/usb/ehci.h index 01dd69751..ee65339e0 100755 --- a/nuttx/include/nuttx/usb/ehci.h +++ b/nuttx/include/nuttx/usb/ehci.h @@ -536,7 +536,7 @@ #define QTD_TOKEN_IOC (1 << 15) /* Bit 15: Interrupt On Complete */ #define QTD_TOKEN_NBYTES_SHIFT (16) /* Bits 16-30: Total Bytes to Transfer */ #define QTD_TOKEN_NBYTES_MASK (0x7fff << QTD_TOKEN_NBYTES_SHIFT) -#define QTD_TOKEN_TOGGLE (1 << 13) /* Bit 31: Data Toggle +#define QTD_TOKEN_TOGGLE (1 << 13) /* Bit 31: Data Toggle */ /* qTD Buffer Page Pointer List. Paragraph 3.5.4 */ /* Page 0 */ diff --git a/nuttx/include/nuttx/userspace.h b/nuttx/include/nuttx/userspace.h index 6a78c6ffa..5115aad7d 100644 --- a/nuttx/include/nuttx/userspace.h +++ b/nuttx/include/nuttx/userspace.h @@ -91,6 +91,7 @@ # define umm_malloc(s) USERSPACE->mm_malloc(s) # define umm_zalloc(s) USERSPACE->mm_zalloc(s) # define umm_realloc(p,s) USERSPACE->mm_realloc(p,s) +# define umm_memalign(a,s) USERSPACE->mm_memalign(a,s) # define umm_free(p) USERSPACE->mm_free(p) #endif @@ -140,6 +141,9 @@ struct userspace_s FAR void *(*mm_malloc)(size_t size); FAR void *(*mm_realloc)(FAR void *oldmem, size_t newsize); +#if 0 /* Not yet integrated */ + FAR void *(*mm_memalign)(size_t alignment, size_t size); +#endif FAR void *(*mm_zalloc)(size_t size); void (*mm_free)(FAR void *mem); diff --git a/nuttx/mm/mm_kernel.c b/nuttx/mm/mm_kernel.c index 0cf592e0a..ee156e889 100644 --- a/nuttx/mm/mm_kernel.c +++ b/nuttx/mm/mm_kernel.c @@ -169,6 +169,26 @@ FAR void *krealloc(FAR void *oldmem, size_t newsize) } /************************************************************************ + * Name: kmemalign + * + * Description: + * Allocate aligned memory in the kernel heap. + * + * Parameters: + * alignment - Log2 byte alignment + * size - Size (in bytes) of the new memory region to be allocated. + * + * Return Value: + * The address of the re-allocated memory (NULL on failure to allocate) + * + ************************************************************************/ + +FAR void *kmemalign(size_t alignment, size_t size) +{ + return mm_memalign(&g_kmmheap, alignment, size); +} + +/************************************************************************ * Name: kfree * * Description: |