[rtems commit] Optional Classic Timer initialization

Sebastian Huber sebh at rtems.org
Wed Feb 3 09:30:30 UTC 2016


Module:    rtems
Branch:    master
Commit:    26335844f484c8cd061444cebba9480b62d165cb
Changeset: http://git.rtems.org/rtems/commit/?id=26335844f484c8cd061444cebba9480b62d165cb

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Dec 14 14:52:35 2015 +0100

Optional Classic Timer initialization

Update #2408.

---

 cpukit/rtems/Makefile.am                     |  1 -
 cpukit/rtems/include/rtems/rtems/timerimpl.h | 23 ++---------------------
 cpukit/rtems/src/rtemstimer.c                | 22 ++++++++++++----------
 cpukit/rtems/src/rtemstimerdata.c            | 23 -----------------------
 cpukit/sapi/src/rtemsapi.c                   |  2 --
 cpukit/score/include/rtems/sysinit.h         |  1 +
 testsuites/sptests/sp43/init.c               |  6 ++++++
 testsuites/sptests/sp43/sp43.scn             | 10 +++++-----
 testsuites/sptests/spsysinit01/init.c        | 17 +++++++++++++++++
 9 files changed, 43 insertions(+), 62 deletions(-)

diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index d0f3907..83ee630 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -171,7 +171,6 @@ librtems_a_SOURCES += src/timerreset.c
 librtems_a_SOURCES += src/timerserver.c
 librtems_a_SOURCES += src/timerserverfireafter.c
 librtems_a_SOURCES += src/timerserverfirewhen.c
-librtems_a_SOURCES += src/rtemstimerdata.c
 
 ## MESSAGE_QUEUE_C_FILES
 librtems_a_SOURCES += src/msg.c
diff --git a/cpukit/rtems/include/rtems/rtems/timerimpl.h b/cpukit/rtems/include/rtems/rtems/timerimpl.h
index e5b37aa..55be634 100644
--- a/cpukit/rtems/include/rtems/rtems/timerimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/timerimpl.h
@@ -35,18 +35,6 @@ extern "C" {
  * @{
  */
 
-/**
- *  @brief Instantiate RTEMS Timer Data
- *
- *  This constant is defined to extern most of the time when using
- *  this header file.  However by defining it to nothing, the data
- *  declared in this header file can be instantiated.  This is done
- *  in a single per manager file.
- */
-#ifndef RTEMS_TIMER_EXTERN
-#define RTEMS_TIMER_EXTERN extern
-#endif
-
 typedef struct Timer_server_Control Timer_server_Control;
 
 /**
@@ -128,20 +116,13 @@ struct Timer_server_Control {
  *
  * This value is @c NULL when the default timer server is not initialized.
  */
-RTEMS_TIMER_EXTERN Timer_server_Control *volatile _Timer_server;
+extern Timer_server_Control *volatile _Timer_server;
 
 /**
  *  The following defines the information control block used to manage
  *  this class of objects.
  */
-RTEMS_TIMER_EXTERN Objects_Information  _Timer_Information;
-
-/**
- *  @brief Timer Manager Initialization
- *
- *  This routine performs the initialization necessary for this manager.
- */
-void _Timer_Manager_initialization(void);
+extern Objects_Information  _Timer_Information;
 
 /**
  *  @brief Timer_Allocate
diff --git a/cpukit/rtems/src/rtemstimer.c b/cpukit/rtems/src/rtemstimer.c
index 259a81c..f591c25 100644
--- a/cpukit/rtems/src/rtemstimer.c
+++ b/cpukit/rtems/src/rtemstimer.c
@@ -20,13 +20,16 @@
 
 #include <rtems/system.h>
 #include <rtems/config.h>
+#include <rtems/sysinit.h>
 #include <rtems/rtems/status.h>
 #include <rtems/rtems/support.h>
-#include <rtems/score/thread.h>
 #include <rtems/rtems/timerimpl.h>
-#include <rtems/score/watchdog.h>
 
-void _Timer_Manager_initialization(void)
+Timer_server_Control *volatile _Timer_server;
+
+Objects_Information  _Timer_Information;
+
+static void _Timer_Manager_initialization(void)
 {
   _Objects_Initialize_information(
     &_Timer_Information,       /* object information table */
@@ -43,11 +46,10 @@ void _Timer_Manager_initialization(void)
     NULL                       /* Proxy extraction support callout */
 #endif
   );
-
-  /*
-   *  Initialize the pointer to the default timer server control block to NULL
-   *  indicating that task-based timer support is not initialized.
-   */
-
-  _Timer_server = NULL;
 }
