]> rtime.felk.cvut.cz Git - orte.git/blob - orte/examples/rtems-shell/init.c
Reformat the sources with orte/uncrustify script
[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
86 testcmd_forshell(int argc, char **argv)
87 {
88   int i;
89
90   printf("Command %s called\n", argv[0]);
91   for (i = 1; i < argc; i++)
92     if (argv[i])
93       printf("%s", argv[i]);
94   printf("\n");
95   return 0;
96 }
97
98 rtems_task
99 Init(
100   rtems_task_argument ignored
101   )
102 {
103   rtems_status_code status;
104
105   printf("\n\nRTEMS v "
106          BUILD_VERSION_STRING(__RTEMS_MAJOR__, __RTEMS_MINOR__, __RTEMS_REVISION__)
107          "\n");
108
109   rtems_monitor_init(RTEMS_MONITOR_SUSPEND|RTEMS_MONITOR_GLOBAL);
110   /*rtems_capture_cli_init (0);*/
111
112   if (rtems_bsdnet_initialize_network() < 0)
113     printf("Network initialization failed\n");
114   else
115     printf("Network initialization OK\n");
116
117
118   printf("Starting shell with ORTE commands included\n");
119
120   rtems_shell_init("SHLL", RTEMS_MINIMUM_STACK_SIZE+0x1000,
121                    SHELL_TASK_PRIORITY, "/dev/console", 1, 0, NULL);
122
123   rtems_shell_add_cmd("testcmd", "app",
124                       "test command for shell",
125                       testcmd_forshell);
126
127  #ifdef CONFIG_OC_ETH_ORTE_MANAGER
128   rtems_shell_add_cmd("ortemanager", "orte",
129                       "start orte manager",
130                       ortemanager_main);
131  #endif /*CONFIG_OC_ETH_ORTE_MANAGER*/
132
133  #ifdef CONFIG_OC_ETH_ORTE_EXAMPLES
134   rtems_shell_add_cmd("orte_h_publisher", "orte",
135                       "start orte_h_publisher",
136                       orte_h_publisher_main);
137
138   rtems_shell_add_cmd("orte_h_subscriber", "orte",
139                       "start orte_h_subscriber",
140                       orte_h_subscriber_main);
141
142   rtems_shell_add_cmd("orte_m_subscriber", "orte",
143                       "start orte_m_subscriber",
144                       orte_m_subscriber_main);
145
146   rtems_shell_add_cmd("orteping", "orte",
147                       "start orteping",
148                       orte_ping_main);
149
150   rtems_shell_add_cmd("orte_spy", "orte",
151                       "start orte_spy",
152                       orte_spy_main);
153
154   rtems_shell_add_cmd("orte_r_publisher", "orte",
155                       "start orte_r_publisher",
156                       orte_r_publisher_main);
157
158   rtems_shell_add_cmd("orte_r_subscriber_besteffort", "orte",
159                       "start orte_r_subscriber_besteffort",
160                       orte_r_subscriber_besteffort_main);
161
162   rtems_shell_add_cmd("orte_r_subscriber_reliable", "orte",
163                       "start orte_r_subscriber_reliable",
164                       orte_r_subscriber_reliable_main);
165  #endif /*CONFIG_OC_ETH_ORTE_EXAMPLES*/
166
167   rtems_shell_add_cmd("spawn", "orte",
168                       "spawn task or command in background",
169                       orte_spawn_main);
170
171   //rtems_monitor_wakeup();
172
173   status = rtems_task_delete(RTEMS_SELF);
174
175   printf("*** END OF TEST2 ***\n");
176   exit(0);
177 }