From dd4caf172f711b1f36dbcce2285c88e7edfba3c1 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 3 Jul 2014 08:50:24 -0600 Subject: [PATCH] CCM PROCFS: Changed the configuration a bit. I am still not happy about the coupling between procfs, mtd, and now STM32 --- arch/arm/src/stm32/Kconfig | 9 +++++++++ arch/arm/src/stm32/Make.defs | 5 ++++- arch/arm/src/stm32/stm32_procfs_ccm.c | 21 ++++++++------------- fs/procfs/Kconfig | 11 +++++------ fs/procfs/fs_procfs.c | 16 ++++++++++++++-- 5 files changed, 40 insertions(+), 22 deletions(-) diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index 30cbd8b279..62641b434d 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -1658,6 +1658,15 @@ config STM32_CCMEXCLUDE and (2) it appears to be impossible to execute ELF modules from CCM 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 bool "Workaround non-DMA capable memory" depends on ARCH_DMA diff --git a/arch/arm/src/stm32/Make.defs b/arch/arm/src/stm32/Make.defs index 77d6b4c7ef..f5dd212891 100644 --- a/arch/arm/src/stm32/Make.defs +++ b/arch/arm/src/stm32/Make.defs @@ -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_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_procfs_ccm.c ifeq ($(CONFIG_ARMV7M_CMNVECTOR),y) CHIP_ASRCS += stm32_vectors.S @@ -106,6 +105,10 @@ ifeq ($(CONFIG_NUTTX_KERNEL),y) CHIP_CSRCS += stm32_userspace.c stm32_mpuinit.c endif +ifeq ($(CONFIG_STM32_CCM_PROCFS),y) +CHIP_CSRCS += stm32_procfs_ccm.c +endif + ifeq ($(CONFIG_STM32_I2C_ALT),y) CHIP_CSRCS += stm32_i2c_alt.c else diff --git a/arch/arm/src/stm32/stm32_procfs_ccm.c b/arch/arm/src/stm32/stm32_procfs_ccm.c index 68666f4661..d025f9e5ce 100644 --- a/arch/arm/src/stm32/stm32_procfs_ccm.c +++ b/arch/arm/src/stm32/stm32_procfs_ccm.c @@ -82,14 +82,11 @@ struct ccm_file_s { - struct procfs_file_s base; /* Base open file structure */ - unsigned int linesize; /* Number of valid characters in line[] */ + struct procfs_file_s base; /* Base open file structure */ + unsigned int linesize; /* Number of valid characters in line[] */ char line[CCM_LINELEN]; /* Pre-allocated buffer for formatted lines */ - - /* Add context specific data types for managing an open file here */ }; - /**************************************************************************** * 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 ssize_t ccm_read(FAR struct file *filep, FAR char *buffer, size_t buflen); - static int ccm_dup(FAR const struct file *oldp, FAR struct file *newp); - 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_close, /* close */ ccm_read, /* read */ - NULL, /* write */ + NULL, /* write */ ccm_dup, /* dup */ - NULL, /* opendir */ - NULL, /* closedir */ - NULL, /* readdir */ - NULL, /* rewinddir */ + NULL, /* opendir */ + NULL, /* closedir */ + NULL, /* readdir */ + NULL, /* rewinddir */ ccm_stat /* stat */ }; @@ -294,7 +289,7 @@ static int ccm_dup(FAR const struct file *oldp, FAR struct file *newp) 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)); diff --git a/fs/procfs/Kconfig b/fs/procfs/Kconfig index 16fb8ce97c..633aef4204 100644 --- a/fs/procfs/Kconfig +++ b/fs/procfs/Kconfig @@ -55,10 +55,9 @@ config FS_PROCFS_EXCLUDE_SMARTFS default n config FS_PROCFS_EXCLUDE_CCM - bool "Exclude ccm memory usage" - depends on STM32_CCMEXCLUDE - default n + bool "Exclude CCM memory usage" + depends on STM32_CCM_PROCFS + default n -endmenu - -endif +endmenu # +endif # FS_PROCFS diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c index 9ed3c3e580..8714f0d417 100644 --- a/fs/procfs/fs_procfs.c +++ b/fs/procfs/fs_procfs.c @@ -78,10 +78,21 @@ extern const struct procfs_operations proc_operations; extern const struct procfs_operations cpuload_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 part_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; #endif @@ -117,7 +128,8 @@ static const struct procfs_entry_s g_procfsentries[] = #if !defined(CONFIG_FS_PROCFS_EXCLUDE_UPTIME) { "uptime", &uptime_operations }, #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 }, #endif };