+
+RTEMS_SYSINIT_ITEM(
+  _Timer_Manager_initialization,
+  RTEMS_SYSINIT_CLASSIC_TIMER,
+  RTEMS_SYSINIT_ORDER_MIDDLE
+);
diff --git a/cpukit/rtems/src/rtemstimerdata.c b/cpukit/rtems/src/rtemstimerdata.c
deleted file mode 100644
index 522e9cb..0000000
--- a/cpukit/rtems/src/rtemstimerdata.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- *  @file
- *
- *  @brief Instantiate RTEMS Timer Data
- *  @ingroup ClassicTimer
- */
-
-/*
- *  COPYRIGHT (c) 1989-2007.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#define RTEMS_TIMER_EXTERN
-
-#include <rtems/rtems/timerimpl.h>
diff --git a/cpukit/sapi/src/rtemsapi.c b/cpukit/sapi/src/rtemsapi.c
index 251d772..422cf6c 100644
--- a/cpukit/sapi/src/rtemsapi.c
+++ b/cpukit/sapi/src/rtemsapi.c
@@ -36,11 +36,9 @@
 #include <rtems/rtems/regionimpl.h>
 #include <rtems/rtems/semimpl.h>
 #include <rtems/rtems/signalimpl.h>
-#include <rtems/rtems/timerimpl.h>
 
 void _RTEMS_API_Initialize(void)
 {
-  _Timer_Manager_initialization();
   _Signal_Manager_initialization();
   _Event_Manager_initialization();
   _Message_queue_Manager_initialization();
diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h
index bac6663..cd60487 100644
--- a/cpukit/score/include/rtems/sysinit.h
+++ b/cpukit/score/include/rtems/sysinit.h
@@ -32,6 +32,7 @@ extern "C" {
 #define RTEMS_SYSINIT_DATA_STRUCTURES            000301
 #define RTEMS_SYSINIT_USER_EXTENSIONS            000320
 #define RTEMS_SYSINIT_CLASSIC_TASKS              000340
+#define RTEMS_SYSINIT_CLASSIC_TIMER              000341
 #define RTEMS_SYSINIT_IDLE_THREADS               000380
 #define RTEMS_SYSINIT_BSP_LIBC                   000400
 #define RTEMS_SYSINIT_BEFORE_DRIVERS             000500
diff --git a/testsuites/sptests/sp43/init.c b/testsuites/sptests/sp43/init.c
index dbea7fa..03fe5a5 100644
--- a/testsuites/sptests/sp43/init.c
+++ b/testsuites/sptests/sp43/init.c
@@ -412,6 +412,12 @@ rtems_task Init(
   print_class_info( OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TASKS, &info );
 
   puts( "rtems_object_get_class_information - Classic Timers - OK" );
+  sc = rtems_timer_create(0, NULL);
+  fatal_directive_status(
+    sc,
+    RTEMS_INVALID_NAME,
+    "rtems_timer_create"
+  );
   sc = rtems_object_get_class_information(
              OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TIMERS, &info );
   directive_failed( sc, "rtems_object_get_class_information" );
diff --git a/testsuites/sptests/sp43/sp43.scn b/testsuites/sptests/sp43/sp43.scn
index f34fc33..9594f12 100644
--- a/testsuites/sptests/sp43/sp43.scn
+++ b/testsuites/sptests/sp43/sp43.scn
@@ -1,5 +1,5 @@
-*** TEST 43 ***
-RTEMS Version: rtems-4.10.99.0(SPARC/w/FPU/sis)
+*** BEGIN OF TEST SP 43 ***
+RTEMS Version: rtems-4.11.99.0(SPARC/w/FPU/sis)
 rtems_object_get_classic_name - INVALID_ADDRESS
 rtems_object_get_classic_name - INVALID_ID (bad index)
 rtems_object_get_classic_name - INVALID_ID (unallocated index)
@@ -29,8 +29,8 @@ rtems_object_set_name - change name of init task to (N)
 N    - name returned by rtems_object_get_classic_name
 rtems_object_get_name returned (N   ) for init task
 rtems_object_set_name - change name of init task to ()
-*    - name returned by rtems_object_get_classic_name
-rtems_object_get_name returned () for init task
+     - name returned by rtems_object_get_classic_name
+rtems_object_get_name returned (    ) for init task
 rtems_object_set_name - change name of init task to (N-0x07-0x09-1)
 N**1 - name returned by rtems_object_get_classic_name
 rtems_object_get_name returned (N**1) for init task
@@ -91,4 +91,4 @@ rtems_task_set_priority - use valid Idle thread id again
 rtems_task_set_priority - restore internal thread class info
 rtems_semaphore_obtain - good but uncreated ID - INVALID_ID - OK
 rtems_object_get_classic_name - bad API pointer - INVALID_ID
-*** END OF TEST 43 ***
+*** END OF TEST SP 43 ***
diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c
index 4a707de..6d05e0f 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -26,6 +26,7 @@
 
 #include <rtems/extensionimpl.h>
 #include <rtems/rtems/tasksimpl.h>
+#include <rtems/rtems/timerimpl.h>
 #include <rtems/score/apimutex.h>
 #include <rtems/score/sysstate.h>
 #include <rtems/score/userextimpl.h>
@@ -46,6 +47,8 @@ typedef enum {
   USER_EXTENSIONS_POST,
   CLASSIC_TASKS_PRE,
   CLASSIC_TASKS_POST,
+  CLASSIC_TIMER_PRE,
+  CLASSIC_TIMER_POST,
   IDLE_THREADS_PRE,
   IDLE_THREADS_POST,
   BSP_LIBC_PRE,
@@ -163,6 +166,18 @@ LAST(RTEMS_SYSINIT_CLASSIC_TASKS)
   next_step(CLASSIC_TASKS_POST);
 }
 
+FIRST(RTEMS_SYSINIT_CLASSIC_TIMER)
+{
+  assert(_Timer_Information.maximum == 0);
+  next_step(CLASSIC_TIMER_PRE);
+}
+
+LAST(RTEMS_SYSINIT_CLASSIC_TIMER)
+{
+  assert(_Timer_Information.maximum != 0);
+  next_step(CLASSIC_TIMER_POST);
+}
+
 FIRST(RTEMS_SYSINIT_IDLE_THREADS)
 {
   assert(_System_state_Is_before_initialization(_System_state_Get()));
@@ -250,6 +265,8 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_MAXIMUM_TASKS 1
 
+#define CONFIGURE_MAXIMUM_TIMERS 1
+
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
 #define CONFIGURE_STACK_CHECKER_ENABLED




More information about the vc mailing list