diff --git a/arch/arm/src/lpc31xx/Kconfig b/arch/arm/src/lpc31xx/Kconfig index 1355196991e..0e9d1d1fda0 100644 --- a/arch/arm/src/lpc31xx/Kconfig +++ b/arch/arm/src/lpc31xx/Kconfig @@ -294,7 +294,7 @@ config LPC31_EHCI_PREALLOCATE ---help--- Select this option to pre-allocate EHCI queue and descriptor structure pools in .bss. Otherwise, these pools will be - dynamically allocated using kmemalign(). + dynamically allocated using kmm_memalign(). config LPC31_EHCI_REGDEBUG bool "Enable low-level EHCI register debug" diff --git a/arch/arm/src/lpc31xx/lpc31_ehci.c b/arch/arm/src/lpc31xx/lpc31_ehci.c index 46a4b495162..bbac7edfa05 100755 --- a/arch/arm/src/lpc31xx/lpc31_ehci.c +++ b/arch/arm/src/lpc31xx/lpc31_ehci.c @@ -1,7 +1,7 @@ /******************************************************************************* * arch/arm/src/lpc31xx/lpc31_ehci.c * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -4254,7 +4254,7 @@ FAR struct usbhost_connection_s *lpc31_ehci_initialize(int controller) /* Allocate a pool of free Queue Head (QH) structures */ g_qhpool = (struct lpc31_qh_s *) - kmemalign(32, CONFIG_LPC31_EHCI_NQHS * sizeof(struct lpc31_qh_s)); + kmm_memalign(32, CONFIG_LPC31_EHCI_NQHS * sizeof(struct lpc31_qh_s)); if (!g_qhpool) { usbhost_trace1(EHCI_TRACE1_QHPOOLALLOC_FAILED, 0); @@ -4275,7 +4275,7 @@ FAR struct usbhost_connection_s *lpc31_ehci_initialize(int controller) /* Allocate a pool of free Transfer Descriptor (qTD) structures */ g_qtdpool = (struct lpc31_qtd_s *) - kmemalign(32, CONFIG_LPC31_EHCI_NQTDS * sizeof(struct lpc31_qtd_s)); + kmm_memalign(32, CONFIG_LPC31_EHCI_NQTDS * sizeof(struct lpc31_qtd_s)); if (!g_qtdpool) { usbhost_trace1(EHCI_TRACE1_QTDPOOLALLOC_FAILED, 0); @@ -4288,7 +4288,7 @@ FAR struct usbhost_connection_s *lpc31_ehci_initialize(int controller) /* Allocate the periodic framelist */ g_framelist = (uint32_t *) - kmemalign(4096, FRAME_LIST_SIZE * sizeof(uint32_t)); + kmm_memalign(4096, FRAME_LIST_SIZE * sizeof(uint32_t)); if (!g_framelist) { usbhost_trace1(EHCI_TRACE1_PERFLALLOC_FAILED, 0); diff --git a/arch/arm/src/sam34/sam_emac.c b/arch/arm/src/sam34/sam_emac.c index 4805aa93dee..0dc5fb783da 100644 --- a/arch/arm/src/sam34/sam_emac.c +++ b/arch/arm/src/sam34/sam_emac.c @@ -588,7 +588,7 @@ static int sam_buffer_initialize(struct sam_emac_s *priv) /* Allocate buffers */ allocsize = CONFIG_SAM34_EMAC_NTXBUFFERS * sizeof(struct emac_txdesc_s); - priv->txdesc = (struct emac_txdesc_s *)kmemalign(8, allocsize); + priv->txdesc = (struct emac_txdesc_s *)kmm_memalign(8, allocsize); if (!priv->txdesc) { nlldbg("ERROR: Failed to allocate TX descriptors\n"); @@ -598,7 +598,7 @@ static int sam_buffer_initialize(struct sam_emac_s *priv) memset(priv->txdesc, 0, allocsize); allocsize = CONFIG_SAM34_EMAC_NRXBUFFERS * sizeof(struct emac_rxdesc_s); - priv->rxdesc = (struct emac_rxdesc_s *)kmemalign(8, allocsize); + priv->rxdesc = (struct emac_rxdesc_s *)kmm_memalign(8, allocsize); if (!priv->rxdesc) { nlldbg("ERROR: Failed to allocate RX descriptors\n"); @@ -609,7 +609,7 @@ static int sam_buffer_initialize(struct sam_emac_s *priv) memset(priv->rxdesc, 0, allocsize); allocsize = CONFIG_SAM34_EMAC_NTXBUFFERS * EMAC_TX_UNITSIZE; - priv->txbuffer = (uint8_t *)kmemalign(8, allocsize); + priv->txbuffer = (uint8_t *)kmm_memalign(8, allocsize); if (!priv->txbuffer) { nlldbg("ERROR: Failed to allocate TX buffer\n"); @@ -618,7 +618,7 @@ static int sam_buffer_initialize(struct sam_emac_s *priv) } allocsize = CONFIG_SAM34_EMAC_NRXBUFFERS * EMAC_RX_UNITSIZE; - priv->rxbuffer = (uint8_t *)kmemalign(8, allocsize); + priv->rxbuffer = (uint8_t *)kmm_memalign(8, allocsize); if (!priv->rxbuffer) { nlldbg("ERROR: Failed to allocate RX buffer\n"); diff --git a/arch/arm/src/sama5/Kconfig b/arch/arm/src/sama5/Kconfig index caf30bac22e..f3baca2f046 100644 --- a/arch/arm/src/sama5/Kconfig +++ b/arch/arm/src/sama5/Kconfig @@ -2684,7 +2684,7 @@ config SAMA5_EHCI_PREALLOCATE ---help--- Select this option to pre-allocate EHCI queue and descriptor structure pools in .bss. Otherwise, these pools will be - dynamically allocated using kmemalign(). + dynamically allocated using kmm_memalign(). config SAMA5_EHCI_REGDEBUG bool "Enable low-level EHCI register debug" diff --git a/arch/arm/src/sama5/sam_ehci.c b/arch/arm/src/sama5/sam_ehci.c index 6e552b9cfb2..025b27e7780 100755 --- a/arch/arm/src/sama5/sam_ehci.c +++ b/arch/arm/src/sama5/sam_ehci.c @@ -4152,7 +4152,7 @@ FAR struct usbhost_connection_s *sam_ehci_initialize(int controller) /* Allocate a pool of free Queue Head (QH) structures */ g_qhpool = (struct sam_qh_s *) - kmemalign(32, CONFIG_SAMA5_EHCI_NQHS * sizeof(struct sam_qh_s)); + kmm_memalign(32, CONFIG_SAMA5_EHCI_NQHS * sizeof(struct sam_qh_s)); if (!g_qhpool) { usbhost_trace1(EHCI_TRACE1_QHPOOLALLOC_FAILED, 0); @@ -4173,7 +4173,7 @@ FAR struct usbhost_connection_s *sam_ehci_initialize(int controller) /* Allocate a pool of free Transfer Descriptor (qTD) structures */ g_qtdpool = (struct sam_qtd_s *) - kmemalign(32, CONFIG_SAMA5_EHCI_NQTDS * sizeof(struct sam_qtd_s)); + kmm_memalign(32, CONFIG_SAMA5_EHCI_NQTDS * sizeof(struct sam_qtd_s)); if (!g_qtdpool) { usbhost_trace1(EHCI_TRACE1_QTDPOOLALLOC_FAILED, 0); @@ -4186,7 +4186,7 @@ FAR struct usbhost_connection_s *sam_ehci_initialize(int controller) /* Allocate the periodic framelist */ g_framelist = (uint32_t *) - kmemalign(4096, FRAME_LIST_SIZE * sizeof(uint32_t)); + kmm_memalign(4096, FRAME_LIST_SIZE * sizeof(uint32_t)); if (!g_framelist) { usbhost_trace1(EHCI_TRACE1_PERFLALLOC_FAILED, 0); diff --git a/arch/arm/src/sama5/sam_emaca.c b/arch/arm/src/sama5/sam_emaca.c index 4a8555ef554..50e1f1a4992 100644 --- a/arch/arm/src/sama5/sam_emaca.c +++ b/arch/arm/src/sama5/sam_emaca.c @@ -593,7 +593,7 @@ static int sam_buffer_initialize(struct sam_emac_s *priv) /* Allocate buffers */ allocsize = CONFIG_SAMA5_EMAC_NTXBUFFERS * sizeof(struct emac_txdesc_s); - priv->txdesc = (struct emac_txdesc_s *)kmemalign(8, allocsize); + priv->txdesc = (struct emac_txdesc_s *)kmm_memalign(8, allocsize); if (!priv->txdesc) { nlldbg("ERROR: Failed to allocate TX descriptors\n"); @@ -603,7 +603,7 @@ static int sam_buffer_initialize(struct sam_emac_s *priv) memset(priv->txdesc, 0, allocsize); allocsize = CONFIG_SAMA5_EMAC_NRXBUFFERS * sizeof(struct emac_rxdesc_s); - priv->rxdesc = (struct emac_rxdesc_s *)kmemalign(8, allocsize); + priv->rxdesc = (struct emac_rxdesc_s *)kmm_memalign(8, allocsize); if (!priv->rxdesc) { nlldbg("ERROR: Failed to allocate RX descriptors\n"); @@ -614,7 +614,7 @@ static int sam_buffer_initialize(struct sam_emac_s *priv) memset(priv->rxdesc, 0, allocsize); allocsize = CONFIG_SAMA5_EMAC_NTXBUFFERS * EMAC_TX_UNITSIZE; - priv->txbuffer = (uint8_t *)kmemalign(8, allocsize); + priv->txbuffer = (uint8_t *)kmm_memalign(8, allocsize); if (!priv->txbuffer) { nlldbg("ERROR: Failed to allocate TX buffer\n"); @@ -623,7 +623,7 @@ static int sam_buffer_initialize(struct sam_emac_s *priv) } allocsize = CONFIG_SAMA5_EMAC_NRXBUFFERS * EMAC_RX_UNITSIZE; - priv->rxbuffer = (uint8_t *)kmemalign(8, allocsize); + priv->rxbuffer = (uint8_t *)kmm_memalign(8, allocsize); if (!priv->rxbuffer) { nlldbg("ERROR: Failed to allocate RX buffer\n"); diff --git a/arch/arm/src/sama5/sam_emacb.c b/arch/arm/src/sama5/sam_emacb.c index fb81624adf7..89024a7a847 100644 --- a/arch/arm/src/sama5/sam_emacb.c +++ b/arch/arm/src/sama5/sam_emacb.c @@ -920,7 +920,7 @@ static int sam_buffer_initialize(struct sam_emac_s *priv) /* Allocate buffers */ allocsize = priv->attr->ntxbuffers * sizeof(struct emac_txdesc_s); - priv->txdesc = (struct emac_txdesc_s *)kmemalign(8, allocsize); + priv->txdesc = (struct emac_txdesc_s *)kmm_memalign(8, allocsize); if (!priv->txdesc) { nlldbg("ERROR: Failed to allocate TX descriptors\n"); @@ -930,7 +930,7 @@ static int sam_buffer_initialize(struct sam_emac_s *priv) memset(priv->txdesc, 0, allocsize); allocsize = priv->attr->nrxbuffers * sizeof(struct emac_rxdesc_s); - priv->rxdesc = (struct emac_rxdesc_s *)kmemalign(8, allocsize); + priv->rxdesc = (struct emac_rxdesc_s *)kmm_memalign(8, allocsize); if (!priv->rxdesc) { nlldbg("ERROR: Failed to allocate RX descriptors\n"); @@ -941,7 +941,7 @@ static int sam_buffer_initialize(struct sam_emac_s *priv) memset(priv->rxdesc, 0, allocsize); allocsize = priv->attr->ntxbuffers * EMAC_TX_UNITSIZE; - priv->txbuffer = (uint8_t *)kmemalign(8, allocsize); + priv->txbuffer = (uint8_t *)kmm_memalign(8, allocsize); if (!priv->txbuffer) { nlldbg("ERROR: Failed to allocate TX buffer\n"); @@ -950,7 +950,7 @@ static int sam_buffer_initialize(struct sam_emac_s *priv) } allocsize = priv->attr->nrxbuffers * EMAC_RX_UNITSIZE; - priv->rxbuffer = (uint8_t *)kmemalign(8, allocsize); + priv->rxbuffer = (uint8_t *)kmm_memalign(8, allocsize); if (!priv->rxbuffer) { nlldbg("ERROR: Failed to allocate RX buffer\n"); diff --git a/arch/arm/src/sama5/sam_gmac.c b/arch/arm/src/sama5/sam_gmac.c index 7ee3d727bc5..905b56ce4a1 100644 --- a/arch/arm/src/sama5/sam_gmac.c +++ b/arch/arm/src/sama5/sam_gmac.c @@ -524,7 +524,7 @@ static int sam_buffer_initialize(struct sam_gmac_s *priv) /* Allocate buffers */ allocsize = CONFIG_SAMA5_GMAC_NTXBUFFERS * sizeof(struct gmac_txdesc_s); - priv->txdesc = (struct gmac_txdesc_s *)kmemalign(8, allocsize); + priv->txdesc = (struct gmac_txdesc_s *)kmm_memalign(8, allocsize); if (!priv->txdesc) { nlldbg("ERROR: Failed to allocate TX descriptors\n"); @@ -534,7 +534,7 @@ static int sam_buffer_initialize(struct sam_gmac_s *priv) memset(priv->txdesc, 0, allocsize); allocsize = CONFIG_SAMA5_GMAC_NRXBUFFERS * sizeof(struct gmac_rxdesc_s); - priv->rxdesc = (struct gmac_rxdesc_s *)kmemalign(8, allocsize); + priv->rxdesc = (struct gmac_rxdesc_s *)kmm_memalign(8, allocsize); if (!priv->rxdesc) { nlldbg("ERROR: Failed to allocate RX descriptors\n"); @@ -545,7 +545,7 @@ static int sam_buffer_initialize(struct sam_gmac_s *priv) memset(priv->rxdesc, 0, allocsize); allocsize = CONFIG_SAMA5_GMAC_NTXBUFFERS * GMAC_TX_UNITSIZE; - priv->txbuffer = (uint8_t *)kmemalign(8, allocsize); + priv->txbuffer = (uint8_t *)kmm_memalign(8, allocsize); if (!priv->txbuffer) { nlldbg("ERROR: Failed to allocate TX buffer\n"); @@ -554,7 +554,7 @@ static int sam_buffer_initialize(struct sam_gmac_s *priv) } allocsize = CONFIG_SAMA5_GMAC_NRXBUFFERS * GMAC_RX_UNITSIZE; - priv->rxbuffer = (uint8_t *)kmemalign(8, allocsize); + priv->rxbuffer = (uint8_t *)kmm_memalign(8, allocsize); if (!priv->rxbuffer) { nlldbg("ERROR: Failed to allocate RX buffer\n"); diff --git a/arch/arm/src/sama5/sam_udphs.c b/arch/arm/src/sama5/sam_udphs.c index ca16b9e8ada..f61f2e22198 100644 --- a/arch/arm/src/sama5/sam_udphs.c +++ b/arch/arm/src/sama5/sam_udphs.c @@ -4291,7 +4291,7 @@ static void sam_sw_setup(struct sam_usbdev_s *priv) /* Allocate a pool of free DMA transfer descriptors */ priv->dtdpool = (struct sam_dtd_s *) - kmemalign(16, CONFIG_SAMA5_UDPHS_NDTDS * sizeof(struct sam_dtd_s)); + kmm_memalign(16, CONFIG_SAMA5_UDPHS_NDTDS * sizeof(struct sam_dtd_s)); if (!priv->dtdpool) { udbg("ERROR: Failed to allocate the DMA transfer descriptor pool\n"); diff --git a/include/nuttx/kmalloc.h b/include/nuttx/kmalloc.h index c26fb521e7e..018d34888a8 100644 --- a/include/nuttx/kmalloc.h +++ b/include/nuttx/kmalloc.h @@ -129,7 +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 kmm_memalign(a,s) memalign(a,s) # define kfree(p) free(p) #elif !defined(CONFIG_MM_KERNEL_HEAP) @@ -146,12 +146,12 @@ 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 kmm_memalign(a,s) umm_memalign(a,s) # define kfree(p) umm_free(p) #else -/* Otherwise, the kernel-space allocators are declared here and we can call - * them directly. +/* Otherwise, the kernel-space allocators are declared in include/nuttx/mm.h + * and we can call them directly. */ void kmm_initialize(FAR void *heap_start, size_t heap_size); @@ -162,7 +162,6 @@ 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/include/nuttx/mm.h b/include/nuttx/mm.h index 53eb95d2b07..9e9c7631cb4 100644 --- a/include/nuttx/mm.h +++ b/include/nuttx/mm.h @@ -337,6 +337,12 @@ FAR void *mm_zalloc(FAR struct mm_heap_s *heap, size_t size); FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment, size_t size); +/* Functions contained in kmm_memalign.c ************************************/ + +#ifdef CONFIG_MM_KERNEL_HEAP +FAR void *kmm_memalign(size_t alignment, size_t size); +#endif + /* Functions contained in mm_brkaddr.c **************************************/ FAR void *mm_brkaddr(FAR struct mm_heap_s *heap, int region); diff --git a/mm/kmm_memalign.c b/mm/kmm_memalign.c index b7fc3d59973..783ea9ff4a2 100644 --- a/mm/kmm_memalign.c +++ b/mm/kmm_memalign.c @@ -58,7 +58,7 @@ ****************************************************************************/ /************************************************************************ - * Name: kmemalign + * Name: kmm_memalign * * Description: * Allocate aligned memory in the kernel heap. @@ -72,7 +72,7 @@ * ************************************************************************/ -FAR void *kmemalign(size_t alignment, size_t size) +FAR void *kmm_memalign(size_t alignment, size_t size) { return mm_memalign(&g_kmmheap, alignment, size); }