]> rtime.felk.cvut.cz Git - rtems-devel.git/blob - rtems-omk-template/appfoo/init.c
Allocate some number of threads and other resources for POSIX API.
[rtems-devel.git] / rtems-omk-template / appfoo / 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 <stdio.h>
28 #include <stdlib.h>
29 #include <rtems/error.h>
30 #include <rtems/monitor.h>
31 #include <rtems/shell.h>
32
33 #define BUILD_VERSION_STRING(major,minor,patch) \
34         __XSTRING(major) "." __XSTRING(minor) "." __XSTRING(patch)
35
36 void 
37 bad_rtems_status(rtems_status_code status, int fail_level, const char *text)
38 {
39   printf("ERROR: %s status %s", text, rtems_status_text(status));
40   status = rtems_task_delete( RTEMS_SELF );
41 }
42
43 int testcmd_forshell(int argc, char **argv)
44 {
45   int i;
46   printf("Command %s called\n",argv[0]);
47   for(i=1;i<argc;i++)
48     if(argv[i])
49       printf("%s",argv[i]);
50   printf("\n");
51   return 0;
52 }
53
54 rtems_task Init(
55   rtems_task_argument ignored
56 )
57 {
58   rtems_status_code status;
59
60   printf( "\n\nRTEMS v "
61           BUILD_VERSION_STRING(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__)
62           "\n");
63   
64   rtems_monitor_init(RTEMS_MONITOR_SUSPEND|RTEMS_MONITOR_GLOBAL);
65   /*rtems_capture_cli_init (0);*/
66   
67   printf( "Starting application " SW_VER_ID " v "
68           BUILD_VERSION_STRING(SW_VER_MAJOR,SW_VER_MINOR,SW_VER_PATCH)
69           "\n" );
70
71   Task_1_name = rtems_build_name( 'T', 'S', 'K', '1' );
72     
73   status = rtems_task_create(
74      Task_1_name,
75      TASK_1_PRIORITY,
76      RTEMS_MINIMUM_STACK_SIZE+0x10000,
77      RTEMS_DEFAULT_MODES /*& ~(RTEMS_TIMESLICE_MASK) | RTEMS_TIMESLICE*/,
78      RTEMS_DEFAULT_ATTRIBUTES,
79      &Task_1_id
80   );
81   check_rtems_status(status, 0, "rtems_task_create of Task_1");
82
83   status = rtems_task_start( Task_1_id, Task_1, 0 );
84   check_rtems_status(status, 0, "rtems_task_start of Task_1\n");
85
86   shell_init("SHLL",RTEMS_MINIMUM_STACK_SIZE+0x1000,
87               SHELL_TASK_PRIORITY,"/dev/console",B19200 | CS8, 0);
88
89   shell_add_cmd("testcmd", "app",
90                 "test command for shell",
91                 testcmd_forshell);
92
93   //rtems_monitor_wakeup();
94
95   status = rtems_task_delete( RTEMS_SELF );
96   
97   printf( "*** END OF TEST2 ***\n" );
98   exit( 0 );
99 }