Add kernel/user memalign functions. Not fully integrated

This commit is contained in:
Gregory Nutt
2013-08-20 13:04:49 -06:00
parent b04ea3efa6
commit e3a76b2e64
5 changed files with 33 additions and 6 deletions
+3 -5
View File
@@ -215,8 +215,6 @@ struct sam_rhport_s
struct sam_ohci_s struct sam_ohci_s
{ {
/* Driver status */
volatile bool rhswait; /* TRUE: Thread is waiting for Root Hub Status change */ volatile bool rhswait; /* TRUE: Thread is waiting for Root Hub Status change */
#ifndef CONFIG_USBHOST_INT_DISABLE #ifndef CONFIG_USBHOST_INT_DISABLE
@@ -611,7 +609,7 @@ static void sam_putle16(uint8_t *dest, uint16_t val)
* Name: sam_edalloc * Name: sam_edalloc
* *
* Description: * 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 * Name: sam_edfree
* *
* Description: * 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 * Name: sam_tdfree
* *
* Description: * Description:
* Return an transfer descriptor to the free list * Free a transfer descriptor by returning it to the free list
* *
* Assumptions: * Assumptions:
* - Only called from the WDH interrupt handler (and during initialization). * - Only called from the WDH interrupt handler (and during initialization).
+5
View File
@@ -97,6 +97,7 @@ extern "C"
# define kumalloc(s) malloc(s) # define kumalloc(s) malloc(s)
# define kuzalloc(s) zalloc(s) # define kuzalloc(s) zalloc(s)
# define kurealloc(p,s) realloc(p,s) # define kurealloc(p,s) realloc(p,s)
# define kumemalign(a,s) memalign(a,s)
# define kufree(p) free(p) # define kufree(p) free(p)
#else #else
@@ -108,6 +109,7 @@ extern "C"
# define kumalloc(s) umm_malloc(s) # define kumalloc(s) umm_malloc(s)
# define kuzalloc(s) umm_zalloc(s) # define kuzalloc(s) umm_zalloc(s)
# define kurealloc(p,s) umm_realloc(p,s) # define kurealloc(p,s) umm_realloc(p,s)
# define kumemalign(a,s) umm_memalign(a,s)
# define kufree(p) umm_free(p) # define kufree(p) umm_free(p)
#endif #endif
@@ -127,6 +129,7 @@ extern "C"
# define kmalloc(s) malloc(s) # define kmalloc(s) malloc(s)
# define kzalloc(s) zalloc(s) # define kzalloc(s) zalloc(s)
# define krealloc(p,s) realloc(p,s) # define krealloc(p,s) realloc(p,s)
# define kmemalign(a,s) memalign(a,s)
# define kfree(p) free(p) # define kfree(p) free(p)
#elif !defined(CONFIG_MM_KERNEL_HEAP) #elif !defined(CONFIG_MM_KERNEL_HEAP)
@@ -143,6 +146,7 @@ extern "C"
# define kmalloc(s) umm_malloc(s) # define kmalloc(s) umm_malloc(s)
# define kzalloc(s) umm_zalloc(s) # define kzalloc(s) umm_zalloc(s)
# define krealloc(p,s) umm_realloc(p,s) # define krealloc(p,s) umm_realloc(p,s)
# define kmemalign(a,s) umm_memalign(a,s)
# define kfree(p) umm_free(p) # define kfree(p) umm_free(p)
#else #else
@@ -158,6 +162,7 @@ void kmm_givesemaphore(void);
FAR void *kmalloc(size_t size); FAR void *kmalloc(size_t size);
FAR void *kzalloc(size_t size); FAR void *kzalloc(size_t size);
FAR void *krealloc(FAR void *oldmem, size_t newsize); FAR void *krealloc(FAR void *oldmem, size_t newsize);
FAR void *kmemalign(size_t alignment, size_t size);
void kfree(FAR void *mem); void kfree(FAR void *mem);
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
+1 -1
View File
@@ -536,7 +536,7 @@
#define QTD_TOKEN_IOC (1 << 15) /* Bit 15: Interrupt On Complete */ #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_SHIFT (16) /* Bits 16-30: Total Bytes to Transfer */
#define QTD_TOKEN_NBYTES_MASK (0x7fff << QTD_TOKEN_NBYTES_SHIFT) #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 */ /* qTD Buffer Page Pointer List. Paragraph 3.5.4 */
/* Page 0 */ /* Page 0 */
+4
View File
@@ -91,6 +91,7 @@
# define umm_malloc(s) USERSPACE->mm_malloc(s) # define umm_malloc(s) USERSPACE->mm_malloc(s)
# define umm_zalloc(s) USERSPACE->mm_zalloc(s) # define umm_zalloc(s) USERSPACE->mm_zalloc(s)
# define umm_realloc(p,s) USERSPACE->mm_realloc(p,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) # define umm_free(p) USERSPACE->mm_free(p)
#endif #endif
@@ -140,6 +141,9 @@ struct userspace_s
FAR void *(*mm_malloc)(size_t size); FAR void *(*mm_malloc)(size_t size);
FAR void *(*mm_realloc)(FAR void *oldmem, size_t newsize); 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); FAR void *(*mm_zalloc)(size_t size);
void (*mm_free)(FAR void *mem); void (*mm_free)(FAR void *mem);
+20
View File
@@ -168,6 +168,26 @@ FAR void *krealloc(FAR void *oldmem, size_t newsize)
return mm_realloc(&g_kmmheap, oldmem, newsize); return mm_realloc(&g_kmmheap, oldmem, 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 * Name: kfree
* *