You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/08/25 12:05:22 UTC
[incubator-nuttx] branch master updated: Refine how to specify iob and ramlog data section
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 130b196876 Refine how to specify iob and ramlog data section
130b196876 is described below
commit 130b196876bbebc5286d8b68987258d99d36531e
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Aug 22 15:51:31 2022 +0800
Refine how to specify iob and ramlog data section
1.Remove the default value(.bss)
2.Remove !ARCH_SIM dependence
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
drivers/syslog/Kconfig | 2 --
drivers/syslog/Make.defs | 4 ++++
drivers/syslog/ramlog.c | 17 +++++++++--------
mm/iob/Kconfig | 2 --
mm/iob/Make.defs | 4 ++++
mm/iob/iob_initialize.c | 14 +++++---------
6 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/drivers/syslog/Kconfig b/drivers/syslog/Kconfig
index 9bf064d164..2e3f9dba96 100644
--- a/drivers/syslog/Kconfig
+++ b/drivers/syslog/Kconfig
@@ -250,8 +250,6 @@ if RAMLOG_SYSLOG
config RAMLOG_BUFFER_SECTION
string "The section where ramlog buffer is located"
- default ".bss"
- depends on !ARCH_SIM
---help---
The section where ramlog buffer is located.
The section shall not be initialized on system boot.
diff --git a/drivers/syslog/Make.defs b/drivers/syslog/Make.defs
index 96e5d7d794..9bdc0165c5 100644
--- a/drivers/syslog/Make.defs
+++ b/drivers/syslog/Make.defs
@@ -36,6 +36,10 @@ endif
ifeq ($(CONFIG_RAMLOG),y)
CSRCS += ramlog.c
+
+ ifneq ($(CONFIG_RAMLOG_BUFFER_SECTION),"")
+ CFLAGS += ${shell $(DEFINE) "$(CC)" RAMLOG_BUFFER_SECTION=CONFIG_RAMLOG_BUFFER_SECTION}
+ endif
endif
############################################################################
diff --git a/drivers/syslog/ramlog.c b/drivers/syslog/ramlog.c
index 55cca259bb..8146f986f2 100644
--- a/drivers/syslog/ramlog.c
+++ b/drivers/syslog/ramlog.c
@@ -124,11 +124,12 @@ static const struct file_operations g_ramlogfops =
*/
#ifdef CONFIG_RAMLOG_SYSLOG
+# ifdef RAMLOG_BUFFER_SECTION
static char g_sysbuffer[CONFIG_RAMLOG_BUFSIZE]
-#ifdef CONFIG_RAMLOG_BUFFER_SECTION
- locate_data(CONFIG_RAMLOG_BUFFER_SECTION)
-#endif
-;
+ locate_data(RAMLOG_BUFFER_SECTION);
+# else
+static char g_sysbuffer[CONFIG_RAMLOG_BUFSIZE];
+# endif
/* This is the device structure for the console or syslogging function. It
* must be statically initialized because the RAMLOG ramlog_putc function
@@ -137,15 +138,15 @@ static char g_sysbuffer[CONFIG_RAMLOG_BUFSIZE]
static struct ramlog_dev_s g_sysdev =
{
-#ifndef CONFIG_RAMLOG_NONBLOCKING
+# ifndef CONFIG_RAMLOG_NONBLOCKING
0, /* rl_nwaiters */
-#endif
+# endif
CONFIG_RAMLOG_BUFSIZE, /* rl_head */
CONFIG_RAMLOG_BUFSIZE, /* rl_tail */
SEM_INITIALIZER(1), /* rl_exclsem */
-#ifndef CONFIG_RAMLOG_NONBLOCKING
+# ifndef CONFIG_RAMLOG_NONBLOCKING
SEM_INITIALIZER(0), /* rl_waitsem */
-#endif
+# endif
CONFIG_RAMLOG_BUFSIZE, /* rl_bufsize */
g_sysbuffer /* rl_buffer */
};
diff --git a/mm/iob/Kconfig b/mm/iob/Kconfig
index b5156fa5b0..31b8b1091e 100644
--- a/mm/iob/Kconfig
+++ b/mm/iob/Kconfig
@@ -48,8 +48,6 @@ config IOB_ALIGNMENT
config IOB_SECTION
string "The section where iob buffer is located"
- default ".bss"
- depends on !ARCH_SIM
---help---
The section where iob buffer is located.
The section must be zero-initialized on system boot.
diff --git a/mm/iob/Make.defs b/mm/iob/Make.defs
index b69a2a0481..5ecd99cc93 100644
--- a/mm/iob/Make.defs
+++ b/mm/iob/Make.defs
@@ -38,6 +38,10 @@ ifeq ($(CONFIG_DEBUG_FEATURES),y)
CSRCS += iob_dump.c
endif
+ifneq ($(CONFIG_IOB_SECTION),"")
+ CFLAGS += ${shell $(DEFINE) "$(CC)" IOB_SECTION=CONFIG_IOB_SECTION}
+endif
+
# Include iob build support
DEPPATH += --dep-path iob
diff --git a/mm/iob/iob_initialize.c b/mm/iob/iob_initialize.c
index 36577665b6..5d3cbbb57c 100644
--- a/mm/iob/iob_initialize.c
+++ b/mm/iob/iob_initialize.c
@@ -42,14 +42,6 @@
#define IOB_BUFFER_SIZE (IOB_ALIGN_SIZE * CONFIG_IOB_NBUFFERS + \
CONFIG_IOB_ALIGNMENT - 1)
-/* Improve Flexibility */
-
-#ifdef CONFIG_IOB_SECTION
-# define IOB_SECTION locate_data(CONFIG_IOB_SECTION)
-#else
-# define IOB_SECTION
-#endif
-
/****************************************************************************
* Private Data
****************************************************************************/
@@ -59,7 +51,11 @@
* to the CONFIG_IOB_ALIGNMENT memory boundary.
*/
-static uint8_t g_iob_buffer[IOB_BUFFER_SIZE] IOB_SECTION;
+#ifdef IOB_SECTION
+static uint8_t g_iob_buffer[IOB_BUFFER_SIZE] locate_data(IOB_SECTION);
+#else
+static uint8_t g_iob_buffer[IOB_BUFFER_SIZE];
+#endif
#if CONFIG_IOB_NCHAINS > 0
/* This is a pool of pre-allocated iob_qentry_s buffers */