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.
9 * Input parameters: NONE
11 * Output parameters: NONE
13 * COPYRIGHT (c) 1989-1999.
14 * On-Line Applications Research Corporation (OAR).
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.
20 * $Id: init.c,v 1.12.4.1 2003/09/04 18:46:30 joel Exp $
23 #define CONFIGURE_INIT
24 #include <system_def.h>
27 #include "appl_config.h"
30 #include <rtems/error.h>
31 #include <rtems/monitor.h>
32 #include <rtems/shell.h>
34 #include <rtems/rtems_bsdnet.h>
36 #include "networkconfig.h"
38 #include <sys/types.h>
39 #include <sys/socket.h>
40 #include <netinet/in.h>
41 #include <arpa/inet.h>
45 #define CONFIGURE_SHELL_COMMANDS_INIT
46 #define CONFIGURE_SHELL_COMMANDS_ALL
47 #define CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING
48 #define CONFIGURE_SHELL_MOUNT_MSDOS
49 #define CONFIGURE_SHELL_MOUNT_NFS
51 #include <rtems/shellconfig.h>
53 #define BUILD_VERSION_STRING(major,minor,patch) \
54 __XSTRING(major) "." __XSTRING(minor) "." __XSTRING(patch)
56 #define RTEMS_VER_CODE VER_CODE(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__)
58 #if RTEMS_VER_CODE < VER_CODE(4,7,99)
59 #define rtems_shell_add_cmd shell_add_cmd
60 #define rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait,m_login_check) \
61 shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,B19200 | CS8,m_forever)
62 #elif RTEMS_VER_CODE < VER_CODE(4,9,99)
63 #define rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait,m_login_check) \
64 rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait)
67 #ifdef CONFIG_OC_APP_APPNET_TELNETD
68 #include <rtems/telnetd.h>
70 rtems_telnetd_config_table rtems_telnetd_config;
72 void run_telnetd_command(char *device_name, void *arg)
74 rtems_shell_env_t shell_env;
76 rtems_shell_dup_current_env(&shell_env);
77 shell_env.taskname = NULL;
78 shell_env.devname = device_name;
79 rtems_shell_main_loop(&shell_env);
81 #endif /*CONFIG_OC_APP_APPNET_TELNETD*/
84 bad_rtems_status(rtems_status_code status, int fail_level, const char *text)
86 printf("ERROR: %s status %s", text, rtems_status_text(status));
87 status = rtems_task_delete( RTEMS_SELF );
90 int testcmd_forshell(int argc, char **argv)
93 printf("Command %s called\n",argv[0]);
102 rtems_task_argument ignored
105 rtems_status_code status;
107 printf( "\n\nRTEMS v "
108 BUILD_VERSION_STRING(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__)
111 printf("RTEMS_BSP_NETWORK_DRIVER_NAME = %s\n", __XSTRING(RTEMS_BSP_NETWORK_DRIVER_NAME));
112 printf("RTEMS_BSP_NETWORK_DRIVER_ATTACH = %s\n", __XSTRING(RTEMS_BSP_NETWORK_DRIVER_ATTACH));
114 rtems_monitor_init(RTEMS_MONITOR_SUSPEND|RTEMS_MONITOR_GLOBAL);
115 /*rtems_capture_cli_init (0);*/
117 if (rtems_bsdnet_initialize_network() < 0)
118 printf( "Network initialization failed\n");
120 printf( "Network initialization OK\n");
123 printf( "Starting application " APP_VER_ID " v "
124 BUILD_VERSION_STRING(SW_VER_MAJOR,SW_VER_MINOR,SW_VER_PATCH)
127 Task_1_name = rtems_build_name( 'T', 'S', 'K', '1' );
129 status = rtems_task_create(
132 RTEMS_MINIMUM_STACK_SIZE+0x10000,
133 RTEMS_DEFAULT_MODES /*& ~(RTEMS_TIMESLICE_MASK) | RTEMS_TIMESLICE*/,
134 RTEMS_DEFAULT_ATTRIBUTES,
137 check_rtems_status(status, 0, "rtems_task_create of Task_1");
139 status = rtems_task_start( Task_1_id, Task_1, 0 );
140 check_rtems_status(status, 0, "rtems_task_start of Task_1\n");
142 rtems_shell_init("SHLL",RTEMS_MINIMUM_STACK_SIZE+0x1000,
143 SHELL_TASK_PRIORITY,"/dev/console",1,0, NULL);
145 rtems_shell_add_cmd("testcmd", "app",
146 "test command for shell",
149 //rtems_monitor_wakeup();
151 #ifdef CONFIG_OC_APP_APPNET_TELNETD
152 rtems_telnetd_config.command = run_telnetd_command;
153 rtems_telnetd_config.arg = NULL;
154 rtems_telnetd_config.priority = SHELL_TASK_PRIORITY;
155 rtems_telnetd_config.stack_size = RTEMS_MINIMUM_STACK_SIZE+0x1000;
156 rtems_telnetd_config.login_check = NULL;
157 rtems_telnetd_config.keep_stdio = 0;
159 status = rtems_telnetd_initialize();
160 check_rtems_status(status, 0, "rtems_telnetd_initialize\n");
161 #endif /*CONFIG_OC_APP_APPNET_TELNETD*/
163 status = rtems_task_delete( RTEMS_SELF );
165 printf( "*** END OF TEST2 ***\n" );