summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/stackallocatorforidle.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cpukit/score/src/stackallocatorforidle.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/cpukit/score/src/stackallocatorforidle.c b/cpukit/score/src/stackallocatorforidle.c
index 7c4fd10c7d..c8c8c0b766 100644
--- a/cpukit/score/src/stackallocatorforidle.c
+++ b/cpukit/score/src/stackallocatorforidle.c
@@ -1,7 +1,16 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSScoreStack
*
- * Copyright (C) 2021 OAR Corporation
+ * @brief This source file contains the implementation of
+ * _Stack_Allocator_allocate_for_idle_static().
+ */
+
+/*
+ * Copyright (C) 2021 On-Line Applications Research Corporation (OAR)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,30 +39,21 @@
#endif
#include <rtems/score/stack.h>
-#include <rtems/score/thread.h>
+#include <rtems/score/assert.h>
-/**
- * @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.
- *
- * The default allocator for IDLE thread stacks gets the memory from a
- * statically allocated area provided via confdefs.h.
- *
- * @param cpu Index of 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 (never returned).
- * @retval other Pointer to begin of stack area.
- */
-static void *_Stack_Allocator_allocate_for_idle_default(
- uint32_t cpu,
- size_t stack_size
+void *_Stack_Allocator_allocate_for_idle_static(
+ uint32_t cpu_index,
+ size_t *storage_size
)
{
- return &_Thread_Idle_stacks[ cpu * stack_size ];
-}
+ size_t size;
-const Stack_Allocator_allocate_for_idle _Stack_Allocator_allocate_for_idle =
- _Stack_Allocator_allocate_for_idle_default;
+ size = _Stack_Allocator_allocate_for_idle_storage_size;
+ *storage_size = size;
+#if defined(RTEMS_SMP)
+ return &_Stack_Allocator_allocate_for_idle_storage_areas[ cpu_index * size ];
+#else
+ _Assert( cpu_index == 0 );
+ return &_Stack_Allocator_allocate_for_idle_storage_areas[ 0 ];
+#endif
+}