source: rtems/testsuites/samples/ticker/system.h @ dfc6f3dc

4.104.114.84.9
Last change on this file since dfc6f3dc was dfc6f3dc, checked in by Joel Sherrill <joel.sherrill@…>, on May 10, 2007 at 7:31:36 PM

2007-05-10 Joel Sherrill <joel.sherrill@…>

  • ticker/Makefile.am, ticker/init.c, ticker/system.h, ticker/tasks.c: Test needs clock manager. Should use rtems_test_exit() instead of exit().
  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*  system.h
2 *
3 *  This include file contains information that is included in every
4 *  function in the test set.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#include <rtems.h>
17#include <inttypes.h>
18#include "../../support/include/buffer_test_io.h"
19
20/* functions */
21
22rtems_task Init(
23  rtems_task_argument argument
24);
25
26rtems_task Test_task(
27  rtems_task_argument argument
28);
29
30/* global variables */
31
32/*
33 *  Keep the names and IDs in global variables so another task can use them.
34 */
35
36extern rtems_id   Task_id[ 4 ];         /* array of task ids */
37extern rtems_name Task_name[ 4 ];       /* array of task names */
38
39
40/* configuration information */
41
42#include <bsp.h> /* for device driver prototypes */
43
44#if defined(CONFIGURE_INIT)
45int atexit(void (*function)(void)){}
46#endif
47#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
48#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY
49
50#define CONFIGURE_MAXIMUM_TASKS             4
51
52#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
53
54#define CONFIGURE_EXTRA_TASK_STACKS         (3 * RTEMS_MINIMUM_STACK_SIZE)
55
56#include <rtems/confdefs.h>
57
58/*
59 *  Handy macros and static inline functions
60 */
61
62/*
63 *  Macro to hide the ugliness of printing the time.
64 */
65
66#define print_time(_s1, _tb, _s2) \
67  do { \
68    printf( "%s%02" PRId32 ":%02" PRId32 ":%02" PRId32 "   %02" PRId32 "/%02" PRId32 "/%04" PRId32 "%s", \
69       _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
70       (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
71  } while ( 0 )
72
73/*
74 *  Macro to print an task name that is composed of ASCII characters.
75 *
76 */
77
78#define put_name( _name, _crlf ) \
79  do { \
80    uint32_t   c0, c1, c2, c3; \
81    \
82    c0 = ((_name) >> 24) & 0xff; \
83    c1 = ((_name) >> 16) & 0xff; \
84    c2 = ((_name) >> 8) & 0xff; \
85    c3 = (_name) & 0xff; \
86    putchar( (char)c0 ); \
87    if ( c1 ) putchar( (char)c1 ); \
88    if ( c2 ) putchar( (char)c2 ); \
89    if ( c3 ) putchar( (char)c3 ); \
90    if ( (_crlf) ) \
91      putchar( '\n' ); \
92  } while (0)
93
94/*
95 *  static inline routine to make obtaining ticks per second easier.
96 */
97
98static inline uint32_t   get_ticks_per_second( void )
99{
100  rtems_interval ticks_per_second;
101  (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second );  return ticks_per_second;
102}
103
104
105/*
106 *  This allows us to view the "Test_task" instantiations as a set
107 *  of numbered tasks by eliminating the number of application
108 *  tasks created.
109 *
110 *  In reality, this is too complex for the purposes of this
111 *  example.  It would have been easier to pass a task argument. :)
112 *  But it shows how rtems_id's can sometimes be used.
113 */
114
115#define task_number( tid ) \
116  ( rtems_get_index( tid ) - \
117     rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks )
118
119/* end of include file */
Note: See TracBrowser for help on using the repository browser.