esp32: Retire XTENSA_IMEM_PROCFS

Now /proc/meminfo has the equivalent.
This commit is contained in:
YAMAMOTO Takashi 2021-02-12 14:56:11 +09:00 committed by David Sidrane
parent 7bb849535c
commit aed24f1255
7 changed files with 0 additions and 443 deletions

View File

@ -133,11 +133,6 @@ config XTENSA_IMEM_REGION_SIZE
depends on XTENSA_USE_SEPARATE_IMEM
default 0x18000
config XTENSA_IMEM_PROCFS
bool "Internal memory PROCFS support"
default n
depends on XTENSA_USE_SEPARATE_IMEM && !DISABLE_MOUNTPOINT && FS_PROCFS && FS_PROCFS_REGISTER
source arch/xtensa/src/lx6/Kconfig
if ARCH_CHIP_ESP32
source arch/xtensa/src/esp32/Kconfig

View File

@ -168,10 +168,6 @@ CHIP_CSRCS += esp32_tim_lowerhalf.c
endif
endif
ifeq ($(CONFIG_XTENSA_IMEM_PROCFS),y)
CHIP_CSRCS += esp32_procfs_imm.c
endif
ifeq ($(CONFIG_ESP32_PARTITION),y)
CHIP_CSRCS += esp32_partition.c
endif

View File

