You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by da...@apache.org on 2021/02/12 11:16:19 UTC
[incubator-nuttx] 07/07: esp32: Retire XTENSA_IMEM_PROCFS
This is an automated email from the ASF dual-hosted git repository.
davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit aed24f1255a60f4732cc6d535ea24f0fb3605e7a
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Fri Feb 12 14:56:11 2021 +0900
esp32: Retire XTENSA_IMEM_PROCFS
Now /proc/meminfo has the equivalent.
---
arch/xtensa/Kconfig | 5 -
arch/xtensa/src/esp32/Make.defs | 4 -
arch/xtensa/src/esp32/esp32_procfs_imm.c | 319 ---------------------
arch/xtensa/src/esp32/esp32_procfs_imm.h | 64 -----
.../xtensa/esp32/esp32-devkitc/src/esp32_bringup.c | 17 --
.../esp32/esp32-ethernet-kit/src/esp32_bringup.c | 17 --
.../esp32/esp32-wrover-kit/src/esp32_bringup.c | 17 --
7 files changed, 443 deletions(-)
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index e562274..ba82cdd 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -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
diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs
index a721eb1..d578959 100644
--- a/arch/xtensa/src/esp32/Make.defs
+++ b/arch/xtensa/src/esp32/Make.defs
@@ -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
diff --git a/arch/xtensa/src/esp32/esp32_procfs_imm.c b/arch/xtensa/src/esp32/esp32_procfs_imm.c
deleted file mode 100644
index 3983af6..0000000
--- a/arch/xtensa/src/esp32/esp32_procfs_imm.c
+++ /dev/null
@@ -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 */
diff --git a/arch/xtensa/src/esp32/esp32_procfs_imm.h b/arch/xtensa/src/esp32/esp32_procfs_imm.h
deleted file mode 100644
index 84e843d..0000000
--- a/arch/xtensa/src/esp32/esp32_procfs_imm.h
+++ /dev/null
@@ -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 */
-
diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c
index ee3a1cb..f0479d8 100644
--- a/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c
+++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c
@@ -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)
diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c
index 48b073b..4a03c2b 100644
--- a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c
+++ b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c
@@ -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();
diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c
index 8d40a20..28d8f69 100644
--- a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c
+++ b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c
@@ -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();