[rtems commit] score: Create idle threads via linker set
Sebastian Huber
sebh at rtems.org
Wed Feb 3 09:29:45 UTC 2016
Module: rtems
Branch: master
Commit: 36b86d7eb5e51a62c0cee1906210b389c2ab96eb
Changeset: http://git.rtems.org/rtems/commit/?id=36b86d7eb5e51a62c0cee1906210b389c2ab96eb
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon Jan 25 20:55:52 2016 +0100
score: Create idle threads via linker set
This allows a more fine grained rtems_initialize_data_structures().
Update #2408.
---
cpukit/sapi/src/exinit.c | 30 +++++++-------
cpukit/score/include/rtems/sysinit.h | 1 +
cpukit/score/src/threadcreateidle.c | 3 ++
testsuites/sptests/spsysinit01/init.c | 76 ++++++++++++++++++++++++++---------
4 files changed, 75 insertions(+), 35 deletions(-)
diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c
index 7c1ffd6..faaf283 100644
--- a/cpukit/sapi/src/exinit.c
+++ b/cpukit/sapi/src/exinit.c
@@ -142,21 +142,6 @@ static void rtems_initialize_data_structures(void)
_Extension_Manager_initialization();
_POSIX_API_Initialize();
-
- _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
-
- /*
- * No threads should be created before this point!!!
- * _Thread_Executing and _Thread_Heir are not set.
- *
- * At this point all API extensions are in place. After the call to
- * _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
- */
- _Thread_Create_idle();
-
- /*
- * Scheduling can properly occur now as long as we avoid dispatching.
- */
}
static void rtems_initialize_before_drivers(void)
@@ -261,6 +246,21 @@ RTEMS_SYSINIT_ITEM(
RTEMS_SYSINIT_ORDER_MIDDLE
);
+/*
+ * No threads should be created before this point!!!
+ * _Thread_Executing and _Thread_Heir are not set.
+ *
+ * At this point all API extensions are in place. After the call to
+ * _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set.
+ *
+ * Scheduling can properly occur afterwards as long as we avoid dispatching.
+ */
+RTEMS_SYSINIT_ITEM(
+ _Thread_Create_idle,
+ RTEMS_SYSINIT_IDLE_THREADS,
+ RTEMS_SYSINIT_ORDER_MIDDLE
+);
+
RTEMS_SYSINIT_ITEM(
rtems_initialize_before_drivers,
RTEMS_SYSINIT_BEFORE_DRIVERS,
diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h
index 855198d..e6fe62f 100644
--- a/cpukit/score/include/rtems/sysinit.h
+++ b/cpukit/score/include/rtems/sysinit.h
@@ -29,6 +29,7 @@ extern "C" {
#define RTEMS_SYSINIT_BSP_WORK_AREAS 000100
#define RTEMS_SYSINIT_BSP_START 000200
#define RTEMS_SYSINIT_DATA_STRUCTURES 000300
+#define RTEMS_SYSINIT_IDLE_THREADS 000380
#define RTEMS_SYSINIT_BSP_LIBC 000400
#define RTEMS_SYSINIT_BEFORE_DRIVERS 000500
#define RTEMS_SYSINIT_BSP_PRE_DRIVERS 000600
diff --git a/cpukit/score/src/threadcreateidle.c b/cpukit/score/src/threadcreateidle.c
index 3430881..a07e238 100644
--- a/cpukit/score/src/threadcreateidle.c
+++ b/cpukit/score/src/threadcreateidle.c
@@ -21,6 +21,7 @@
#include <rtems/score/threadimpl.h>
#include <rtems/score/schedulerimpl.h>
#include <rtems/score/stackimpl.h>
+#include <rtems/score/sysstate.h>
#include <rtems/score/userextimpl.h>
#include <rtems/config.h>
@@ -84,6 +85,8 @@ void _Thread_Create_idle( void )
uint32_t cpu_count = _SMP_Get_processor_count();
uint32_t cpu_index;
+ _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
+
for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c
index 76f8afd..fd34264 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -24,11 +24,35 @@
#include <rtems/sysinit.h>
#include <rtems/test.h>
+#include <rtems/score/apimutex.h>
#include <rtems/score/sysstate.h>
#include <rtems/score/wkspace.h>
const char rtems_test_name[] = "SPSYSINIT 1";
+typedef enum {
+ BSP_WORK_AREAS_PRE,
+ BSP_WORK_AREAS_POST,
+ BSP_START_PRE,
+ BSP_START_POST,
+ DATA_STRUCTURES_PRE,
+ DATA_STRUCTURES_POST,
+ IDLE_THREADS_PRE,
+ IDLE_THREADS_POST,
+ BSP_LIBC_PRE,
+ BSP_LIBC_POST,
+ BEFORE_DRIVERS_PRE,
+ BEFORE_DRIVERS_POST,
+ BSP_PRE_DRIVERS_PRE,
+ BSP_PRE_DRIVERS_POST,
+ DEVICE_DRIVERS_PRE,
+ DEVICE_DRIVERS_POST,
+ BSP_POST_DRIVERS_PRE,
+ BSP_POST_DRIVERS_POST,
+ INIT_TASK,
+ DONE
+} init_step;
+
#define FIRST(x) \
static void x##_first(void); \
RTEMS_SYSINIT_ITEM( \
@@ -47,9 +71,9 @@ const char rtems_test_name[] = "SPSYSINIT 1";
); \
static void x##_last(void)
-static int step;
+static init_step step;
-static void next_step(int expected)
+static void next_step(init_step expected)
{
assert(step == expected);
step = expected + 1;
@@ -59,13 +83,13 @@ FIRST(RTEMS_SYSINIT_BSP_WORK_AREAS)
{
rtems_test_begink();
assert(_Workspace_Area.area_begin == 0);
- next_step(0);
+ next_step(BSP_WORK_AREAS_PRE);
}
LAST(RTEMS_SYSINIT_BSP_WORK_AREAS)
{
assert(_Workspace_Area.area_begin != 0);
- next_step(1);
+ next_step(BSP_WORK_AREAS_POST);
}
FIRST(RTEMS_SYSINIT_BSP_START)
@@ -74,47 +98,59 @@ FIRST(RTEMS_SYSINIT_BSP_START)
* Since the work performed here is BSP-specific, there is no way to test pre
* and post conditions.
*/
- next_step(2);
+ next_step(BSP_START_PRE);
}
LAST(RTEMS_SYSINIT_BSP_START)
{
- next_step(3);
+ next_step(BSP_START_POST);
}
FIRST(RTEMS_SYSINIT_DATA_STRUCTURES)
{
- assert(_System_state_Is_before_initialization(_System_state_Get()));
- next_step(4);
+ assert(_RTEMS_Allocator_Mutex == NULL);
+ next_step(DATA_STRUCTURES_PRE);
}
LAST(RTEMS_SYSINIT_DATA_STRUCTURES)
{
+ assert(_RTEMS_Allocator_Mutex != NULL);
+ next_step(DATA_STRUCTURES_POST);
+}
+
+FIRST(RTEMS_SYSINIT_IDLE_THREADS)
+{
+ assert(_System_state_Is_before_initialization(_System_state_Get()));
+ next_step(IDLE_THREADS_PRE);
+}
+
+LAST(RTEMS_SYSINIT_IDLE_THREADS)
+{
assert(_System_state_Is_before_multitasking(_System_state_Get()));
- next_step(5);
+ next_step(IDLE_THREADS_POST);
}
FIRST(RTEMS_SYSINIT_BSP_LIBC)
{
assert(rtems_libio_semaphore == 0);
- next_step(6);
+ next_step(BSP_LIBC_PRE);
}
LAST(RTEMS_SYSINIT_BSP_LIBC)
{
assert(rtems_libio_semaphore != 0);
- next_step(7);
+ next_step(BSP_LIBC_POST);
}
FIRST(RTEMS_SYSINIT_BEFORE_DRIVERS)
{
/* Omit test of build configuration specific pre and post conditions */
- next_step(8);
+ next_step(BEFORE_DRIVERS_PRE);
}
LAST(RTEMS_SYSINIT_BEFORE_DRIVERS)
{
- next_step(9);
+ next_step(BEFORE_DRIVERS_POST);
}
FIRST(RTEMS_SYSINIT_BSP_PRE_DRIVERS)
@@ -123,41 +159,41 @@ FIRST(RTEMS_SYSINIT_BSP_PRE_DRIVERS)
* Since the work performed here is BSP-specific, there is no way to test pre
* and post conditions.
*/
- next_step(10);
+ next_step(BSP_PRE_DRIVERS_PRE);
}
LAST(RTEMS_SYSINIT_BSP_PRE_DRIVERS)
{
- next_step(11);
+ next_step(BSP_PRE_DRIVERS_POST);
}
FIRST(RTEMS_SYSINIT_DEVICE_DRIVERS)
{
assert(!_IO_All_drivers_initialized);
- next_step(12);
+ next_step(DEVICE_DRIVERS_PRE);
}
LAST(RTEMS_SYSINIT_DEVICE_DRIVERS)
{
assert(_IO_All_drivers_initialized);
- next_step(13);
+ next_step(DEVICE_DRIVERS_POST);
}
FIRST(RTEMS_SYSINIT_BSP_POST_DRIVERS)
{
assert(rtems_libio_iop_freelist != NULL);
- next_step(14);
+ next_step(BSP_POST_DRIVERS_PRE);
}
LAST(RTEMS_SYSINIT_BSP_POST_DRIVERS)
{
assert(rtems_libio_iop_freelist == NULL);
- next_step(15);
+ next_step(BSP_POST_DRIVERS_POST);
}
static void Init(rtems_task_argument arg)
{
- next_step(16);
+ next_step(INIT_TASK);
rtems_test_endk();
exit(0);
}
More information about the vc
mailing list