summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2013-12-13 11:01:48 -0600
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-04-28 11:33:52 -0500
commit726b27c5bf4b2f4200953950b985b6e0fb7ce20f (patch)
tree6ae666752f68e3171dd8966bcca4431629369ba0
parent.configure.swp: Junk file removed from git (diff)
downloadrtems-schedsim-726b27c5bf4b2f4200953950b985b6e0fb7ce20f.tar.bz2
schedsim: Update to latest RTEMS. Works Uniprocessor
-rw-r--r--schedsim/rtems/Makefile.am97
-rw-r--r--schedsim/rtems/rtems_init.c76
-rw-r--r--schedsim/rtems/sched_cpu/cpu_asm.c151
-rw-r--r--schedsim/rtems/sched_cpu/rtems/score/cpu.h38
-rw-r--r--schedsim/rtems/sched_cpu/rtems/score/cpusmplock.h118
-rw-r--r--schedsim/rtems/sched_cpu/rtems/score/types.h3
-rw-r--r--schedsim/rtems/wkspace.c23
-rw-r--r--schedsim/shell/schedsim_priority/Makefile.am11
-rw-r--r--schedsim/shell/schedsim_priority/smp_stub.c6
-rw-r--r--schedsim/shell/schedsim_smpsimple/main_dispatch.c2
-rw-r--r--schedsim/shell/schedsim_smpsimple/main_dump_all_cpus.c11
-rw-r--r--schedsim/shell/schedsim_smpsimple/main_dump_ready_tasks.c2
-rw-r--r--schedsim/shell/schedsim_smpsimple/smp_stub.c15
-rw-r--r--schedsim/shell/shared/main_rtemsinit.c5
-rw-r--r--schedsim/shell/shared/schedsim_shell.h1
15 files changed, 304 insertions, 255 deletions
diff --git a/schedsim/rtems/Makefile.am b/schedsim/rtems/Makefile.am
index f95bab6..2f302c7 100644
--- a/schedsim/rtems/Makefile.am
+++ b/schedsim/rtems/Makefile.am
@@ -8,11 +8,8 @@ librtems_a_CPPFLAGS += -I$(top_builddir)/score/include
librtems_a_CPPFLAGS += -I$(srcdir)/sched_cpu
librtems_a_CPPFLAGS += -I$(cpukitdir)/include
librtems_a_CPPFLAGS += -I$(cpukitdir)/score/include
-librtems_a_CPPFLAGS += -I$(cpukitdir)/score/inline
librtems_a_CPPFLAGS += -I$(cpukitdir)/rtems/include
-librtems_a_CPPFLAGS += -I$(cpukitdir)/rtems/inline
librtems_a_CPPFLAGS += -I$(cpukitdir)/sapi/include
-librtems_a_CPPFLAGS += -I$(cpukitdir)/sapi/inline
librtems_a_CPPFLAGS += -I$(cpukitdir)/libcsupport/include
librtems_a_CPPFLAGS += -I$(cpukitdir)/libmisc/stringto
if HAS_PTHREADS
@@ -31,7 +28,6 @@ librtems_a_SOURCES += sched_cpu/cpu.c
librtems_a_SOURCES += $(cpukitdir)/score/src/interr.c
librtems_a_SOURCES += $(cpukitdir)/score/src/percpu.c
librtems_a_SOURCES += $(cpukitdir)/score/src/apiext.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/apimutexallocate.c
librtems_a_SOURCES += $(cpukitdir)/score/src/apimutex.c
librtems_a_SOURCES += $(cpukitdir)/score/src/apimutexlock.c
librtems_a_SOURCES += $(cpukitdir)/score/src/apimutexunlock.c
@@ -52,11 +48,13 @@ librtems_a_SOURCES += $(cpukitdir)/score/src/coresemsurrender.c
librtems_a_SOURCES += $(cpukitdir)/score/src/coretod.c
librtems_a_SOURCES += $(cpukitdir)/score/src/coretodget.c
librtems_a_SOURCES += $(cpukitdir)/score/src/coretodgetuptimetimespec.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/coretodsecondssinceepoch.c
librtems_a_SOURCES += $(cpukitdir)/score/src/coretodset.c
librtems_a_SOURCES += $(cpukitdir)/score/src/coretodtickle.c
librtems_a_SOURCES += $(cpukitdir)/score/src/coretodtickspersec.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/coretodusectoticks.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/freechain.c
librtems_a_SOURCES += $(cpukitdir)/score/src/isr.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/log2table.c
librtems_a_SOURCES += $(cpukitdir)/score/src/objectallocate.c
librtems_a_SOURCES += $(cpukitdir)/score/src/objectapimaximumclass.c
librtems_a_SOURCES += $(cpukitdir)/score/src/objectclose.c
@@ -76,21 +74,32 @@ librtems_a_SOURCES += $(cpukitdir)/score/src/objectnametoid.c
librtems_a_SOURCES += $(cpukitdir)/score/src/objectnametoidstring.c
librtems_a_SOURCES += $(cpukitdir)/score/src/objectsetname.c
librtems_a_SOURCES += $(cpukitdir)/score/src/objectshrinkinformation.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/rbtree.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/rbtreeextract.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/rbtreefind.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/rbtreeinsert.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/rbtreeiterate.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/rbtreenext.c
librtems_a_SOURCES += $(cpukitdir)/score/src/scheduler.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerpriorityallocate.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerdefaultallocatefree.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerdefaultreleasejob.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerdefaultstartidle.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerdefaulttick.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerdefaultupdate.c
+
+# Uniprocessor Deterministic Scheduler
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerpriorityblock.c
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerpriority.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerprioritytick.c
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerpriorityenqueue.c
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerpriorityenqueuefirst.c
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerpriorityextract.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerpriorityfree.c
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerpriorityprioritycompare.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerpriorityreleasejob.c
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerpriorityschedule.c
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerpriorityunblock.c
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerpriorityupdate.c
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerpriorityyield.c
+
+# Uniprocessor Scheduler Simple
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimpleblock.c
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimple.c
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimpleenqueue.c
@@ -101,10 +110,10 @@ librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimplereadyqueueenqueuefir
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimpleschedule.c
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimpleunblock.c
librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimpleyield.c
+
librtems_a_SOURCES += $(cpukitdir)/score/src/thread.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threadchangepriority.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threadclearstate.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/threadclose.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threadcreateidle.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threaddelayended.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threaddispatch.c
@@ -113,7 +122,6 @@ librtems_a_SOURCES += $(cpukitdir)/score/src/threadhandler.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threadinitialize.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threadloadenv.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threadready.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/threadreset.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threadrestart.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threadsetpriority.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threadsetstate.c
@@ -158,10 +166,7 @@ librtems_a_SOURCES += $(cpukitdir)/score/src/watchdogadjust.c
librtems_a_SOURCES += $(cpukitdir)/score/src/watchdogadjusttochain.c
librtems_a_SOURCES += $(cpukitdir)/score/src/watchdog.c
librtems_a_SOURCES += $(cpukitdir)/score/src/watchdoginsert.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/watchdognanoseconds.c
librtems_a_SOURCES += $(cpukitdir)/score/src/watchdogremove.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/watchdogreport.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/watchdogreportchain.c
librtems_a_SOURCES += $(cpukitdir)/score/src/watchdogtickle.c
librtems_a_SOURCES += $(cpukitdir)/sapi/src/debug.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/clockgetsecondssinceepoch.c
@@ -184,7 +189,9 @@ librtems_a_SOURCES += $(cpukitdir)/rtems/src/semident.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/semobtain.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/semrelease.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/semtranslatereturncode.c
+librtems_a_SOURCES += $(cpukitdir)/rtems/src/signalcatch.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/status.c
+librtems_a_SOURCES += $(cpukitdir)/rtems/src/statustext.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/tasks.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/taskdata.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/taskmode.c
@@ -198,6 +205,9 @@ librtems_a_SOURCES += $(cpukitdir)/rtems/src/tasksuspend.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/tasksetpriority.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/taskmode.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/taskwakeafter.c
+librtems_a_SOURCES += $(cpukitdir)/posix/src/key.c
+librtems_a_SOURCES += $(cpukitdir)/posix/src/keyfreememory.c
+librtems_a_SOURCES += $(cpukitdir)/posix/src/keyrundestructors.c
librtems_a_SOURCES += $(cpukitdir)/libcsupport/src/assoclocalbyname.c
librtems_a_SOURCES += $(cpukitdir)/libcsupport/src/assoclocalbyremotebitfield.c
librtems_a_SOURCES += $(cpukitdir)/libcsupport/src/assoclocalbyremote.c
@@ -228,15 +238,12 @@ librtems_a_SOURCES += $(cpukitdir)/libmisc/stringto/stringtounsignedlong.c
if HAS_SMP
librtems_a_SOURCES += $(cpukitdir)/score/src/smp.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/smplock.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/isrsmp.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threaddisabledispatch.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threadenabledispatch.c
librtems_a_SOURCES += $(cpukitdir)/score/src/threaddispatchdisablelevel.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimplesmpblock.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimplesmpschedule.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimplesmptick.c
-librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimplesmpunblock.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerprioritysmp.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimplesmp.c
+librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersmpstartidle.c
endif
schedsim_includedir = $(includedir)/schedsim
@@ -251,7 +258,6 @@ schedsim_rtems_include_HEADERS = \
${cpukitdir}/score/include//rtems/seterr.h \
${cpukitdir}/score/include/rtems/system.h \
${cpukitdir}/score/include/rtems/debug.h \
- ${cpukitdir}/score/include/rtems/bspsmp.h \
${cpukitdir}/include/rtems/bspIo.h \
$(cpukitdir)/sapi/include/rtems/fatal.h \
$(cpukitdir)/sapi/include/rtems/init.h \
@@ -322,36 +328,7 @@ schedsim_rtems_score_include_HEADERS = \
${cpukitdir}/score/include/rtems/score/schedulerpriority.h \
${cpukitdir}/score/include/rtems/score/schedulersimple.h \
${cpukitdir}/score/include/rtems/score/timespec.h \
- ${cpukitdir}/score/include/rtems/score/tqdata.h \
- ${cpukitdir}/score/include/rtems/score/bitfield.h \
${cpukitdir}/score/include/rtems/score/interr.h \
- $(cpukitdir)/score/inline/rtems/score/address.inl \
- $(cpukitdir)/score/inline/rtems/score/corespinlock.inl \
- $(cpukitdir)/score/inline/rtems/score/priority.inl \
- $(cpukitdir)/score/inline/rtems/score/threadmp.inl \
- $(cpukitdir)/score/inline/rtems/score/chain.inl \
- $(cpukitdir)/score/inline/rtems/score/heap.inl \
- $(cpukitdir)/score/inline/rtems/score/scheduler.inl \
- $(cpukitdir)/score/inline/rtems/score/threadq.inl \
- $(cpukitdir)/score/inline/rtems/score/corebarrier.inl \
- $(cpukitdir)/score/inline/rtems/score/isr.inl \
- $(cpukitdir)/score/inline/rtems/score/schedulerpriority.inl \
- $(cpukitdir)/score/inline/rtems/score/tod.inl \
- $(cpukitdir)/score/inline/rtems/score/coremsg.inl \
- $(cpukitdir)/score/inline/rtems/score/mppkt.inl \
- $(cpukitdir)/score/inline/rtems/score/stack.inl \
- $(cpukitdir)/score/inline/rtems/score/tqdata.inl \
- $(cpukitdir)/score/inline/rtems/score/coremutex.inl \
- $(cpukitdir)/score/inline/rtems/score/object.inl \
- $(cpukitdir)/score/inline/rtems/score/states.inl \
- $(cpukitdir)/score/inline/rtems/score/watchdog.inl \
- $(cpukitdir)/score/inline/rtems/score/corerwlock.inl \
- $(cpukitdir)/score/inline/rtems/score/objectmp.inl \
- $(cpukitdir)/score/inline/rtems/score/sysstate.inl \
- $(cpukitdir)/score/inline/rtems/score/wkspace.inl \
- $(cpukitdir)/score/inline/rtems/score/coresem.inl \
- $(cpukitdir)/score/inline/rtems/score/prioritybitmap.inl \
- $(cpukitdir)/score/inline/rtems/score/thread.inl \
sched_cpu/rtems/score/cpu_asm.h \
$(top_builddir)/score/include/rtems/score/cpuopts.h \
sched_cpu/rtems/score/cpu.h \
@@ -367,7 +344,6 @@ schedsim_rtems_rtems_include_HEADERS = \
${cpukitdir}/rtems/include/rtems/rtems/config.h \
${cpukitdir}/rtems/include/rtems/rtems/ratemon.h \
${cpukitdir}/rtems/include/rtems/rtems/rtemsapi.h \
- ${cpukitdir}/rtems/include/rtems/rtems/eventset.h \
${cpukitdir}/rtems/include/rtems/rtems/mp.h \
${cpukitdir}/rtems/include/rtems/rtems/dpmem.h \
${cpukitdir}/rtems/include/rtems/rtems/status.h \
@@ -393,24 +369,7 @@ schedsim_rtems_rtems_include_HEADERS = \
${cpukitdir}/rtems/include/rtems/rtems/support.h \
${cpukitdir}/rtems/include/rtems/rtems/signal.h \
${cpukitdir}/rtems/include/rtems/rtems/barrier.h \
- ${cpukitdir}/rtems/include/rtems/rtems/tasks.h \
- $(cpukitdir)/rtems/inline/rtems/rtems/asr.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/eventset.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/ratemon.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/tasks.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/attr.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/message.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/region.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/timer.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/barrier.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/modes.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/sem.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/dpmem.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/options.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/status.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/event.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/part.inl \
- $(cpukitdir)/rtems/inline/rtems/rtems/support.inl
+ ${cpukitdir}/rtems/include/rtems/rtems/tasks.h
schedsim_include_HEADERS += rtems_sched.h
diff --git a/schedsim/rtems/rtems_init.c b/schedsim/rtems/rtems_init.c
index 26343bc..2d44fba 100644
--- a/schedsim/rtems/rtems_init.c
+++ b/schedsim/rtems/rtems_init.c
@@ -1,7 +1,9 @@
/*
* BASED UPON SOURCE IN RTEMS, MODIFIED FOR SIMULATOR
- *
- * COPYRIGHT (c) 1989-2013.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -12,18 +14,43 @@
#define SAPI_INIT
#define SCORE_INIT
#define RTEMS_API_INIT
+#define POSIX_API_INIT
+
+#include <rtems/system.h>
+#include <rtems/config.h>
+#include <rtems/debug.h>
+#include <rtems/extensionimpl.h>
+#include <rtems/fatal.h>
+#include <rtems/init.h>
+#include <rtems/io.h>
+#include <rtems/score/sysstate.h>
-#include <rtems.h>
#include <rtems/score/apiext.h>
-#include <rtems/score/bitfield.h>
#include <rtems/score/apimutex.h>
+#include <rtems/score/cpusetimpl.h>
#include <rtems/score/userextimpl.h>
+#include <rtems/score/schedulerimpl.h>
+#include <rtems/score/smpimpl.h>
+#include <rtems/score/threadimpl.h>
+#include <rtems/score/todimpl.h>
+#include <rtems/score/watchdogimpl.h>
#include <rtems/score/wkspace.h>
+#include <rtems/rtems/tasksimpl.h>
+#include <rtems/rtems/semimpl.h>
+
+#include <rtems/posix/keyimpl.h>
+
+/*
+ * Declare Object Information tables directly here instead of API
+ * specific initialization files as in cpukit/sapi/src.
+ */
Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
Objects_Information *_RTEMS_Objects[ OBJECTS_RTEMS_CLASSES_LAST + 1 ];
+Objects_Information *_POSIX_Objects[ OBJECTS_POSIX_CLASSES_LAST + 1 ];
+
extern void check_heir_and_executing(void);
void rtems_initialize_data_structures(void)
@@ -40,18 +67,7 @@ void rtems_initialize_data_structures(void)
_Thread_Dispatch_initialization();
- /*
- * Before this is called, we are not allowed to allocate memory
- * from the Workspace because it is not initialized.
- */
- _Workspace_Handler_initialization(NULL, 0, NULL);
-
- #if defined(RTEMS_SMP)
- _SMP_Handler_initialize();
- #endif
-
_User_extensions_Handler_initialization();
-
_ISR_Handler_initialization();
/*
@@ -59,10 +75,10 @@ void rtems_initialize_data_structures(void)
*/
_Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects;
- _API_Mutex_Initialization( 1 );
+ _API_Mutex_Initialization( 2 );
_API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
+ _API_Mutex_Allocate( &_Once_Mutex );
- _Priority_bit_map_Handler_initialization();
_Watchdog_Handler_initialization();
_TOD_Handler_initialization();
@@ -70,6 +86,9 @@ void rtems_initialize_data_structures(void)
_Scheduler_Handler_initialization();
+ _SMP_Handler_initialize();
+
+ _CPU_set_Handler_initialization();
/* MANAGERS */
/*
@@ -82,12 +101,17 @@ void rtems_initialize_data_structures(void)
_Semaphore_Manager_initialization();
/*
+ * Install our API Object Management Table and initialize the
+ * various managers.
+ */
+ _Objects_Information_table[OBJECTS_POSIX_API] = _POSIX_Objects;
+
+ _POSIX_Key_Manager_initialization();
+
+ /*
* Discover and initialize the secondary cores in an SMP system.
*/
- #if defined(RTEMS_SMP)
- _SMP_Processor_count =
- bsp_smp_initialize( rtems_configuration_smp_maximum_processors );
- #endif
+ _SMP_Handler_initialize();
_System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
@@ -104,14 +128,20 @@ void rtems_initialize_data_structures(void)
* Scheduling can properly occur now as long as we avoid dispatching.
*/
- _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING );
+ _System_state_Set( SYSTEM_STATE_UP );
+
+ _SMP_Request_start_multitasking();
_Thread_Start_multitasking();
/*
* Now we are back in a non-dispatching critical section
*/
- _Thread_Dispatch_set_disable_level(0);
+ #if defined(RTEMS_SMP)
+ #error "NOT IMPLEMENTED"
+ #else
+ _Thread_Enable_dispatch();
+ #endif
/*
* Print an initial message
diff --git a/schedsim/rtems/sched_cpu/cpu_asm.c b/schedsim/rtems/sched_cpu/cpu_asm.c
index 45ab43f..0928794 100644
--- a/schedsim/rtems/sched_cpu/cpu_asm.c
+++ b/schedsim/rtems/sched_cpu/cpu_asm.c
@@ -1,14 +1,14 @@
-/* cpu_asm.c ===> cpu_asm.S or cpu_asm.s
- * BASED UPON SOURCE IN RTEMS, MODIFIED FOR SIMULATOR
- *
- *
- * This file contains the basic algorithms for all assembly code used
- * in an specific CPU port of RTEMS. These algorithms must be implemented
- * in assembly language
+/**
+ * @file
*
- * NOTE: This is supposed to be a .S or .s file NOT a C file.
+ * BASED UPON SOURCE IN RTEMS, MODIFIED FOR SIMULATOR
*
- * COPYRIGHT (c) 1989-2013.
+ * Every method in this file is stubbed. There are no real
+ * context switches or interrupts.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -16,36 +16,12 @@
* http://www.rtems.com/license/LICENSE.
*/
-/*
- * This is supposed to be an assembly file. This means that system.h
- * and cpu.h should not be included in a "real" cpu_asm file. An
- * implementation in assembly should include "cpu_asm.h>
- */
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/system.h>
#include <rtems/score/cpu.h>
-/* #include "cpu_asm.h> */
-
-/*
- * _CPU_Context_save_fp_context
- *
- * This routine is responsible for saving the FP context
- * at *fp_context_ptr. If the point to load the FP context
- * from is changed then the pointer is modified by this routine.
- *
- * Sometimes a macro implementation of this is in cpu.h which dereferences
- * the ** and a similarly named routine in this file is passed something
- * like a (Context_Control_fp *). The general rule on making this decision
- * is to avoid writing assembly language.
- *
- * NO_CPU Specific Information:
- *
- * XXX document implementation including references if appropriate
- */
void _CPU_Context_save_fp(
Context_Control_fp **fp_context_ptr
@@ -53,38 +29,12 @@ void _CPU_Context_save_fp(
{
}
-/*
- * _CPU_Context_restore_fp_context
- *
- * This routine is responsible for restoring the FP context
- * at *fp_context_ptr. If the point to load the FP context
- * from is changed then the pointer is modified by this routine.
- *
- * Sometimes a macro implementation of this is in cpu.h which dereferences
- * the ** and a similarly named routine in this file is passed something
- * like a (Context_Control_fp *). The general rule on making this decision
- * is to avoid writing assembly language.
- *
- * NO_CPU Specific Information:
- *
- * XXX document implementation including references if appropriate
- */
-
void _CPU_Context_restore_fp(
Context_Control_fp **fp_context_ptr
)
{
}
-/* _CPU_Context_switch
- *
- * This routine performs a normal non-FP context switch.
- *
- * NO_CPU Specific Information:
- *
- * XXX document implementation including references if appropriate
- */
-
void _CPU_Context_switch(
Context_Control *run,
Context_Control *heir
@@ -92,95 +42,12 @@ void _CPU_Context_switch(
{
}
-/*
- * _CPU_Context_restore
- *
- * This routine is generally used only to restart self in an
- * efficient manner. It may simply be a label in _CPU_Context_switch.
- *
- * NOTE: May be unnecessary to reload some registers.
- *
- * NO_CPU Specific Information:
- *
- * XXX document implementation including references if appropriate
- */
-
void _CPU_Context_restore(
Context_Control *new_context
)
{
}
-/* void __ISR_Handler()
- *
- * This routine provides the RTEMS interrupt management.
- *
- * NO_CPU Specific Information:
- *
- * XXX document implementation including references if appropriate
- */
-
void _ISR_Handler(void)
{
- /*
- * This discussion ignores a lot of the ugly details in a real
- * implementation such as saving enough registers/state to be
- * able to do something real. Keep in mind that the goal is
- * to invoke a user's ISR handler which is written in C and
- * uses a certain set of registers.
- *
- * Also note that the exact order is to a large extent flexible.
- * Hardware will dictate a sequence for a certain subset of
- * _ISR_Handler while requirements for setting
- */
-
- /*
- * At entry to "common" _ISR_Handler, the vector number must be
- * available. On some CPUs the hardware puts either the vector
- * number or the offset into the vector table for this ISR in a
- * known place. If the hardware does not give us this information,
- * then the assembly portion of RTEMS for this port will contain
- * a set of distinct interrupt entry points which somehow place
- * the vector number in a known place (which is safe if another
- * interrupt nests this one) and branches to _ISR_Handler.
- *
- * save some or all context on stack
- * may need to save some special interrupt information for exit
- *
- * #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE )
- * if ( _ISR_Nest_level == 0 )
- * switch to software interrupt stack
- * #endif
- *
- * _ISR_Nest_level++;
- *
- * _Thread_Dispatch_disable_level++;
- *
- * (*_ISR_Vector_table[ vector ])( vector );
- *
- * _Thread_Dispatch_disable_level--;
- *
- * --_ISR_Nest_level;
- *
- * if ( _ISR_Nest_level )
- * goto the label "exit interrupt (simple case)"
- *
- * if ( _Thread_Dispatch_disable_level )
- * _ISR_Signals_to_thread_executing = FALSE;
- * goto the label "exit interrupt (simple case)"
- *
- * if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) {
- * _ISR_Signals_to_thread_executing = FALSE;
- * call _Thread_Dispatch() or prepare to return to _ISR_Dispatch
- * prepare to get out of interrupt
- * return from interrupt (maybe to _ISR_Dispatch)
- *
- * LABEL "exit interrupt (simple case):
- * #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE )
- * if outermost interrupt
- * restore stack
- * #endif
- * prepare to get out of interrupt
- * return from interrupt
- */
}
diff --git a/schedsim/rtems/sched_cpu/rtems/score/cpu.h b/schedsim/rtems/sched_cpu/rtems/score/cpu.h
index 5ab67f0..219a347 100644
--- a/schedsim/rtems/sched_cpu/rtems/score/cpu.h
+++ b/schedsim/rtems/sched_cpu/rtems/score/cpu.h
@@ -291,7 +291,7 @@ extern "C" {
*
* XXX document implementation including references if appropriate
*/
-#define CPU_USE_DEFERRED_FP_SWITCH TRUE
+#define CPU_USE_DEFERRED_FP_SWITCH FALSE
/**
* Does this port provide a CPU dependent IDLE task implementation?
@@ -461,6 +461,10 @@ extern "C" {
* XXX document implementation including references if appropriate
*/
+typedef struct {
+ /* There is no CPU specific per-CPU state */
+} CPU_Per_CPU_control;
+
/**
* @ingroup CPUContext Management
* This defines the minimal set of integer and processor state registers
@@ -834,7 +838,7 @@ uint32_t _CPU_ISR_Get_level( void );
* XXX document implementation including references if appropriate
*/
#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \
- _isr, _entry_point, _is_fp ) \
+ _isr, _entry_point, _is_fp, tls_area ) \
{ \
}
@@ -1123,6 +1127,15 @@ void _CPU_ISR_install_vector(
*/
void _CPU_Install_interrupt_stack( void );
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+CPU_Counter_ticks _CPU_Counter_difference(
+ CPU_Counter_ticks second,
+ CPU_Counter_ticks first
+);
+
/**
* This routine is the CPU dependent IDLE thread body.
*
@@ -1204,6 +1217,25 @@ void _CPU_Context_restore_fp(
Context_Control_fp **fp_context_ptr
);
+#ifdef RTEMS_SMP
+ #define _CPU_Context_switch_to_first_task_smp(_context )
+
+ RTEMS_COMPILER_PURE_ATTRIBUTE static inline uint32_t
+ _CPU_SMP_Get_current_processor( void )
+ {
+ return 0;
+ }
+
+ #define _CPU_SMP_Send_interrupt( dest);
+
+ static inline void _CPU_SMP_Processor_event_broadcast( void )
+ {
+ }
+
+ static inline void _CPU_SMP_Processor_event_receive( void )
+ {
+ }
+#endif
typedef struct {
uint32_t trap;
CPU_Interrupt_frame *isf;
@@ -1283,8 +1315,6 @@ void __SMP_cpu_swap(
*(_a) = _value; \
} while (0)
-#define _CPU_Context_switch_to_first_task_smp(_ignored)
-
#ifdef __cplusplus
}
#endif
diff --git a/schedsim/rtems/sched_cpu/rtems/score/cpusmplock.h b/schedsim/rtems/sched_cpu/rtems/score/cpusmplock.h
new file mode 100644
index 0000000..41e68af
--- /dev/null
+++ b/schedsim/rtems/sched_cpu/rtems/score/cpusmplock.h
@@ -0,0 +1,118 @@
+/**
+ * @file
+ *
+ * @ingroup ScoreSMPLockCPU
+ *
+ * @brief CPU SMP Lock Implementation
+ */
+
+/*
+ * Copyright (c) 2013 embedded brains GmbH
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifndef _RTEMS_SCORE_NO_CPU_SMPLOCK_H
+#define _RTEMS_SCORE_NO_CPU_SMPLOCK_H
+
+#include <rtems/score/cpu.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup ScoreSMPLockCPU CPU SMP Locks
+ *
+ * @ingroup ScoreSMPLock
+ *
+ * This example will implement a ticket lock.
+ *
+ * @{
+ */
+
+/**
+ * @brief CPU SMP lock control.
+ */
+typedef struct {
+ unsigned int next_ticket;
+ unsigned int now_serving;
+} CPU_SMP_lock_Control;
+
+/**
+ * @brief CPU SMP lock control initializer for static initialization.
+ */
+#define CPU_SMP_LOCK_INITIALIZER { 0, 0 }
+
+/**
+ * @brief Initializes a CPU SMP lock control.
+ *
+ * @param[out] lock The CPU SMP lock control.
+ */
+static inline void _CPU_SMP_lock_Initialize( CPU_SMP_lock_Control *lock )
+{
+ lock->next_ticket = 0;
+ lock->now_serving = 0;
+}
+
+/**
+ * @brief Acquires a CPU SMP lock.
+ *
+ * @param[in,out] lock The CPU SMP lock control.
+ */
+static inline void _CPU_SMP_lock_Acquire( CPU_SMP_lock_Control *lock )
+{
+#if 0
+ unsigned int my_ticket = _Atomic_Fetch_and_increment( &lock->next_ticket );
+
+ while ( _Atomic_Load_and_acquire( &lock->now_serving ) != my_ticket ) {
+ _Wait_some_time();
+ }
+#endif
+}
+
+/**
+ * @brief Releases a CPU SMP lock.
+ *
+ * @param[in,out] lock The CPU SMP lock control.
+ */
+static inline void _CPU_SMP_lock_Release( CPU_SMP_lock_Control *lock )
+{
+#if 0
+ _Atomic_Store_and_release( &lock->now_serving, lock->now_serving + 1 );
+#endif
+}
+
+/**
+ * @brief Disables interrupts and acquires the CPU SMP lock.
+ *
+ * @param[in,out] lock The CPU SMP lock control.
+ * @param[out] isr_cookie The ISR cookie.
+ */
+#define _CPU_SMP_lock_ISR_disable_and_acquire( lock, isr_cookie ) \
+ do { \
+ _CPU_ISR_Disable( isr_cookie ); \
+ _CPU_SMP_lock_Acquire( lock ); \
+ } while (0)
+
+/**
+ * @brief Releases the CPU SMP lock and enables interrupts.
+ *
+ * @param[in,out] lock The CPU SMP lock control.
+ * @param[in] isr_cookie The ISR cookie.
+ */
+#define _CPU_SMP_lock_Release_and_ISR_enable( lock, isr_cookie ) \
+ do { \
+ _CPU_SMP_lock_Release( lock ); \
+ _CPU_ISR_Enable( isr_cookie ); \
+ } while (0)
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _RTEMS_SCORE_NO_CPU_SMPLOCK_H */
diff --git a/schedsim/rtems/sched_cpu/rtems/score/types.h b/schedsim/rtems/sched_cpu/rtems/score/types.h
index 98c1db8..bebbef3 100644
--- a/schedsim/rtems/sched_cpu/rtems/score/types.h
+++ b/schedsim/rtems/sched_cpu/rtems/score/types.h
@@ -31,8 +31,7 @@ extern "C" {
* This section defines the basic types for this processor.
*/
-/** This defines the type for a priority bit map entry. */
-typedef uint16_t Priority_bit_map_Control;
+typedef uint16_t Priority_bit_map_Word;
/** This defines the return type for an ISR entry point. */
typedef void no_cpu_isr;
diff --git a/schedsim/rtems/wkspace.c b/schedsim/rtems/wkspace.c
index de9f76c..61fbb47 100644
--- a/schedsim/rtems/wkspace.c
+++ b/schedsim/rtems/wkspace.c
@@ -20,7 +20,9 @@
#include <rtems/score/interr.h>
#include <stdlib.h>
+#include <malloc.h>
+#define DEBUG_WORKSPACE
#if defined(DEBUG_WORKSPACE)
#include <stdio.h>
#endif
@@ -59,6 +61,27 @@ void *_Workspace_Allocate(
return memory;
}
+void *_Workspace_Allocate_aligned( size_t size, size_t alignment )
+{
+ void *memory;
+ int sc;
+
+ memory = memalign( alignment, size );
+ #if defined(DEBUG_WORKSPACE)
+ fprintf(
+ stderr,
+ "Workspace_Allocate_aligned(%d, %d) from %p/%p -> %p\n",
+ size,
+ alignment,
+ __builtin_return_address( 0 ),
+ __builtin_return_address( 1 ),
+ memory
+ );
+ #endif
+ return memory;
+}
+
+
/*
* _Workspace_Free
*/
diff --git a/schedsim/shell/schedsim_priority/Makefile.am b/schedsim/shell/schedsim_priority/Makefile.am
index 32febc6..378aea2 100644
--- a/schedsim/shell/schedsim_priority/Makefile.am
+++ b/schedsim/shell/schedsim_priority/Makefile.am
@@ -26,7 +26,16 @@ schedsim_priority_CPPFLAGS += -I$(cpukitdir)/posix/include
schedsim_priority_CPPFLAGS += -I$(cpukitdir)/posix/inline
endif
-schedsim_priority_LDFLAGS =-Wl,--wrap=_Thread_Dispatch
+## Ensure all linker provided symbols are available
+schedsim_priority_LDFLAGS =
+schedsim_priority_LDFLAGS += -Wl,--defsym=_TLS_Data_begin=0
+schedsim_priority_LDFLAGS += -Wl,--defsym=_TLS_BSS_end=0
+schedsim_priority_LDFLAGS += -Wl,--defsym=_TLS_Alignment=4
+
+## Wrap _Thread_Dispatch so we can see context switches
+schedsim_priority_LDFLAGS += -Wl,--wrap=_Thread_Dispatch
+
+## Link in all support libraries
## schedsim_priorityLDADD +=-Wl,--start-group
schedsim_priority_LDADD = ../shared/libschedsim.a
schedsim_priority_LDADD += ../../rtems/librtems.a
diff --git a/schedsim/shell/schedsim_priority/smp_stub.c b/schedsim/shell/schedsim_priority/smp_stub.c
index d7c7323..c2f1308 100644
--- a/schedsim/shell/schedsim_priority/smp_stub.c
+++ b/schedsim/shell/schedsim_priority/smp_stub.c
@@ -24,12 +24,12 @@ int bsp_smp_processor_id(void)
return 0;
}
-int bsp_smp_initialize(
- int maximum
+uint32_t bsp_smp_initialize(
+ uint32_t configured_cpu_count
)
{
/* return the number of CPUs */
- return maximum;
+ return configured_cpu_count;
}
void bsp_smp_broadcast_interrupt(void)
diff --git a/schedsim/shell/schedsim_smpsimple/main_dispatch.c b/schedsim/shell/schedsim_smpsimple/main_dispatch.c
index 5f13da6..4c1461f 100644
--- a/schedsim/shell/schedsim_smpsimple/main_dispatch.c
+++ b/schedsim/shell/schedsim_smpsimple/main_dispatch.c
@@ -31,7 +31,7 @@ int main_dispatch(int argc, char **argv)
current_cpu = Schedsim_Current_cpu;
for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) {
- if ( _Per_CPU_Information[cpu].dispatch_necessary ) {
+ if ( _Per_CPU_Information[cpu].per_cpu.dispatch_necessary ) {
printf( "=== Invoke Thread Dispatch on CPU %d\n", cpu );
Schedsim_Current_cpu = cpu;
_Thread_Dispatch();
diff --git a/schedsim/shell/schedsim_smpsimple/main_dump_all_cpus.c b/schedsim/shell/schedsim_smpsimple/main_dump_all_cpus.c
index 7e19065..faa4de7 100644
--- a/schedsim/shell/schedsim_smpsimple/main_dump_all_cpus.c
+++ b/schedsim/shell/schedsim_smpsimple/main_dump_all_cpus.c
@@ -36,16 +36,15 @@ int main_dump_all_cpus(int argc, char **argv)
" SWITCH NEEDED\n"
);
for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) {
- e = _Per_CPU_Information[cpu].executing;
- h = _Per_CPU_Information[cpu].heir;
- i = _Per_CPU_Information[cpu].idle;
+ e = _Per_CPU_Information[cpu].per_cpu.executing;
+ h = _Per_CPU_Information[cpu].per_cpu.heir;
printf(
- " CPU %d: 0x%08x @%3ld / 0x%08x @%3ld / 0x%08x @%3ld %s\n",
+ " CPU %d: 0x%08x @%3ld / 0x%08x @%3ld %s\n",
cpu,
e->Object.id, (long) e->current_priority,
h->Object.id, (long) h->current_priority,
- i->Object.id, (long) i->current_priority,
- ((_Per_CPU_Information[cpu].dispatch_necessary) ? "true" : "false")
+ ((_Per_CPU_Information[cpu].per_cpu.dispatch_necessary) ?
+ "true" : "false")
);
}
printf( "=== End of Ready Set of Threads\n" );
diff --git a/schedsim/shell/schedsim_smpsimple/main_dump_ready_tasks.c b/schedsim/shell/schedsim_smpsimple/main_dump_ready_tasks.c
index 2ee875b..ba9a9cd 100644
--- a/schedsim/shell/schedsim_smpsimple/main_dump_ready_tasks.c
+++ b/schedsim/shell/schedsim_smpsimple/main_dump_ready_tasks.c
@@ -15,6 +15,8 @@
#include "shell.h"
#include "rtems_sched.h"
+#include <rtems/score/chainimpl.h>
+#include <rtems/score/thread.h>
#include <rtems/score/schedulerpriority.h>
diff --git a/schedsim/shell/schedsim_smpsimple/smp_stub.c b/schedsim/shell/schedsim_smpsimple/smp_stub.c
index 581f4ac..fc9c1dd 100644
--- a/schedsim/shell/schedsim_smpsimple/smp_stub.c
+++ b/schedsim/shell/schedsim_smpsimple/smp_stub.c
@@ -15,6 +15,7 @@
#include <stdlib.h>
uint32_t Schedsim_Current_cpu;
+extern uint32_t Schedsim_Maximum_CPUs_From_Command_Line;
void bsp_smp_secondary_cpu_initialize(int cpu)
{
@@ -26,12 +27,20 @@ int bsp_smp_processor_id(void)
return Schedsim_Current_cpu;
}
-int bsp_smp_initialize(
- int maximum
+uint32_t bsp_smp_initialize(
+ uint32_t configured_cpu_count
)
{
+ if ( configured_cpu_count < Schedsim_Maximum_CPUs_From_Command_Line ) {
+ printf(
+ "ERROR - Maximum cores per confdefs.h is %d\n",
+ configured_cpu_count
+ );
+ exit( 1 );
+ }
+
/* return the number of CPUs */
- return maximum;
+ return Schedsim_Maximum_CPUs_From_Command_Line;
}
void bsp_smp_broadcast_interrupt(void)
diff --git a/schedsim/shell/shared/main_rtemsinit.c b/schedsim/shell/shared/main_rtemsinit.c
index 51510d6..063316a 100644
--- a/schedsim/shell/shared/main_rtemsinit.c
+++ b/schedsim/shell/shared/main_rtemsinit.c
@@ -22,8 +22,11 @@
#if defined(RTEMS_SMP)
#include <rtems/score/smp.h>
+
+ uint32_t Schedsim_Maximum_CPUs_From_Command_Line;
#endif
+
int rtems_shell_main_rtems_init(
int argc,
char *argv[]
@@ -37,7 +40,7 @@ int rtems_shell_main_rtems_init(
printf( "Number of CPUs argument (%s) is not a number\n", argv[1] );
return -1;
}
- rtems_configuration_smp_maximum_processors = cpus;
+ Schedsim_Maximum_CPUs_From_Command_Line = cpus;
}
#endif
diff --git a/schedsim/shell/shared/schedsim_shell.h b/schedsim/shell/shared/schedsim_shell.h
index c6de989..d1f2406 100644
--- a/schedsim/shell/shared/schedsim_shell.h
+++ b/schedsim/shell/shared/schedsim_shell.h
@@ -13,6 +13,7 @@
#define __SCHEDSIM_SHELL_h
#include <rtems.h>
+#include <rtems/score/sysstate.h>
#ifdef __cplusplus
extern "C" {