Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9207 | turbocat | 1 | #include |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include |
||
6 | |||
7 | char app_name[13]; |
||
8 | char __shell_shm_name[32]; |
||
9 | char*__shell_shm=NULL; |
||
10 | int __shell_is_init=0; |
||
11 | |||
12 | int __shell_shm_init() |
||
13 | { |
||
14 | __shell_is_init=1; |
||
15 | ksys_thread_t *proc_info = (ksys_thread_t*)malloc(sizeof(ksys_thread_t)); |
||
16 | if(proc_info == NULL){ |
||
17 | return -1; |
||
18 | } |
||
19 | unsigned PID; |
||
20 | |||
21 | _ksys_thread_info(proc_info, -1); |
||
22 | PID = proc_info->pid; |
||
23 | strncpy(app_name, proc_info->name, 12); |
||
24 | free(proc_info); |
||
25 | |||
26 | itoa(PID, __shell_shm_name); |
||
27 | strcat(__shell_shm_name, "-SHELL"); |
||
28 | return _ksys_shm_open(__shell_shm_name, KSYS_SHM_OPEN_ALWAYS | KSYS_SHM_WRITE, SHELL_SHM_MAX, &__shell_shm); |
||
29 | } |
||
30 | |||
31 | void __shell_init() |
||
32 | { |
||
33 | if(!__shell_is_init){ |
||
34 | if(__shell_shm_init()){ |
||
35 | debug_printf("%s: shell problems detected!\n", app_name); |
||
36 | _ksys_exit(); |
||
37 | } |
||
38 | |||
39 | if(!shell_ping()){ |
||
40 | debug_printf("%s: no shell found!\n", app_name); |
||
41 | _ksys_exit(); |
||
42 | } |
||
43 | } |
||
44 | } |