[PATCH v2 26/44] config: Add <rtems/confdefs/percpu.h>

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Feb 21 10:52:38 UTC 2020


Remove comments and copyrightable content from the moved content.  Use
BSD-2-Clause for new file according to file history of
<rtems/confdefs.h>.

Update #3053.
Update #3875.
---
 cpukit/headers.am                      |   1 +
 cpukit/include/rtems/confdefs.h        | 164 +--------------------------------
 cpukit/include/rtems/confdefs/percpu.h | 158 +++++++++++++++++++++++++++++++
 3 files changed, 161 insertions(+), 162 deletions(-)
 create mode 100644 cpukit/include/rtems/confdefs/percpu.h

diff --git a/cpukit/headers.am b/cpukit/headers.am
index 9f736e0c87..e0b5af6402 100644
--- a/cpukit/headers.am
+++ b/cpukit/headers.am
@@ -186,6 +186,7 @@ include_rtems_HEADERS += include/rtems/watchdogdrv.h
 include_rtems_confdefs_HEADERS += include/rtems/confdefs/bsp.h
 include_rtems_confdefs_HEADERS += include/rtems/confdefs/libpci.h
 include_rtems_confdefs_HEADERS += include/rtems/confdefs/obsolete.h
+include_rtems_confdefs_HEADERS += include/rtems/confdefs/percpu.h
 include_rtems_debugger_HEADERS += include/rtems/debugger/rtems-debugger-bsp.h
 include_rtems_debugger_HEADERS += include/rtems/debugger/rtems-debugger-remote.h
 include_rtems_debugger_HEADERS += include/rtems/debugger/rtems-debugger-server.h
diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index eca210190c..240dd855cc 100644
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -31,7 +31,6 @@
 #include <rtems/sysinit.h>
 #include <rtems/score/apimutex.h>
 #include <rtems/score/context.h>
-#include <rtems/score/percpu.h>
 #include <rtems/score/userextimpl.h>
 #include <rtems/score/wkspace.h>
 #include <rtems/rtems/barrierdata.h>
@@ -51,8 +50,8 @@
 #include <rtems/posix/shm.h>
 #include <rtems/posix/timer.h>
 #include <rtems/confdefs/obsolete.h>
-#include <rtems/confdefs/bsp.h>
 #include <rtems/confdefs/libpci.h>
+#include <rtems/confdefs/percpu.h>
 
 #include <limits.h>
 
