Fixed some nxstyle errors

This commit is contained in:
John Rippetoe 2020-04-01 12:26:00 -04:00 committed by Xiang Xiao
parent acb16e087a
commit 2f54204035
3 changed files with 152 additions and 144 deletions

View File

@ -101,9 +101,9 @@
/* MPU Region Base Address Register Bit Definitions */ /* MPU Region Base Address Register Bit Definitions */
#define MPU_RBAR_REGION_SHIFT (0) /* Bits 0-3: MPU region */ #define MPU_RBAR_REGION_SHIFT (0) /* Bits 0-3: MPU region */
#define MPU_RBAR_REGION_MASK (15 << MPU_RBAR_REGION_SHIFT) #define MPU_RBAR_REGION_MASK (15 << MPU_RBAR_REGION_SHIFT)
#define MPU_RBAR_VALID (1 << 4) /* Bit 4: MPU Region Number valid */ #define MPU_RBAR_VALID (1 << 4) /* Bit 4: MPU Region Number valid */
#define MPU_RBAR_ADDR_MASK 0xffffffe0 /* Bits N-31: Region base addrese */ #define MPU_RBAR_ADDR_MASK 0xffffffe0 /* Bits N-31: Region base addrese */
/* MPU Region Attributes and Size Register Bit Definitions */ /* MPU Region Attributes and Size Register Bit Definitions */
@ -204,8 +204,8 @@ uint8_t mpu_log2regionfloor(size_t size);
* *
* Description: * Description:
* Given (1) the offset to the beginning of valid data, (2) the size of the * Given (1) the offset to the beginning of valid data, (2) the size of the
* memory to be mapped and (2) the log2 size of the mapping to use, determine * memory to be mapped and (2) the log2 size of the mapping to use,
* the minimal sub-region set to span that memory region. * determine the minimal sub-region set to span that memory region.
* *
* Assumption: * Assumption:
* l2size has the same properties as the return value from * l2size has the same properties as the return value from

View File

