mm: Move procfs_register_meminfo into common place
to avoid the code duplication and ensure the consistent behaviour Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
817259ec2d
commit
b1f711f790
@ -109,10 +109,6 @@ ifeq ($(CONFIG_BUILD_PROTECTED),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_HAVE_IP_I2C_V1),y)
|
||||
ifeq ($(CONFIG_STM32_I2C_ALT),y)
|
||||
CHIP_CSRCS += stm32_i2c_alt.c
|
||||
|
@ -69,7 +69,7 @@
|
||||
*/
|
||||
|
||||
#define ccm_initialize() \
|
||||
mm_initialize(&g_ccm_heap, (FAR void *)CCM_START, CCM_END-CCM_START)
|
||||
mm_initialize(&g_ccm_heap, "ccm", (FAR void *)CCM_START, CCM_END-CCM_START)
|
||||
|
||||
/* The ccm_addregion interface could be used if, for example, you want to
|
||||
* add some other memory region to the CCM heap. I don't really know why
|
||||
@ -118,18 +118,6 @@ EXTERN struct mm_heap_s g_ccm_heap;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ccm_procfs_register
|
||||
*
|
||||
* Description:
|
||||
* Register the CCM procfs file system entry
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32_CCM_PROCFS
|
||||
int ccm_procfs_register(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* HAVE_CCM_HEAP */
|
||||
#endif /* __ARCH_ARM_SRC_STM32_STM32_CCM_H */
|
||||
|
@ -1,335 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/stm32/stm32_procfs_ccm.c
|
||||
*
|
||||
* Copyright (C) 2014 Pelle Windestam. All rights reserved.
|
||||
* Author: Pelle Windestam (pelle@windestam.se)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fs/procfs.h>
|
||||
#include <nuttx/fs/dirent.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "stm32_ccm.h"
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \
|
||||
defined(CONFIG_FS_PROCFS_REGISTER) && defined(CONFIG_STM32_CCM_PROCFS)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define CCM_LINELEN 64
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This structure describes one open "file" */
|
||||
|
||||
struct ccm_file_s
|
||||
{
|
||||
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 */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* File system methods */
|
||||
|
||||
static int ccm_open(FAR struct file *filep, FAR const char *relpath,
|
||||
int oflags, mode_t mode);
|
||||
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);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* See include/nutts/fs/procfs.h
|
||||
* We use the old-fashioned kind of initializers so that this will compile
|
||||
* with any compiler.
|
||||
*/
|
||||
|
||||
static const struct procfs_operations ccm_procfsoperations =
|
||||
{
|
||||
ccm_open, /* open */
|
||||
ccm_close, /* close */
|
||||
ccm_read, /* read */
|
||||
NULL, /* write */
|
||||
ccm_dup, /* dup */
|
||||
NULL, /* opendir */
|
||||
NULL, /* closedir */
|
||||
NULL, /* readdir */
|
||||
NULL, /* rewinddir */
|
||||
ccm_stat /* stat */
|
||||
};
|
||||
|
||||
static const struct procfs_entry_s g_procfs_ccm =
|
||||
{
|
||||
"ccm",
|
||||
&ccm_procfsoperations
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ccm_open
|
||||
****************************************************************************/
|
||||
|
||||
static int ccm_open(FAR struct file *filep, FAR const char *relpath,
|
||||
int oflags, mode_t mode)
|
||||
{
|
||||
FAR struct ccm_file_s *priv;
|
||||
|
||||
finfo("Open '%s'\n", relpath);
|
||||
|
||||
/* PROCFS is read-only. Any attempt to open with any kind of write
|
||||
* access is not permitted.
|
||||
*
|
||||
* REVISIT: Write-able proc files could be quite useful.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
}
|
||||
|
||||
/* "cpuload" is the only acceptable value for the relpath */
|
||||
|
||||
if (strcmp(relpath, "ccm") != 0)
|
||||
{
|
||||
ferr("ERROR: relpath is '%s'\n", relpath);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* Allocate a container to hold the task and attribute selection */
|
||||
|
||||
priv = (FAR struct ccm_file_s *)kmm_zalloc(sizeof(struct ccm_file_s));
|
||||
if (!priv)
|
||||
{
|
||||
ferr("ERROR: Failed to allocate file attributes\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Save the index as the open-specific state in filep->f_priv */
|
||||
|
||||
filep->f_priv = (FAR void *)priv;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ccm_close
|
||||
****************************************************************************/
|
||||
|
||||
static int ccm_close(FAR struct file *filep)
|
||||
{
|
||||
FAR struct ccm_file_s *priv;
|
||||
|
||||
/* Recover our private data from the struct file instance */
|
||||
|
||||
priv = (FAR struct ccm_file_s *)filep->f_priv;
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
/* Release the file attributes structure */
|
||||
|
||||
kmm_free(priv);
|
||||
filep->f_priv = NULL;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ccm_read
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t ccm_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
FAR struct ccm_file_s *priv;
|
||||
size_t linesize;
|
||||
size_t copysize;
|
||||
size_t remaining;
|
||||
size_t totalsize;
|
||||
struct mallinfo mem;
|
||||
off_t offset = filep->f_pos;
|
||||
|
||||
finfo("buffer=%p buflen=%d\n", buffer, (int)buflen);
|
||||
|
||||
/* Recover our private data from the struct file instance */
|
||||
|
||||
priv = (FAR struct ccm_file_s *)filep->f_priv;
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
mm_mallinfo(&g_ccm_heap, &mem);
|
||||
|
||||
remaining = buflen;
|
||||
totalsize = 0;
|
||||
|
||||
linesize = snprintf(priv->line,
|
||||
CCM_LINELEN,
|
||||
" total used free largest\n");
|
||||
copysize = procfs_memcpy(priv->line, linesize, buffer, remaining, &offset);
|
||||
totalsize += copysize;
|
||||
buffer += copysize;
|
||||
remaining -= copysize;
|
||||
|
||||
if (totalsize >= buflen)
|
||||
{
|
||||
return totalsize;
|
||||
}
|
||||
|
||||
linesize = snprintf(priv->line,
|
||||
CCM_LINELEN,
|
||||
"Mem: %11d%11d%11d%11d\n",
|
||||
mem.arena,
|
||||
mem.uordblks,
|
||||
mem.fordblks,
|
||||
mem.mxordblk);
|
||||
copysize = procfs_memcpy(priv->line, linesize, buffer, remaining, &offset);
|
||||
totalsize += copysize;
|
||||
|
||||
/* Update the file offset */
|
||||
|
||||
if (totalsize > 0)
|
||||
{
|
||||
filep->f_pos += totalsize;
|
||||
}
|
||||
|
||||
return totalsize;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ccm_dup
|
||||
*
|
||||
* Description:
|
||||
* Duplicate open file data in the new file structure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int ccm_dup(FAR const struct file *oldp, FAR struct file *newp)
|
||||
{
|
||||
FAR struct ccm_file_s *oldpriv;
|
||||
FAR struct ccm_file_s *newpriv;
|
||||
|
||||
finfo("Dup %p->%p\n", oldp, newp);
|
||||
|
||||
/* Recover our private data from the old struct file instance */
|
||||
|
||||
oldpriv = (FAR struct ccm_file_s *)oldp->f_priv;
|
||||
DEBUGASSERT(oldpriv);
|
||||
|
||||
/* Allocate a new container to hold the task and attribute selection */
|
||||
|
||||
newpriv = (FAR struct ccm_file_s *)kmm_zalloc(sizeof(struct ccm_file_s));
|
||||
if (!newpriv)
|
||||
{
|
||||
ferr("ERROR: Failed to allocate file attributes\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* The copy the file attributes from the old attributes to the new */
|
||||
|
||||
memcpy(newpriv, oldpriv, sizeof(struct ccm_file_s));
|
||||
|
||||
/* Save the new attributes in the new file structure */
|
||||
|
||||
newp->f_priv = (FAR void *)newpriv;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int ccm_stat(const char *relpath, struct stat *buf)
|
||||
{
|
||||
if (strcmp(relpath, "ccm") != 0)
|
||||
{
|
||||
ferr("ERROR: relpath is '%s'\n", relpath);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
|
||||
buf->st_size = 0;
|
||||
buf->st_blksize = 0;
|
||||
buf->st_blocks = 0;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ccm_procfs_register
|
||||
*
|
||||
* Description:
|
||||
* Register the CCM procfs file system entry
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ccm_procfs_register(void)
|
||||
{
|
||||
return procfs_register(&g_procfs_ccm);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_PROCFS &&
|
||||
* CONFIG_FS_PROCFS_REGISTER && CONFIG_STM32_CCM_PROCFS */
|
@ -104,9 +104,6 @@ endif
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_DTCM),y)
|
||||
CHIP_CSRCS += stm32_dtcm.c
|
||||
ifeq ($(CONFIG_STM32F7_DTCM_PROCFS),y)
|
||||
CHIP_CSRCS += stm32_procfs_dtcm.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STM32F7_DMA),y)
|
||||
|
@ -69,7 +69,7 @@
|
||||
*/
|
||||
|
||||
#define dtcm_initialize() \
|
||||
mm_initialize(&g_dtcm_heap, (FAR void *)DTCM_START, DTCM_END-DTCM_START)
|
||||
mm_initialize(&g_dtcm_heap, "dtcm", (FAR void *)DTCM_START, DTCM_END-DTCM_START)
|
||||
|
||||
/* The dtcm_addregion interface could be used if, for example, you want to
|
||||
* add some other memory region to the DTCM heap. I don't really know why
|
||||
@ -118,18 +118,6 @@ EXTERN struct mm_heap_s g_dtcm_heap;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dtcm_procfs_register
|
||||
*
|
||||
* Description:
|
||||
* Register the DTCM procfs file system entry
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32F7_DTCM_PROCFS
|
||||
int dtcm_procfs_register(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* HAVE_DTCM_HEAP */
|
||||
#endif /* __ARCH_ARM_SRC_STM32F7_STM32_DTCM_H */
|
||||
|
@ -1,348 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/stm32f7/stm32_procfs_dtcm.c
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Based on STM32 CCM code contributed by Pelle Windestam:
|
||||
*
|
||||
* Copyright (C) 2014 Pelle Windestam. All rights reserved.
|
||||
* Author: Pelle Windestam (pelle@windestam.se)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fs/procfs.h>
|
||||
#include <nuttx/fs/dirent.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "stm32_dtcm.h"
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \
|
||||
defined(CONFIG_FS_PROCFS_REGISTER) && defined(CONFIG_STM32F7_DTCM_PROCFS)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define DTCM_LINELEN 64
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This enumeration identifies all of the thread attributes that can be
|
||||
* accessed via the procfs file system.
|
||||
*/
|
||||
|
||||
/* This structure describes one open "file" */
|
||||
|
||||
struct dtcm_file_s
|
||||
{
|
||||
struct procfs_file_s base; /* Base open file structure */
|
||||
unsigned int linesize; /* Number of valid characters in line[] */
|
||||
char line[DTCM_LINELEN]; /* Pre-allocated buffer for formatted lines */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* File system methods */
|
||||
|
||||
static int dtcm_open(FAR struct file *filep, FAR const char *relpath,
|
||||
int oflags, mode_t mode);
|
||||
static int dtcm_close(FAR struct file *filep);
|
||||
static ssize_t dtcm_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
static int dtcm_dup(FAR const struct file *oldp,
|
||||
FAR struct file *newp);
|
||||
static int dtcm_stat(FAR const char *relpath, FAR struct stat *buf);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* See include/nutts/fs/procfs.h
|
||||
* We use the old-fashioned kind of initializers so that this will compile
|
||||
* with any compiler.
|
||||
*/
|
||||
|
||||
static const struct procfs_operations dtcm_procfsoperations =
|
||||
{
|
||||
dtcm_open, /* open */
|
||||
dtcm_close, /* close */
|
||||
dtcm_read, /* read */
|
||||
NULL, /* write */
|
||||
dtcm_dup, /* dup */
|
||||
NULL, /* opendir */
|
||||
NULL, /* closedir */
|
||||
NULL, /* readdir */
|
||||
NULL, /* rewinddir */
|
||||
dtcm_stat /* stat */
|
||||
};
|
||||
|
||||
static const struct procfs_entry_s g_procfs_dtcm =
|
||||
{
|
||||
"dtcm",
|
||||
&dtcm_procfsoperations
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dtcm_open
|
||||
****************************************************************************/
|
||||
|
||||
static int dtcm_open(FAR struct file *filep, FAR const char *relpath,
|
||||
int oflags, mode_t mode)
|
||||
{
|
||||
FAR struct dtcm_file_s *priv;
|
||||
|
||||
finfo("Open '%s'\n", relpath);
|
||||
|
||||
/* PROCFS is read-only. Any attempt to open with any kind of write
|
||||
* access is not permitted.
|
||||
*
|
||||
* REVISIT: Write-able proc files could be quite useful.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
}
|
||||
|
||||
/* "cpuload" is the only acceptable value for the relpath */
|
||||
|
||||
if (strcmp(relpath, "dtcm") != 0)
|
||||
{
|
||||
ferr("ERROR: relpath is '%s'\n", relpath);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* Allocate a container to hold the task and attribute selection */
|
||||
|
||||
priv = (FAR struct dtcm_file_s *)kmm_zalloc(sizeof(struct dtcm_file_s));
|
||||
if (!priv)
|
||||
{
|
||||
ferr("ERROR: Failed to allocate file attributes\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Save the index as the open-specific state in filep->f_priv */
|
||||
|
||||
filep->f_priv = (FAR void *)priv;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dtcm_close
|
||||
****************************************************************************/
|
||||
|
||||
static int dtcm_close(FAR struct file *filep)
|
||||
{
|
||||
FAR struct dtcm_file_s *priv;
|
||||
|
||||
/* Recover our private data from the struct file instance */
|
||||
|
||||
priv = (FAR struct dtcm_file_s *)filep->f_priv;
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
/* Release the file attributes structure */
|
||||
|
||||
kmm_free(priv);
|
||||
filep->f_priv = NULL;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dtcm_read
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t dtcm_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
FAR struct dtcm_file_s *priv;
|
||||
size_t linesize;
|
||||
size_t copysize;
|
||||
size_t remaining;
|
||||
size_t totalsize;
|
||||
struct mallinfo mem;
|
||||
off_t offset = filep->f_pos;
|
||||
|
||||
finfo("buffer=%p buflen=%d\n", buffer, (int)buflen);
|
||||
|
||||
/* Recover our private data from the struct file instance */
|
||||
|
||||
priv = (FAR struct dtcm_file_s *)filep->f_priv;
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
mm_mallinfo(&g_dtcm_heap, &mem);
|
||||
|
||||
remaining = buflen;
|
||||
totalsize = 0;
|
||||
|
||||
linesize = snprintf(priv->line,
|
||||
DTCM_LINELEN,
|
||||
" total used free largest\n");
|
||||
copysize = procfs_memcpy(priv->line, linesize, buffer, remaining, &offset);
|
||||
totalsize += copysize;
|
||||
buffer += copysize;
|
||||
remaining -= copysize;
|
||||
|
||||
if (totalsize >= buflen)
|
||||
{
|
||||
return totalsize;
|
||||
}
|
||||
|
||||
linesize = snprintf(priv->line,
|
||||
DTCM_LINELEN,
|
||||
"Mem: %11d%11d%11d%11d\n",
|
||||
mem.arena,
|
||||
mem.uordblks,
|
||||
mem.fordblks,
|
||||
mem.mxordblk);
|
||||
copysize = procfs_memcpy(priv->line, linesize, buffer, remaining, &offset);
|
||||
totalsize += copysize;
|
||||
|
||||
/* Update the file offset */
|
||||
|
||||
if (totalsize > 0)
|
||||
{
|
||||
filep->f_pos += totalsize;
|
||||
}
|
||||
|
||||
return totalsize;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dtcm_dup
|
||||
*
|
||||
* Description:
|
||||
* Duplicate open file data in the new file structure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int dtcm_dup(FAR const struct file *oldp, FAR struct file *newp)
|
||||
{
|
||||
FAR struct dtcm_file_s *oldpriv;
|
||||
FAR struct dtcm_file_s *newpriv;
|
||||
|
||||
finfo("Dup %p->%p\n", oldp, newp);
|
||||
|
||||
/* Recover our private data from the old struct file instance */
|
||||
|
||||
oldpriv = (FAR struct dtcm_file_s *)oldp->f_priv;
|
||||
DEBUGASSERT(oldpriv);
|
||||
|
||||
/* Allocate a new container to hold the task and attribute selection */
|
||||
|
||||
newpriv = (FAR struct dtcm_file_s *)kmm_zalloc(sizeof(struct dtcm_file_s));
|
||||
if (!newpriv)
|
||||
{
|
||||
ferr("ERROR: Failed to allocate file attributes\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* The copy the file attributes from the old attributes to the new */
|
||||
|
||||
memcpy(newpriv, oldpriv, sizeof(struct dtcm_file_s));
|
||||
|
||||
/* Save the new attributes in the new file structure */
|
||||
|
||||
newp->f_priv = (FAR void *)newpriv;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int dtcm_stat(const char *relpath, struct stat *buf)
|
||||
{
|
||||
if (strcmp(relpath, "dtcm") != 0)
|
||||
{
|
||||
ferr("ERROR: relpath is '%s'\n", relpath);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
|
||||
buf->st_size = 0;
|
||||
buf->st_blksize = 0;
|
||||
buf->st_blocks = 0;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dtcm_procfs_register
|
||||
*
|
||||
* Description:
|
||||
* Register the DTCM procfs file system entry
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int dtcm_procfs_register(void)
|
||||
{
|
||||
return procfs_register(&g_procfs_dtcm);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_PROCFS &&
|
||||
* CONFIG_FS_PROCFS_REGISTER && CONFIG_STM32F7_DTCM_PROCFS */
|
@ -101,9 +101,6 @@ endif
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_DTCM),y)
|
||||
CHIP_CSRCS += stm32_dtcm.c
|
||||
ifeq ($(CONFIG_STM32H7_DTCM_PROCFS),y)
|
||||
CHIP_CSRCS += stm32_procfs_dtcm.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STM32H7_ADC),y)
|
||||
|
@ -61,7 +61,7 @@
|
||||
*/
|
||||
|
||||
#define dtcm_initialize() \
|
||||
mm_initialize(&g_dtcm_heap, (FAR void *)DTCM_START, DTCM_END-DTCM_START)
|
||||
mm_initialize(&g_dtcm_heap, "dtcm", (FAR void *)DTCM_START, DTCM_END-DTCM_START)
|
||||
|
||||
/* The dtcm_addregion interface could be used if, for example, you want to
|
||||
* add some other memory region to the DTCM heap. I don't really know why
|
||||
@ -110,18 +110,6 @@ EXTERN struct mm_heap_s g_dtcm_heap;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dtcm_procfs_register
|
||||
*
|
||||
* Description:
|
||||
* Register the DTCM procfs file system entry
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32H7_DTCM_PROCFS
|
||||
int dtcm_procfs_register(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* HAVE_DTCM_HEAP */
|
||||
#endif /* __ARCH_ARM_SRC_STM32H7_STM32_DTCM_H */
|
||||
|
@ -1,349 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/stm32h7/stm32_procfs_dtcm.c
|
||||
*
|
||||
* Copyright (C) 2015, 2019 Gregory Nutt. All rights reserved.
|
||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||
* David Sidrane <david.sidrane@nscdg.com>
|
||||
*
|
||||
* Based on STM32 CCM code contributed by Pelle Windestam:
|
||||
*
|
||||
* Copyright (C) 2014 Pelle Windestam. All rights reserved.
|
||||
* Author: Pelle Windestam (pelle@windestam.se)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fs/procfs.h>
|
||||
#include <nuttx/fs/dirent.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "stm32_dtcm.h"
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \
|
||||
defined(CONFIG_FS_PROCFS_REGISTER) && defined(CONFIG_STM32H7_DTCM_PROCFS)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define DTCM_LINELEN 64
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This enumeration identifies all of the thread attributes that can be
|
||||
* accessed via the procfs file system.
|
||||
*/
|
||||
|
||||
/* This structure describes one open "file" */
|
||||
|
||||
struct dtcm_file_s
|
||||
{
|
||||
struct procfs_file_s base; /* Base open file structure */
|
||||
unsigned int linesize; /* Number of valid characters in line[] */
|
||||
char line[DTCM_LINELEN]; /* Pre-allocated buffer for formatted lines */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* File system methods */
|
||||
|
||||
static int dtcm_open(FAR struct file *filep, FAR const char *relpath,
|
||||
int oflags, mode_t mode);
|
||||
static int dtcm_close(FAR struct file *filep);
|
||||
static ssize_t dtcm_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
static int dtcm_dup(FAR const struct file *oldp,
|
||||
FAR struct file *newp);
|
||||
static int dtcm_stat(FAR const char *relpath, FAR struct stat *buf);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* See include/nutts/fs/procfs.h
|
||||
* We use the old-fashioned kind of initializers so that this will compile
|
||||
* with any compiler.
|
||||
*/
|
||||
|
||||
static const struct procfs_operations dtcm_procfsoperations =
|
||||
{
|
||||
dtcm_open, /* open */
|
||||
dtcm_close, /* close */
|
||||
dtcm_read, /* read */
|
||||
NULL, /* write */
|
||||
dtcm_dup, /* dup */
|
||||
NULL, /* opendir */
|
||||
NULL, /* closedir */
|
||||
NULL, /* readdir */
|
||||
NULL, /* rewinddir */
|
||||
dtcm_stat /* stat */
|
||||
};
|
||||
|
||||
static const struct procfs_entry_s g_procfs_dtcm =
|
||||
{
|
||||
"dtcm",
|
||||
&dtcm_procfsoperations
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dtcm_open
|
||||
****************************************************************************/
|
||||
|
||||
static int dtcm_open(FAR struct file *filep, FAR const char *relpath,
|
||||
int oflags, mode_t mode)
|
||||
{
|
||||
FAR struct dtcm_file_s *priv;
|
||||
|
||||
finfo("Open '%s'\n", relpath);
|
||||
|
||||
/* PROCFS is read-only. Any attempt to open with any kind of write
|
||||
* access is not permitted.
|
||||
*
|
||||
* REVISIT: Write-able proc files could be quite useful.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
}
|
||||
|
||||
/* "cpuload" is the only acceptable value for the relpath */
|
||||
|
||||
if (strcmp(relpath, "dtcm") != 0)
|
||||
{
|
||||
ferr("ERROR: relpath is '%s'\n", relpath);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* Allocate a container to hold the task and attribute selection */
|
||||
|
||||
priv = (FAR struct dtcm_file_s *)kmm_zalloc(sizeof(struct dtcm_file_s));
|
||||
if (!priv)
|
||||
{
|
||||
ferr("ERROR: Failed to allocate file attributes\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Save the index as the open-specific state in filep->f_priv */
|
||||
|
||||
filep->f_priv = (FAR void *)priv;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dtcm_close
|
||||
****************************************************************************/
|
||||
|
||||
static int dtcm_close(FAR struct file *filep)
|
||||
{
|
||||
FAR struct dtcm_file_s *priv;
|
||||
|
||||
/* Recover our private data from the struct file instance */
|
||||
|
||||
priv = (FAR struct dtcm_file_s *)filep->f_priv;
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
/* Release the file attributes structure */
|
||||
|
||||
kmm_free(priv);
|
||||
filep->f_priv = NULL;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dtcm_read
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t dtcm_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
FAR struct dtcm_file_s *priv;
|
||||
size_t linesize;
|
||||
size_t copysize;
|
||||
size_t remaining;
|
||||
size_t totalsize;
|
||||
struct mallinfo mem;
|
||||
off_t offset = filep->f_pos;
|
||||
|
||||
finfo("buffer=%p buflen=%d\n", buffer, (int)buflen);
|
||||
|
||||
/* Recover our private data from the struct file instance */
|
||||
|
||||
priv = (FAR struct dtcm_file_s *)filep->f_priv;
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
mm_mallinfo(&g_dtcm_heap, &mem);
|
||||
|
||||
remaining = buflen;
|
||||
totalsize = 0;
|
||||
|
||||
linesize = snprintf(priv->line,
|
||||
DTCM_LINELEN,
|
||||
" total used free largest\n");
|
||||
copysize = procfs_memcpy(priv->line, linesize, buffer, remaining, &offset);
|
||||
totalsize += copysize;
|
||||
buffer += copysize;
|
||||
remaining -= copysize;
|
||||
|
||||
if (totalsize >= buflen)
|
||||
{
|
||||
return totalsize;
|
||||
}
|
||||
|
||||
linesize = snprintf(priv->line,
|
||||
DTCM_LINELEN,
|
||||
"Mem: %11d%11d%11d%11d\n",
|
||||
mem.arena,
|
||||
mem.uordblks,
|
||||
mem.fordblks,
|
||||
mem.mxordblk);
|
||||
copysize = procfs_memcpy(priv->line, linesize, buffer, remaining, &offset);
|
||||
totalsize += copysize;
|
||||
|
||||
/* Update the file offset */
|
||||
|
||||
if (totalsize > 0)
|
||||
{
|
||||
filep->f_pos += totalsize;
|
||||
}
|
||||
|
||||
return totalsize;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dtcm_dup
|
||||
*
|
||||
* Description:
|
||||
* Duplicate open file data in the new file structure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int dtcm_dup(FAR const struct file *oldp, FAR struct file *newp)
|
||||
{
|
||||
FAR struct dtcm_file_s *oldpriv;
|
||||
FAR struct dtcm_file_s *newpriv;
|
||||
|
||||
finfo("Dup %p->%p\n", oldp, newp);
|
||||
|
||||
/* Recover our private data from the old struct file instance */
|
||||
|
||||
oldpriv = (FAR struct dtcm_file_s *)oldp->f_priv;
|
||||
DEBUGASSERT(oldpriv);
|
||||
|
||||
/* Allocate a new container to hold the task and attribute selection */
|
||||
|
||||
newpriv = (FAR struct dtcm_file_s *)kmm_zalloc(sizeof(struct dtcm_file_s));
|
||||
if (!newpriv)
|
||||
{
|
||||
ferr("ERROR: Failed to allocate file attributes\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* The copy the file attributes from the old attributes to the new */
|
||||
|
||||
memcpy(newpriv, oldpriv, sizeof(struct dtcm_file_s));
|
||||
|
||||
/* Save the new attributes in the new file structure */
|
||||
|
||||
newp->f_priv = (FAR void *)newpriv;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int dtcm_stat(const char *relpath, struct stat *buf)
|
||||
{
|
||||
if (strcmp(relpath, "dtcm") != 0)
|
||||
{
|
||||
ferr("ERROR: relpath is '%s'\n", relpath);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
|
||||
buf->st_size = 0;
|
||||
buf->st_blksize = 0;
|
||||
buf->st_blocks = 0;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dtcm_procfs_register
|
||||
*
|
||||
* Description:
|
||||
* Register the DTCM procfs file system entry
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int dtcm_procfs_register(void)
|
||||
{
|
||||
return procfs_register(&g_procfs_dtcm);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_PROCFS &&
|
||||
* CONFIG_FS_PROCFS_REGISTER && CONFIG_STM32H7_DTCM_PROCFS */
|
@ -25,7 +25,6 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/procfs.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
#include <malloc.h>
|
||||
|
||||
@ -63,16 +62,7 @@ void esp32c3_rtcheap_initialize(void)
|
||||
|
||||
start = (FAR void *)&_srtcheap;
|
||||
size = (size_t)((uintptr_t)&_ertcheap - (uintptr_t)&_srtcheap);
|
||||
mm_initialize(&g_rtcheap, start, size);
|
||||
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||
static struct procfs_meminfo_entry_s g_rtc_procfs;
|
||||
|
||||
g_rtc_procfs.name = "rtcheap";
|
||||
g_rtc_procfs.mallinfo = (void *)mm_mallinfo;
|
||||
g_rtc_procfs.user_data = &g_rtcheap;
|
||||
procfs_register_meminfo(&g_rtc_procfs);
|
||||
#endif
|
||||
mm_initialize(&g_rtcheap, "rtcheap", start, size);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -53,6 +53,10 @@ struct mm_heap_impl_s
|
||||
#else
|
||||
struct mm_delaynode_s *mm_delaylist[1];
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||
struct procfs_meminfo_entry_s mm_procfs;
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@ -135,8 +139,8 @@ static void mm_free_delaylist(FAR struct mm_heap_s *heap)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void mm_initialize(FAR struct mm_heap_s *heap, FAR void *heap_start,
|
||||
size_t heap_size)
|
||||
void mm_initialize(FAR struct mm_heap_s *heap, FAR const char *name,
|
||||
FAR void *heap_start, size_t heap_size)
|
||||
{
|
||||
FAR struct mm_heap_impl_s *impl;
|
||||
|
||||
@ -145,6 +149,13 @@ void mm_initialize(FAR struct mm_heap_s *heap, FAR void *heap_start,
|
||||
|
||||
memset(impl, 0, sizeof(struct mm_heap_impl_s));
|
||||
heap->mm_impl = impl;
|
||||
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||
heap_impl->mm_procfs.name = name;
|
||||
heap_impl->mm_procfs.mallinfo = (FAR void *)mm_mallinfo;
|
||||
heap_impl->mm_procfs.user_data = heap;
|
||||
procfs_register_meminfo(&heap_impl->mm_procfs);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/procfs.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
#include <malloc.h>
|
||||
#include <arch/esp32/memory_layout.h>
|
||||
@ -63,16 +62,7 @@ void xtensa_imm_initialize(void)
|
||||
|
||||
start = (FAR void *)ESP32_IMEM_START;
|
||||
size = CONFIG_XTENSA_IMEM_REGION_SIZE;
|
||||
mm_initialize(&g_iheap, start, size);
|
||||
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||
static struct procfs_meminfo_entry_s g_imm_procfs;
|
||||
|
||||
g_imm_procfs.name = "esp32-imem";
|
||||
g_imm_procfs.mallinfo = (void *)mm_mallinfo;
|
||||
g_imm_procfs.user_data = &g_iheap;
|
||||
procfs_register_meminfo(&g_imm_procfs);
|
||||
#endif
|
||||
mm_initialize(&g_iheap, "esp32-imem", start, size);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/procfs.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
#include <malloc.h>
|
||||
|
||||
@ -61,16 +60,7 @@ void esp32_iramheap_initialize(void)
|
||||
|
||||
start = (void *)&_siramheap;
|
||||
size = (size_t)((uintptr_t)&_eiramheap - (uintptr_t)&_siramheap);
|
||||
mm_initialize(&g_iramheap, start, size);
|
||||
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||
static struct procfs_meminfo_entry_s g_iram_procfs;
|
||||
|
||||
g_iram_procfs.name = "iramheap";
|
||||
g_iram_procfs.mallinfo = (void *)mm_mallinfo;
|
||||
g_iram_procfs.user_data = &g_iramheap;
|
||||
procfs_register_meminfo(&g_iram_procfs);
|
||||
#endif
|
||||
mm_initialize(&g_iramheap, "iramheap", start, size);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/procfs.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
#include <malloc.h>
|
||||
|
||||
@ -61,16 +60,7 @@ void esp32_rtcheap_initialize(void)
|
||||
|
||||
start = (void *)&_srtcheap;
|
||||
size = (size_t)((uintptr_t)&_ertcheap - (uintptr_t)&_srtcheap);
|
||||
mm_initialize(&g_rtcheap, start, size);
|
||||
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||
static struct procfs_meminfo_entry_s g_rtc_procfs;
|
||||
|
||||
g_rtc_procfs.name = "rtcheap";
|
||||
g_rtc_procfs.mallinfo = (void *)mm_mallinfo;
|
||||
g_rtc_procfs.user_data = &g_rtcheap;
|
||||
procfs_register_meminfo(&g_rtc_procfs);
|
||||
#endif
|
||||
mm_initialize(&g_rtcheap, "rtcheap", start, size);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -63,15 +63,6 @@ int stm32_bringup(void)
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_FS_PROCFS
|
||||
|
||||
#ifdef CONFIG_STM32_CCM_PROCFS
|
||||
/* Register the CCM procfs entry. This must be done before the procfs is
|
||||
* mounted.
|
||||
*/
|
||||
|
||||
ccm_procfs_register();
|
||||
#endif
|
||||
|
||||
/* Mount the procfs file system */
|
||||
|
||||
ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
|
||||
|
@ -57,14 +57,6 @@ int stm32_bringup(void)
|
||||
int ret = OK;
|
||||
|
||||
#ifdef CONFIG_FS_PROCFS
|
||||
#ifdef CONFIG_STM32_CCM_PROCFS
|
||||
/* Register the CCM procfs entry. This must be done before the procfs is
|
||||
* mounted.
|
||||
*/
|
||||
|
||||
ccm_procfs_register();
|
||||
#endif
|
||||
|
||||
/* Mount the procfs file system */
|
||||
|
||||
ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
|
||||
|
@ -150,14 +150,6 @@ int stm32_bringup(void)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FS_PROCFS
|
||||
#ifdef CONFIG_STM32_CCM_PROCFS
|
||||
/* Register the CCM procfs entry. This must be done before the procfs is
|
||||
* mounted.
|
||||
*/
|
||||
|
||||
ccm_procfs_register();
|
||||
#endif /* CONFIG_STM32_CCM_PROCFS */
|
||||
|
||||
/* Mount the procfs file system */
|
||||
|
||||
ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
|
||||
|
@ -72,14 +72,6 @@ int stm32_bringup(void)
|
||||
UNUSED(ret);
|
||||
|
||||
#ifdef CONFIG_FS_PROCFS
|
||||
#ifdef CONFIG_STM32_CCM_PROCFS
|
||||
/* Register the CCM procfs entry. This must be done before the procfs is
|
||||
* mounted.
|
||||
*/
|
||||
|
||||
ccm_procfs_register();
|
||||
#endif /* CONFIG_STM32_CCM_PROCFS */
|
||||
|
||||
/* Mount the procfs file system */
|
||||
|
||||
ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
|
||||
|
@ -136,14 +136,6 @@ int stm32_bringup(void)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FS_PROCFS
|
||||
#ifdef CONFIG_STM32_CCM_PROCFS
|
||||
/* Register the CCM procfs entry. This must be done before the procfs is
|
||||
* mounted.
|
||||
*/
|
||||
|
||||
(void)ccm_procfs_register();
|
||||
#endif /* CONFIG_STM32_CCM_PROCFS */
|
||||
|
||||
/* Mount the procfs file system */
|
||||
|
||||
ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
|
||||
|
@ -158,8 +158,8 @@ EXTERN struct mm_heap_s g_kmmheap;
|
||||
|
||||
/* Functions contained in mm_initialize.c ***********************************/
|
||||
|
||||
void mm_initialize(FAR struct mm_heap_s *heap, FAR void *heap_start,
|
||||
size_t heap_size);
|
||||
void mm_initialize(FAR struct mm_heap_s *heap, FAR const char *name,
|
||||
FAR void *heap_start, size_t heap_size);
|
||||
void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
|
||||
size_t heapsize);
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/fs/procfs.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#ifdef CONFIG_MM_KERNEL_HEAP
|
||||
@ -59,16 +58,7 @@ struct mm_heap_s g_kmmheap;
|
||||
|
||||
void kmm_initialize(FAR void *heap_start, size_t heap_size)
|
||||
{
|
||||
mm_initialize(&g_kmmheap, heap_start, heap_size);
|
||||
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||
static struct procfs_meminfo_entry_s g_kmm_procfs;
|
||||
|
||||
g_kmm_procfs.name = "Kmem";
|
||||
g_kmm_procfs.mallinfo = (void *)mm_mallinfo;
|
||||
g_kmm_procfs.user_data = &g_kmmheap;
|
||||
procfs_register_meminfo(&g_kmm_procfs);
|
||||
#endif
|
||||
mm_initialize(&g_kmmheap, "Kmem", heap_start, heap_size);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_MM_KERNEL_HEAP */
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/fs/procfs.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
@ -207,6 +209,10 @@ struct mm_heap_impl_s
|
||||
#else
|
||||
FAR struct mm_delaynode_s *mm_delaylist[1];
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||
struct procfs_meminfo_entry_s mm_procfs;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Functions contained in mm_sem.c ******************************************/
|
||||
|
@ -161,14 +161,14 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void mm_initialize(FAR struct mm_heap_s *heap, FAR void *heapstart,
|
||||
size_t heapsize)
|
||||
void mm_initialize(FAR struct mm_heap_s *heap, FAR const char *name,
|
||||
FAR void *heapstart, size_t heapsize)
|
||||
{
|
||||
FAR struct mm_heap_impl_s *heap_impl;
|
||||
uintptr_t heap_adj;
|
||||
int i;
|
||||
|
||||
minfo("Heap: start=%p size=%zu\n", heapstart, heapsize);
|
||||
minfo("Heap: name=%s, start=%p size=%zu\n", name, heapstart, heapsize);
|
||||
|
||||
/* First ensure the memory to be used is aligned */
|
||||
|
||||
@ -216,4 +216,13 @@ void mm_initialize(FAR struct mm_heap_s *heap, FAR void *heapstart,
|
||||
/* Add the initial region of memory to the heap */
|
||||
|
||||
mm_addregion(heap, heapstart, heapsize);
|
||||
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
heap_impl->mm_procfs.name = name;
|
||||
heap_impl->mm_procfs.mallinfo = (FAR void *)mm_mallinfo;
|
||||
heap_impl->mm_procfs.user_data = heap;
|
||||
procfs_register_meminfo(&heap_impl->mm_procfs);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ FAR void *mm_sbrk(FAR struct mm_heap_s *heap, intptr_t incr,
|
||||
{
|
||||
/* No... then initialize it now */
|
||||
|
||||
mm_initialize(heap, (FAR void *)allocbase, bytesize);
|
||||
mm_initialize(heap, "Umem", (FAR void *)allocbase, bytesize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/fs/procfs.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#include "umm_heap/umm_heap.h"
|
||||
@ -82,17 +81,5 @@
|
||||
|
||||
void umm_initialize(FAR void *heap_start, size_t heap_size)
|
||||
{
|
||||
mm_initialize(USR_HEAP, heap_start, heap_size);
|
||||
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||
#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \
|
||||
defined(CONFIG_BUILD_FLAT)
|
||||
static struct procfs_meminfo_entry_s g_umm_procfs;
|
||||
|
||||
g_umm_procfs.name = "Umem";
|
||||
g_umm_procfs.mallinfo = (void *)mm_mallinfo;
|
||||
g_umm_procfs.user_data = USR_HEAP;
|
||||
procfs_register_meminfo(&g_umm_procfs);
|
||||
#endif
|
||||
#endif
|
||||
mm_initialize(USR_HEAP, "Umem", heap_start, heap_size);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user