FreeCalypso > hg > fc-selenite
comparison src/gpf/frame/vsi_drv.c @ 5:1ea54a97e831
src/gpf: import of Magnetite src/gpf3
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jul 2018 08:11:07 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:6e457872f745 | 5:1ea54a97e831 |
---|---|
1 /* | |
2 +------------------------------------------------------------------------------ | |
3 | File: vsi_drv.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 | for driver access. | |
18 +----------------------------------------------------------------------------- | |
19 */ | |
20 | |
21 #ifndef __VSI_DRV_C__ | |
22 #define __VSI_DRV_C__ | |
23 #endif | |
24 | |
25 /*==== INCLUDES ===================================================*/ | |
26 | |
27 #include "string.h" | |
28 #include "stdio.h" | |
29 #include "typedefs.h" | |
30 | |
31 #include "vsi.h" | |
32 #include "gdi.h" | |
33 #include "os.h" | |
34 #ifdef _TOOLS_ | |
35 #include "drvconf.h" | |
36 #endif | |
37 #include "frm_defs.h" | |
38 #include "frm_types.h" | |
39 #include "frm_glob.h" | |
40 #include "frame.h" | |
41 | |
42 /*==== TYPES ======================================================*/ | |
43 | |
44 | |
45 #ifdef _TOOLS_ | |
46 typedef struct | |
47 { | |
48 char Name[RESOURCE_NAMELEN]; | |
49 char Process[RESOURCE_NAMELEN]; | |
50 char DrvConfig[80]; | |
51 } _T_DRV_LIST_ENTRY; | |
52 | |
53 typedef struct | |
54 { | |
55 _T_DRV_LIST_ENTRY DrvEntry [ 5 ]; | |
56 } _T_DRV_LIST; | |
57 | |
58 #endif | |
59 | |
60 /*==== CONSTANTS ==================================================*/ | |
61 | |
62 | |
63 /*==== EXTERNALS ==================================================*/ | |
64 | |
65 /* -------------- S H A R E D - BEGIN ---------------- */ | |
66 #ifdef _TOOLS_ | |
67 #pragma data_seg("FRAME_SHARED") | |
68 #endif | |
69 | |
70 extern T_DRV_TABLE_ENTRY DrvTable []; | |
71 | |
72 /*==== VARIABLES ==================================================*/ | |
73 | |
74 #undef EXTR_SEND_CONTROL | |
75 #ifndef RUN_INT_RAM | |
76 T_DRV_LIST *DriverConfigList; /* pointer to start of driver cinfiguration list */ | |
77 static T_DRV_LIST *DriverList; /* pointer to selected driver list */ | |
78 #ifdef EXTR_SEND_CONTROL | |
79 FILE *fp; | |
80 #endif | |
81 #endif | |
82 | |
83 #ifdef _TOOLS_ | |
84 _T_DRV_LIST _DrvList={0}; | |
85 T_DRV_LIST DrvList={0}; | |
86 #endif | |
87 | |
88 #ifdef _TOOLS_ | |
89 #pragma data_seg() | |
90 #endif /* _TOOLS_ */ | |
91 /* -------------- S H A R E D - END ---------------- */ | |
92 | |
93 | |
94 /*==== FUNCTIONS ==================================================*/ | |
95 | |
96 void ClearDriverTable ( void ); | |
97 | |
98 #ifndef RUN_INT_RAM | |
99 /* | |
100 +--------------------------------------------------------------------+ | |
101 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
102 | STATE : code ROUTINE : vsi_d_create | | |
103 +--------------------------------------------------------------------+ | |
104 | |
105 PURPOSE : enter a new driver in the driver list | |
106 | |
107 */ | |
108 int vsi_d_create ( T_HANDLE caller, T_TST_DRV_ENTRY *drv_info ) | |
109 { | |
110 T_HANDLE drv_handle; | |
111 | |
112 drv_handle = drv_info->drv_pos; | |
113 vsi_d_exit ( caller, 0 ); | |
114 DriverList->DrvEntry[drv_handle].drv_Init = drv_info->entry.drv_Init; | |
115 DriverList->DrvEntry[drv_handle].Name = drv_info->entry.Name; | |
116 DriverList->DrvEntry[drv_handle].Process = drv_info->entry.Process; | |
117 DriverList->DrvEntry[drv_handle].DrvConfig = drv_info->entry.DrvConfig; | |
118 | |
119 ClearDriverTable(); | |
120 vsi_d_init ( caller ); | |
121 vsi_d_setsignal ( caller, 0, DRV_SIGTYPE_READ|DRV_SIGTYPE_CONNECT|DRV_SIGTYPE_DISCONNECT); | |
122 vsi_d_setconfig ( caller, 0, NULL ); | |
123 return VSI_OK; | |
124 } | |
125 #endif | |
126 | |
127 #ifndef RUN_INT_RAM | |
128 /* | |
129 +--------------------------------------------------------------------+ | |
130 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
131 | STATE : code ROUTINE : vsi_d_callback | | |
132 +--------------------------------------------------------------------+ | |
133 | |
134 PURPOSE : callback from a driver | |
135 | |
136 */ | |
137 void vsi_d_callback ( T_DRV_SIGNAL *Signal ) | |
138 { | |
139 T_HANDLE Caller; | |
140 T_HANDLE DrvHandle; | |
141 int sts; | |
142 #ifdef EXTR_SEND_CONTROL | |
143 OS_TIME time; | |
144 T_PRIM_HEADER *p; | |
145 static int cnt = 0; | |
146 int bytes; | |
147 #endif | |
148 | |
149 Caller = Signal->DrvHandle; | |
150 DrvHandle = DrvTable[Caller].UpperDrv; | |
151 if ( DrvHandle ) | |
152 { | |
153 if ( DrvTable[DrvHandle].DrvInfo->DrvFunc.drv_Callback != NULL ) | |
154 { | |
155 #if defined _TARGET_ && defined _NUCLEUS_ | |
156 if ( DrvTable[Caller].DrvInfo->Flags & CALLED_FROM_ISR ) | |
157 os_ExecuteCallback ( Caller, DrvTable[DrvHandle].DrvInfo->DrvFunc.drv_Callback, Signal ); | |
158 else | |
159 #endif | |
160 (DrvTable[DrvHandle].DrvInfo->DrvFunc.drv_Callback)( Signal ); | |
161 } | |
162 } | |
163 else | |
164 { | |
165 if ( DrvTable[Caller].ProcessHandle ) | |
166 { | |
167 OS_QDATA Msg; | |
168 OS_TIME time; | |
169 Msg.data16 = MSG_SIGNAL; | |
170 Msg.data32 = Signal->SignalType; | |
171 Msg.ptr = Signal->UserData; | |
172 os_GetTime ( 0, &time ); | |
173 Msg.time = (ULONG)time; | |
174 Msg.e_id = DrvTable[Caller].ProcessHandle; | |
175 #ifdef EXTR_SEND_CONTROL | |
176 if ( Msg.ptr ) | |
177 { | |
178 os_GetTime(0,&time); | |
179 fp = fopen("test.txt", "a"); | |
180 p = (T_PRIM_HEADER*)((T_PRIM_X*)Msg.ptr)->prim_ptr; | |
181 if ( p->opc == 0x8000 ) | |
182 { | |
183 printf("EXTR: Start sending %s, time %d, %d\n", (char*)P2D(p),time, cnt & 1023 ); | |
184 bytes = fprintf(fp, "EXTR: Start sending %s, time %d, %d\n", (char*)P2D(p),time, cnt & 1023 ); | |
185 } | |
186 else | |
187 { | |
188 printf("EXTR: Start sending primitive, time %d, %d\n", time, cnt & 1023); | |
189 bytes = fprintf(fp, "EXTR: Start sending primitive, time %d, %d\n", time, cnt & 1023); | |
190 } | |
191 fclose(fp); | |
192 } | |
193 #endif | |
194 #ifdef _TOOLS_ | |
195 sts = os_SendToQueue (NO_TASK, DrvTable[Caller].ProcessHandle, OS_NORMAL, OS_SUSPEND, &Msg ); | |
196 #else | |
197 sts = os_SendToQueue (NO_TASK, pf_TaskTable[DrvTable[Caller].ProcessHandle].QueueHandle, OS_NORMAL, OS_SUSPEND, &Msg ); | |
198 #endif | |
199 #ifdef EXTR_SEND_CONTROL | |
200 os_GetTime(0,&time); | |
201 fp = fopen("test.txt", "a"); | |
202 printf("EXTR: Complete sending, time %d %d\n", time, cnt & 1023); | |
203 bytes = fprintf(fp,"EXTR: Complete sending, time %d %d\n", time, cnt++ & 1023); | |
204 fclose(fp); | |
205 #endif | |
206 /* | |
207 * This is a dirty patch, but due to the missing return value there is no other choice | |
208 */ | |
209 if ( sts == OS_TIMEOUT || sts == OS_ERROR ) | |
210 { | |
211 T_PRIM_X *sys_prim; | |
212 | |
213 sys_prim = (T_PRIM_X*)Signal->UserData; | |
214 PFREE(P2D(sys_prim->prim_ptr)); | |
215 PFREE(P2D(sys_prim)); | |
216 } | |
217 } | |
218 } | |
219 } | |
220 #endif | |
221 | |
222 #ifndef RUN_INT_RAM | |
223 /* | |
224 +--------------------------------------------------------------------+ | |
225 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
226 | STATE : code ROUTINE : vsi_d_init | | |
227 +--------------------------------------------------------------------+ | |
228 | |
229 PURPOSE : initialize drivers | |
230 | |
231 */ | |
232 /*lint -esym(644,DrvInfo) */ | |
233 int vsi_d_init ( T_HANDLE Caller ) | |
234 { | |
235 T_DRV_EXPORT const *DrvInfo; | |
236 USHORT i; | |
237 SHORT sts; | |
238 | |
239 #ifdef EXTR_SEND_CONTROL | |
240 fp = fopen("test.txt", "a"); | |
241 fprintf(fp,"=========================================================\n"); | |
242 fclose (fp); | |
243 #endif | |
244 for ( i = 1; i < MAX_TST_DRV; i++ ) | |
245 { | |
246 sts = DRV_NOTCONFIGURED; | |
247 #ifdef _TOOLS_ | |
248 if ( DrvTable[i].DrvInfo ) | |
249 sts = (SHORT)(DrvTable[i].DrvInfo->DrvFunc.drv_Init)(i,vsi_d_callback,&DrvInfo); | |
250 else | |
251 #endif | |
252 if ( DriverList->DrvEntry[i].drv_Init ) | |
253 sts = (SHORT)(DriverList->DrvEntry[i].drv_Init)(i,vsi_d_callback,&DrvInfo); | |
254 if ( sts == DRV_OK ) | |
255 { | |
256 if ( DriverList->DrvEntry[i].Process ) | |
257 DrvTable[i].ProcessHandle = vsi_c_open ( Caller, (char*)DriverList->DrvEntry[i].Process ); | |
258 DrvTable[i].UpperDrv = i-1; | |
259 DrvTable[i-1].LowerDrv = i; | |
260 DrvTable[i].DrvInfo = DrvInfo; | |
261 #if defined _TARGET_ && defined _NUCLEUS_ | |
262 if ( DrvTable[i].DrvInfo->Flags & CALLED_FROM_ISR ) | |
263 if ( os_CreateCallback() == OS_ERROR ) | |
264 return VSI_ERROR; | |
265 #endif | |
266 } | |
267 else | |
268 { | |
269 if ( sts != DRV_NOTCONFIGURED ) | |
270 { | |
271 return VSI_ERROR; | |
272 } | |
273 } | |
274 } | |
275 return VSI_OK; | |
276 } | |
277 #endif | |
278 | |
279 #ifndef RUN_INT_RAM | |
280 /* | |
281 +--------------------------------------------------------------------+ | |
282 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
283 | STATE : code ROUTINE : vsi_d_exit | | |
284 +--------------------------------------------------------------------+ | |
285 | |
286 PURPOSE : exit drivers | |
287 | |
288 */ | |
289 int vsi_d_exit ( T_HANDLE Caller, T_HANDLE DrvHandle ) | |
290 { | |
291 T_HANDLE Handle; | |
292 T_HANDLE min, max; | |
293 | |
294 if ( DrvHandle ) | |
295 { | |
296 min = DrvHandle; | |
297 max = DrvHandle+1; | |
298 } | |
299 else | |
300 { | |
301 min = 1; | |
302 max = MAX_TST_DRV; | |
303 } | |
304 | |
305 for ( Handle = min; Handle < max; Handle++ ) | |
306 { | |
307 if ( DrvTable[Handle].DrvInfo ) | |
308 { | |
309 if ( DrvTable[Handle].DrvInfo->DrvFunc.drv_Exit != NULL ) | |
310 (DrvTable[Handle].DrvInfo->DrvFunc.drv_Exit)(); | |
311 } | |
312 } | |
313 return VSI_OK; | |
314 } | |
315 #endif | |
316 | |
317 #ifndef RUN_INT_RAM | |
318 /* | |
319 +--------------------------------------------------------------------+ | |
320 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
321 | STATE : code ROUTINE : vsi_d_open | | |
322 +--------------------------------------------------------------------+ | |
323 | |
324 PURPOSE : open a drivers | |
325 | |
326 */ | |
327 int vsi_d_open ( T_HANDLE Caller, char *Name ) | |
328 { | |
329 int i; | |
330 | |
331 for ( i = 1; i <= MAX_TST_DRV; i++ ) | |
332 { | |
333 if ( DrvTable[i].DrvInfo && DrvTable[i].DrvInfo->Name ) | |
334 if ( !strcmp ( DrvTable[i].DrvInfo->Name, Name ) ) | |
335 return (i); | |
336 } | |
337 return VSI_ERROR; | |
338 } | |
339 #endif | |
340 | |
341 #ifndef RUN_INT_RAM | |
342 /* | |
343 +--------------------------------------------------------------------+ | |
344 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
345 | STATE : code ROUTINE : vsi_d_close | | |
346 +--------------------------------------------------------------------+ | |
347 | |
348 PURPOSE : close a driver | |
349 | |
350 */ | |
351 /*lint -esym(715,DrvHandle) suppress Info -- Symbol 'DrvHandle' not referenced */ | |
352 int vsi_d_close ( T_HANDLE Caller, T_HANDLE DrvHandle ) | |
353 { | |
354 | |
355 return VSI_OK; | |
356 } | |
357 #endif | |
358 | |
359 #ifndef RUN_INT_RAM | |
360 /* | |
361 +--------------------------------------------------------------------+ | |
362 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
363 | STATE : code ROUTINE : vsi_d_read | | |
364 +--------------------------------------------------------------------+ | |
365 | |
366 PURPOSE : read data from a driver | |
367 | |
368 */ | |
369 int vsi_d_read ( T_HANDLE Caller, T_HANDLE DrvHandle, void *Buffer, ULONG *Size ) | |
370 { | |
371 T_HANDLE Handle; | |
372 | |
373 if ( DrvHandle ) | |
374 Handle = DrvHandle; /* Caller TST: opened driver with vsi_d_open() */ | |
375 else | |
376 Handle = DrvTable[Caller].LowerDrv; /* Caller drv: handle defined by ConfigSring */ | |
377 | |
378 if ( DrvTable[Handle].DrvInfo->DrvFunc.drv_Read != NULL ) | |
379 if ( (DrvTable[Handle].DrvInfo->DrvFunc.drv_Read)( (void*)Buffer, Size ) == DRV_OK ) | |
380 return VSI_OK; | |
381 | |
382 return VSI_ERROR; | |
383 } | |
384 #endif | |
385 | |
386 #ifndef RUN_FLASH | |
387 /* | |
388 +--------------------------------------------------------------------+ | |
389 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
390 | STATE : code ROUTINE : vsi_d_write | | |
391 +--------------------------------------------------------------------+ | |
392 | |
393 PURPOSE : write data to a driver | |
394 | |
395 */ | |
396 int vsi_d_write ( T_HANDLE Caller, T_HANDLE DrvHandle, void *Buffer, ULONG Size ) | |
397 { | |
398 T_HANDLE Handle; | |
399 ULONG TotalBytesToWrite = Size; | |
400 ULONG BytesToWrite = Size; | |
401 ULONG TotalBytesWritten = 0; | |
402 ULONG BytesWritten = 0; | |
403 char *ptr = (char*)Buffer; | |
404 | |
405 if ( DrvHandle ) | |
406 Handle = DrvHandle; /* Caller TST: opened driver with vsi_d_open() */ | |
407 else | |
408 Handle = DrvTable[Caller].LowerDrv; /* Caller drv: handle defined by ConfigSring */ | |
409 | |
410 if ( DrvTable[Handle].DrvInfo->DrvFunc.drv_Write != NULL ) | |
411 { | |
412 while ( TotalBytesWritten < TotalBytesToWrite ) | |
413 { | |
414 BytesWritten = BytesToWrite; | |
415 if ( (DrvTable[Handle].DrvInfo->DrvFunc.drv_Write)( (void*)ptr, &BytesWritten ) != DRV_OK ) | |
416 return VSI_ERROR; | |
417 ptr += BytesWritten; | |
418 TotalBytesWritten += BytesWritten; | |
419 BytesToWrite = TotalBytesToWrite - TotalBytesWritten; | |
420 } | |
421 } | |
422 return VSI_OK; | |
423 } | |
424 #endif | |
425 | |
426 #ifndef RUN_INT_RAM | |
427 /* | |
428 +--------------------------------------------------------------------+ | |
429 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
430 | STATE : code ROUTINE : vsi_d_flush | | |
431 +--------------------------------------------------------------------+ | |
432 | |
433 PURPOSE : flush the internal buffers of a driver | |
434 | |
435 */ | |
436 int vsi_d_flush ( T_HANDLE Caller, T_HANDLE DrvHandle ) | |
437 { | |
438 T_HANDLE Handle; | |
439 T_HANDLE min, max; | |
440 | |
441 if ( DrvHandle ) | |
442 { | |
443 min = DrvHandle; | |
444 max = DrvHandle+1; | |
445 } | |
446 else | |
447 { | |
448 min = 1; | |
449 max = MAX_TST_DRV; | |
450 } | |
451 | |
452 for ( Handle = min; Handle < max; Handle++ ) | |
453 { | |
454 if ( DrvTable[Handle].DrvInfo ) | |
455 if ( DrvTable[Handle].DrvInfo->DrvFunc.drv_Flush != NULL ) | |
456 if ( (DrvTable[Handle].DrvInfo->DrvFunc.drv_Flush)() != DRV_OK ) | |
457 return VSI_ERROR; | |
458 } | |
459 return VSI_OK; | |
460 } | |
461 #endif | |
462 | |
463 #ifndef RUN_INT_RAM | |
464 /* | |
465 +--------------------------------------------------------------------+ | |
466 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
467 | STATE : code ROUTINE : vsi_d_setsignal | | |
468 +--------------------------------------------------------------------+ | |
469 | |
470 PURPOSE : enable a signal in a driver | |
471 | |
472 */ | |
473 int vsi_d_setsignal ( T_HANDLE Caller, T_HANDLE DrvHandle, USHORT SignalType ) | |
474 { | |
475 T_HANDLE Handle; | |
476 T_HANDLE min, max; | |
477 | |
478 if ( DrvHandle ) | |
479 { | |
480 min = DrvHandle; | |
481 max = DrvHandle+1; | |
482 } | |
483 else | |
484 { | |
485 min = 1; | |
486 max = MAX_TST_DRV; | |
487 } | |
488 | |
489 for ( Handle = min; Handle < max; Handle++ ) | |
490 { | |
491 if ( DrvTable[Handle].DrvInfo ) | |
492 if ( DrvTable[Handle].DrvInfo->DrvFunc.drv_SetSignal != NULL ) | |
493 if ( (DrvTable[Handle].DrvInfo->DrvFunc.drv_SetSignal)( SignalType ) != DRV_OK ) | |
494 return VSI_ERROR; | |
495 } | |
496 return VSI_OK; | |
497 } | |
498 #endif | |
499 | |
500 #ifndef RUN_INT_RAM | |
501 /* | |
502 +--------------------------------------------------------------------+ | |
503 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
504 | STATE : code ROUTINE : vsi_d_resetsignal | | |
505 +--------------------------------------------------------------------+ | |
506 | |
507 PURPOSE : disable a signal in a driver | |
508 | |
509 */ | |
510 int vsi_d_resetsignal ( T_HANDLE Caller, T_HANDLE DrvHandle, USHORT SignalType ) | |
511 { | |
512 T_HANDLE Handle; | |
513 T_HANDLE min, max; | |
514 | |
515 if ( DrvHandle ) | |
516 { | |
517 min = DrvHandle; | |
518 max = DrvHandle+1; | |
519 } | |
520 else | |
521 { | |
522 min = 1; | |
523 max = MAX_TST_DRV; | |
524 } | |
525 | |
526 for ( Handle = min; Handle < max; Handle++ ) | |
527 { | |
528 if ( DrvTable[Handle].DrvInfo ) | |
529 if ( DrvTable[Handle].DrvInfo->DrvFunc.drv_ResetSignal != NULL ) | |
530 if ( (DrvTable[Handle].DrvInfo->DrvFunc.drv_ResetSignal)( SignalType ) != DRV_OK ) | |
531 return VSI_ERROR; | |
532 } | |
533 return VSI_OK; | |
534 } | |
535 #endif | |
536 | |
537 #ifndef RUN_INT_RAM | |
538 /* | |
539 +--------------------------------------------------------------------+ | |
540 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
541 | STATE : code ROUTINE : vsi_d_setconfig | | |
542 +--------------------------------------------------------------------+ | |
543 | |
544 PURPOSE : configure a driver | |
545 | |
546 */ | |
547 int vsi_d_setconfig ( T_HANDLE Caller, T_HANDLE DrvHandle, char *Config ) | |
548 { | |
549 T_HANDLE Handle; | |
550 | |
551 if ( Config && DrvHandle != 0) | |
552 { | |
553 if ( DrvTable[DrvHandle].DrvInfo->DrvFunc.drv_SetConfig != NULL ) | |
554 if ( (DrvTable[DrvHandle].DrvInfo->DrvFunc.drv_SetConfig)( Config ) != DRV_OK ) | |
555 return VSI_ERROR; | |
556 } | |
557 else | |
558 { | |
559 T_HANDLE min, max; | |
560 | |
561 if ( DrvHandle ) | |
562 { | |
563 min = DrvHandle; | |
564 max = DrvHandle+1; | |
565 } | |
566 else | |
567 { | |
568 min = 1; | |
569 max = MAX_TST_DRV; | |
570 } | |
571 | |
572 for ( Handle = min; Handle < max; Handle++ ) | |
573 { | |
574 if ( DriverList->DrvEntry[Handle].DrvConfig ) | |
575 { | |
576 if ( DrvTable[Handle].DrvInfo->DrvFunc.drv_SetConfig != NULL ) | |
577 if ( (DrvTable[Handle].DrvInfo->DrvFunc.drv_SetConfig)( (char*)DriverList->DrvEntry[Handle].DrvConfig ) != DRV_OK ) | |
578 return VSI_ERROR; | |
579 } | |
580 } | |
581 } | |
582 return VSI_OK; | |
583 } | |
584 #endif | |
585 | |
586 #ifndef RUN_INT_RAM | |
587 /* | |
588 +--------------------------------------------------------------------+ | |
589 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
590 | STATE : code ROUTINE : vsi_d_getconfig | | |
591 +--------------------------------------------------------------------+ | |
592 | |
593 PURPOSE : read configuration data from a driver | |
594 | |
595 */ | |
596 | |
597 int vsi_d_getconfig ( T_HANDLE Caller, T_HANDLE DrvHandle, char *Config ) | |
598 { | |
599 T_HANDLE Handle; | |
600 char Buffer[40]; | |
601 char *ptr = Config; | |
602 | |
603 Handle = DrvHandle; | |
604 while ( Handle ) | |
605 { | |
606 if ( DrvTable[Handle].DrvInfo ) | |
607 if ( DrvTable[Handle].DrvInfo->DrvFunc.drv_GetConfig != NULL ) | |
608 if ( (DrvTable[Handle].DrvInfo->DrvFunc.drv_GetConfig)( Buffer ) != DRV_OK ) | |
609 return VSI_ERROR; | |
610 | |
611 sprintf ( ptr, "%s:%s;",DrvTable[Handle].DrvInfo->Name,Buffer ); | |
612 ptr = ptr + strlen(DrvTable[Handle].DrvInfo->Name) + strlen(Buffer) + 2; | |
613 Handle = DrvTable[Handle].LowerDrv; | |
614 } | |
615 return VSI_OK; | |
616 } | |
617 #endif | |
618 | |
619 #ifndef RUN_INT_RAM | |
620 /* | |
621 +--------------------------------------------------------------------+ | |
622 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
623 | STATE : code ROUTINE : InitializeDriverTable | | |
624 +--------------------------------------------------------------------+ | |
625 | |
626 PURPOSE : Initialize the driver table | |
627 | |
628 */ | |
629 void InitializeDriverConfig ( void ) | |
630 { | |
631 #ifdef _TOOLS_ | |
632 USHORT j; | |
633 | |
634 for ( j = 1; j < MAX_TST_DRV ; j++ ) | |
635 { | |
636 if ( DriverConfigList->DrvEntry[j].Name ) | |
637 { | |
638 strcpy ( _DrvList.DrvEntry[j].Name, DriverConfigList->DrvEntry[j].Name ); | |
639 DrvList.DrvEntry[j].Name = _DrvList.DrvEntry[j].Name; | |
640 } | |
641 | |
642 if ( DriverConfigList->DrvEntry[j].drv_Init ) | |
643 { | |
644 DrvList.DrvEntry[j].drv_Init = DriverConfigList->DrvEntry[j].drv_Init; | |
645 } | |
646 | |
647 if ( DriverConfigList->DrvEntry[j].Process ) | |
648 { | |
649 strcpy ( _DrvList.DrvEntry[j].Process, DriverConfigList->DrvEntry[j].Process ); | |
650 DrvList.DrvEntry[j].Process = _DrvList.DrvEntry[j].Process; | |
651 } | |
652 | |
653 if ( DriverConfigList->DrvEntry[j].DrvConfig ) | |
654 { | |
655 strcpy ( _DrvList.DrvEntry[j].DrvConfig, DriverConfigList->DrvEntry[j].DrvConfig ); | |
656 DrvList.DrvEntry[j].DrvConfig = _DrvList.DrvEntry[j].DrvConfig; | |
657 } | |
658 } | |
659 | |
660 DriverList = &DrvList; | |
661 #else | |
662 DriverList = DriverConfigList; | |
663 #endif /* _TOOLS_ */ | |
664 ClearDriverTable(); | |
665 } | |
666 #endif | |
667 | |
668 #ifndef RUN_INT_RAM | |
669 /* | |
670 +--------------------------------------------------------------------+ | |
671 | PROJECT : GSM-Frame (8415) MODULE : VSI_DRV | | |
672 | STATE : code ROUTINE : ClearDriverTable | | |
673 +--------------------------------------------------------------------+ | |
674 | |
675 PURPOSE : Clear the driver table | |
676 | |
677 */ | |
678 void ClearDriverTable ( void ) | |
679 { | |
680 char i; | |
681 | |
682 for ( i = 1; i <= MAX_TST_DRV; i++ ) | |
683 { | |
684 memset ( &DrvTable[i], 0, sizeof(T_DRV_TABLE_ENTRY) ); | |
685 } | |
686 | |
687 } | |
688 #endif |