@ -1,4 +1,4 @@
/**************************************************************************** /*****************************************************************************
* arch/arm/src/armv7-m/up_mpu.c * arch/arm/src/armv7-m/up_mpu.c
* *
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
****************************************************************************/ *****************************************************************************/
/**************************************************************************** /*****************************************************************************
* Included Files * Included Files
****************************************************************************/ *****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@ -45,19 +45,19 @@
#include "mpu.h" #include "mpu.h"
#include "up_internal.h" #include "up_internal.h"
/**************************************************************************** /*****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ *****************************************************************************/
/* Configuration ************************************************************/ /* Configuration *************************************************************/
#ifndef CONFIG_ARM_MPU_NREGIONS #ifndef CONFIG_ARM_MPU_NREGIONS
# define CONFIG_ARM_MPU_NREGIONS 8 # define CONFIG_ARM_MPU_NREGIONS 8
#endif #endif
/**************************************************************************** /*****************************************************************************
* Private Data * Private Data
****************************************************************************/ *****************************************************************************/
/* These sets represent the set of disabled memory sub-regions. A bit set /* These sets represent the set of disabled memory sub-regions. A bit set
* corresponds to a disabled sub-region; the LS bit corresponds to the first * corresponds to a disabled sub-region; the LS bit corresponds to the first
@ -87,11 +87,11 @@ static const uint8_t g_ls_regionmask[9] =
static uint8_t g_region; static uint8_t g_region;
/**************************************************************************** /*****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ *****************************************************************************/
/**************************************************************************** /*****************************************************************************
* Name: mpu_subregion_ms * Name: mpu_subregion_ms
* *
* Description: * Description:
@ -103,7 +103,7 @@ static uint8_t g_region;
* l2size has the same properties as the return value from * l2size has the same properties as the return value from
* mpu_log2regionceil() * mpu_log2regionceil()
* *
****************************************************************************/ *****************************************************************************/
static inline uint32_t mpu_subregion_ms(size_t size, uint8_t l2size) static inline uint32_t mpu_subregion_ms(size_t size, uint8_t l2size)
{ {
@ -122,7 +122,7 @@ static inline uint32_t mpu_subregion_ms(size_t size, uint8_t l2size)
if (l2size < 32) if (l2size < 32)
{ {
mask = ((1 << l2size)-1) >> 3; /* Shifted mask */ mask = ((1 << l2size) - 1) >> 3; /* Shifted mask */
} }
/* The 4Gb region size is a special case */ /* The 4Gb region size is a special case */
@ -133,15 +133,15 @@ static inline uint32_t mpu_subregion_ms(size_t size, uint8_t l2size)
* input. * input.
*/ */
mask = 0x1fffffff; /* Shifted mask */ mask = 0x1fffffff; /* Shifted mask */
} }
asize = (size + mask) & ~mask; /* Adjusted size */ asize = (size + mask) & ~mask; /* Adjusted size */
nsrs = asize >> (l2size-3); /* Number of subregions */ nsrs = asize >> (l2size - 3); /* Number of subregions */
return g_ms_regionmask[nsrs]; return g_ms_regionmask[nsrs];
} }
/**************************************************************************** /*****************************************************************************
* Name: mpu_subregion_ls * Name: mpu_subregion_ls
* *
* Description: * Description:
@ -154,7 +154,7 @@ static inline uint32_t mpu_subregion_ms(size_t size, uint8_t l2size)
* l2size has the same properties as the return value from * l2size has the same properties as the return value from
* mpu_log2regionceil() * mpu_log2regionceil()
* *
****************************************************************************/ *****************************************************************************/
static inline uint32_t mpu_subregion_ls(size_t offset, uint8_t l2size) static inline uint32_t mpu_subregion_ls(size_t offset, uint8_t l2size)
{ {
@ -184,19 +184,19 @@ static inline uint32_t mpu_subregion_ls(size_t offset, uint8_t l2size)
* input. * input.
*/ */
mask = 0x1fffffff; /* Shifted mask */ mask = 0x1fffffff; /* Shifted mask */
} }
aoffset = offset & ~mask; /* Adjusted offset */ aoffset = offset & ~mask; /* Adjusted offset */
nsrs = aoffset >> (l2size-3); /* Number of subregions */ nsrs = aoffset >> (l2size - 3); /* Number of subregions */
return g_ls_regionmask[nsrs]; return g_ls_regionmask[nsrs];
} }
/**************************************************************************** /*****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ *****************************************************************************/
/**************************************************************************** /*****************************************************************************
* Name: mpu_allocregion * Name: mpu_allocregion
* *
* Description: * Description:
@ -207,7 +207,7 @@ static inline uint32_t mpu_subregion_ls(size_t offset, uint8_t l2size)
* - Regions are only allocated early in initialization, so no special * - Regions are only allocated early in initialization, so no special
* protection against re-entrancy is required; * protection against re-entrancy is required;
* *
****************************************************************************/ *****************************************************************************/
unsigned int mpu_allocregion(void) unsigned int mpu_allocregion(void)
{ {
@ -215,7 +215,7 @@ unsigned int mpu_allocregion(void)
return (unsigned int)g_region++; return (unsigned int)g_region++;
} }
/**************************************************************************** /*****************************************************************************
* Name: mpu_log2regionceil * Name: mpu_log2regionceil
* *
* Description: * Description:
@ -224,7 +224,7 @@ unsigned int mpu_allocregion(void)
* *
* size <= (1 << l2size) * size <= (1 << l2size)
* *
****************************************************************************/ *****************************************************************************/
uint8_t mpu_log2regionceil(size_t size) uint8_t mpu_log2regionceil(size_t size)
{ {
@ -236,7 +236,7 @@ uint8_t mpu_log2regionceil(size_t size)
return l2size; return l2size;
} }
/**************************************************************************** /*****************************************************************************
* Name: mpu_log2regionfloor * Name: mpu_log2regionfloor
* *
* Description: * Description:
@ -245,7 +245,7 @@ uint8_t mpu_log2regionceil(size_t size)
* *
* size >= (1 << l2size) * size >= (1 << l2size)
* *
****************************************************************************/ *****************************************************************************/
uint8_t mpu_log2regionfloor(size_t size) uint8_t mpu_log2regionfloor(size_t size)
{ {
@ -259,7 +259,7 @@ uint8_t mpu_log2regionfloor(size_t size)
return l2size; return l2size;
} }
/**************************************************************************** /*****************************************************************************
* Name: mpu_subregion * Name: mpu_subregion
* *
* Description: * Description:
@ -271,7 +271,7 @@ uint8_t mpu_log2regionfloor(size_t size)
* l2size has the same properties as the return value from * l2size has the same properties as the return value from
* mpu_log2regionceil() * mpu_log2regionceil()
* *
****************************************************************************/ *****************************************************************************/
uint32_t mpu_subregion(uintptr_t base, size_t size, uint8_t l2size) uint32_t mpu_subregion(uintptr_t base, size_t size, uint8_t l2size)
{ {

View File

@ -1,4 +1,4 @@
/**************************************************************************** /******************************************************************************
* arch/arm/src/stm32/stm32_allocateheap.c * arch/arm/src/stm32/stm32_allocateheap.c
* *
* Copyright (C) 2011-2013, 2015 Gregory Nutt. All rights reserved. * Copyright (C) 2011-2013, 2015 Gregory Nutt. All rights reserved.
@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
****************************************************************************/ ******************************************************************************/
/**************************************************************************** /******************************************************************************
* Included Files * Included Files
****************************************************************************/ ******************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@ -60,9 +60,10 @@
#include "stm32_mpuinit.h" #include "stm32_mpuinit.h"
/**************************************************************************** /******************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ******************************************************************************/
/* Internal SRAM is available in all members of the STM32 family. The /* Internal SRAM is available in all members of the STM32 family. The
* following definitions must be provided to specify the size and * following definitions must be provided to specify the size and
* location of internal(system) SRAM: * location of internal(system) SRAM:
@ -76,9 +77,9 @@
* *
* CONFIG_STM32_CCMEXCLUDE : Exclude CCM SRAM from the HEAP * CONFIG_STM32_CCMEXCLUDE : Exclude CCM SRAM from the HEAP
* *
* In addition to internal SRAM, external RAM may also be available through the * In addition to internal SRAM, external RAM may also be available through
* FMC/FSMC. To use external RAM, the following things need to be present in * the FMC/FSMC. To use external RAM, the following things need to be present
* the NuttX configuration file: * in the NuttX configuration file:
* *
* CONFIG_STM32_FSMC=y : Enables the FSMC * CONFIG_STM32_FSMC=y : Enables the FSMC
* CONFIG_STM32_FMC=y : Enables the FMC * CONFIG_STM32_FMC=y : Enables the FMC
@ -95,17 +96,20 @@
# undef CONFIG_STM32_EXTERNAL_RAM # undef CONFIG_STM32_EXTERNAL_RAM
#endif #endif
/* The STM32L15xxx family has only internal SRAM. The heap is in one contiguous /* The STM32L15xxx family has only internal SRAM. The heap is in one
* block starting at g_idle_topstack and extending through CONFIG_RAM_END. * contiguous block starting at g_idle_topstack and extending through
* CONFIG_RAM_END.
*/ */
#if defined(CONFIG_STM32_STM32L15XX) #if defined(CONFIG_STM32_STM32L15XX)
/* Set the end of system SRAM */ /* Set the end of system SRAM */
# define SRAM1_END CONFIG_RAM_END # define SRAM1_END CONFIG_RAM_END
/* There is no FSMC (Other EnergyLite STM32's do have an FSMC, but not the STM32L15X */ /* There is no FSMC (Other EnergyLite STM32's do have an FSMC, but not
* the STM32L15X
*/
# undef CONFIG_STM32_EXTERNAL_RAM # undef CONFIG_STM32_EXTERNAL_RAM
@ -120,9 +124,10 @@
# error "CONFIG_MM_REGIONS > 1. The STM32L15X has only one memory region." # error "CONFIG_MM_REGIONS > 1. The STM32L15X has only one memory region."
# endif # endif
/* For the STM312F10xxx family, all internal SRAM is in one contiguous block /* For the STM312F10xxx family, all internal SRAM is in one contiguous
* starting at g_idle_topstack and extending through CONFIG_RAM_END (my apologies * block starting at g_idle_topstack and extending through CONFIG_RAM_END
* for the bad naming). In addition, external FSMC SRAM may be available. * (my apologies for the bad naming). In addition, external FSMC SRAM
* may be available.
*/ */
#elif defined(CONFIG_STM32_STM32F10XX) #elif defined(CONFIG_STM32_STM32F10XX)
@ -184,44 +189,44 @@
* CONFIG_STM32_CCMEXCLUDE NOT defined * CONFIG_STM32_CCMEXCLUDE NOT defined
*/ */
# if CONFIG_MM_REGIONS < 2 # if CONFIG_MM_REGIONS < 2
/* Only one memory region. Force Configuration 1 */ /* Only one memory region. Force Configuration 1 */
# ifndef CONFIG_STM32_CCMEXCLUDE # ifndef CONFIG_STM32_CCMEXCLUDE
# ifdef CONFIG_STM32_HAVE_CCM # ifdef CONFIG_STM32_HAVE_CCM
# warning "CCM SRAM excluded from the heap" # warning "CCM SRAM excluded from the heap"
# endif
# define CONFIG_STM32_CCMEXCLUDE 1
# endif # endif
# define CONFIG_STM32_CCMEXCLUDE 1
# endif
/* CONFIG_MM_REGIONS may be 2 if CCM SRAM is included in the head */ /* CONFIG_MM_REGIONS may be 2 if CCM SRAM is included in the head */
# elif CONFIG_MM_REGIONS >= 2 # elif CONFIG_MM_REGIONS >= 2
# if CONFIG_MM_REGIONS > 2 # if CONFIG_MM_REGIONS > 2
# error "No more than two memory regions can be supported (CONFIG_MM_REGIONS)" # error "No more than two memory regions can be supported (CONFIG_MM_REGIONS)"
# undef CONFIG_MM_REGIONS # undef CONFIG_MM_REGIONS
# define CONFIG_MM_REGIONS 2 # define CONFIG_MM_REGIONS 2
# endif # endif
/* Two memory regions is okay if CCM SRAM is not disabled. */ /* Two memory regions is okay if CCM SRAM is not disabled. */
# ifdef CONFIG_STM32_CCMEXCLUDE # ifdef CONFIG_STM32_CCMEXCLUDE
/* Configuration 1: CONFIG_MM_REGIONS should have been 2 */ /* Configuration 1: CONFIG_MM_REGIONS should have been 2 */
# error "CONFIG_MM_REGIONS >= 2 but but CCM SRAM is excluded (CONFIG_STM32_CCMEXCLUDE)" # error "CONFIG_MM_REGIONS >= 2 but but CCM SRAM is excluded (CONFIG_STM32_CCMEXCLUDE)"
# undef CONFIG_MM_REGIONS # undef CONFIG_MM_REGIONS
# define CONFIG_MM_REGIONS 1 # define CONFIG_MM_REGIONS 1
# else # else
/* Configuration 2: DMA should be disabled */ /* Configuration 2: DMA should be disabled */
# ifdef CONFIG_ARCH_DMA # ifdef CONFIG_ARCH_DMA
# warning "CCM SRAM is included in the heap AND DMA is enabled" # warning "CCM SRAM is included in the heap AND DMA is enabled"
# endif
# endif # endif
# endif # endif
# endif
/* All members of the STM32F33xxx families have 16 Kbi ram and 4 KB CCM SRAM. /* All members of the STM32F33xxx families have 16 Kbi ram and 4 KB CCM SRAM.
* No external RAM is supported (the F3 family has no FSMC). * No external RAM is supported (the F3 family has no FSMC).
@ -254,43 +259,43 @@
* CONFIG_STM32_CCMEXCLUDE NOT defined * CONFIG_STM32_CCMEXCLUDE NOT defined
*/ */
# if CONFIG_MM_REGIONS < 2 # if CONFIG_MM_REGIONS < 2
/* Only one memory region. Force Configuration 1 */ /* Only one memory region. Force Configuration 1 */
# ifndef CONFIG_STM32_CCMEXCLUDE # ifndef CONFIG_STM32_CCMEXCLUDE
# ifdef CONFIG_STM32_HAVE_CCM # ifdef CONFIG_STM32_HAVE_CCM
# warning "CCM SRAM excluded from the heap" # warning "CCM SRAM excluded from the heap"
# endif
# define CONFIG_STM32_CCMEXCLUDE 1
# endif # endif
# define CONFIG_STM32_CCMEXCLUDE 1
# endif
/* CONFIG_MM_REGIONS may be 2 if CCM SRAM is included in the head */ /* CONFIG_MM_REGIONS may be 2 if CCM SRAM is included in the head */
# elif CONFIG_MM_REGIONS >= 2 # elif CONFIG_MM_REGIONS >= 2
# if CONFIG_MM_REGIONS > 2 # if CONFIG_MM_REGIONS > 2
# error "No more than two memory regions can be supported (CONFIG_MM_REGIONS)" # error "No more than two memory regions can be supported (CONFIG_MM_REGIONS)"
# undef CONFIG_MM_REGIONS # undef CONFIG_MM_REGIONS
# define CONFIG_MM_REGIONS 2 # define CONFIG_MM_REGIONS 2
# endif # endif
/* Two memory regions is okay if CCM SRAM is not disabled. */ /* Two memory regions is okay if CCM SRAM is not disabled. */
# ifdef CONFIG_STM32_CCMEXCLUDE # ifdef CONFIG_STM32_CCMEXCLUDE
/* Configuration 1: CONFIG_MM_REGIONS should have been 2 */ /* Configuration 1: CONFIG_MM_REGIONS should have been 2 */
# error "CONFIG_MM_REGIONS >= 2 but but CCM SRAM is excluded (CONFIG_STM32_CCMEXCLUDE)" # error "CONFIG_MM_REGIONS >= 2 but but CCM SRAM is excluded (CONFIG_STM32_CCMEXCLUDE)"
# undef CONFIG_MM_REGIONS # undef CONFIG_MM_REGIONS
# define CONFIG_MM_REGIONS 1 # define CONFIG_MM_REGIONS 1
# else # else
/* Configuration 2: DMA should be disabled */ /* Configuration 2: DMA should be disabled */
# ifdef CONFIG_ARCH_DMA # ifdef CONFIG_ARCH_DMA
# warning "CCM SRAM is included in the heap AND DMA is enabled" # warning "CCM SRAM is included in the heap AND DMA is enabled"
# endif
# endif # endif
# endif
# endif # endif
/* All members of the STM32F37xxx families have 16-32 Kib ram in a single /* All members of the STM32F37xxx families have 16-32 Kib ram in a single
@ -323,19 +328,19 @@
* 1) 112KiB of System SRAM beginning at address 0x2000:0000 * 1) 112KiB of System SRAM beginning at address 0x2000:0000
* 2) 16KiB of System SRAM beginning at address 0x2001:c000 * 2) 16KiB of System SRAM beginning at address 0x2001:c000
* *
* The STM32F401 family is an exception and has only 64KiB or 96Kib total on one * The STM32F401 family is an exception and has only 64KiB or 96Kib total
* bank: * on one bank:
* *
* 3) 64KiB (STM32F401xB/C) or 96KiB (STM32401xD/E) of System SRAM beginning * 3) 64KiB (STM32F401xB/C) or 96KiB (STM32401xD/E) of System SRAM
* at address 0x2000:0000 * beginning at address 0x2000:0000
* *
* Members of the STM32F40xxx family have an additional 64Kib of CCM RAM * Members of the STM32F40xxx family have an additional 64Kib of CCM RAM
* for a total of 192KB. * for a total of 192KB.
* *
* 4) 64Kib of CCM SRAM beginning at address 0x1000:0000 * 4) 64Kib of CCM SRAM beginning at address 0x1000:0000
* *
* The STM32F427/437/429/439 parts have another 64KiB of System SRAM for a total * The STM32F427/437/429/439 parts have another 64KiB of System SRAM for
* of 256KiB. * a total of 256KiB.
* *
* 5) 64Kib of System SRAM beginning at address 0x2002:0000 * 5) 64Kib of System SRAM beginning at address 0x2002:0000
* *
@ -344,9 +349,10 @@
* regions are contiguous and treated as one in this logic that extends to * regions are contiguous and treated as one in this logic that extends to
* 0x2002:0000 (or 0x2003:0000 for the F427/F437/F429/F439). * 0x2002:0000 (or 0x2003:0000 for the F427/F437/F429/F439).
* *
* As a complication, CCM SRAM cannot be used for DMA. So, if STM32 DMA is enabled, * As a complication, CCM SRAM cannot be used for DMA. So, if STM32 DMA is
* CCM SRAM should probably be excluded from the heap or the application must take * enabled, CCM SRAM should probably be excluded from the heap or the
* extra care to ensure that DMA buffers are not allocated in CCM SRAM. * application must take extra care to ensure that DMA buffers are not
* allocated in CCM SRAM.
* *
* In addition, external FSMC SRAM may be available. * In addition, external FSMC SRAM may be available.
*/ */
@ -409,9 +415,9 @@
# if defined(CONFIG_STM32_EXTERNAL_RAM) # if defined(CONFIG_STM32_EXTERNAL_RAM)
/* Configuration 3 or 4. External SRAM is available. CONFIG_MM_REGIONS /* Configuration 3 or 4. External SRAM is available. CONFIG_MM_REGIONS
* should be at least 2. * should be at least 2.
*/ */
# if CONFIG_MM_REGIONS < 2 # if CONFIG_MM_REGIONS < 2
@ -422,7 +428,7 @@
# undef CONFIG_STM32_CCMEXCLUDE # undef CONFIG_STM32_CCMEXCLUDE
# define CONFIG_STM32_CCMEXCLUDE 1 # define CONFIG_STM32_CCMEXCLUDE 1
/* CONFIG_MM_REGIONS may be 3 if CCM SRAM is included in the head */ /* CONFIG_MM_REGIONS may be 3 if CCM SRAM is included in the head */
# elif CONFIG_MM_REGIONS > 2 # elif CONFIG_MM_REGIONS > 2
@ -454,9 +460,9 @@
# endif # endif
# endif # endif
/* CONFIG_MM_REGIONS is exactly 2. We cannot support both CCM SRAM and /* CONFIG_MM_REGIONS is exactly 2. We cannot support both CCM SRAM and
* FSMC SRAM. * FSMC SRAM.
*/ */
# elif !defined(CONFIG_STM32_CCMEXCLUDE) # elif !defined(CONFIG_STM32_CCMEXCLUDE)
# error "CONFIG_MM_REGIONS == 2, cannot support both CCM SRAM and FSMC SRAM" # error "CONFIG_MM_REGIONS == 2, cannot support both CCM SRAM and FSMC SRAM"
@ -466,9 +472,9 @@
# elif !defined(CONFIG_STM32_CCMEXCLUDE) # elif !defined(CONFIG_STM32_CCMEXCLUDE)
/* Configuration 2: FSMC SRAM is not used, but CCM SRAM is requested. DMA /* Configuration 2: FSMC SRAM is not used, but CCM SRAM is requested.
* should be disabled and CONFIG_MM_REGIONS should be 2. * DMA should be disabled and CONFIG_MM_REGIONS should be 2.
*/ */
# ifdef CONFIG_ARCH_DMA # ifdef CONFIG_ARCH_DMA
# warning "CCM SRAM is included in the heap AND DMA is enabled" # warning "CCM SRAM is included in the heap AND DMA is enabled"
@ -503,17 +509,17 @@
# endif # endif
#endif #endif
/**************************************************************************** /******************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ******************************************************************************/
/**************************************************************************** /******************************************************************************
* Name: up_heap_color * Name: up_heap_color
* *
* Description: * Description:
* Set heap memory to a known, non-zero state to checking heap usage. * Set heap memory to a known, non-zero state to checking heap usage.
* *
****************************************************************************/ ******************************************************************************/
#ifdef CONFIG_HEAP_COLORATION #ifdef CONFIG_HEAP_COLORATION
static inline void up_heap_color(FAR void *start, size_t size) static inline void up_heap_color(FAR void *start, size_t size)
@ -524,11 +530,11 @@ static inline void up_heap_color(FAR void *start, size_t size)
# define up_heap_color(start,size) # define up_heap_color(start,size)
#endif #endif
/**************************************************************************** /******************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ******************************************************************************/
/**************************************************************************** /******************************************************************************
* Name: up_allocate_heap * Name: up_allocate_heap
* *
* Description: * Description:
@ -550,16 +556,16 @@ static inline void up_heap_color(FAR void *start, size_t size)
* *
* The following memory map is assumed for the kernel build: * The following memory map is assumed for the kernel build:
* *
* Kernel .data region. Size determined at link time. * Kernel .data region Size determined at link time
* Kernel .bss region Size determined at link time. * Kernel .bss region Size determined at link time
* Kernel IDLE thread stack. Size determined by CONFIG_IDLETHREAD_STACKSIZE. * Kernel IDLE thread stack Size determined by CONFIG_IDLETHREAD_STACKSIZE
* Padding for alignment * Padding for alignment
* User .data region. Size determined at link time. * User .data region Size determined at link time
* User .bss region Size determined at link time. * User .bss region Size determined at link time
* Kernel heap. Size determined by CONFIG_MM_KERNEL_HEAPSIZE. * Kernel heap Size determined by CONFIG_MM_KERNEL_HEAPSIZE
* User heap. Extends to the end of SRAM. * User heap Extends to the end of SRAM
* *
****************************************************************************/ ******************************************************************************/
void up_allocate_heap(FAR void **heap_start, size_t *heap_size) void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
{ {
@ -569,7 +575,8 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
* of CONFIG_MM_KERNEL_HEAPSIZE (subject to alignment). * of CONFIG_MM_KERNEL_HEAPSIZE (subject to alignment).
*/ */
uintptr_t ubase = (uintptr_t)USERSPACE->us_bssend + CONFIG_MM_KERNEL_HEAPSIZE; uintptr_t ubase = (uintptr_t)USERSPACE->us_bssend +
CONFIG_MM_KERNEL_HEAPSIZE;
size_t usize = SRAM1_END - ubase; size_t usize = SRAM1_END - ubase;
int log2; int log2;
@ -598,7 +605,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
/* Allow user-mode access to the user heap memory */ /* Allow user-mode access to the user heap memory */
stm32_mpu_uheap((uintptr_t)ubase, usize); stm32_mpu_uheap((uintptr_t)ubase, usize);
#else #else
/* Return the heap settings */ /* Return the heap settings */
@ -613,7 +620,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
#endif #endif
} }
/**************************************************************************** /******************************************************************************
* Name: up_allocate_kheap * Name: up_allocate_kheap
* *
* Description: * Description:
@ -621,7 +628,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
* user-space heaps (CONFIG_MM_KERNEL_HEAP=y), this function allocates * user-space heaps (CONFIG_MM_KERNEL_HEAP=y), this function allocates
* (and protects) the kernel-space heap. * (and protects) the kernel-space heap.
* *
****************************************************************************/ ******************************************************************************/
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP) #if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP)
void up_allocate_kheap(FAR void **heap_start, size_t *heap_size) void up_allocate_kheap(FAR void **heap_start, size_t *heap_size)
@ -631,7 +638,8 @@ void up_allocate_kheap(FAR void **heap_start, size_t *heap_size)
* of CONFIG_MM_KERNEL_HEAPSIZE (subject to alignment). * of CONFIG_MM_KERNEL_HEAPSIZE (subject to alignment).
*/ */
uintptr_t ubase = (uintptr_t)USERSPACE->us_bssend + CONFIG_MM_KERNEL_HEAPSIZE; uintptr_t ubase = (uintptr_t)USERSPACE->us_bssend +
CONFIG_MM_KERNEL_HEAPSIZE;
size_t usize = SRAM1_END - ubase; size_t usize = SRAM1_END - ubase;
int log2; int log2;
@ -657,14 +665,14 @@ void up_allocate_kheap(FAR void **heap_start, size_t *heap_size)
} }
#endif #endif
/**************************************************************************** /******************************************************************************
* Name: up_addregion * Name: up_addregion
* *
* Description: * Description:
* Memory may be added in non-contiguous chunks. Additional chunks are * Memory may be added in non-contiguous chunks. Additional chunks are
* added by calling this function. * added by calling this function.
* *
****************************************************************************/ ******************************************************************************/
#if CONFIG_MM_REGIONS > 1 #if CONFIG_MM_REGIONS > 1
void up_addregion(void) void up_addregion(void)
@ -674,17 +682,17 @@ void up_addregion(void)
/* Allow user-mode access to the STM32F20xxx/STM32F40xxx CCM SRAM heap */ /* Allow user-mode access to the STM32F20xxx/STM32F40xxx CCM SRAM heap */
stm32_mpu_uheap((uintptr_t)SRAM2_START, SRAM2_END-SRAM2_START); stm32_mpu_uheap((uintptr_t)SRAM2_START, SRAM2_END - SRAM2_START);
#endif #endif
/* Colorize the heap for debug */ /* Colorize the heap for debug */
up_heap_color((FAR void *)SRAM2_START, SRAM2_END-SRAM2_START); up_heap_color((FAR void *)SRAM2_START, SRAM2_END - SRAM2_START);
/* Add the STM32F20xxx/STM32F40xxx CCM SRAM user heap region. */ /* Add the STM32F20xxx/STM32F40xxx CCM SRAM user heap region. */
kumm_addregion((FAR void *)SRAM2_START, SRAM2_END-SRAM2_START); kumm_addregion((FAR void *)SRAM2_START, SRAM2_END - SRAM2_START);
#endif #endif
#ifdef CONFIG_STM32_EXTERNAL_RAM #ifdef CONFIG_STM32_EXTERNAL_RAM
@ -692,7 +700,7 @@ void up_addregion(void)
/* Allow user-mode access to the FSMC SRAM user heap memory */ /* Allow user-mode access to the FSMC SRAM user heap memory */
stm32_mpu_uheap((uintptr_t)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE); stm32_mpu_uheap((uintptr_t)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE);
#endif #endif