comparison gpf/frame/vsi_pro.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
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
30 #include "gpfconf.h"
31 #include "typedefs.h"
32 #include "os.h"
33 #include "vsi.h"
34 #include "frm_defs.h"
35 #include "frm_types.h"
36 #include "frm_glob.h"
37 #include "frame.h"
38 #include "route.h"
39
40 /*==== TYPES ======================================================*/
41
42
43 /*==== CONSTANTS ==================================================*/
44
45
46 /*==== EXTERNALS ==================================================*/
47
48 /* -------------- S H A R E D - BEGIN ---------------- */
49 #ifdef _TOOLS_
50 #pragma data_seg("FRAME_SHARED")
51 #endif
52
53 extern void pf_TaskEntry(T_HANDLE, ULONG);
54
55 /*==== VARIABLES ==================================================*/
56
57 #ifdef _TOOLS_
58 #pragma data_seg()
59 #endif
60 /* -------------- S H A R E D - END ---------------- */
61
62 /*==== FUNCTIONS ==================================================*/
63
64
65 #ifndef RUN_INT_RAM
66 /*
67 +--------------------------------------------------------------------+
68 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
69 | STATE : code ROUTINE : vsi_p_create |
70 +--------------------------------------------------------------------+
71
72 PURPOSE : creates a process
73
74 */
75
76 T_HANDLE vsi_p_create (T_HANDLE Caller, SHORT (*pei_create)(T_PEI_INFO const ** info),
77 void (*TaskEntry)(T_HANDLE, ULONG), T_HANDLE MemPoolHandle )
78 {
79 void (*EntryFunc)(T_HANDLE, ULONG);
80 T_PEI_INFO const *Info;
81 T_HANDLE TaskHandle;
82
83 if ( pei_create ( &Info ) == PEI_OK )
84 {
85 if ( TaskEntry == NULL )
86 EntryFunc = pf_TaskEntry;
87 else
88 EntryFunc = TaskEntry;
89
90 if ( os_CreateTask (NO_TASK, (char*)Info->Name, EntryFunc, Info->StackSize, Info->Priority,
91 &TaskHandle, MemPoolHandle) == OS_OK )
92 {
93 pf_TaskTable[TaskHandle].Flags = Info->Flags;
94 pf_TaskTable[TaskHandle].PeiTable = &Info->PeiTable;
95 pf_TaskTable[TaskHandle].QueueEntries = Info->QueueEntries;
96 pf_TaskTable[TaskHandle].NumOfTimers = Info->NumOfTimers;
97 strncpy (pf_TaskTable[TaskHandle].Name, Info->Name, RESOURCE_NAMELEN);
98 pf_TaskTable[TaskHandle].Name[RESOURCE_NAMELEN-1] = 0;
99 pf_TaskTable[TaskHandle].TaskHandle = TaskHandle;
100
101 pf_TaskTable[TaskHandle].MemPoolHandle = MemPoolHandle;
102 return TaskHandle;
103 }
104 }
105 return VSI_ERROR;
106 }
107 #endif
108
109 #ifndef RUN_INT_RAM
110 /*
111 +--------------------------------------------------------------------+
112 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
113 | STATE : code ROUTINE : vsi_p_exit |
114 +--------------------------------------------------------------------+
115
116 PURPOSE : exits and deletes a process
117
118 */
119 #undef VSI_CALLER
120 #define VSI_CALLER Caller,
121 #define VSI_CALLER_SINGLE Caller
122 int vsi_p_exit (T_HANDLE Caller, T_HANDLE TaskHandle)
123 {
124 ULONG old_mask;
125 T_PRIM_HEADER *prim;
126 T_S_HEADER *s_hdr;
127 ULONG size;
128 char name[RESOURCE_NAMELEN];
129
130 size = S_ALLOC_SIZE(strlen(SYSPRIM_EXIT_TOKEN));
131 #ifdef MEMORY_SUPERVISION
132 prim = (T_PRIM_HEADER*)vsi_c_new ( Caller, size, 0, __FILE__, __LINE__ );
133 #else
134 prim = (T_PRIM_HEADER*)vsi_c_new ( Caller, size, 0 );
135 #endif
136
137 prim->opc = SYS_MASK;
138 prim->sh_offset = S_HDR_OFFSET(size - sizeof(T_S_HEADER));
139 prim->len = strlen(SYSPRIM_EXIT_TOKEN) + sizeof(T_PRIM_HEADER);
140 s_hdr = (T_S_HEADER*)((ULONG*)prim + prim->sh_offset);
141 s_hdr->snd[0] =(char)Caller;
142 strcpy((char*)P2D(prim),SYSPRIM_EXIT_TOKEN);
143
144 if (vsi_gettaskname(Caller,TaskHandle,name) < VSI_OK)
145 {
146 return VSI_ERROR;
147 }
148 /* switch off tracing for Caller */
149 vsi_gettracemask ( Caller, Caller, &old_mask);
150 vsi_settracemask ( Caller, Caller, 0);
151 PSEND(vsi_c_open(Caller,name),P2D(prim));
152 /* set tracing to old value for Caller */
153 vsi_settracemask ( Caller, Caller, old_mask);
154 return VSI_OK;
155 }
156 #endif
157
158 #ifndef RUN_INT_RAM
159 /*
160 +--------------------------------------------------------------------+
161 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
162 | STATE : code ROUTINE : vsi_p_delete |
163 +--------------------------------------------------------------------+
164
165 PURPOSE : deletes a process
166
167 */
168
169 int vsi_p_delete (T_HANDLE Caller, T_HANDLE TaskHandle)
170 {
171 rt_RoutingModify ( TaskHandle, (char*)SYSPRIM_REDIRECT_TOKEN, (char*)SYSPRIM_CLEAR_TOKEN );
172
173 if ( os_DestroyQueue ( Caller, pf_TaskTable[TaskHandle].QueueHandle ) != OS_OK )
174 return VSI_ERROR;
175
176 memset ( &pf_TaskTable[TaskHandle], 0, sizeof (T_FRM_TASK_TABLE_ENTRY) );
177
178 if ( os_DestroyTask ( Caller, TaskHandle ) != OS_OK )
179 return VSI_ERROR;
180
181 return VSI_OK;
182 }
183 #endif
184
185 #ifndef RUN_INT_RAM
186 /*
187 +--------------------------------------------------------------------+
188 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
189 | STATE : code ROUTINE : vsi_p_start |
190 +--------------------------------------------------------------------+
191
192 PURPOSE : starts a process
193
194 */
195
196 int vsi_p_start (T_HANDLE Caller, T_HANDLE TaskHandle)
197 {
198
199 if ( os_StartTask ( Caller, TaskHandle, 0 ) == OS_OK )
200 return VSI_OK;
201 else
202 return VSI_ERROR;
203
204 }
205 #endif
206
207 #ifndef RUN_INT_RAM
208 /*
209 +--------------------------------------------------------------------+
210 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
211 | STATE : code ROUTINE : vsi_p_stop |
212 +--------------------------------------------------------------------+
213
214 PURPOSE : stops a process
215
216 */
217
218 int vsi_p_stop (T_HANDLE Caller, T_HANDLE TaskHandle)
219 {
220
221 if ( os_StopTask ( Caller, TaskHandle ) == OS_OK )
222 return VSI_OK;
223 else
224 return VSI_ERROR;
225
226 }
227 #endif
228
229 #ifndef RUN_INT_RAM
230 /*
231 +--------------------------------------------------------------------+
232 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
233 | STATE : code ROUTINE : vsi_p_name |
234 +--------------------------------------------------------------------+
235
236 PURPOSE : reads the name of a task
237
238 */
239
240 int vsi_p_name (T_HANDLE Caller, T_HANDLE Handle, char *Name)
241 {
242
243 if ( os_GetTaskName ( Caller, Handle, Name ) != OS_ERROR )
244 return VSI_OK;
245
246 return VSI_ERROR;
247 }
248 #endif
249
250 #ifndef RUN_INT_RAM
251 /*
252 +--------------------------------------------------------------------+
253 | PROJECT : GSM-Frame (8415) MODULE : VSI_PRO |
254 | STATE : code ROUTINE : vsi_p_handle |
255 +--------------------------------------------------------------------+
256
257 PURPOSE : reads the name of a task
258
259 */
260
261 T_HANDLE vsi_p_handle (T_HANDLE Caller, char *Name)
262 {
263 OS_HANDLE Handle;
264
265 if ( os_GetTaskHandle ( Caller, Name, &Handle ) != OS_ERROR )
266 return Handle;
267
268 return VSI_ERROR;
269 }
270 #endif