CCM PROCFS: Changed the configuration a bit. I am still not happy about the coupling between procfs, mtd, and now STM32

This commit is contained in:
Gregory Nutt
2014-07-03 08:50:24 -06:00
parent 64cd7a81ed
commit dd4caf172f
5 changed files with 40 additions and 22 deletions
+9
View File
@@ -1658,6 +1658,15 @@ config STM32_CCMEXCLUDE
and (2) it appears to be impossible to execute ELF modules from CCM and (2) it appears to be impossible to execute ELF modules from CCM
RAM. RAM.
config STM32_CCM_PROCFS
bool "CCM PROCFS support"
default n
depends on STM32_CCMEXCLUDE && MM_MULTIHEAP && FS_PROCFS
---help---
Select to build in support for /proc/ccm. Reading from /proc/ccm
will provide statistics about CCM memory use similar to what you
would get from mallinfo() for the user heap.
config STM32_DMACAPABLE config STM32_DMACAPABLE
bool "Workaround non-DMA capable memory" bool "Workaround non-DMA capable memory"
depends on ARCH_DMA depends on ARCH_DMA
+4 -1
View File
@@ -96,7 +96,6 @@ CHIP_CSRCS = stm32_allocateheap.c stm32_start.c stm32_rcc.c stm32_lse.c
CHIP_CSRCS += stm32_lsi.c stm32_gpio.c stm32_exti_gpio.c stm32_flash.c stm32_irq.c CHIP_CSRCS += stm32_lsi.c stm32_gpio.c stm32_exti_gpio.c stm32_flash.c stm32_irq.c
CHIP_CSRCS += stm32_timerisr.c stm32_dma.c stm32_lowputc.c stm32_serial.c CHIP_CSRCS += stm32_timerisr.c stm32_dma.c stm32_lowputc.c stm32_serial.c
CHIP_CSRCS += stm32_spi.c stm32_sdio.c stm32_tim.c stm32_waste.c stm32_ccm.c CHIP_CSRCS += stm32_spi.c stm32_sdio.c stm32_tim.c stm32_waste.c stm32_ccm.c
CHIP_CSRCS += stm32_procfs_ccm.c
ifeq ($(CONFIG_ARMV7M_CMNVECTOR),y) ifeq ($(CONFIG_ARMV7M_CMNVECTOR),y)
CHIP_ASRCS += stm32_vectors.S CHIP_ASRCS += stm32_vectors.S
@@ -106,6 +105,10 @@ ifeq ($(CONFIG_NUTTX_KERNEL),y)
CHIP_CSRCS += stm32_userspace.c stm32_mpuinit.c CHIP_CSRCS += stm32_userspace.c stm32_mpuinit.c
endif endif
ifeq ($(CONFIG_STM32_CCM_PROCFS),y)
CHIP_CSRCS += stm32_procfs_ccm.c
endif
ifeq ($(CONFIG_STM32_I2C_ALT),y) ifeq ($(CONFIG_STM32_I2C_ALT),y)
CHIP_CSRCS += stm32_i2c_alt.c CHIP_CSRCS += stm32_i2c_alt.c
else else
+8 -13
View File
@@ -82,14 +82,11 @@
struct ccm_file_s struct ccm_file_s
{ {
struct procfs_file_s base; /* Base open file structure */ struct procfs_file_s base; /* Base open file structure */
unsigned int linesize; /* Number of valid characters in line[] */ unsigned int linesize; /* Number of valid characters in line[] */
char line[CCM_LINELEN]; /* Pre-allocated buffer for formatted lines */ char line[CCM_LINELEN]; /* Pre-allocated buffer for formatted lines */
/* Add context specific data types for managing an open file here */
}; };
/**************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
@@ -100,10 +97,8 @@ static int ccm_open(FAR struct file *filep, FAR const char *relpath,
static int ccm_close(FAR struct file *filep); static int ccm_close(FAR struct file *filep);
static ssize_t ccm_read(FAR struct file *filep, FAR char *buffer, static ssize_t ccm_read(FAR struct file *filep, FAR char *buffer,
size_t buflen); size_t buflen);
static int ccm_dup(FAR const struct file *oldp, static int ccm_dup(FAR const struct file *oldp,
FAR struct file *newp); FAR struct file *newp);
static int ccm_stat(FAR const char *relpath, FAR struct stat *buf); static int ccm_stat(FAR const char *relpath, FAR struct stat *buf);
/**************************************************************************** /****************************************************************************
@@ -124,12 +119,12 @@ const struct procfs_operations ccm_procfsoperations =
ccm_open, /* open */ ccm_open, /* open */
ccm_close, /* close */ ccm_close, /* close */
ccm_read, /* read */ ccm_read, /* read */
NULL, /* write */ NULL, /* write */
ccm_dup, /* dup */ ccm_dup, /* dup */
NULL, /* opendir */ NULL, /* opendir */
NULL, /* closedir */ NULL, /* closedir */
NULL, /* readdir */ NULL, /* readdir */
NULL, /* rewinddir */ NULL, /* rewinddir */
ccm_stat /* stat */ ccm_stat /* stat */
}; };
@@ -294,7 +289,7 @@ static int ccm_dup(FAR const struct file *oldp, FAR struct file *newp)
return -ENOMEM; return -ENOMEM;
} }
/* The copy the file attribtes from the old attributes to the new */ /* The copy the file attributes from the old attributes to the new */
memcpy(newpriv, oldpriv, sizeof(struct ccm_file_s)); memcpy(newpriv, oldpriv, sizeof(struct ccm_file_s));
+5 -6
View File
@@ -55,10 +55,9 @@ config FS_PROCFS_EXCLUDE_SMARTFS
default n default n
config FS_PROCFS_EXCLUDE_CCM config FS_PROCFS_EXCLUDE_CCM
bool "Exclude ccm memory usage" bool "Exclude CCM memory usage"
depends on STM32_CCMEXCLUDE depends on STM32_CCM_PROCFS
default n default n
endmenu endmenu #
endif # FS_PROCFS
endif
+14 -2
View File
@@ -78,10 +78,21 @@
extern const struct procfs_operations proc_operations; extern const struct procfs_operations proc_operations;
extern const struct procfs_operations cpuload_operations; extern const struct procfs_operations cpuload_operations;
extern const struct procfs_operations uptime_operations; extern const struct procfs_operations uptime_operations;
/* This is not good. These are implemented in drivers/mtd. Having to
* deal with them here is not a good coupling.
*/
extern const struct procfs_operations mtd_procfsoperations; extern const struct procfs_operations mtd_procfsoperations;
extern const struct procfs_operations part_procfsoperations; extern const struct procfs_operations part_procfsoperations;
extern const struct procfs_operations smartfs_procfsoperations; extern const struct procfs_operations smartfs_procfsoperations;
#if defined(CONFIG_STM32_CCMEXCLUDE) && defined(CONFIG_MM_MULTIHEAP) && !defined(FS_PROCFS_EXCLUDE_CCM)
/* And even worse, this one is specific to the STM32. The solution to
* this nasty couple would be to replace this hard-coded, ROM-able
* operations table with a RAM-base registration table.
*/
#if defined(CONFIG_STM32_CCM_PROCFS)
extern const struct procfs_operations ccm_procfsoperations; extern const struct procfs_operations ccm_procfsoperations;
#endif #endif
@@ -117,7 +128,8 @@ static const struct procfs_entry_s g_procfsentries[] =
#if !defined(CONFIG_FS_PROCFS_EXCLUDE_UPTIME) #if !defined(CONFIG_FS_PROCFS_EXCLUDE_UPTIME)
{ "uptime", &uptime_operations }, { "uptime", &uptime_operations },
#endif #endif
#if defined(CONFIG_STM32_CCMEXCLUDE) && defined(CONFIG_MM_MULTIHEAP) && !defined(FS_PROCFS_EXCLUDE_CCM)
#if defined(#if defined(CONFIG_STM32_CCM_PROCFS)
{ "ccm", &ccm_procfsoperations }, { "ccm", &ccm_procfsoperations },
#endif #endif
}; };