]> rtime.felk.cvut.cz Git - rtems-devel.git/blob - rtems-tests/prioinh_check/init.c
Adapt tests system configurations to new RTEMS version.
[rtems-devel.git] / rtems-tests / prioinh_check / init.c
1 /*  Init
2  *
3  *  This routine is the initialization task for this test program.
4  *  It is called from init_exec and has the responsibility for creating
5  *  and starting the tasks that make up the test.  If the time of day
6  *  clock is required for the test, it should also be set to a known
7  *  value by this function.
8  *
9  *  Input parameters:  NONE
10  *
11  *  Output parameters:  NONE
12  *
13  *  COPYRIGHT (c) 1989-1999.
14  *  On-Line Applications Research Corporation (OAR).
15  *
16  *  The license and distribution terms for this file may be
17  *  found in the file LICENSE in this distribution or at
18  *  http://www.rtems.com/license/LICENSE.
19  *
20  *  $Id: init.c,v 1.12.4.1 2003/09/04 18:46:30 joel Exp $
21  */
22
23 #define CONFIGURE_INIT
24 #include "system.h"
25 #include "app_def.h"
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <rtems/error.h>
29 #include <rtems/monitor.h>
30 #include <rtems/shell.h>
31
32 #define VER_CODE(major,minor,patch) (major*0x10000+minor*0x100+patch)
33
34 #define BUILD_VERSION_STRING(major,minor,patch) \
35         __XSTRING(major) "." __XSTRING(minor) "." __XSTRING(patch)
36
37 #define RTEMS_VER_CODE VER_CODE(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__)
38
39 #if RTEMS_VER_CODE < VER_CODE(4,7,99)
40   #define rtems_shell_add_cmd shell_add_cmd
41   #define rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait,m_login_check) \
42                 shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,B19200 | CS8,m_forever)
43 #elif RTEMS_VER_CODE < VER_CODE(4,9,99)
44   #define rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait,m_login_check) \
45           rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait)
46 #endif
47
48 void 
49 bad_rtems_status(rtems_status_code status, int fail_level, const char *text)
50 {
51   printf("ERROR: %s status %s\n", text, rtems_status_text(status));
52   status = rtems_task_delete( RTEMS_SELF );
53 }
54
55 int testcmd_forshell(int argc, char **argv)
56 {
57   int i;
58   printf("Command %s called\n",argv[0]);
59   for(i=1;i<argc;i++)
60     if(argv[i])
61       printf("%s",argv[i]);
62   printf("\n");
63   return 0;
64 }
65
66 rtems_task Init(
67   rtems_task_argument ignored
68 )
69 {
70   rtems_status_code status;
71
72   printf( "\n\nRTEMS v "
73           BUILD_VERSION_STRING(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__)
74           "\n");
75   
76   rtems_monitor_init(RTEMS_MONITOR_SUSPEND|RTEMS_MONITOR_GLOBAL);
77   /*rtems_capture_cli_init (0);*/
78   
79   printf( "Starting application prioinh_check\n" );
80
81   Task_1_name = rtems_build_name( 'T', 'S', 'K', '1' );
82     
83   status = rtems_task_create(
84      Task_1_name,
85      TASK_1_PRIORITY,
86      RTEMS_MINIMUM_STACK_SIZE+0x10000,
87      RTEMS_DEFAULT_MODES /*& ~(RTEMS_TIMESLICE_MASK) | RTEMS_TIMESLICE*/,
88      RTEMS_DEFAULT_ATTRIBUTES,
89      &Task_1_id
90   );
91   check_rtems_status(status, 0, "rtems_task_create of Task_1");
92
93   status = rtems_task_start( Task_1_id, Task_1, 0 );
94   check_rtems_status(status, 0, "rtems_task_start of Task_1\n");
95
96   if(1) {
97
98     rtems_shell_init("SHLL",RTEMS_MINIMUM_STACK_SIZE+0x1000,
99               SHELL_TASK_PRIORITY,"/dev/console",1,0, NULL);
100
101     rtems_shell_add_cmd("testcmd", "app",
102                 "test command for shell",
103                 testcmd_forshell);
104
105     //rtems_monitor_wakeup();
106
107   }
108
109   status = rtems_task_delete( RTEMS_SELF );
110   
111   printf( "*** END OF TEST2 ***\n" );
112   exit( 0 );
113 }