comparison gsm-fw/gpf/frame/vsi_pro.c @ 316:79080922d8e4

GPF: FRAME C sources and include files imported from LoCosto source
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 10 Apr 2014 04:06:05 +0000
parents
children 2c760f6b1fe0
comparison
equal deleted inserted replaced
315:1b4beffc8055 316:79080922d8e4
1 /*
2 +------------------------------------------------------------------------------
3 | File: vsi_pro.c
4 +------------------------------------------------------------------------------
5 | Copyright 2002 Texas Instruments Berlin, AG
6 | All rights reserved.
7 |
8 | This file is confidential and a trade secret of Texas
9 | Instruments Berlin, AG
10 | The receipt of or possession of this file does not convey
11 | any rights to reproduce or disclose its contents or to
12 | manufacture, use, or sell anything it may describe, in
13 | whole, or in part, without the specific written consent of
14 | Texas Instruments Berlin, AG.
15 +-----------------------------------------------------------------------------
16 | Purpose : This Module defines the virtual system interface part
17 | about the processes
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef __VSI_PRO_C__
22 #define __VSI_PRO_C__
23 #endif
24
25
26 /*==== INCLUDES ===================================================*/
27
28 #include "string.h"
29 #include "typedefs.h"
30 #include "os.h"
31 #include "vsi.h"
32 #include "frm_defs.h"
33 #include "frm_types.h"
34 #include "frm_glob.h"
35 #include "frame.h"
36 #include "route.h"
37
38 /*==== TYPES ======================================================*/
39
40
41 /*==== CONSTANTS ==================================================*/
42
43
44 /*==== EXTERNALS ==================================================*/
45
46 /* -------------- S H A R E D - BEGIN ---------------- */
47 #ifdef _TOOLS_
48 #pragma data_seg("FRAME_SHARED")
49 #endif
50
51 extern void pf_TaskEntry(T_HANDLE, ULONG);
52
53 /*==== VARIABLES ==================================================*/
54
55 #ifdef _TOOLS_
56 #pragma data_seg()
57 #endif
58 /* -------------- S H A R E D - END ---------------- */
59
60 /*==== FUNCTIONS ==================================================*/
61
62
63 #ifndef RUN_INT_RAM
64 /*
65 +--------------------------------------------------------------------+
66 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
67 | STATE : code ROUTINE : vsi_p_create |
68 +--------------------------------------------------------------------+
69
70 PURPOSE : creates a process
71
72 */
73
74 T_HANDLE vsi_p_create (T_HANDLE Caller, SHORT (*pei_create)(T_PEI_INFO const ** info),
75 void (*TaskEntry)(T_HANDLE, ULONG), T_HANDLE MemPoolHandle )
76 {
77 void (*EntryFunc)(T_HANDLE, ULONG);
78 T_PEI_INFO const *Info;
79 T_HANDLE TaskHandle;
80
81 if ( pei_create ( &Info ) == PEI_OK )
82 {
83 if ( TaskEntry == NULL )
84 EntryFunc = pf_TaskEntry;
85 else
86 EntryFunc = TaskEntry;
87
88 if ( os_CreateTask (NO_TASK, (char*)Info->Name, EntryFunc, Info->StackSize, Info->Priority,
89 &TaskHandle, MemPoolHandle) == OS_OK )
90 {
91 pf_TaskTable[TaskHandle].Flags = Info->Flags;
92 pf_TaskTable[TaskHandle].PeiTable = &Info->PeiTable;
93 pf_TaskTable[TaskHandle].QueueEntries = Info->QueueEntries;
94 pf_TaskTable[TaskHandle].NumOfTimers = Info->NumOfTimers;
95 strncpy (pf_TaskTable[TaskHandle].Name, Info->Name, RESOURCE_NAMELEN);
96 pf_TaskTable[TaskHandle].Name[RESOURCE_NAMELEN-1] = 0;
97 pf_TaskTable[TaskHandle].TaskHandle = TaskHandle;
98
99 pf_TaskTable[TaskHandle].MemPoolHandle = MemPoolHandle;
100 return TaskHandle;
101 }
102 }
103 return VSI_ERROR;
104 }
105 #endif
106
107 #ifndef RUN_INT_RAM
108 /*
109 +--------------------------------------------------------------------+
110 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
111 | STATE : code ROUTINE : vsi_p_exit |
112 +--------------------------------------------------------------------+
113
114 PURPOSE : exits and deletes a process
115
116 */
117 #undef VSI_CALLER
118 #define VSI_CALLER Caller,
119 #define VSI_CALLER_SINGLE Caller
120 int vsi_p_exit (T_HANDLE Caller, T_HANDLE TaskHandle)
121 {
122 ULONG old_mask;
123 T_PRIM_HEADER *prim;
124 T_S_HEADER *s_hdr;
125 ULONG size;
126 char name[RESOURCE_NAMELEN];
127
128 size = S_ALLOC_SIZE(strlen(SYSPRIM_EXIT_TOKEN));
129 #ifdef MEMORY_SUPERVISION
130 prim = (T_PRIM_HEADER*)vsi_c_new ( Caller, size, 0, __FILE__, __LINE__ );
131 #else
132 prim = (T_PRIM_HEADER*)vsi_c_new ( Caller, size, 0 );
133 #endif
134
135 prim->opc = SYS_MASK;
136 prim->sh_offset = S_HDR_OFFSET(size - sizeof(T_S_HEADER));
137 prim->len = strlen(SYSPRIM_EXIT_TOKEN) + sizeof(T_PRIM_HEADER);
138 s_hdr = (T_S_HEADER*)((ULONG*)prim + prim->sh_offset);
139 s_hdr->snd[0] =(char)Caller;
140 strcpy((char*)P2D(prim),SYSPRIM_EXIT_TOKEN);
141
142 if (vsi_gettaskname(Caller,TaskHandle,name) < VSI_OK)
143 {
144 return VSI_ERROR;
145 }
146 /* switch off tracing for Caller */
147 vsi_gettracemask ( Caller, Caller, &old_mask);
148 vsi_settracemask ( Caller, Caller, 0);
149 PSEND(vsi_c_open(Caller,name),P2D(prim));
150 /* set tracing to old value for Caller */
151 vsi_settracemask ( Caller, Caller, old_mask);
152 return VSI_OK;
153 }
154 #endif
155
156 #ifndef RUN_INT_RAM
157 /*
158 +--------------------------------------------------------------------+
159 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
160 | STATE : code ROUTINE : vsi_p_delete |
161 +--------------------------------------------------------------------+
162
163 PURPOSE : deletes a process
164
165 */
166
167 int vsi_p_delete (T_HANDLE Caller, T_HANDLE TaskHandle)
168 {
169 rt_RoutingModify ( TaskHandle, (char*)SYSPRIM_REDIRECT_TOKEN, (char*)SYSPRIM_CLEAR_TOKEN );
170
171 if ( os_DestroyQueue ( Caller, pf_TaskTable[TaskHandle].QueueHandle ) != OS_OK )
172 return VSI_ERROR;
173
174 memset ( &pf_TaskTable[TaskHandle], 0, sizeof (T_FRM_TASK_TABLE_ENTRY) );
175
176 if ( os_DestroyTask ( Caller, TaskHandle ) != OS_OK )
177 return VSI_ERROR;
178
179 return VSI_OK;
180 }
181 #endif
182
183 #ifndef RUN_INT_RAM
184 /*
185 +--------------------------------------------------------------------+
186 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
187 | STATE : code ROUTINE : vsi_p_start |
188 +--------------------------------------------------------------------+
189
190 PURPOSE : starts a process
191
192 */
193
194 int vsi_p_start (T_HANDLE Caller, T_HANDLE TaskHandle)
195 {
196
197 if ( os_StartTask ( Caller, TaskHandle, 0 ) == OS_OK )
198 return VSI_OK;
199 else
200 return VSI_ERROR;
201
202 }
203 #endif
204
205 #ifndef RUN_INT_RAM
206 /*
207 +--------------------------------------------------------------------+
208 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
209 | STATE : code ROUTINE : vsi_p_stop |
210 +--------------------------------------------------------------------+
211
212 PURPOSE : stops a process
213
214 */
215
216 int vsi_p_stop (T_HANDLE Caller, T_HANDLE TaskHandle)
217 {
218
219 if ( os_StopTask ( Caller, TaskHandle ) == OS_OK )
220 return VSI_OK;
221 else
222 return VSI_ERROR;
223
224 }
225 #endif
226
227 #ifndef RUN_INT_RAM
228 /*
229 +--------------------------------------------------------------------+
230 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
231 | STATE : code ROUTINE : vsi_p_name |
232 +--------------------------------------------------------------------+
233
234 PURPOSE : reads the name of a task
235
236 */
237
238 int vsi_p_name (T_HANDLE Caller, T_HANDLE Handle, char *Name)
239 {
240
241 if ( os_GetTaskName ( Caller, Handle, Name ) != OS_ERROR )
242 return VSI_OK;
243
244 return VSI_ERROR;
245 }
246 #endif
247
248 #ifndef RUN_INT_RAM
249 /*
250 +--------------------------------------------------------------------+
251 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
252 | STATE : code ROUTINE : vsi_p_handle |
253 +--------------------------------------------------------------------+
254
255 PURPOSE : reads the name of a task
256
257 */
258
259 T_HANDLE vsi_p_handle (T_HANDLE Caller, char *Name)
260 {
261 OS_HANDLE Handle;
262
263 if ( os_GetTaskHandle ( Caller, Name, &Handle ) != OS_ERROR )
264 return Handle;
265
266 return VSI_ERROR;
267 }
268 #endif