comparison g23m-glue/cst/cst_pei.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 bceffa414fc6
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /*
2 +--------------------------------------------------------------------+
3 /*
4 +-------------------------------------------------------------------+
5 | PROJECT: GSM-F&D (8411) $Workfile:: cst_pei.c $|
6 | $Author:: Be $ CONDAT GmbH $Revision:: 14 $|
7 | CREATED: 01.02.99 $Modtime:: 14.02.00 12:14 $|
8 | STATE : code |
9 +--------------------------------------------------------------------+
10
11 MODULE : CST_PEI
12
13 PURPOSE : This Modul defines the process body interface for the
14 component CST of the mobile station.
15
16 EXPORT : pei_create - Create the Protocol Stack Entity
17 pei_init - Initialize Protocol Stack Entity
18 pei_primitive - Process Primitive
19 pei_timeout - Process Timeout
20 pei_exit - Close resources and terminate
21 pei_run - Process Primitive
22 pei_config - Dynamic Configuration
23 pei_monitor - Monitoring of physical Parameters
24 */
25
26 #ifndef CST_PEI_C
27 #define CST_PEI_C
28 #endif
29
30 #include "config.h"
31 #include "fixedconf.h"
32 #include "condat-features.h"
33
34 #define ENTITY_CST
35
36 /*==== INCLUDES ===================================================*/
37
38 #include <string.h>
39 #include <stdlib.h>
40 #include <ctype.h>
41 #include "typedefs.h"
42 #include "vsi.h"
43 #include "custom.h"
44 #include "gsm.h"
45 #include "prim.h"
46 #include "cnf_cst.h"
47 #include "cus_cst.h"
48 #include "mon_cst.h"
49 #include "tok.h"
50 #include "p_cst.h"
51 #include "cst.h"
52 #include "rx.h"
53 #include "audio.h"
54
55 /*==== CONSTANTS ==================================================*/
56
57 // token processing
58 #define ERROR -1
59 #define EOS 1
60 #define COMMA 2
61 #define EQUAL 3
62 #define IDENT 4
63 #define STRING 5
64 #define LBRACK 6
65 #define RBRACK 7
66
67 /*==== EXPORT =====================================================*/
68 extern void CST_stack_trace(void);
69 int cst_gsm_parameters(TOK_DCB *dcb);
70 extern void l1_cst_l1_parameters(char*);
71 extern void csf_adc_start (UBYTE tx_flag, UBYTE traffic_period, UBYTE idle_period);
72 extern void spi_adc_on (void);
73
74 GLOBAL T_HANDLE t_adc_timer = VSI_ERROR;
75 GLOBAL T_HANDLE hCommPL = VSI_ERROR; /* PL Communication */
76 GLOBAL T_HANDLE hCommL1 = VSI_ERROR; /* L1 Communication */
77 T_HANDLE cst_handle;
78 GLOBAL UBYTE extDisplay = 0;
79
80 EXTERN UBYTE audio_is_free;
81 /*==== PRIVATE ====================================================*/
82
83 LOCAL void pei_not_supported (void *data);
84
85 #ifdef OPTION_RELATIVE
86 LOCAL ULONG offset;
87 #endif
88
89 /*==== VARIABLES ==================================================*/
90
91 LOCAL USHORT t_flag = 0;
92 LOCAL BOOL exit_flag = FALSE;
93 LOCAL BOOL first_access = TRUE;
94 LOCAL T_MONITOR cst_mon;
95
96 /*==== FUNCTIONS ==================================================*/
97 LOCAL const T_FUNC cst_table[] =
98 {
99 MAK_FUNC_0 ( csf_adc_process , CST_ADC_IND )
100 };
101
102 /*==== PROTOTYPES==================================================*/
103
104 #if 1 //defined (_TMS470)
105
106 static SHORT cst_tok_gettok (TOK_DCB *dcb, char ** token);
107 static SHORT cst_tok_value (TOK_DCB *dcb, char * value []);
108 static int cst_tokenizer_has_more_data(const TOK_DCB *dcb);
109 static SHORT cst_tok_issep (char c);
110 static void cst_tok_init (char * s, TOK_DCB *dcb, char *buf, int buf_len);
111 static SHORT cst_get_values(TOK_DCB *dcb, char *value[]);
112 static int cst_getbyte(TOK_DCB *dcb);
113
114 #endif
115
116 /*
117 +--------------------------------------------------------------------+
118 | PROJECT : XXX MODULE : CST_PEI |
119 | STATE : code ROUTINE : pei_primitive |
120 +--------------------------------------------------------------------+
121
122 PURPOSE : This function processes protocol specific primitives.
123 */
124 LOCAL SHORT pei_primitive (void * ptr)
125 {
126 T_PRIM *prim = ptr;
127
128 if (prim NEQ NULL)
129 {
130 USHORT opc = prim->custom.opc;
131 USHORT n;
132 const T_FUNC *table;
133
134 VSI_PPM_REC ((T_PRIM_HEADER*)prim, __FILE__, __LINE__);
135
136 switch (opc & OPC_MASK)
137 {
138 case CST_DL: table = cst_table; n = TAB_SIZE (cst_table); break;
139 default : table = NULL; n = 0; break;
140 }
141
142 if (table != NULL )
143 {
144 if ((opc & PRM_MASK) < n)
145 {
146 table += opc & PRM_MASK;
147 #ifdef PALLOC_TRANSITION
148 P_SDU(prim) = table->soff ? (T_sdu*) (((char*)&prim->data) + table->soff) : 0;
149 P_LEN(prim) = table->size + sizeof (T_PRIM_HEADER);
150 #endif
151 JUMP (table->func) (P2D(prim));
152 }
153 else
154 {
155 pei_not_supported (P2D(prim));
156 }
157 return PEI_OK;
158 }
159
160 #ifdef GSM_ONLY
161 PFREE (P2D(prim))
162 return PEI_ERROR;
163 #else
164 if (opc & SYS_MASK)
165 {
166 vsi_c_primitive (VSI_CALLER prim);
167 }
168 else
169 {
170 PFREE (P2D(prim))
171 return PEI_ERROR;
172 }
173 #endif
174 }
175 return PEI_OK;
176 }
177
178 /*
179 +--------------------------------------------------------------------+
180 | PROJECT : XXX MODULE : CST_PEI |
181 | STATE : code ROUTINE : pei_not_supported |
182 +--------------------------------------------------------------------+
183
184 PURPOSE : This function handles an unsupported primitive.
185 */
186 LOCAL void pei_not_supported (void *data)
187 {
188 TRACE_FUNCTION ("pei_not_supported()");
189
190 PFREE (data);
191 }
192
193
194 /*
195 +--------------------------------------------------------------------+
196 | PROJECT : XXX MODULE : CST_PEI |
197 | STATE : code ROUTINE : pei_init |
198 +--------------------------------------------------------------------+
199
200 PURPOSE : This function initializes the protocol stack entity
201
202 */
203
204 LOCAL SHORT pei_init (T_HANDLE handle)
205 {
206 cst_handle = handle;
207
208 TRACE_FUNCTION ("pei_init()");
209
210 exit_flag = FALSE;
211
212 if (hCommPL < VSI_OK)
213 {
214 if ((hCommPL = vsi_c_open (VSI_CALLER PL_NAME)) < VSI_OK)
215 {
216 return PEI_ERROR;
217 }
218 }
219
220 if (hCommL1 < VSI_OK)
221 {
222 if ((hCommL1 = vsi_c_open (VSI_CALLER L1_NAME)) < VSI_OK)
223 {
224 return PEI_ERROR;
225 }
226 }
227
228 vsi_t_start (VSI_CALLER CST_ADC_TIMER, 230); // equal to 50 TDMA frames
229
230 #if 1 //defined (_TMS470)
231 // Set the sleep mode authorized for the layer1 synchronous.
232 // Possible modes are :
233 // for CHIPSET = 0 : NO_SLEEP, SMALL_SLEEP, BIG_SLEEP.
234 // It is necessary to indicate in the prototype of power_down_config()
235 // function which clocks (amongst ARMIO_CLK, UWIRE_CLK, SIM_CLK and UART_CLK)
236 // to be stopped in case of BIG_SLEEP mode.
237 // With this default init, ARMIO_CLK, UWIRE_CLK, SIM_CLK and UART_CLK will be stopped
238 // in case of BIG_SLEEP mode, but it can be changed here.
239
240 // other CHIPSETs : NO_SLEEP, SMALL_SLEEP, BIG_SLEEP, DEEP_SLEEP, ALL_SLEEP.
241 // It is necessary to indicate in the prototype of power_down_config()
242 // function which clocks to be stopped in case of BIG_SLEEP mode,
243 // amongst ARMIO and UWIRE clocks.
244 // With this default init, UWIRE_CLK will always be stopped
245 // in case of BIG_SLEEP mode, but it can be changed here.
246
247 // The default configuration is ALL SLEEP. It can be changed in this init.
248
249 // WARNING !! THE SLEEP MODE SHOULD NOT BE MODIFIED ONCE THE SYSTEM INIT IS FINISHED !!
250
251 #if !defined (TI_VERSION)
252 #if (CHIPSET == 0)
253 power_down_config(NO_SLEEP, ARMIO_CLK | UWIRE_CLK | SIM_CLK | UART_CLK);
254 #elif ((CHIPSET == 2) || (CHIPSET == 3) || \
255 (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11))
256 power_down_config(ALL_SLEEP, UWIRE_CLK_CUT);
257 #elif ((CHIPSET == 4) || (CHIPSET == 9))
258 power_down_config(NO_SLEEP, UWIRE_CLK_CUT);
259 #endif
260 #endif
261 #endif
262
263 return PEI_OK;
264 }
265
266 /*
267 +--------------------------------------------------------------------+
268 | PROJECT : XXX MODULE : CST_PEI |
269 | STATE : code ROUTINE : pei_timeout |
270 +--------------------------------------------------------------------+
271
272 PURPOSE : This function processes timeouts.
273 */
274
275 LOCAL SHORT pei_timeout (USHORT index)
276 {
277 rx_timeout (index);
278 audio_timeout (index);
279
280 if (index EQ CST_ADC_TIMER)
281 {
282 // start the AD conversions in layer1 synchronous
283 // this function will send MMI_ADC_REQ primitive to L1A for test reason.
284 // The user has to implement it by himself in the MMI.
285 // The parameters are : tx_flag, traffic_period, idle_period.
286 // Please refer to the ADC specification for details.
287
288 // WCS Patch : Schedule ADC on RX and TX
289 #if (OP_WCP == 1)
290 csf_adc_start(1, 10, 1);
291 #else
292 csf_adc_start(0, 10, 1);
293 #endif
294
295 spi_adc_on();
296 }
297
298 return PEI_OK;
299 }
300
301
302 /*
303 +--------------------------------------------------------------------+
304 | PROJECT : XXX MODULE : CST_PEI |
305 | STATE : code ROUTINE : pei_exit |
306 +--------------------------------------------------------------------+
307
308 PURPOSE : This function closes all resources and terminates.
309 */
310
311 LOCAL SHORT pei_exit (void)
312 {
313 TRACE_FUNCTION ("pei_exit()");
314
315 /*
316 * clean up communication
317 */
318
319 vsi_c_close (VSI_CALLER hCommPL);
320 hCommPL = VSI_ERROR;
321
322 vsi_c_close (VSI_CALLER hCommL1);
323 hCommL1 = VSI_ERROR;
324
325 exit_flag = TRUE;
326
327 return PEI_OK;
328 }
329
330 /*
331 +--------------------------------------------------------------------+
332 | PROJECT : XXX MODULE : CST_PEI |
333 | STATE : code ROUTINE : pei_config |
334 +--------------------------------------------------------------------+
335
336 PURPOSE : Dynamic Configuration
337
338 */
339
340 #if !defined (NCONFIG)
341 LOCAL KW_DATA kwtab[] = {
342 CST_CONFIG, ID_CONFIG,
343 CST_MUTE, ID_MUTE,
344 CST_GSM_PARAMETERS, ID_GSM_PARAMETERS,
345 CST_L1_PARAMETERS, ID_L1_PARAMETERS,
346 "", 0
347 };
348
349 GLOBAL KW_DATA partab[] = {
350 "", 0
351 };
352 #endif
353
354
355 GLOBAL SHORT pei_config (T_PEI_CONFIG inString)
356 {
357 #if !defined (NCONFIG)
358 char * s = inString;
359 SHORT valno;
360 USHORT keyno;
361 char * keyw;
362 char * val [10];
363 TOK_DCB tokenizer;
364 char token_buf[80];
365 SHORT token_type;
366 int error; /* terminate processing */
367
368 TRACE_FUNCTION ("pei_config()");
369
370 TRACE_FUNCTION (s);
371
372 cst_tok_init(s, &tokenizer, &token_buf[0], sizeof(token_buf));
373
374 /*
375 * Parse next keyword and number of variables
376 */
377 error = 0;
378 while (!error && cst_tokenizer_has_more_data(&tokenizer))
379 {
380 token_type = cst_tok_gettok(&tokenizer, &keyw);
381 if (token_type != IDENT)
382 {
383 error = 1;
384 }
385 else
386 {
387 switch ((keyno = tok_key((KW_DATA *)kwtab, keyw)))
388 {
389 case ID_CONFIG:
390 valno = cst_get_values(&tokenizer, val);
391 if (valno EQ 3)
392 {
393 extDisplay = 1;
394 }
395 break;
396 case ID_MUTE:
397 valno = cst_get_values(&tokenizer, val); /* eat up rest of line */
398 /*
399 * FTA testcase 26.6.3.4 needs the the MS is in audio free
400 * environment. This config disables opening of the audio
401 * path.
402 */
403 audio_is_free = FALSE;
404 break;
405 case ID_GSM_PARAMETERS:
406 cst_gsm_parameters(&tokenizer);
407 break;
408 case ID_L1_PARAMETERS:
409 /* pass parameters to L1 function for further process */
410 l1_cst_l1_parameters(s);
411 valno = cst_get_values(&tokenizer, val); /* eat up rest of line */
412 break;
413 default:
414 TRACE_ERROR ("[PEI_CONFIG]: Illegal Keyword");
415 break;
416 }
417 }
418 }
419 #endif
420 return PEI_OK;
421 }
422
423 /*
424 +--------------------------------------------------------------------+
425 | PROJECT : GSM-PS (6147) MODULE : CST_PEI |
426 | STATE : code ROUTINE : cst_pei_config |
427 +--------------------------------------------------------------------+
428
429 PURPOSE : Dynamic Configuration
430
431 */
432
433 GLOBAL SHORT cst_pei_config ( char * inString, char * dummy )
434 {
435 pei_config ( inString );
436 }
437
438
439 /*
440 +--------------------------------------------------------------------+
441 | PROJECT : XXX MODULE : CST_PEI |
442 | STATE : code ROUTINE : pei_monitor |
443 +--------------------------------------------------------------------+
444
445 PURPOSE : This function monitors physical parameters.
446 */
447 LOCAL SHORT pei_monitor (void ** monitor)
448 {
449 TRACE_FUNCTION ("pei_monitor()");
450
451 cst_mon.version = VERSION_CST;
452
453 *monitor = &cst_mon;
454
455 return PEI_OK;
456 }
457
458 /*
459 +--------------------------------------------------------------------+
460 | PROJECT : XXX MODULE : CST_PEI |
461 | STATE : code ROUTINE : pei_create |
462 +--------------------------------------------------------------------+
463
464 PURPOSE : This function creates the protocol stack entity.
465 */
466
467 GLOBAL SHORT cst_pei_create (T_PEI_INFO **info)
468 {
469 static const T_PEI_INFO pei_info =
470 {
471 "CST",
472 {
473 pei_init,
474 pei_exit,
475 pei_primitive,
476 pei_timeout,
477 NULL, /* no signal function */
478 NULL, /* no run function */
479 pei_config,
480 pei_monitor,
481 },
482 1536, /* Stack Size */
483 10, /* Queue Entries */
484 55, /* Priority */
485 MAX_CST_TIMER, /* number of timer */
486 0x03 /* flags */
487 };
488
489 TRACE_FUNCTION ("pei_create()");
490
491 /*
492 * Close Resources if open
493 */
494
495 if (first_access)
496 first_access = FALSE;
497 else
498 pei_exit ();
499
500 /*
501 * Export startup configuration data
502 */
503
504 *info = (T_PEI_INFO *)&pei_info;
505
506 return PEI_OK;
507 }
508
509
510 /*
511 +--------------------------------------------------------------------+
512 | PROJECT : XXX MODULE : CST_PEI |
513 | STATE : code ROUTINE : cst_tok_init |
514 +--------------------------------------------------------------------+
515
516 PURPOSE : Initialize token scanner.
517
518 */
519 static void cst_tok_init (char * s, TOK_DCB *dcb, char *buf, int buf_len)
520 {
521 int i;
522 dcb->nexttok = dcb->tokbuf = buf;
523 // can't use strcpy since it stops at 0s
524 for (i=0; i<buf_len-1; i++)
525 {
526 dcb->tokbuf[i] = s[i];
527 }
528 dcb->tokbuf[buf_len-1] = '\0';
529 dcb->lastchar = 0;
530 }
531
532 /*
533 +--------------------------------------------------------------------+
534 | PROJECT : XXX MODULE : CST_PEI |
535 | STATE : code ROUTINE : cst_get_values |
536 +--------------------------------------------------------------------+
537 */
538 static SHORT cst_get_values(TOK_DCB *dcb, char *value[])
539 {
540 char * val; /* not identifier, so thrown away */
541 /*
542 * Check next token
543 */
544 switch (cst_tok_gettok (dcb, &val))
545 {
546 /*
547 * No value present
548 */
549 case COMMA:
550 return (0);
551 /*
552 * Value(s) follows
553 */
554 case EQUAL:
555 return (cst_tok_value (dcb, value));
556 /*
557 * No value present and EOS
558 */
559 case EOS:
560 dcb->nexttok = NULL;
561 return (0);
562 /*
563 * Syntax error
564 */
565 default:
566 dcb->nexttok = NULL;
567 return (TOK_EOCS);
568 }
569 }
570
571 /*
572 +--------------------------------------------------------------------+
573 | PROJECT : XXX MODULE : CST_PEI |
574 | STATE : code ROUTINE : cst_tok_value |
575 +--------------------------------------------------------------------+
576 */
577 static SHORT cst_tok_value (TOK_DCB *dcb, char * value [])
578 {
579 SHORT count;
580 SHORT tok;
581 SHORT inbrack;
582 char * val;
583 char * val2;
584
585 inbrack = 0;
586 /*
587 * Get next token
588 */
589 tok = cst_tok_gettok (dcb, &val);
590
591 switch (tok)
592 {
593 case LBRACK:
594 inbrack++;
595 break;
596
597 case IDENT :
598 case STRING :
599 tok = cst_tok_gettok (dcb, &val2); /* val2 ignored since next tok */
600 if ((tok == COMMA) || (tok == EOS)) /* shouldn't be an IDENT */
601 {
602 /* just single value, return */
603 value[0] = val;
604 return (1);
605 }
606 else
607 {
608 /* error */
609 dcb->nexttok = NULL;
610 return (0);
611 }
612
613 case EOS :
614 default :
615 dcb->nexttok = NULL;
616 return (0);
617 }
618
619 /*
620 * Get first token of list
621 */
622
623 tok = cst_tok_gettok (dcb, &val);
624 count = 0;
625 while (1)
626 {
627 if ((tok == IDENT) || (tok == STRING))
628 {
629 value[count++] = val;
630 }
631 else
632 {
633 dcb->nexttok = NULL;
634 return (0);
635 }
636
637 tok = cst_tok_gettok (dcb, &val);
638 switch (tok)
639 {
640 case COMMA:
641 break;
642
643 case RBRACK :
644 if (inbrack)
645 {
646 if (((tok = cst_tok_gettok (dcb, &val)) == COMMA) ||
647 (tok == EOS))
648 {
649 return (count);
650 }
651 }
652 /*
653 * Fall through
654 */
655 default:
656 dcb->nexttok = NULL;
657 return (0);
658 }
659 tok = cst_tok_gettok (dcb, &val);
660 }
661 return (0);
662 }
663
664 /*
665 +--------------------------------------------------------------------+
666 | PROJECT : XXX MODULE : CST_PEI |
667 | STATE : code ROUTINE : cst_tok_gettok |
668 +--------------------------------------------------------------------+
669
670 PURPOSE : Get list of values for token.
671 Return number of values found.
672
673 Formats: Value
674 (Value)
675 (Value, Value,...)
676 ()
677 */
678 static SHORT cst_tok_gettok (TOK_DCB *dcb, char ** token)
679 {
680 SHORT tok;
681 /* if previous token was IDENT, a '\0' was placed afterwards
682 * for string processing and the overwritten character was
683 * placed in lastchar. We now replace this character.
684 */
685 if (dcb->lastchar)
686 {
687 *(dcb->nexttok) = dcb->lastchar;
688 dcb->lastchar = 0;
689 }
690 /*
691 * Skip leading white space
692 */
693 while (isspace (*(dcb->nexttok)))
694 {
695 dcb->nexttok++;
696 }
697
698 * token = dcb->nexttok++;
699
700 switch (** token)
701 {
702 case '\0': /* End of string */
703 case '\n':
704 tok = EOS;
705 break;
706
707 case ',':
708 ** token = '\0';
709 tok = COMMA;
710 break;
711
712 case '=':
713 ** token = '\0';
714 tok = EQUAL;
715 break;
716
717 case '(':
718 case '<':
719 case '[':
720 ** token = '\0';
721 tok = LBRACK;
722 break;
723
724 case ')':
725 case '>':
726 case ']':
727 ** token = '\0';
728 tok = RBRACK;
729 break;
730
731 case '"':
732 /*
733 * Get first char of string
734 */
735 * token = dcb->nexttok;
736 while ((*(dcb->nexttok) != '\0') && (*(dcb->nexttok) != '"'))
737 {
738 dcb->nexttok++;
739 }
740
741 if (*(dcb->nexttok) != '\0')
742 {
743 *(dcb->nexttok++) = '\0';
744 }
745
746 tok = STRING;
747 break;
748
749 default:
750 /*
751 * Read an identifier
752 */
753 while ( !cst_tok_issep (*(dcb->nexttok)) )
754 {
755 dcb->nexttok++;
756 }
757
758 dcb->lastchar = *(dcb->nexttok);
759 *(dcb->nexttok) = '\0';
760
761 if (*token == dcb->nexttok)
762 {
763 /* no characters in identifier. Error in code! */
764 tok = ERROR;
765 }
766 else
767 {
768 tok = IDENT;
769 }
770 break;
771 }
772 return (tok);
773 }
774
775 /*
776 +--------------------------------------------------------------------+
777 | PROJECT : XXX MODULE : CST_PEI |
778 | STATE : code ROUTINE : cst_tok_issep |
779 +--------------------------------------------------------------------+
780
781 PURPOSE : Return 1 if special character.
782 */
783 static SHORT cst_tok_issep (char c)
784 {
785 switch (c)
786 {
787 case '\0' :
788 case '\n' :
789 case ',' :
790 case '=' :
791 case '(' :
792 case '<' :
793 case '[' :
794 case ')' :
795 case '>' :
796 case ']' :
797 case '"' : return (1);
798
799 default : return (isspace (c));
800 }
801 }
802
803 /* if string in tokenizer state has unprocessed tokens return 1 */
804 /*
805 +--------------------------------------------------------------------+
806 | PROJECT : XXX MODULE : CST_PEI |
807 | STATE : code ROUTINE : cst_tokenizer_has_more_data |
808 +--------------------------------------------------------------------+
809
810 PURPOSE : Return 1 if string in tokenizer state has unprocessed tokens.
811 */
812 static int cst_tokenizer_has_more_data(const TOK_DCB *dcb)
813 {
814 return (dcb->nexttok != NULL);
815 }
816
817 /*
818 +--------------------------------------------------------------------+
819 | PROJECT : XXX MODULE : CST_PEI |
820 | STATE : code ROUTINE : cst_getbyte |
821 +--------------------------------------------------------------------+
822 */
823
824 static int cst_getbyte(TOK_DCB *dcb)
825 {
826 if (dcb->nexttok)
827 {
828 return *(dcb->nexttok++);
829 }
830 else
831 {
832 return -1;
833 }
834 }
835
836 /*
837 +--------------------------------------------------------------------+
838 | PROJECT : XXX MODULE : CST_PEI |
839 | STATE : code ROUTINE : cst_gsm_parameters |
840 +--------------------------------------------------------------------+
841 */
842
843 int cst_gsm_parameters(TOK_DCB *dcb)
844 {
845 unsigned char id;
846 char str[80];
847 int i;
848
849 // STRIP FIRST TWO DELIMITERS
850 {
851 char *tok_string;
852
853 if (cst_tok_gettok(dcb, &tok_string) != EQUAL)
854 {
855 return (0);
856 }
857 if (cst_tok_gettok(dcb, &tok_string) != LBRACK)
858 {
859 return (0);
860 }
861 }
862
863 // GET CONTROL ID
864 if ((id = cst_getbyte(dcb)) == -1)
865 {
866 vsi_o_trace("CST", 0x08, "gsm_parameters() parser error: out of bytes");
867 return (0);
868 }
869
870 // STACK TRACE
871 else if (id == '1')
872 {
873 CST_stack_trace();
874 } //end else if (id == '1')
875
876 // Crash Me
877 else if (id == '2')
878 {
879 // No instruction before setting the reset vector
880 void (*reset_vector)() = (void (*)()) 0;
881 (*reset_vector)();
882 } //end else if (id == '2')
883 #if defined (ALR)
884 // Print Reg Copy
885 else if (id == '3')
886 {
887 extern int xdump_buffer;
888 int *xp = &xdump_buffer;
889 int magic_word;
890
891 // displays the 16 User mode 32bits registers saved on exception
892 // vsi_o_trace("CST", 0x08, "User mode registers [r0-r15] = ...");
893 for (i=0; i<4; i++)
894 {
895 sprintf(str, "%08x %08x %08x %08x", *(xp++), *(xp++),
896 *(xp++), *(xp++));
897 vsi_o_trace("CST", 0x08, str);
898 }
899
900 // displays the User mode CPSR saved on exception
901 sprintf(str, "User mode CPSR = %08x", *(xp++));
902 vsi_o_trace("CST", 0x08, str);
903
904 // displays the magic word and the index of vector taken
905 magic_word = *(xp++);
906 sprintf(str, "Magic Word + Index of Vector = %08x", magic_word);
907 vsi_o_trace("CST", 0x08, str);
908
909 // displays the cause of the exception
910 magic_word &= 0x000F;
911
912 switch (magic_word) {
913
914 case 1:
915 vsi_o_trace("CST", 0x08, "Exception: Undefined Instruction");
916 break;
917
918 case 2:
919 vsi_o_trace("CST", 0x08, "Exception: Unexpected Software Interrupt");
920 break;
921
922 case 3:
923 vsi_o_trace("CST", 0x08, "Exception: Abort Prefetch");
924 break;
925
926 case 4:
927 vsi_o_trace("CST", 0x08, "Exception: Abort Data");
928 break;
929
930 case 5:
931 vsi_o_trace("CST", 0x08, "Exception: Reserved");
932 break;
933
934 default:
935 break;
936 }
937
938 // displays the bottom 20 words of user mode stack saved on exception
939 // vsi_o_trace("CST", 0x08, "Bottom 20 words of User mode stack = ...");
940 for (i=0; i<5; i++)
941 {
942 sprintf(str, "%08x %08x %08x %08x", *(xp++), *(xp++),
943 *(xp++), *(xp++));
944 vsi_o_trace("CST", 0x08, str);
945 }
946 } //end else if (id == '3')
947
948 // Clear Reg Copy
949 else if (id == '4')
950 {
951 extern int xdump_buffer;
952 int *xp = &xdump_buffer;
953 // Clears the 38 32bits registers saved on exception
954 for (i=0; i<38; i++)
955 {
956 *(xp+i) = 0;
957 }
958 // vsi_o_trace("CST", 0x08, "Registers Copy cleared ...");
959 } //end else if (id == '4')
960 #endif
961 #if (OP_WCP == 1)
962 #if (WCP_PROF == 1)
963 // Enable/disable MC profiler
964 else if (id == '5')
965 {
966 PR_EnableProfiler(0);
967 }
968 else if (id == '6')
969 {
970 PR_EnableProfiler(1);
971 power_down_config(0, 0x5ff); // disable sleep, which interferes with profiler
972 }
973
974 // Enable/disable CPU Meter
975 else if (id == '7')
976 {
977 PR_EnableCpuMeter(0);
978 }
979 else if (id == '8')
980 {
981 PR_EnableCpuMeter(1);
982 power_down_config(0, 0x5ff); // disable sleep, which interferes with CPU meter
983 }
984 #endif
985 #endif
986
987 // STRIP LAST DELIMITER
988 {
989 char *tok_string;
990
991 if (cst_tok_gettok(dcb, &tok_string) != RBRACK)
992 {
993 return (0);
994 }
995 }
996 } // end cst_gsm_parameters
997
998 /*
999 * Reach here if unexpected event occurs (e.g. Undefined instruction, Abort,
1000 * out of memory); choose whether to restart or stay in datadump mode to find
1001 * out cause of problem
1002 */
1003 void exception_handler(void)
1004 {
1005 void (*jump_address)() = (void (*)()) ((unsigned)0x0);
1006
1007 (*jump_address)();
1008 }