@@ -134,13 +133,6 @@ extern "C" {
   const uint32_t rtems_libio_number_iops = RTEMS_ARRAY_SIZE(rtems_libio_iops);
 #endif
 
-/* Ensure that _CONFIGURE_MAXIMUM_PROCESSORS > 1 only in SMP configurations */
-#if defined(CONFIGURE_MAXIMUM_PROCESSORS) && defined(RTEMS_SMP)
-  #define _CONFIGURE_MAXIMUM_PROCESSORS CONFIGURE_MAXIMUM_PROCESSORS
-#else
-  #define _CONFIGURE_MAXIMUM_PROCESSORS 1
-#endif
-
 /*
  * This sets up the resources for the FIFOs/pipes.
  */
@@ -978,130 +970,6 @@ extern "C" {
 #endif
 /**@}*/ /* end of Scheduler Configuration */
 
-/**
- * @defgroup ConfigurationIdle IDLE Thread Configuration
- *
- * @addtogroup Configuration
- *
- * This module contains configuration parameters related to the
- * set of IDLE threads. On a uniprocessor system, there is one
- * IDLE thread. On an SMP system, there is one for each core.
- */
-
-/*
- *  If you said the IDLE task was going to do application initialization
- *  and didn't override the IDLE body, then something is amiss.
- */
-#if (defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) && \
-     !defined(CONFIGURE_IDLE_TASK_BODY))
-  #error "CONFIGURE_ERROR: You did not override the IDLE task body."
-#endif
-
-/**
- * @brief Idle task body configuration.
- *
- * There is a default IDLE thread body provided by RTEMS which
- * has the possibility of being CPU specific.  There may be a
- * BSP specific override of the RTEMS default body and in turn,
- * the application may override and provide its own.
- */
-#ifndef CONFIGURE_IDLE_TASK_BODY
-  #if defined(BSP_IDLE_TASK_BODY)
-    #define CONFIGURE_IDLE_TASK_BODY BSP_IDLE_TASK_BODY
-  #endif
-#endif
-
-#if defined(CONFIGURE_INIT) && defined(CONFIGURE_IDLE_TASK_BODY)
-const Thread_Idle_body _Thread_Idle_body = CONFIGURE_IDLE_TASK_BODY;
-#endif
-/**@}*/ /* end of IDLE thread configuration */
-
-/**
- * @defgroup ConfigurationStackSize Configuration Thread Stack Size
- *
- * @addtogroup Configuration
- *
- * This module contains parameters related to thread and interrupt stacks.
- */
-
-/**
- * By default, use the minimum stack size requested by this port.
- */
-#ifndef CONFIGURE_MINIMUM_TASK_STACK_SIZE
-  #define CONFIGURE_MINIMUM_TASK_STACK_SIZE CPU_STACK_MINIMUM_SIZE
-#endif
-
-/**
- * This specifies the default POSIX thread stack size. By default, it is
- * twice that recommended for the port.
- */
-#ifndef CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE
-#define CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE \
-  (2 * CONFIGURE_MINIMUM_TASK_STACK_SIZE)
-#endif
-
-/**
- * @brief Idle task stack size configuration.
- *
- * By default, the IDLE task will have a stack of minimum size.
- * The BSP or application may override this value.
- */
-#ifndef CONFIGURE_IDLE_TASK_STACK_SIZE
-  #ifdef BSP_IDLE_TASK_STACK_SIZE
-    #define CONFIGURE_IDLE_TASK_STACK_SIZE BSP_IDLE_TASK_STACK_SIZE
-  #else
-    #define CONFIGURE_IDLE_TASK_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE
-  #endif
-#endif
-#if CONFIGURE_IDLE_TASK_STACK_SIZE < CONFIGURE_MINIMUM_TASK_STACK_SIZE
-  #error "CONFIGURE_IDLE_TASK_STACK_SIZE less than CONFIGURE_MINIMUM_TASK_STACK_SIZE"
-#endif
-
-#ifdef CONFIGURE_INIT
-  const size_t _Thread_Idle_stack_size = CONFIGURE_IDLE_TASK_STACK_SIZE;
-#endif
-
-/*
- * Interrupt stack configuration.
- *
- * By default, the interrupt stack will be of minimum size.
- * The BSP or application may override this value.
- */
-
-#ifndef CONFIGURE_INTERRUPT_STACK_SIZE
-  #ifdef BSP_INTERRUPT_STACK_SIZE
-    #define CONFIGURE_INTERRUPT_STACK_SIZE BSP_INTERRUPT_STACK_SIZE
-  #else
-    #define CONFIGURE_INTERRUPT_STACK_SIZE CPU_STACK_MINIMUM_SIZE
-  #endif
-#endif
-
-#if CONFIGURE_INTERRUPT_STACK_SIZE % CPU_INTERRUPT_STACK_ALIGNMENT != 0
-  #error "CONFIGURE_INTERRUPT_STACK_SIZE fails to meet the CPU port interrupt stack alignment"
-#endif
-
-#ifdef CONFIGURE_INIT
-  RTEMS_DEFINE_GLOBAL_SYMBOL(
-    _ISR_Stack_size,
-    CONFIGURE_INTERRUPT_STACK_SIZE
-  );
-
-  char _ISR_Stack_area_begin[
-    _CONFIGURE_MAXIMUM_PROCESSORS * CONFIGURE_INTERRUPT_STACK_SIZE
-  ] RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT )
-  RTEMS_SECTION( ".rtemsstack.interrupt.begin" );
-
-  RTEMS_DEFINE_GLOBAL_SYMBOL_IN_SECTION(
-    _ISR_Stack_area_end,
-    ".rtemsstack.interrupt.end"
-  );
-#endif
-
-/**
- * @addtogroup Configuration
- */
-/**@{*/
-
 /**
  * @defgroup ConfigurationMalloc RTEMS Malloc configuration
  *
@@ -2106,12 +1974,6 @@ struct _reent *__getreent(void)
 #define _CONFIGURE_HEAP_HANDLER_OVERHEAD \
   _Configure_Align_up( HEAP_BLOCK_HEADER_SIZE, CPU_HEAP_ALIGNMENT )
 
-/**
- * This calculates the amount of memory reserved for the IDLE tasks.
- * In an SMP system, each CPU core has its own idle task.
- */
-#define _CONFIGURE_IDLE_TASKS_COUNT _CONFIGURE_MAXIMUM_PROCESSORS
-
 /*
  *  Calculate the RAM size based on the maximum number of objects configured.
  */
