comparison src/cs/services/cst/cst_pei.c @ 0:92470e5d0b9e

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