]> rtime.felk.cvut.cz Git - can-benchmark.git/blob - rtems/gw/cangw/init.c
63e00eab0c70060633dcba2fe653cb7bbe6100b6
[can-benchmark.git] / rtems / gw / cangw / 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_def.h>
25 #include "system.h"
26 #include "app_def.h"
27 #include <unistd.h>
28 #include <fcntl.h>
29 #include <stdio.h>
30 #include <errno.h>
31 #include <stdlib.h>
32 #include <rtems/error.h>
33 #include <rtems/monitor.h>
34 #include <rtems/shell.h>
35
36 #include <bsp/mscan.h>
37 #include <bsp/mscan-base.h>
38
39 #include "helpers.h"
40
41 #define BUILD_VERSION_STRING(major,minor,patch) \
42         __XSTRING(major) "." __XSTRING(minor) "." __XSTRING(patch)
43
44 #define RTEMS_VER_CODE VER_CODE(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__)
45
46 #if RTEMS_VER_CODE < VER_CODE(4,7,99)
47   #define rtems_shell_add_cmd shell_add_cmd
48   #define rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait,m_login_check) \
49                 shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,B19200 | CS8,m_forever)
50 #elif RTEMS_VER_CODE < VER_CODE(4,9,99)
51   #define rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait,m_login_check) \
52           rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait)
53 #endif
54
55 void bad_rtems_status(rtems_status_code status, int fail_level, const char *text){
56   printf("ERROR: %s status %s", text, rtems_status_text(status));
57   status = rtems_task_delete( RTEMS_SELF );
58 }
59
60
61 \r
62
63 rtems_task Init(rtems_task_argument ignored){
64     rtems_status_code status;
65     
66     printf( "\n\nRTEMS v "
67             BUILD_VERSION_STRING(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__)
68         "\n");
69     
70     rtems_monitor_init(RTEMS_MONITOR_SUSPEND|RTEMS_MONITOR_GLOBAL);
71     /*rtems_capture_cli_init (0);*/
72     
73     printf( "Starting application " SW_VER_ID " v "
74             BUILD_VERSION_STRING(SW_VER_MAJOR,SW_VER_MINOR,SW_VER_PATCH)
75         "\n" );
76     \r
77     
78     rtems_shell_init("SHLL", RTEMS_MINIMUM_STACK_SIZE+0x1000,
79                 SHELL_TASK_PRIORITY, "/dev/console", 1, 0, NULL);
80     
81     rtems_shell_add_cmd("startGW", "app",
82                     "initialize can driver and startGW",
83                     start_can);
84     
85     rtems_shell_add_cmd("stopGW", "app",
86                     "stops GW",
87                     end_can);
88             
89     rtems_shell_add_cmd("printvar", "app",
90                     "prints info from vars",
91                     print_regs);\r
92                     \r
93     rtems_shell_add_cmd("printcan", "app",\r
94                     "prints error rate from CANs",\r
95                     print_can_totals);
96     \r
97     rtems_shell_add_cmd("startNET", "app",\r
98                     "tries to start network adapter",\r
99                     start_net);\r
100     \r
101     rtems_shell_add_cmd("showNET", "app",\r
102                     "prints some diagnostic info from network adapter/driver",\r
103                     show_net);\r
104     
105     status = rtems_task_delete( RTEMS_SELF );
106     
107     exit( 0 );
108 }