[..]
+
+/*
+ * If the application wants to provide an IDLE threads stack allocator, it
+ * must also provide a custom allocator/deallocator for user thread stacks.
+ */
+#elif (!defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
+  && !defined(CONFIGURE_TASK_STACK_DEALLOCATOR)) \
+  && defined(CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE)
+  #error "CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE can only be provided if both 
CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR are provided"
  #endif

Is this really a hard error? The allocators are independent.

#ifdef CONFIGURE_DIRTY_MEMORY
diff --git a/cpukit/include/rtems/config.h b/cpukit/include/rtems/config.h
index e82c7abf11..a826581658 100644
--- a/cpukit/include/rtems/config.h
+++ b/cpukit/include/rtems/config.h
@@ -129,6 +129,9 @@ uint32_t rtems_configuration_get_maximum_extensions( void );
  #define rtems_configuration_get_stack_free_hook() \
    (_Stack_Allocator_free)
+#define rtems_configuration_get_stack_allocate_for_idle_hook() \
+  (_Stack_Allocator_allocate_for_idle)
+
   /**
    * This macro assists in accessing the field which indicates whether
    * RTEMS is responsible for zeroing the Executive Workspace.
diff --git a/cpukit/include/rtems/score/stack.h 
b/cpukit/include/rtems/score/stack.h
index df1df74867..6b20d4b977 100644
--- a/cpukit/include/rtems/score/stack.h
+++ b/cpukit/include/rtems/score/stack.h
@@ -23,6 +23,7 @@
  #define _RTEMS_SCORE_STACK_H
#include <rtems/score/basedefs.h>
+#include <rtems/score/percpu.h>

Please do not include this header in an header visible to the API.

#ifdef __cplusplus
  extern "C" {
@@ -81,6 +82,23 @@ typedef void *( *Stack_Allocator_allocate )( size_t 
stack_size );
   */
  typedef void ( *Stack_Allocator_free )( void *addr );
+/**
+ * @brief Stack allocator allocate for idle handler.
+ *
+ * The allocate for idle handler is optional even when the user thread stack
+ * allocator and deallocator are configured.
+ *
+ * @param cpu Information for the CPU for the IDLE thread using this stack
+ * @param stack_size The size of the stack area to allocate in bytes.
+ *
+ * @retval NULL Not enough memory.
+ * @retval other Pointer to begin of stack area.
+ */
+typedef void *( *Stack_Allocator_allocate_for_idle )(
+  Per_CPU_Control *cpu,

Please use

uint32_t cpu_index

instead.

+  size_t           stack_size
+);
+
  /**
   * @brief The minimum stack size.
   *
@@ -124,6 +142,30 @@ extern const Stack_Allocator_allocate 
_Stack_Allocator_allocate;
  extern const Stack_Allocator_free _Stack_Allocator_free;
/** @} */
+/**
+ * @brief The stack allocator allocate stack for idle thread handler.
+ *
+ * Application provided via <rtems/confdefs.h>.
+ */
+extern const Stack_Allocator_allocate_for_idle
+  _Stack_Allocator_allocate_for_idle;
+
+/**
+ * @brief Default stack allocator allocate for idle handler.
+ *
+ * The allocate for idle handler is optional even when the user thread stack
+ * allocator and deallocator are configured.
+ *
+ * @param cpu Information for the CPU for the IDLE thread using this stack
+ * @param stack_size The size of the stack area to allocate in bytes.
+ *
+ * @retval NULL Not enough memory.
+ * @retval other Pointer to begin of stack area.
+ */
+void *_Stack_Allocator_allocate_for_idle_default(
+  Per_CPU_Control *cpu,
+  size_t           stack_size
+);
#ifdef __cplusplus
  }
diff --git a/cpukit/score/src/stackallocatorforidle.c 
b/cpukit/score/src/stackallocatorforidle.c
new file mode 100644
index 0000000000..d33cd4dbf5
--- /dev/null
+++ b/cpukit/score/src/stackallocatorforidle.c
@@ -0,0 +1,36 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2021 OAR Corporation
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/score/stack.h>
+#include <rtems/score/wkspace.h>

Why the wkspace.h include?

+
+const Stack_Allocator_allocate_for_idle _Stack_Allocator_allocate_for_idle =
+        _Stack_Allocator_allocate_for_idle_default;

Please move the definition to this file and make _Stack_Allocator_allocate_for_idle_default() static.

[...]

--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to