@ -1,319 +0,0 @@
/****************************************************************************
* arch/xtensa/src/esp32/esp32_procfs_imm.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* 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>
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \
defined(CONFIG_FS_PROCFS_REGISTER) && defined(CONFIG_XTENSA_IMEM_PROCFS)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define IMM_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 imm_file_s
{
struct procfs_file_s base; /* Base open file structure */
unsigned int linesize; /* Number of valid characters in line[] */
char line[IMM_LINELEN]; /* Pre-allocated buffer for formatted lines */
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* File system methods */
static int imm_open(FAR struct file *filep, FAR const char *relpath,
int oflags, mode_t mode);
static int imm_close(FAR struct file *filep);
static ssize_t imm_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
static int imm_dup(FAR const struct file *oldp,
FAR struct file *newp);
static int imm_stat(FAR const char *relpath, FAR struct stat *buf);
/****************************************************************************
* Public Data
****************************************************************************/
/* See include/nutts/fs/procfs.h */
static const struct procfs_operations imm_procfsoperations =
{
imm_open, /* open */
imm_close, /* close */
imm_read, /* read */
NULL, /* write */
imm_dup, /* dup */
NULL, /* opendir */
NULL, /* closedir */
NULL, /* readdir */
NULL, /* rewinddir */
imm_stat /* stat */
};
static const struct procfs_entry_s g_procfs_imm =
{
"imm",
&imm_procfsoperations
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: imm_open
****************************************************************************/
static int imm_open(FAR struct file *filep, FAR const char *relpath,
int oflags, mode_t mode)
{
FAR struct imm_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;
}
/* "imm" is the only acceptable value for the relpath */
if (strcmp(relpath, "imm") != 0)
{
ferr("ERROR: relpath is '%s'\n", relpath);
return -ENOENT;
}
/* Allocate a container to hold the task and attribute selection */
priv = (FAR struct imm_file_s *)kmm_zalloc(sizeof(struct imm_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: imm_close
****************************************************************************/
static int imm_close(FAR struct file *filep)
{
FAR struct imm_file_s *priv;
/* Recover our private data from the struct file instance */
priv = (FAR struct imm_file_s *)filep->f_priv;
DEBUGASSERT(priv);
/* Release the file attributes structure */
kmm_free(priv);
filep->f_priv = NULL;
return OK;
}
/****************************************************************************
* Name: imm_read
****************************************************************************/
static ssize_t imm_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
FAR struct imm_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 imm_file_s *)filep->f_priv;
DEBUGASSERT(priv);
xtensa_imm_mallinfo(&mem);
remaining = buflen;
totalsize = 0;
linesize = snprintf(priv->line,
IMM_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,
IMM_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: imm_dup
****************************************************************************/
static int imm_dup(FAR const struct file *oldp, FAR struct file *newp)
{
FAR struct imm_file_s *oldpriv;
FAR struct imm_file_s *newpriv;
finfo("Dup %p->%p\n", oldp, newp);
/* Recover our private data from the old struct file instance */
oldpriv = (FAR struct imm_file_s *)oldp->f_priv;
DEBUGASSERT(oldpriv);
/* Allocate a new container to hold the task and attribute selection */
newpriv = (FAR struct imm_file_s *)kmm_zalloc(sizeof(struct imm_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 imm_file_s));
/* Save the new attributes in the new file structure */
newp->f_priv = (FAR void *)newpriv;
return OK;
}
/****************************************************************************
* Name: imm_stat
****************************************************************************/
static int imm_stat(const char *relpath, struct stat *buf)
{
if (strcmp(relpath, "imm") != 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: imm_procfs_register
*
* Description:
* Register the internal heap procfs file system entry
*
****************************************************************************/
int imm_procfs_register(void)
{
return procfs_register(&g_procfs_imm);
}
#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_PROCFS &&
* CONFIG_FS_PROCFS_REGISTER && CONFIG_XTENSA_IMEM_PROCFS */

View File

@ -1,64 +0,0 @@
/****************************************************************************
* arch/xtensa/src/esp32/esp32_procfs_imm.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __ARCH_XTENSA_SRC_ESP32_IMM_H
#define __ARCH_XTENSA_SRC_ESP32_IMM_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: imm_procfs_register
*
* Description:
* Register the internal heap procfs file system entry
*
****************************************************************************/
#ifdef CONFIG_XTENSA_IMEM_PROCFS
int imm_procfs_register(void);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_XTENSA_SRC_ESP32_IMM_H */

View File

@ -55,8 +55,6 @@
#include <sys/errno.h>
#include <nuttx/himem/himem.h>
#include "esp32_procfs_imm.h"
#include "esp32_wlan.h"
#include "esp32_spiflash.h"
#include "esp32_partition.h"
@ -137,21 +135,6 @@ int esp32_bringup(void)
{
int ret;
#ifdef CONFIG_XTENSA_IMEM_PROCFS
/* Register the internal memory procfs entry.
* This must be done before the procfs is mounted.
*/
ret = imm_procfs_register();
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: Failed to register internal memory to PROCFS: %d\n",
ret);
}
#endif
#ifdef CONFIG_ESP32_AES_ACCELERATOR
ret = esp32_aes_init();
if (ret < 0)

View File

@ -40,8 +40,6 @@
#include <sys/errno.h>
#include <nuttx/himem/himem.h>
#include "esp32_procfs_imm.h"
#include "esp32_wlan.h"
#include "esp32_spiflash.h"
#include "esp32_partition.h"
@ -118,21 +116,6 @@ int esp32_bringup(void)
{
int ret;
#ifdef CONFIG_XTENSA_IMEM_PROCFS
/* Register the internal memory procfs entry.
* This must be done before the procfs is mounted.
*/
ret = imm_procfs_register();
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: Failed to register internal memory to PROCFS: %d\n",
ret);
}
#endif
#if defined(CONFIG_ESP32_SPIRAM) && \
defined(CONFIG_ESP32_SPIRAM_BANKSWITCH_ENABLE)
ret = esp_himem_init();

View File

@ -40,8 +40,6 @@
#include <sys/errno.h>
#include <nuttx/himem/himem.h>
#include "esp32_procfs_imm.h"
#include "esp32_wlan.h"
#include "esp32_spiflash.h"
#include "esp32_partition.h"
@ -118,21 +116,6 @@ int esp32_bringup(void)
{
int ret;
#ifdef CONFIG_XTENSA_IMEM_PROCFS
/* Register the internal memory procfs entry.
* This must be done before the procfs is mounted.
*/
ret = imm_procfs_register();
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: Failed to register internal memory to PROCFS: %d\n",
ret);
}
#endif
#if defined(CONFIG_ESP32_SPIRAM) && \
defined(CONFIG_ESP32_SPIRAM_BANKSWITCH_ENABLE)
ret = esp_himem_init();