@@ -2376,16 +2238,9 @@ struct _reent *__getreent(void)
     _Thread,
     OBJECTS_INTERNAL_API,
     OBJECTS_INTERNAL_THREADS,
-    _CONFIGURE_IDLE_TASKS_COUNT + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT
+    _CONFIGURE_MAXIMUM_PROCESSORS + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT
   );
 
-  char _Thread_Idle_stacks[
-    _CONFIGURE_IDLE_TASKS_COUNT
-      * ( CONFIGURE_IDLE_TASK_STACK_SIZE
-        + CPU_IDLE_TASK_IS_FP * CONTEXT_FP_SIZE )
-  ] RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT )
-  RTEMS_SECTION( ".rtemsstack.idle" );
-
   #if CONFIGURE_MAXIMUM_BARRIERS > 0
     BARRIER_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_BARRIERS );
   #endif
@@ -2528,11 +2383,6 @@ struct _reent *__getreent(void)
     #error "CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR must be both defined or both undefined"
   #endif
 
-  #ifdef RTEMS_SMP
-    const uint32_t _SMP_Processor_configured_maximum =
-      _CONFIGURE_MAXIMUM_PROCESSORS;
-  #endif
-
   const uintptr_t _Workspace_Size = CONFIGURE_EXECUTIVE_RAM_SIZE;
 
   #ifdef CONFIGURE_UNIFIED_WORK_AREAS
@@ -2594,16 +2444,6 @@ struct _reent *__getreent(void)
   #endif
 #endif
 
