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

@ -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)
{ {
@ -141,7 +141,7 @@ static inline uint32_t mpu_subregion_ms(size_t size, uint8_t l2size)
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)
{ {
@ -192,11 +192,11 @@ static inline uint32_t mpu_subregion_ls(size_t offset, uint8_t l2size)
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,8 +96,9 @@
# 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)
@ -105,7 +107,9 @@
# 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)
@ -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.
*/ */
@ -466,8 +472,8 @@
# 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
@ -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;
@ -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)