]> rtime.felk.cvut.cz Git - orte.git/blob - orte/examples/rtems-shell/init.c
37293b40002f2f478ff14e482037cb5f598ee843
[orte.git] / orte / examples / rtems-shell / 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 "rtems_shell_local_config.h"
25 #include "system.h"
26 #include "app_def.h"
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <rtems/error.h>
30 #include <rtems/monitor.h>
31 #include <rtems/shell.h>
32
33 #include <rtems/rtems_bsdnet.h>
34
35 #include <orte_rtems_shell.h>
36
37 #include <sys/types.h>
38 #include <sys/socket.h>
39 #include <netinet/in.h>
40 #include <arpa/inet.h>
41 #include <string.h>
42 #include <unistd.h>
43
44 #define CONFIGURE_SHELL_COMMANDS_INIT
45 #define CONFIGURE_SHELL_COMMANDS_ALL
46 #define CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING
47 #define CONFIGURE_SHELL_MOUNT_MSDOS
48 #define CONFIGURE_SHELL_MOUNT_NFS
49
50 #include <rtems/shellconfig.h>
51
52 #define BUILD_VERSION_STRING(major,minor,patch) \
53         __XSTRING(major) "." __XSTRING(minor) "." __XSTRING(patch)
54
55 #ifndef VER_CODE
56   #define VER_CODE(major,minor,patch) (major*0x10000+minor*0x100+patch)
57 #endif
58
59 #define RTEMS_VER_CODE VER_CODE(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__)
60
61 #if RTEMS_VER_CODE < VER_CODE(4,10,99)
62   #ifndef RTEMS_USE_LOOPBACK
63     #define RTEMS_USE_LOOPBACK 1
64   #endif
65 #endif
66
67 #include "networkconfig.h"
68
69 #if RTEMS_VER_CODE < VER_CODE(4,7,99)
70   #define rtems_shell_add_cmd shell_add_cmd
71   #define rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait,m_login_check) \
72                 shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,B19200 | CS8,m_forever)
73 #elif RTEMS_VER_CODE < VER_CODE(4,9,99)
74   #define rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait,m_login_check) \
75           rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait)
76 #endif
77
78 void
79 bad_rtems_status(rtems_status_code status, int fail_level, const char *text)
80 {
81   printf("ERROR: %s status %s", text, rtems_status_text(status));
82   status = rtems_task_delete( RTEMS_SELF );
83 }
84
85 int testcmd_forshell(int argc, char **argv)
86 {
87   int i;
88   printf("Command %s called\n",argv[0]);
89   for(i=1;i<argc;i++)
90     if(argv[i])
91       printf("%s",argv[i]);
92   printf("\n");
93   return 0;
94 }
95
96 rtems_task Init(
97   rtems_task_argument ignored
98 )
99 {
100   rtems_status_code status;
101
102   printf( "\n\nRTEMS v "
103           BUILD_VERSION_STRING(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__)
104           "\n");
105
106   rtems_monitor_init(RTEMS_MONITOR_SUSPEND|RTEMS_MONITOR_GLOBAL);
107   /*rtems_capture_cli_init (0);*/
108
109   if (rtems_bsdnet_initialize_network() < 0)
110     printf( "Network initialization failed\n");
111   else
112     printf( "Network initialization OK\n");
113
114
115   printf( "Starting shell with ORTE commands included\n" );
116
117   rtems_shell_init("SHLL",RTEMS_MINIMUM_STACK_SIZE+0x1000,
118               SHELL_TASK_PRIORITY,"/dev/console",1,0, NULL);
119
120   rtems_shell_add_cmd("testcmd", "app",
121                 "test command for shell",
122                 testcmd_forshell);
123
124  #ifdef CONFIG_OC_ETH_ORTE_MANAGER
125   rtems_shell_add_cmd("ortemanager", "orte",
126                 "start orte manager",
127                 ortemanager_main);
128  #endif /*CONFIG_OC_ETH_ORTE_MANAGER*/
129
130  #ifdef CONFIG_OC_ETH_ORTE_EXAMPLES
131   rtems_shell_add_cmd("orte_h_publisher", "orte",
132                 "start orte_h_publisher",
133                 orte_h_publisher_main);
134
135   rtems_shell_add_cmd("orte_h_subscriber", "orte",
136                 "start orte_h_subscriber",
137                 orte_h_subscriber_main);
138
139   rtems_shell_add_cmd("orte_m_subscriber", "orte",
140                 "start orte_m_subscriber",
141                 orte_m_subscriber_main);
142
143   rtems_shell_add_cmd("orteping", "orte",
144                 "start orteping",
145                 orte_ping_main);
146
147   rtems_shell_add_cmd("orte_spy", "orte",
148                 "start orte_spy",
149                 orte_spy_main);
150
151   rtems_shell_add_cmd("orte_r_publisher", "orte",
152                 "start orte_r_publisher",
153                 orte_r_publisher_main);
154
155   rtems_shell_add_cmd("orte_r_subscriber_besteffort", "orte",
156                 "start orte_r_subscriber_besteffort",
157                 orte_r_subscriber_besteffort_main);
158
159   rtems_shell_add_cmd("orte_r_subscriber_reliable", "orte",
160                 "start orte_r_subscriber_reliable",
161                 orte_r_subscriber_reliable_main);
162  #endif /*CONFIG_OC_ETH_ORTE_EXAMPLES*/
163
164   rtems_shell_add_cmd("spawn", "orte",
165                 "spawn task or command in background",
166                 orte_spawn_main);
167
168   //rtems_monitor_wakeup();
169
170   status = rtems_task_delete( RTEMS_SELF );
171
172   printf( "*** END OF TEST2 ***\n" );
173   exit( 0 );
174 }