-#if defined(RTEMS_SMP)
- /*
-  * Instantiate the Per CPU information based upon the user configuration.
-  */
- #if defined(CONFIGURE_INIT)
-   Per_CPU_Control_envelope _Per_CPU_Information[_CONFIGURE_MAXIMUM_PROCESSORS];
- #endif
-
-#endif
-
 /*
  *  If the user has configured a set of Classic API Initialization Tasks,
  *  then we need to install the code that runs that loop.
diff --git a/cpukit/include/rtems/confdefs/percpu.h b/cpukit/include/rtems/confdefs/percpu.h
new file mode 100644
index 0000000000..84197504d8
--- /dev/null
+++ b/cpukit/include/rtems/confdefs/percpu.h
@@ -0,0 +1,158 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2018, 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSApplicationConfiguration
+ *
+ * @brief Evaluate Per-CPU Configuration Options
+ *
+ * Since the idle thread stack size (CONFIGURE_IDLE_TASK_STACK_SIZE) depends on
+ * CONFIGURE_MINIMUM_TASK_STACK_SIZE, the POSIX-specific
+ * CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE configuration option is also evaluated
+ * in this header file for simplicity.
+ *
+ * This header file defines _CONFIGURE_MAXIMUM_PROCESSORS for use by other
+ * configuration header files.
+ */
+
+#ifndef _RTEMS_CONFDEFS_PERCPU_H
+#define _RTEMS_CONFDEFS_PERCPU_H
+
+#ifndef __CONFIGURATION_TEMPLATE_h
+#error "Do not include this file directly, use <rtems/confdefs.h> instead"
+#endif
+
+#ifdef CONFIGURE_INIT
+
+#include <rtems/confdefs/bsp.h>
+#include <rtems/score/context.h>
+#include <rtems/score/percpu.h>
+#include <rtems/score/smp.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Ensure that _CONFIGURE_MAXIMUM_PROCESSORS > 1 only in SMP configurations */
+#if defined(CONFIGURE_MAXIMUM_PROCESSORS) && defined(RTEMS_SMP)
+  #define _CONFIGURE_MAXIMUM_PROCESSORS CONFIGURE_MAXIMUM_PROCESSORS
+#else
+  #define _CONFIGURE_MAXIMUM_PROCESSORS 1
+#endif
+
+#ifdef RTEMS_SMP
+  const uint32_t _SMP_Processor_configured_maximum =
+    _CONFIGURE_MAXIMUM_PROCESSORS;
+
+  Per_CPU_Control_envelope
+    _Per_CPU_Information[ _CONFIGURE_MAXIMUM_PROCESSORS ];
+#endif
+
+/* Interrupt stack configuration */
+
+#ifndef CONFIGURE_INTERRUPT_STACK_SIZE
+  #ifdef BSP_INTERRUPT_STACK_SIZE
+    #define CONFIGURE_INTERRUPT_STACK_SIZE BSP_INTERRUPT_STACK_SIZE
+  #else
+    #define CONFIGURE_INTERRUPT_STACK_SIZE CPU_STACK_MINIMUM_SIZE
+  #endif
+#endif
+
+#if CONFIGURE_INTERRUPT_STACK_SIZE % CPU_INTERRUPT_STACK_ALIGNMENT != 0
+  #error "CONFIGURE_INTERRUPT_STACK_SIZE fails to meet the CPU port interrupt stack alignment"
+#endif
+
+RTEMS_DEFINE_GLOBAL_SYMBOL(
+  _ISR_Stack_size,
+  CONFIGURE_INTERRUPT_STACK_SIZE
+);
+
+char _ISR_Stack_area_begin[
+  _CONFIGURE_MAXIMUM_PROCESSORS * CONFIGURE_INTERRUPT_STACK_SIZE
+] RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT )
+RTEMS_SECTION( ".rtemsstack.interrupt.begin" );
+
+RTEMS_DEFINE_GLOBAL_SYMBOL_IN_SECTION(
+  _ISR_Stack_area_end,
+  ".rtemsstack.interrupt.end"
+);
+
+/* Thread stack size configuration */
+
+#ifndef CONFIGURE_MINIMUM_TASK_STACK_SIZE
+  #define CONFIGURE_MINIMUM_TASK_STACK_SIZE CPU_STACK_MINIMUM_SIZE
+#endif
+
+#ifndef CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE
+  #define CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE \
+    ( 2 * CONFIGURE_MINIMUM_TASK_STACK_SIZE )
+#endif
+
+/* Idle thread configuration */
+
+#ifndef CONFIGURE_IDLE_TASK_STACK_SIZE
+  #ifdef BSP_IDLE_TASK_STACK_SIZE
+    #define CONFIGURE_IDLE_TASK_STACK_SIZE BSP_IDLE_TASK_STACK_SIZE
+  #else
+    #define CONFIGURE_IDLE_TASK_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE
+  #endif
+#endif
+
+#if CONFIGURE_IDLE_TASK_STACK_SIZE < CONFIGURE_MINIMUM_TASK_STACK_SIZE
+  #error "CONFIGURE_IDLE_TASK_STACK_SIZE less than CONFIGURE_MINIMUM_TASK_STACK_SIZE"
+#endif
+
+const size_t _Thread_Idle_stack_size = CONFIGURE_IDLE_TASK_STACK_SIZE;
+
+char _Thread_Idle_stacks[
+  _CONFIGURE_MAXIMUM_PROCESSORS
+    * ( CONFIGURE_IDLE_TASK_STACK_SIZE + CPU_IDLE_TASK_IS_FP * CONTEXT_FP_SIZE )
+] RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT )
+RTEMS_SECTION( ".rtemsstack.idle" );
+
+#if defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) && \
+  !defined(CONFIGURE_IDLE_TASK_BODY)
+  #error "If you define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, then you must define CONFIGURE_IDLE_TASK_BODY as well"
+#endif
+
+#if !defined(CONFIGURE_IDLE_TASK_BODY) && defined(BSP_IDLE_TASK_BODY)
+  #define CONFIGURE_IDLE_TASK_BODY BSP_IDLE_TASK_BODY
+#endif
+
+#ifdef CONFIGURE_IDLE_TASK_BODY
+  const Thread_Idle_body _Thread_Idle_body = CONFIGURE_IDLE_TASK_BODY;
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CONFIGURE_INIT */
+
+#endif /* _RTEMS_CONFDEFS_PERCPU_H */
-- 
2.16.4



More information about the devel mailing list