FreeCalypso > hg > freecalypso-sw
changeset 832:c14bc60c6c30
gsm-fw/g23m-glue/cst: import from Leonardo source
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Thu, 23 Apr 2015 06:45:55 +0000 |
parents | 549b7ac60300 |
children | ea87417752f9 |
files | gsm-fw/g23m-glue/cst/cnf_cst.h gsm-fw/g23m-glue/cst/cst.h gsm-fw/g23m-glue/cst/cst_csf.c gsm-fw/g23m-glue/cst/cst_exts.c gsm-fw/g23m-glue/cst/cst_pei.c gsm-fw/g23m-glue/cst/cst_stack.c gsm-fw/g23m-glue/cst/cus_cst.h gsm-fw/g23m-glue/cst/mon_cst.h |
diffstat | 8 files changed, 2943 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/g23m-glue/cst/cnf_cst.h Thu Apr 23 06:45:55 2015 +0000 @@ -0,0 +1,35 @@ +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX SOURCE : CNF_CST.H | +| AUTHOR : CONDAT GmbH (pz) VERSION: 1.0 | +| CREATED : 01.02.99 STATE : code | ++--------------------------------------------------------------------+ + + MODULE : CNF_CST + + PURPOSE : Dynamic configuration for the entity CST. +*/ + +#ifndef CNF_CST_H +#define CNF_CST_H + +/*==== CONSTANTS ==================================================*/ +/* + * CONFIGURATION PARAMETER + * + * Description : The constants define the commands for dynamic + * configuration proposals. + */ + +#define CST_CONFIG "MMI_MODEL" +#define CST_MUTE "AUDIO_MUTE" +#define CST_GSM_PARAMETERS "GSM_PARAMETERS" +#define CST_L1_PARAMETERS "L1_PARAMS" + + +/*==== TYPES ======================================================*/ + +/*==== EXPORT =====================================================*/ + +#endif +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/g23m-glue/cst/cst.h Thu Apr 23 06:45:55 2015 +0000 @@ -0,0 +1,147 @@ +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX SOURCE : CST.H | +| AUTHOR : XXX VERSION: 1.0 | +| CREATED : 01.02.99 STATE : code | ++--------------------------------------------------------------------+ + + MODULE : CST + + PURPOSE : Definitions for the protocol stack entity CST. +*/ + +#ifndef CST_H +#define CST_H + +#include "config/swconfig.cfg" +#include "config/chipset.cfg" + +/*==== TEST =====================================================*/ + +/* + * Dynamic Configuration Numbers + */ +#define ID_CONFIG 1 +#define ID_MUTE 2 +#define ID_GSM_PARAMETERS 11 +#define ID_L1_PARAMETERS 12 + +/* + * TIMER IDs + */ +#define T_RX 0 /* request of fieldstrength */ +#define TMAX 0 /* must be the last one */ + +/* + * Configuration Parameter + */ +#define TCST1 0 +#define TCST2 1 + + +#if (CHIPSET == 0) + #define ARMIO_CLK 0x0001 + #define RIF_CLKR 0x0002 + #define RIF_CLKX 0x0004 + #define RIF_CLK13 0x0010 + #define UWIRE_CLK 0x0020 + #define SIM_CLK 0x0040 + #define TSP_CLK 0x0080 + #define UART_CLK 0x0400 +#endif + +#if ((CHIPSET == 2) || (CHIPSET == 3) || (CHIPSET == 4) || \ + (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || \ + (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || \ + (CHIPSET == 11) || (CHIPSET == 12)) + #define ARMIO_CLK_CUT 0x0001 + #define UWIRE_CLK_CUT 0x0002 +#endif + +// ADC timer expiration value defining the ADC period +// with new frame all timer values are in ms not in tdma frames one TDMA approx 4.615 ms +#define ADC_PERIOD 4615 + +#ifdef ALR +//#define VM_BUFFER_SIZE 10240 // 10 seconds (1024 words for about 1 second of recording) +#endif + + +typedef struct +{ + UBYTE t_mode; + ULONG t_val; +} T_TIMER_CONFIG; + +#ifdef OPTION_TIMER +#define CST_TSTART(i,h,v) tim_start_timer(i,h,v) +#else +#define CST_TSTART(i,h,v) vsi_t_start(VSI_CALLER h,v) +#endif + +#define TIMERSTART(i,v,h) csf_alloc_timer(i,v,&h) +#define TIMERSTOP(h) csf_free_timer(h); h = VSI_ERROR; + +/*==== EXPORT =====================================================*/ +/* + * CST global data declarations + */ + +#define CST_ADC_TIMER 0 + +/* + * Prototypes Timer Modul + */ +/* + * If all entities are linked into one module this definitions + * prefixes all this functions with the enity name + */ +#ifdef OPTION_MULTITHREAD + #define tim_init_timer _ENTITY_PREFIXED(tim_init_timer) + #define tim_set_timeout_flag _ENTITY_PREFIXED(tim_set_timeout_flag) + #define tim_handle_timeout _ENTITY_PREFIXED(tim_handle_timeout) + #define tim_config_timer _ENTITY_PREFIXED(tim_config_timer) + #define tim_get_config_timer _ENTITY_PREFIXED(tim_get_config_timer) + #define tim_start_timer _ENTITY_PREFIXED(tim_start_timer) + #define tim_flush_fifo _ENTITY_PREFIXED(tim_flush_fifo) +#endif + +#ifdef OPTION_TIMER + /* + * If all entities are linked into one module this definitions + * prefixes the global data with the entity name + */ + #ifdef OPTION_MULTITHREAD + #define partab _ENTITY_PREFIXED(partab) + #endif + + EXTERN KW_DATA partab[]; +#endif + + /* + * If all entities are linked into one module this definitions + * prefixes the global data with the enity name + */ +#ifdef OPTION_MULTITHREAD + #define hCommPL _ENTITY_PREFIXED(hCommPL) + #define hCommL1 _ENTITY_PREFIXED(hCommL1) +#endif + +EXTERN T_HANDLE hCommPL; /* Communication to TI++ */ +EXTERN T_HANDLE hCommL1; /* Communication to Layer 1 */ +EXTERN T_HANDLE cst_handle; + +/* + * Prototypes Customer Spefific Functions Modul + */ +/* + * If all entities are linked into one module this definitions + * prefixes all this functions with the enity name + */ +GLOBAL void csf_adc_process (T_CST_ADC_IND *adc_results); +EXTERN void adc_start (void); +EXTERN void power_down_config (UBYTE sleep_mode, USHORT clocks); +GLOBAL void csf_aec_enable (USHORT aec_ctrl_reg); + +#endif // CST_H +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/g23m-glue/cst/cst_csf.c Thu Apr 23 06:45:55 2015 +0000 @@ -0,0 +1,218 @@ +/* ++-------------------------------------------------------------------+ +| PROJECT: GSM-F&D (8411) $Workfile:: cst_csf.c $| +| $Author:: Be $ CONDAT GmbH $Revision:: 7 $| +| CREATED: 01.02.99 $Modtime:: 1.12.99 13:16 $| +| STATE : code | ++--------------------------------------------------------------------+ + + + MODULE : CST_CSF + + PURPOSE : This Modul defines the custom specific functionalitys + for the entity CST. +*/ + +#ifndef CST_CSF_C +#define CST_CSF_C +#endif + + +#include "config/swconfig.cfg" +#include "config/board.cfg" + + +#define ENTITY_CST + +/*==== INCLUDES ===================================================*/ + +#include <string.h> +#include "typedefs.h" +#include "vsi.h" +#include "gsm.h" +#include "p_cst.h" +#include "cst/cst.h" + +/*==== CONSTANTS ==================================================*/ + +/*==== TYPES ======================================================*/ + +/*==== EXPORT =====================================================*/ + +/*==== VARIABLES ==================================================*/ + +LOCAL USHORT ADC_CONVERSIONS[9]; + +/*==== FUNCTIONS ==================================================*/ + +#ifdef ALR +extern void madc_hex_2_physical (USHORT *adc_hex, USHORT *adc_phy); +#endif + +#if (BOARD==34) +extern inline unsigned char GC_GetAdcInfo(void); +#endif + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_CSF | +| STATE : code ROUTINE : csf_adc_start | ++--------------------------------------------------------------------+ + + PURPOSE : This function sends a primitive to L1A to activate the ADC */ + + +GLOBAL void csf_adc_start (UBYTE tx_flag, UBYTE traffic_period, UBYTE idle_period) +{ + + // This structure and the #define have to be implemented in the MMI. + // This is a temporary location for test !!!!!!! + // TO BE REMOVED BY USER + typedef struct + { + UBYTE tx_flag; + UBYTE traffic_period; + UBYTE idle_period; + } + T_MMI_ADC_REQ; + + #define MMI_ADC_REQ (111) + + + PALLOC(adc_req, MMI_ADC_REQ); + + adc_req->tx_flag = tx_flag; + adc_req->traffic_period = traffic_period; + adc_req->idle_period = idle_period; + + PSENDX (L1, adc_req); + +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_CSF | +| STATE : code ROUTINE : csf_adc_process | ++--------------------------------------------------------------------+ + + PURPOSE : This function processes ADC results. It stores 10 consecutive + results in an array. +*/ + + +GLOBAL void csf_adc_process (T_CST_ADC_IND *adc_results) +{ +#ifdef ALR + volatile USHORT adc_converted[9]; +#endif + +#ifdef ALR +/* convert adc value into physical values */ + madc_hex_2_physical (adc_results->adc_values, (USHORT*) adc_converted); + + ADC_CONVERSIONS[0] = adc_converted[0]; /* Battery Voltage */ + ADC_CONVERSIONS[1] = adc_converted[1]; /* Charger Voltage */ + ADC_CONVERSIONS[2] = adc_converted[2]; /* I Charger */ + ADC_CONVERSIONS[3] = adc_converted[3]; /* I Charger */ + ADC_CONVERSIONS[4] = adc_converted[4]; /* Battery Type */ + ADC_CONVERSIONS[5] = adc_converted[5]; /* Battery Temperature */ + ADC_CONVERSIONS[6] = adc_converted[6]; /* RF temperature */ + ADC_CONVERSIONS[7] = adc_converted[7]; /* Touch Screen X */ + ADC_CONVERSIONS[8] = adc_converted[8]; /* Touch Screen Y */ +#else + ADC_CONVERSIONS[0] = adc_results->adc_values[0]; + ADC_CONVERSIONS[1] = adc_results->adc_values[1]; + ADC_CONVERSIONS[2] = adc_results->adc_values[2]; + ADC_CONVERSIONS[3] = adc_results->adc_values[3]; + ADC_CONVERSIONS[4] = adc_results->adc_values[4]; +#endif + +// WCS Patch :Avenger 2 uses adc index 5 to store battery informations bit field +#if (BOARD == 34) + ADC_CONVERSIONS[5] = GC_GetAdcInfo(); +#endif + +PFREE (adc_results); +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_CSF | +| STATE : code ROUTINE : csf_aec_enable | ++--------------------------------------------------------------------+ + + PURPOSE : This function sends a primitive to L1A to activate the AEC */ + + +GLOBAL void csf_aec_enable (USHORT aec_ctrl_reg) +{ + + // This structure and the #define have to be implemented in the MMI. + // This is a temporary location for test !!!!!!! + // TO BE REMOVED BY USER + typedef struct + { + USHORT aec_control; + } + T_MMI_AEC_REQ; + + #define MMI_AEC_REQ ( ( ( 0x18 ) << 8 ) | 40 ) + + PALLOC(aec_req, MMI_AEC_REQ); + + aec_req->aec_control = aec_ctrl_reg; + + PSENDX (L1, aec_req); +} + + +/* + Returns the ADC conversions results array +*/ + +GLOBAL USHORT * csf_return_adc (void) +{ + return &(ADC_CONVERSIONS[0]); +} + + + +#ifdef ALR +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (8403) MODULE : CST_CSF | +| STATE : code ROUTINE : csf_vm_record | ++--------------------------------------------------------------------+ + + PURPOSE : activate the Voice Memo recording process for a ten seconds duration + +*/ + +GLOBAL void csf_vm_record (CHAR *output, UBYTE vm_flash_index) +{ + // Dummy function +} + + + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (8403) MODULE : CST_CSF | +| STATE : code ROUTINE : csf_vm_play | ++--------------------------------------------------------------------+ + + PURPOSE : activate the Voice Memo playing process + +*/ + +GLOBAL void csf_vm_play (CHAR *output, UBYTE vm_flash_index) +{ + // Dummy function +} +#endif + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/g23m-glue/cst/cst_exts.c Thu Apr 23 06:45:55 2015 +0000 @@ -0,0 +1,1267 @@ +/* ++--------------------------------------------------------------------+ +| PROJECT: GSM-F&D (8411) $Workfile:: CST_EXTS.C $| +| $Author:: Sa $ CONDAT GmbH $Revision:: 7 $| +| CREATED: 03.08.99 $Modtime:: 14.02.00 16:06 $| +| STATE : code | ++--------------------------------------------------------------------+ + + + MODULE : CST_EXTS + + PURPOSE : This Modul defines the custom specific AT commands +*/ + +#ifndef CST_EXTS_C +#define CST_EXTS_C +#endif + + +#include "config/swconfig.cfg" +#include "config/chipset.cfg" +#include "config/l1sw.cfg" + + + +#define ENTITY_CST +/*==== INCLUDES ===================================================*/ + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include "typedefs.h" +#include "m_sms.val" +#include "m_fac.h" +#include "p_mnsms.h" +#include "p_mmreg.h" +#include "p_mncc.h" +#include "aci_cmh.h" +#include "vsi.h" +#include "gsm.h" +#include "p_cst.h" +#include "cst/cst.h" +#include "custom.h" + +#ifdef ALR + #include "main/sys_ver.h" +#endif + +/*==== MELODY TEST ==================================================*/ + +#define MELODY_E1 0 + +extern void enable_tch_vocoder(BOOL vocoder); + +#if (MELODY_E1) + extern void audio_melo_e1_demo1_start(void); + extern void audio_melo_e1_demo1_stop(void); + extern void audio_melo_e1_demo2_start(void); + extern void audio_melo_e1_demo2_stop(void); +#endif + +#if (MELODY_E2) + extern void audio_melo_e2_load_lsi(void); + extern void audio_melo_e2_demo1_start(void); + extern void audio_melo_e2_demo1_stop(void); + extern void audio_melo_e2_demo2_start(void); + extern void audio_melo_e2_demo2_stop(void); +#endif + + + +/*==== CONSTANTS ==================================================*/ + +#define EXT_ATD "EXT: D, I" +#define EXT_ATCFUN "EXT: +CFUN, I" +#define EXT_ATCOPS_START "EXT: +COPS, I" +#define EXT_ATCOPS_STOP "EXT: +COPS, O" +#define EXT_ENTER "EXT: I" +#define EXT_LEAVE "EXT: O" +#define EXT_UNEXPCTD "EXT: E" + +#define EXT_DIAL_VOICE_PASS "DVCP" + +#define EXT_MAX_BUF_LEN 41 + +#define EXT_VOICE_DELIMITER ';' + +/*==== EXPORT =====================================================*/ + +/*==== TYPES ======================================================*/ + +#ifndef WIN32 + extern USHORT IQ_GetBuild(void); + #ifndef ALR + extern USHORT IQ_GetPoleStarVersion(void); + #endif + extern USHORT IQ_GetJtagId(void); + extern USHORT IQ_GetRevision(void); + extern void l1dmacro_init_hw(void); + + extern BOOL SER_WriteConfig (char *new_config, + BOOL write_to_flash); + extern BOOL SER_ImmediateSwitch (void); +#endif + +LOCAL CHAR* percentCFG ( CHAR* cmd ); +LOCAL CHAR* percentDBG ( CHAR* cmd ); +LOCAL void ext_LeaveEXT ( BOOL final ); +LOCAL void ext_CreatePString ( CHAR* buffer, + CHAR* text ); +GLOBAL void ext_ContinueTest ( CHAR* id ); + +/*==== VARIABLES ==================================================*/ + +LOCAL CHAR* extCmd; /* remaining unparsed command string, */ + /* will be needed in case of asynchronous */ + /* command handling */ +LOCAL USHORT extCmdLen; /* length of command string, will be */ + /* needed in case of asynchronous */ + /* command handling */ +LOCAL CHAR extBuffer[EXT_MAX_BUF_LEN]; /* outbut buffer */ + +LOCAL CHAR extDialNum[MAX_PHB_NUM_LEN]; + /* number to be dialled during testing */ +GLOBAL SHORT extCallId = ACI_NumParmNotPresent; + /* identifier of the call which was */ + /* set-up using AT extension mechansim */ +GLOBAL T_ACI_AT_CMD currExtCmd = AT_CMD_NONE; + /* used for indicating asynchronous */ + /* command handling */ +LOCAL T_ACI_AT_CMD currAbrtCmd = AT_CMD_NONE; + /* used for indicating abort of */ + /* asynchronous command handling */ + +/*==== FUNCTIONS ==================================================*/ + +USHORT * csf_return_adc (void); + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (8403) MODULE : TIL_CSF | +| STATE : code ROUTINE : cmh_show_version | ++--------------------------------------------------------------------+ + + PURPOSE : Trace Layer 1 DSP version numbers + +*/ + +#ifndef WIN32 + + +static void jtagid_to_chipset (USHORT jtagid, CHAR *chipset) +{ + + switch (jtagid) { + + case 0xB268: + + strcpy (chipset, "Hercules"); + break; + + case 0xB2B5: + + strcpy (chipset, "Ulysse 1Mbits rev. B"); + break; + + case 0xB335: + + strcpy (chipset, "Ulysse 1Mbits rev. A"); + break; + + case 0xB334: + + strcpy (chipset, "Ulysse 2Mbits"); + break; + + case 0xB393: + + strcpy (chipset, "Ulysse G1"); + break; + + + case 0xB396: + + strcpy (chipset, "Calypso rev. B"); + break; + + case 0xB2AC: + +// Samson and Calypso rev. A share the same JTAG ID. +#if (CHIPSET != 7) + strcpy (chipset, "Samson"); +#else + strcpy (chipset, "Calypso rev. A"); +#endif + break; + + case 0xB217: + + strcpy (chipset, "Ulysse C035"); + break; + + case 0xB496: + + strcpy (chipset, "Calypso C035"); + break; + + case 0xB4FB: + + strcpy (chipset, "Calypso Lite C035"); + break; + + default: + + strcpy (chipset, "Unknown"); + break; + } +} + +GLOBAL void cmh_show_version ( + CHAR *command, + USHORT *len, + CHAR *output + ) +{ +#ifndef ALR + CHAR buf[80]; + USHORT build, hw, rev; +#else + CHAR buf[160]; + CHAR chipset[25]; +#endif + USHORT jtag; + UCHAR size; + + /* + * Retrieve hardware JTAG ID info + */ + jtag = IQ_GetJtagId(); + +#ifndef ALR + /* + * Retrieve others hardware info and build from library + */ + build = IQ_GetBuild(); + hw = IQ_GetPoleStarVersion(); + rev = IQ_GetRevision(); + + sprintf (buf, "Build %d, Silicon Revision %04X/%04X/%04X", + build, hw, jtag, rev); +#else + + /* + * Retrieve CHIPSET name from JTAG ID + */ + jtagid_to_chipset (jtag, chipset); + + sprintf (buf, + "Chipset Version:\n\r\t%s\n\rS/W Versions:\n\n\r\tLayer1\t%4X_%3X\n\r\tLayer2-3 %3XBERLIN_S420\n\r\tNICE\t %3X_I64", + chipset, + OFFICIAL_VERSION, + INTERNAL_VERSION, + G23VERSION, + SYSTEMVERSION); +#endif + + // Format output as a list of Pascal-like strings + size = strlen(buf); + output[0] = size; + strcpy(&(output[1]), buf); + output[size+1] = (CHAR) 0xFF; // terminate list of strings +} + +#endif /* #ifndef WIN32 */ + + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (8403) MODULE : TIL_CSF | +| STATE : code ROUTINE : show_adc_conversion | ++--------------------------------------------------------------------+ + + PURPOSE : Trace Layer 1 AD conversions results + +*/ + +GLOBAL void show_adc_conversion (CHAR *output) +{ + USHORT * adc_conversion; +#ifdef ALR + CHAR buf[160]; +#else + CHAR buf[80]; +#endif + UCHAR size; + + adc_conversion = csf_return_adc (); +#ifdef ALR + sprintf (buf, "ADC 0 = %x, ADC 1 = %x, ADC 2 = %x, ADC 3 = %x, ADC 4 = %x, ADC 5 = %x, ADC 6 = %x, ADC 7 = %x, ADC 8 = %x", + *adc_conversion++, *adc_conversion++, *adc_conversion++, + *adc_conversion++, *adc_conversion++, *adc_conversion++, + *adc_conversion++, *adc_conversion++, *adc_conversion); + +#else + sprintf (buf, "ADC 0 = %x, ADC 1 = %x, ADC 2 = %x, ADC 3 = %x, ADC 4 = %x", + *adc_conversion++, *adc_conversion++, *adc_conversion++, + *adc_conversion++, *adc_conversion); +#endif + + // Format output as a list of Pascal-like strings + size = strlen(buf); + output[0] = size; + strcpy(&(output[1]), buf); + output[size+1] = (CHAR) 0xFF; // terminate list of strings +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (8403) MODULE : CST_EXTS | +| STATE : code ROUTINE : AEC_Enable | ++--------------------------------------------------------------------+ + + PURPOSE : activate the Acoustic Echo Cancelation + +*/ + +GLOBAL void AEC_Enable (CHAR *command, CHAR *output) +{ + +/* -------------------------------------------------------------------------- */ +/* MMI_AEC_REQ : 0283 = Long AEC, 105 = SPENH, 187 = AEC+SPENH, 1 = STOP */ +/* aec_control register bits | 0 0 Sa t2|t1 g3 g2 g1|g0 e2 e1 ak| */ +/* bit 0 : ACK bit : set to 1 in order to warn DSP that a new command */ +/* is present. */ +/* bit 1 : enable AEC */ +/* bit 2 : enable SPENH (= Speech Enhancement = noise reduction) */ +/* bit 3 : additionnal AEC gain attenuation (lsb) */ +/* bit 4 : additionnal AEC gain attenuation (msb) */ +/* bit 5 : additionnal SPENH gain attenuation (lsb) */ +/* bit 6 : additionnal SPENH gain attenuation (msb) */ +/* bit 7 : reset trigger for AEC */ +/* bit 8 : reset trigger for SPENH */ +/* bit 9 : AEC selector 0 : short AEC, 1 : long AEC */ +/* */ +/* for Short AEC 0083 */ +/* for long AEC 0283 */ +/* for long AEC -6 dB 028B */ +/* for long AEC -12 dB 0293 */ +/* for long AEC -18 dB 029B */ +/* for SPENH 0105 */ +/* for SPENH -6 dB 0125 */ +/* for SPENH -12 dB 0145 */ +/* for SPENH -18 dB 0165 */ +/* for BOTH 0187 */ +/* for STOP ALL 0001 (all bits reset + ACK to 1 to warn the DSP) */ +/* -------------------------------------------------------------------------- */ + + + command++; /* increment command pointer to point on the hexa value of the command */ + + + if (!strncmp(command, "0083", 4)) + { + output[0] = strlen ("Short AEC is active"); + memcpy (&output[1], "Short AEC is active", 19); + + /* end of string list */ + output [20] = (CHAR) 0xff; + csf_aec_enable(0x0083); + } + + else if (!strncmp(command, "0283", 4)) + { + output[0] = strlen ("Long AEC is active"); + memcpy (&output[1], "Long AEC is active", 18); + + /* end of string list */ + output [19] = (CHAR) 0xff; + csf_aec_enable(0x0283); + } + + else if (!strncmp(command, "028B", 4)) + { + output[0] = strlen ("Long AEC -6 dB is active"); + memcpy (&output[1], "Long AEC -6 dB is active", 24); + + /* end of string list */ + output [25] = (CHAR) 0xff; + csf_aec_enable(0x028B); + } + + else if (!strncmp(command, "0293", 4)) + { + output[0] = strlen ("Long AEC -12 dB is active"); + memcpy (&output[1], "Long AEC -12 dB is active", 25); + + /* end of string list */ + output [26] = (CHAR) 0xff; + csf_aec_enable(0x0293); + } + + else if (!strncmp(command, "029B", 4)) + { + output[0] = strlen ("Long AEC -18 dB is active"); + memcpy (&output[1], "Long AEC -18 dB is active", 25); + + /* end of string list */ + output [26] = (CHAR) 0xff; + csf_aec_enable(0x029B); + } + + else if (!strncmp(command, "0105", 4)) + { + output[0] = strlen ("Noise reduction is active"); + memcpy (&output[1], "Noise reduction is active", 25); + + /* end of string list */ + output [26] = (CHAR) 0xff; + csf_aec_enable(0x0105); + } + + else if (!strncmp(command, "0125", 4)) + { + output[0] = strlen ("Noise reduction -6 dB is active"); + memcpy (&output[1], "Noise reduction -6 dB is active", 31); + + /* end of string list */ + output [32] = (CHAR) 0xff; + csf_aec_enable(0x0125); + } + + else if (!strncmp(command, "0145", 4)) + { + output[0] = strlen ("Noise reduction -12 dB is active"); + memcpy (&output[1], "Noise reduction -12 dB is active", 32); + + /* end of string list */ + output [33] = (CHAR) 0xff; + csf_aec_enable(0x0145); + } + + else if (!strncmp(command, "0165", 4)) + { + output[0] = strlen ("Noise reduction -18 dB is active"); + memcpy (&output[1], "Noise reduction -18 dB is active", 32); + + /* end of string list */ + output [33] = (CHAR) 0xff; + csf_aec_enable(0x0165); + } + + else if (!strncmp(command, "0187", 4)) + { + output[0] = strlen ("Both AEC and Noise reduction are active"); + memcpy (&output[1], "Both AEC and Noise reduction are active", 39); + + /* end of string list */ + output [40] = (CHAR) 0xff; + csf_aec_enable(0x0187); + } + + else if (!strncmp(command, "0001", 4)) + { + output[0] = strlen ("AEC and Noise reduction are unactivated"); + memcpy (&output[1], "AEC and Noise reduction are unactivated", 39); + + /* end of string list */ + output [40] = (CHAR) 0xff; + csf_aec_enable(0x0001); + } + + else + { + output[0] = strlen ("Bad AT command"); + memcpy (&output[1], "Bad AT command", 14); + + /* end of string list */ + output [15] = (CHAR) 0xff; + } + +} + + + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6147) MODULE : CST_EXTS | +| STATE : code ROUTINE : rAT_EXT | ++--------------------------------------------------------------------+ + + PURPOSE : This function is called by the interpreter part of the + ACI in case of the detection of an unknown command. + + <cmd> : remaining unparsed command string. + <cmdLen> : length of command string. This value must be + incremented by the amount of parsed characters + by this function. + <out> : this parameter can be used to display some + strings at the AT command interface. + The first char of one string must contain + the length of the following string. The + special length 0xff must be used to define + the end of the string list. + <outLen> : maximum length of output buffer referenced + by parameter <out>. + +*/ + +GLOBAL T_ACI_RETURN rAT_EXT ( + CHAR* cmd, + USHORT* cmdLen, + CHAR* out, + USHORT outLen + ) +{ + /* + * store command string in case it will be needed later on, when + * result code of this function is equal to AT_EXCT + */ + extCmd = cmd; + extCmdLen = *cmdLen; + + /* + * example how to send an unsolicited result code via the AT interface + */ + ext_CreatePString ( extBuffer, EXT_ENTER ); + + sAT_URC ( extBuffer ); + + /* + * example how to process the command AT%H + */ + if (*cmd == '%') + { + cmd++; + + switch (*cmd) + { + case 'A': + /* + * Display AD conversions results + */ + *cmdLen -= 2; + show_adc_conversion(out); + return( AT_CMPL ); + + case 'C': + case 'c': + case 'D': + case 'd': + { + CHAR* nextCmd; + + *cmdLen -= 2; + + switch ( *cmd ) + { + case 'C': + case 'c': + /* dynamic configuration via AT command interface */ + nextCmd = percentCFG ( ++cmd ); + + break; + + case 'D': + case 'd': + /* set debug pin for reset purposes */ + nextCmd = percentDBG ( ++cmd ); + + break; + } + + *out = ( CHAR ) 0xFF; + + if ( nextCmd EQ NULL ) + { + return ( AT_FAIL ); + } + else + { + *cmdLen -= ( nextCmd - cmd ); + + return ( AT_CMPL ); + } + } + + case 'N': + /* + * Enables the AEC by sending a primitive to L1A + */ + *cmdLen -= 6; + AEC_Enable(cmd, out); + return( AT_CMPL ); + +//---------------------------------------------------------------------------// +// Added by Matthieu Vanin for the test of melody E2/E1 +//---------------------------------------------------------------------------// + + + +// End +//---------------------------------------------------------------------------// + case 'S': + case 's': + { + cmd++; + + switch (*cmd) { + + case 'e': + case 'E': + /* 's''e' already detected => assume the command is at%ser. */ + { + cmd += 3; /* Discard the following characters */ + *cmdLen -= 9; + if (SER_WriteConfig (cmd, (BOOL) (*(cmd + 3) - '0'))) + return( AT_CMPL ); + else + return( AT_FAIL ); + } + + case 'w': + case 'W': + /* 's''w' already detected => assume the command is at%switch. */ + { + *cmdLen -= 7; + if (SER_ImmediateSwitch()) + return( AT_CMPL ); + else + return( AT_FAIL ); + } + + case 'l': + case 'L': + /* 's''l' already detected => assume the command is at%sleep. */ + { + cmd += 5; /* Discard the following characters */ + *cmdLen -= 8; + /* + * Checks if the parameter is valid: + * 0 -> NO_SLEEP + * 1 -> SMALL_SLEEP + * 2 -> BIG_SLEEP + * 3 -> DEEP_SLEEP + * 4 -> ALL_SLEEP + */ + + if (((*cmd - '0') >= 0) && ((*cmd - '0') <= 4)) + { + power_down_config ((UBYTE) (*cmd - '0'), UWIRE_CLK_CUT); + return( AT_CMPL ); + } + else + return( AT_FAIL ); + } + + default: + *cmdLen -= 2; + return ( AT_FAIL ); + + } + } + + case 'H': + *cmdLen -= 2; + + /* + * here you can perform some actions with drivers etc. + */ + + /* + * and create some additional output at the AT interface + * The strings: + *"Hello" + *"" + *"World" + * will be displayed at the terminal. + * + * first string Hello + */ + out[0] = strlen ("Hello"); + memcpy (&out[1], "Hello", 5); + /* + * add a spare line with an empty string + */ + out [6] = 0; + /* + * second string World + */ + out [7] = strlen ("World"); + memcpy (&out[8], "World", 5); + + /* + * end of string list + */ + out [13] = (CHAR) 0xff; + return( AT_CMPL ); + +#ifndef WIN32 + case 'R': + case 'r': + *cmdLen -= 2; + l1dmacro_init_hw(); + out[0] = 0; + out[1] = (CHAR) 0xFF; + return( AT_CMPL ); +#endif + +#ifndef WIN32 + case 'V': + case 'v': + *cmdLen -= 2; + + /* + * Display version numbers + */ + + cmh_show_version (cmd, cmdLen, out); + return( AT_CMPL ); +#endif +#if defined (ALR) + case 'T': + case 't': + /* + * Enables RTC or AUDIO tests + */ + cmd++; + *cmdLen -= 3; + if (!strncmp(cmd, "A", 1) || !strncmp(cmd, "a", 1)) + { + //audio_test_misc(); + out[0] = 22; + memcpy (&out[1], "Performing Audio Tests", 22); + out [23] = (CHAR) 0xff; + } + else + { + if (!strncmp(cmd, "R", 1) || !strncmp(cmd, "r", 1)) + { + //rtc_test_misc(); + out[0] = 20; + memcpy (&out[1], "Performing RTC Tests", 20); + out [21] = (CHAR) 0xff; + } + else + return( AT_FAIL ); + } + return( AT_CMPL ); +#endif + default: + *cmdLen -= 2; + return ( AT_FAIL ); + } + } + else if ( *cmd EQ 'D' ) + { + T_ACI_RETURN rslt; + + /* + * this is only a test implementation. As soon as a "ATD" command + * string is detected in the AT interpreter and the mobile is not + * yet registered (neither limited nor full service is availbale) + * this function is called. Then instead of dialling immediately + * an activation of the mobile is performed in advance. + */ + strncpy ( extDialNum, cmd + 1, MINIMUM ( MAX_PHB_NUM_LEN - 1, + *cmdLen - 1 ) ); + extDialNum[MINIMUM ( MAX_PHB_NUM_LEN - 1, *cmdLen - 1 )] = '\0'; + + extCmdLen = 0; + *cmdLen = 0; + + rslt = sAT_PlusCFUN ( CMD_SRC_LCL, + CFUN_FUN_Full, + CFUN_RST_NotPresent ); + + if ( rslt EQ AT_EXCT ) + { + /* + * generate some output at the AT interface + */ + ext_CreatePString ( out, EXT_ATCFUN ); + + /* + * indicating that an extended AT command is still in progress + */ + currExtCmd = AT_CMD_CFUN; + } + else + { + ext_LeaveEXT ( TRUE ); + rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown ); + } + + return ( rslt ); + } + else + return( AT_FAIL ); +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6147) MODULE : CST_EXTS | +| STATE : code ROUTINE : percentCFG | ++--------------------------------------------------------------------+ + + PURPOSE : %CFG command (enables dynamic configuration of the + protocol stack using the AT command interface) +*/ + +EXTERN char *parse (char *b, char *f, ...); + +GLOBAL SHORT cc_pei_config (char * inString, + char * outString); +GLOBAL SHORT cst_pei_config (char * inString, + char * outString); +GLOBAL SHORT dl_pei_config (char * inString, + char * outString); +GLOBAL SHORT mm_pei_config (char * inString, + char * outString); +GLOBAL SHORT rr_pei_config (char * inString, + char * outString); +GLOBAL SHORT sim_pei_config (char * inString, + char * outString); +GLOBAL SHORT sms_pei_config (char * inString, + char * outString); +GLOBAL SHORT ss_pei_config (char * inString, + char * outString); +GLOBAL SHORT pl_pei_config (char * inString, + char * outString); + +#ifdef FAX_AND_DATA +GLOBAL SHORT fad_pei_config (char * inString, + char * outString); +GLOBAL SHORT l2r_pei_config (char * inString, + char * outString); +GLOBAL SHORT ra_pei_config (char * inString, + char * outString); +GLOBAL SHORT rlp_pei_config (char * inString, + char * outString); +GLOBAL SHORT t30_pei_config (char * inString, + char * outString); +#endif + +GLOBAL CHAR* percentCFG ( CHAR* cl ) +{ + CHAR entity[5]; + CHAR config[40]; + CHAR dummy; + + TRACE_FUNCTION ( "percentCFG()" ); + + switch ( *cl ) + { + case('='): + { + cl++; + + cl = parse ( cl, "ss", ( LONG )sizeof(entity), entity, + ( LONG )sizeof(config), config ); + + if( !cl OR + *entity EQ '\0' OR + *config EQ '\0' ) + { + return ( NULL ); + } + + break; + } + + default: + { + return ( NULL ); + } + } + + if ( strcmp ( entity, CC_NAME ) EQ 0 ) + { + cc_pei_config ( config, &dummy ); + } + else if ( strcmp ( entity, CST_NAME ) EQ 0 ) + { + cst_pei_config ( config, &dummy ); + } + else if ( strcmp ( entity, DL_NAME ) EQ 0 ) + { + dl_pei_config ( config, &dummy ); + } + else if ( strcmp ( entity, MM_NAME ) EQ 0 ) + { + mm_pei_config ( config, &dummy ); + } + else if ( strcmp ( entity, RR_NAME ) EQ 0 ) + { + rr_pei_config ( config, &dummy ); + } + else if ( strcmp ( entity, SIM_NAME ) EQ 0 ) + { + sim_pei_config ( config, &dummy ); + } + else if ( strcmp ( entity, SMS_NAME ) EQ 0 ) + { + sms_pei_config ( config, &dummy ); + } + else if ( strcmp ( entity, SS_NAME ) EQ 0 ) + { + ss_pei_config ( config, &dummy ); + } + else if ( strcmp ( entity, PL_NAME ) EQ 0 ) + { + pl_pei_config ( config, &dummy ); + } + +#ifdef FAX_AND_DATA + + else if ( strcmp ( entity, FAD_NAME ) EQ 0 ) + { + fad_pei_config ( config, &dummy ); + } + else if ( strcmp ( entity, L2R_NAME ) EQ 0 ) + { + l2r_pei_config ( config, &dummy ); + } + else if ( strcmp ( entity, RA_NAME ) EQ 0 ) + { + ra_pei_config ( config, &dummy ); + } + else if ( strcmp ( entity, RLP_NAME ) EQ 0 ) + { + rlp_pei_config ( config, &dummy ); + } + else if ( strcmp ( entity, T30_NAME ) EQ 0 ) + { + t30_pei_config ( config, &dummy ); + } + +#endif + + else + { + return ( NULL ); + } + + return ( cl ); +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6147) MODULE : CST_EXTS | +| STATE : code ROUTINE : percentDBG | ++--------------------------------------------------------------------+ + + PURPOSE : %RST command (simulates pressing the reset button + of the ASample) +*/ + +#ifndef TRACE_PORT_TIMING + #ifdef _TMS470 + #if (CHIPSET == 0) + EXTERN void l1s_set_debug_pin ( UBYTE, UBYTE ); + #endif + #endif +#endif + +GLOBAL CHAR* percentDBG ( CHAR* cl ) +{ + SHORT line = 1; + SHORT polarity = 1; + SHORT delay = 650; + + TRACE_FUNCTION ( "atPercentDBG()" ); + + switch ( *cl ) + { + case( '\0' ): + { + break; + } + + case('='): + { + cl++; + + cl = parse ( cl, "rrr", &line, &polarity, &delay ); + + if( !cl OR + polarity < 0 OR polarity > 1 OR + line < 0 OR line > 7 OR + delay < 0 ) + { + return ( NULL ); + } + + break; + } + + default: + { + return ( NULL ); + } + } + +#ifndef TRACE_PORT_TIMING + #ifdef _TMS470 + #if (CHIPSET == 0) +#if defined (NEW_FRAME) + vsi_t_sleep ( VSI_CALLER ( T_TIME ) delay ); +#else + vsi_t_sleep ( VSI_CALLER ( T_VSI_TVALUE ) delay ); +#endif + + l1s_set_debug_pin ( ( UBYTE ) line, ( UBYTE ) polarity ); + #endif + #endif +#endif + + return ( cl ); +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6147) MODULE : CMH_EXTS | +| STATE : code ROUTINE : rAT_ACP | ++--------------------------------------------------------------------+ + + PURPOSE : This function is called by the interpreter part of the + ACI in case of aborting a pending extension command. + + <out> : this parameter can be used to display some + strings at the AT command interface. + The first char of one string must contain + the length of the following string. The + special length 0xff must be used to define + the end of the string list. + <outLen> : maximum length of output buffer referenced + by parameter <out>. + +*/ + +GLOBAL T_ACI_RETURN rAT_ACP ( + CHAR* out, + USHORT outLen + ) +{ + T_ACI_RETURN rslt = AT_CMPL; + + /* call the abort function if necessary */ + if ( currExtCmd NEQ AT_CMD_NONE ) + rslt = sAT_Abort (CMD_SRC_LCL, currExtCmd ); + + switch ( rslt ) + { + case ( AT_CMPL ): + { + currExtCmd = AT_CMD_NONE; + + ext_LeaveEXT ( TRUE ); + } + break; + + case ( AT_EXCT ): + { + currExtCmd = AT_CMD_ABRT; + } + break; + + default: + { + /* do nothing */ + } + break; + } + + return rslt; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6147) MODULE : CMH_EXTS | +| STATE : code ROUTINE : ext_OK | ++--------------------------------------------------------------------+ + + PURPOSE : This function is called by the MMI in case the positive + result of the asynchronous command handling is available. + + <cmdId>: command identity + +*/ +GLOBAL void ext_OK ( T_ACI_AT_CMD cmdId ) +{ + T_ACI_RETURN rslt; + + if ( cmdId EQ AT_CMD_CFUN AND currAbrtCmd EQ AT_CMD_NONE ) + { + rslt = sAT_PlusCOPS ( CMD_SRC_LCL, + COPS_MOD_Auto, + COPS_FRMT_NotPresent, + NULL ); + + if ( rslt EQ AT_EXCT ) + { + /* + * generate some output at the AT interface + */ + ext_CreatePString ( extBuffer, EXT_ATCOPS_START ); + + sAT_URC ( extBuffer ); + + /* + * indicating that an extended AT command is still in progress + */ + currExtCmd = AT_CMD_COPS; + } + else + { + ext_LeaveEXT ( TRUE ); + rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown ); + } + } + else if ( cmdId EQ AT_CMD_COPS AND currAbrtCmd EQ AT_CMD_NONE ) + { + currExtCmd = AT_CMD_NONE; + + /* + * generate some output at the AT interface + */ + ext_CreatePString ( extBuffer, EXT_ATCOPS_STOP ); + + sAT_URC ( extBuffer ); + +#ifndef WIN32 + ext_ContinueTest ( EXT_DIAL_VOICE_PASS ); +#endif + } + else if ( cmdId EQ AT_CMD_D AND currAbrtCmd EQ AT_CMD_NONE ) + { + extCallId = 1; + + ext_LeaveEXT ( TRUE ); + rCI_OK ( AT_CMD_EXT ); + } + else if ( currAbrtCmd NEQ AT_CMD_NONE ) + { + currAbrtCmd = AT_CMD_NONE; + + ext_LeaveEXT ( TRUE ); + rCI_OK ( AT_CMD_EXT ); + } + else + { + /* + * generate some output at the AT interface + */ + ext_CreatePString ( extBuffer, EXT_UNEXPCTD ); + + sAT_URC ( extBuffer ); + } +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6147) MODULE : CMH_EXTS | +| STATE : code ROUTINE : ext_LeaveExtension | ++--------------------------------------------------------------------+ + + PURPOSE : This function is called in case the extensin mechansim + should be left finally. + + <final>: indicates whether final result code should be + sent explicitly + +*/ +LOCAL void ext_LeaveEXT ( BOOL final ) +{ + /* + * generate some output at the AT interface + */ + ext_CreatePString ( extBuffer, EXT_LEAVE ); + + /* + * indicating that no extended AT command is still in progress + */ + currExtCmd = AT_CMD_NONE; + + /* + * indicate end of extended command handling to the AT interpreter + */ + sAT_URC ( extBuffer ); + + if ( final ) + { + sAT_FRI ( extCmdLen ); + } +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6147) MODULE : CMH_EXTS | +| STATE : code ROUTINE : ext_ContinueTest | ++--------------------------------------------------------------------+ + + PURPOSE : This function is called in case the AT extension + procedure should be continued. + + <id>: identifies the specific procedure to be continued + +*/ +GLOBAL void ext_ContinueTest ( CHAR* id ) +{ + T_ACI_RETURN rslt; + + if ( strcmp ( id, EXT_DIAL_VOICE_PASS ) EQ 0 ) + { + T_ACI_D_TOC callType = D_TOC_Data; + + if ( extDialNum [strlen ( extDialNum ) - 1] EQ EXT_VOICE_DELIMITER ) + callType = D_TOC_Voice; + + extDialNum[strlen ( extDialNum ) - 1] = '\0'; + + rslt = sAT_Dn ( CMD_SRC_LCL, + extDialNum, + D_CLIR_OVRD_Default, + D_CUG_CTRL_NotPresent, + callType ); + + if ( rslt EQ AT_EXCT ) + { + /* + * generate some output at the AT interface + */ + ext_CreatePString ( extBuffer, EXT_ATD ); + + sAT_URC ( extBuffer ); + + /* + * indicating that an extended AT command is still in progress + */ + currExtCmd = AT_CMD_D; + } + else + { + ext_LeaveEXT ( TRUE ); + rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown ); + } + } +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6147) MODULE : CMH_EXTS | +| STATE : code ROUTINE : ext_CreatePString | ++--------------------------------------------------------------------+ + + PURPOSE : + +*/ +LOCAL void ext_CreatePString ( CHAR* buffer, CHAR* text ) +{ + buffer[0] = strlen (text); + memcpy (&buffer[1], text, buffer[0]); + buffer [buffer[0]+1] = (CHAR) 0xff; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/g23m-glue/cst/cst_pei.c Thu Apr 23 06:45:55 2015 +0000 @@ -0,0 +1,1008 @@ +/* ++--------------------------------------------------------------------+ +/* ++-------------------------------------------------------------------+ +| PROJECT: GSM-F&D (8411) $Workfile:: cst_pei.c $| +| $Author:: Be $ CONDAT GmbH $Revision:: 14 $| +| CREATED: 01.02.99 $Modtime:: 14.02.00 12:14 $| +| STATE : code | ++--------------------------------------------------------------------+ + + MODULE : CST_PEI + + PURPOSE : This Modul defines the process body interface for the + component CST of the mobile station. + + EXPORT : pei_create - Create the Protocol Stack Entity + pei_init - Initialize Protocol Stack Entity + pei_primitive - Process Primitive + pei_timeout - Process Timeout + pei_exit - Close resources and terminate + pei_run - Process Primitive + pei_config - Dynamic Configuration + pei_monitor - Monitoring of physical Parameters +*/ + +#ifndef CST_PEI_C +#define CST_PEI_C +#endif + +#include "config/swconfig.cfg" +#include "config/chipset.cfg" + + +#define ENTITY_CST + +/*==== INCLUDES ===================================================*/ + +#include <string.h> +#include <stdlib.h> +#include <ctype.h> +#include "typedefs.h" +#include "vsi.h" +#include "custom.h" +#include "gsm.h" +#include "prim.h" +#include "cst/cnf_cst.h" +#include "cst/cus_cst.h" +#include "cst/mon_cst.h" +#include "tok.h" +#include "p_cst.h" +#include "cst/cst.h" +#include "rx.h" +#include "audio.h" + +/*==== CONSTANTS ==================================================*/ + +// token processing +#define ERROR -1 +#define EOS 1 +#define COMMA 2 +#define EQUAL 3 +#define IDENT 4 +#define STRING 5 +#define LBRACK 6 +#define RBRACK 7 + +/*==== EXPORT =====================================================*/ +extern void CST_stack_trace(void); +int cst_gsm_parameters(TOK_DCB *dcb); +extern void l1_cst_l1_parameters(char*); +extern void csf_adc_start (UBYTE tx_flag, UBYTE traffic_period, UBYTE idle_period); +extern void spi_adc_on (void); + +GLOBAL T_HANDLE t_adc_timer = VSI_ERROR; +GLOBAL T_HANDLE hCommPL = VSI_ERROR; /* PL Communication */ +GLOBAL T_HANDLE hCommL1 = VSI_ERROR; /* L1 Communication */ + T_HANDLE cst_handle; +GLOBAL UBYTE extDisplay = 0; + +EXTERN UBYTE audio_is_free; +/*==== PRIVATE ====================================================*/ + +LOCAL const void pei_not_supported (void *data); + +#ifdef OPTION_RELATIVE +LOCAL ULONG offset; +#endif + +/*==== VARIABLES ==================================================*/ + +LOCAL USHORT t_flag = 0; +LOCAL BOOL exit_flag = FALSE; +LOCAL BOOL first_access = TRUE; +LOCAL T_MONITOR cst_mon; + +/*==== FUNCTIONS ==================================================*/ +LOCAL const T_FUNC cst_table[] = +{ + MAK_FUNC_0 ( csf_adc_process , CST_ADC_IND ) +}; + +/*==== PROTOTYPES==================================================*/ + +#if defined (_TMS470) + +static SHORT cst_tok_gettok (TOK_DCB *dcb, char ** token); +static SHORT cst_tok_value (TOK_DCB *dcb, char * value []); +static int cst_tokenizer_has_more_data(const TOK_DCB *dcb); +static SHORT cst_tok_issep (char c); +static void cst_tok_init (char * s, TOK_DCB *dcb, char *buf, int buf_len); +static SHORT cst_get_values(TOK_DCB *dcb, char *value[]); +static int cst_getbyte(TOK_DCB *dcb); + +#endif + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : pei_primitive | ++--------------------------------------------------------------------+ + + PURPOSE : This function processes protocol specific primitives. +*/ +LOCAL SHORT pei_primitive (void * ptr) +{ + T_PRIM *prim = ptr; + + if (prim NEQ NULL) + { + USHORT opc = prim->custom.opc; + USHORT n; + const T_FUNC *table; + + VSI_PPM_REC ((T_PRIM_HEADER*)prim, __FILE__, __LINE__); + + switch (opc & OPC_MASK) + { + case CST_DL: table = cst_table; n = TAB_SIZE (cst_table); break; + default : table = NULL; n = 0; break; + } + + if (table != NULL ) + { + if ((opc & PRM_MASK) < n) + { + table += opc & PRM_MASK; +#ifdef PALLOC_TRANSITION + P_SDU(prim) = table->soff ? (T_sdu*) (((char*)&prim->data) + table->soff) : 0; + P_LEN(prim) = table->size + sizeof (T_PRIM_HEADER); +#endif + JUMP (table->func) (P2D(prim)); + } + else + { + pei_not_supported (P2D(prim)); + } + return PEI_OK; + } + +#ifdef GSM_ONLY + PFREE (P2D(prim)) + return PEI_ERROR; +#else + if (opc & SYS_MASK) + { + vsi_c_primitive (VSI_CALLER prim); + } + else + { + PFREE (P2D(prim)) + return PEI_ERROR; + } +#endif + } + return PEI_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : pei_not_supported | ++--------------------------------------------------------------------+ + + PURPOSE : This function handles an unsupported primitive. +*/ +LOCAL const void pei_not_supported (void *data) +{ + TRACE_FUNCTION ("pei_not_supported()"); + + PFREE (data); +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : pei_init | ++--------------------------------------------------------------------+ + + PURPOSE : This function initializes the protocol stack entity + +*/ + +LOCAL SHORT pei_init (T_HANDLE handle) +{ + cst_handle = handle; + + TRACE_FUNCTION ("pei_init()"); + + exit_flag = FALSE; + + if (hCommPL < VSI_OK) + { + if ((hCommPL = vsi_c_open (VSI_CALLER PL_NAME)) < VSI_OK) + { + return PEI_ERROR; + } + } + + if (hCommL1 < VSI_OK) + { + if ((hCommL1 = vsi_c_open (VSI_CALLER L1_NAME)) < VSI_OK) + { + return PEI_ERROR; + } + } + + vsi_t_start (VSI_CALLER CST_ADC_TIMER, 230); // equal to 50 TDMA frames + +#if defined (_TMS470) + // Set the sleep mode authorized for the layer1 synchronous. + // Possible modes are : + // for CHIPSET = 0 : NO_SLEEP, SMALL_SLEEP, BIG_SLEEP. + // It is necessary to indicate in the prototype of power_down_config() + // function which clocks (amongst ARMIO_CLK, UWIRE_CLK, SIM_CLK and UART_CLK) + // to be stopped in case of BIG_SLEEP mode. + // With this default init, ARMIO_CLK, UWIRE_CLK, SIM_CLK and UART_CLK will be stopped + // in case of BIG_SLEEP mode, but it can be changed here. + + // other CHIPSETs : NO_SLEEP, SMALL_SLEEP, BIG_SLEEP, DEEP_SLEEP, ALL_SLEEP. + // It is necessary to indicate in the prototype of power_down_config() + // function which clocks to be stopped in case of BIG_SLEEP mode, + // amongst ARMIO and UWIRE clocks. + // With this default init, UWIRE_CLK will always be stopped + // in case of BIG_SLEEP mode, but it can be changed here. + + // The default configuration is ALL SLEEP. It can be changed in this init. + + // WARNING !! THE SLEEP MODE SHOULD NOT BE MODIFIED ONCE THE SYSTEM INIT IS FINISHED !! + + #if !defined (TI_VERSION) + #if (CHIPSET == 0) + power_down_config(NO_SLEEP, ARMIO_CLK | UWIRE_CLK | SIM_CLK | UART_CLK); + #elif ((CHIPSET == 2) || (CHIPSET == 3) || \ + (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11)) + power_down_config(ALL_SLEEP, UWIRE_CLK_CUT); + #elif ((CHIPSET == 4) || (CHIPSET == 9)) + power_down_config(NO_SLEEP, UWIRE_CLK_CUT); + #endif + #endif +#endif + + return PEI_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : pei_timeout | ++--------------------------------------------------------------------+ + + PURPOSE : This function processes timeouts. +*/ + +LOCAL SHORT pei_timeout (USHORT index) +{ + rx_timeout (index); + audio_timeout (index); + + if (index EQ CST_ADC_TIMER) + { + // start the AD conversions in layer1 synchronous + // this function will send MMI_ADC_REQ primitive to L1A for test reason. + // The user has to implement it by himself in the MMI. + // The parameters are : tx_flag, traffic_period, idle_period. + // Please refer to the ADC specification for details. + + // WCS Patch : Schedule ADC on RX and TX + #if (OP_WCP == 1) + csf_adc_start(1, 10, 1); + #else + csf_adc_start(0, 10, 1); + #endif + + spi_adc_on(); + } + + return PEI_OK; +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : pei_exit | ++--------------------------------------------------------------------+ + + PURPOSE : This function closes all resources and terminates. +*/ + +LOCAL SHORT pei_exit (void) +{ + TRACE_FUNCTION ("pei_exit()"); + + /* + * clean up communication + */ + + vsi_c_close (VSI_CALLER hCommPL); + hCommPL = VSI_ERROR; + + vsi_c_close (VSI_CALLER hCommL1); + hCommL1 = VSI_ERROR; + + exit_flag = TRUE; + + return PEI_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : pei_config | ++--------------------------------------------------------------------+ + + PURPOSE : Dynamic Configuration + +*/ + +#if !defined (NCONFIG) +LOCAL KW_DATA kwtab[] = { + CST_CONFIG, ID_CONFIG, + CST_MUTE, ID_MUTE, + CST_GSM_PARAMETERS, ID_GSM_PARAMETERS, + CST_L1_PARAMETERS, ID_L1_PARAMETERS, + "", 0 + }; + +GLOBAL KW_DATA partab[] = { + "", 0 + }; +#endif + + +GLOBAL SHORT pei_config (T_PEI_CONFIG inString) +{ +#if !defined (NCONFIG) + char * s = inString; + SHORT valno; + USHORT keyno; + char * keyw; + char * val [10]; + TOK_DCB tokenizer; + char token_buf[80]; + SHORT token_type; + int error; /* terminate processing */ + + TRACE_FUNCTION ("pei_config()"); + + TRACE_FUNCTION (s); + + cst_tok_init(s, &tokenizer, &token_buf[0], sizeof(token_buf)); + + /* + * Parse next keyword and number of variables + */ + error = 0; + while (!error && cst_tokenizer_has_more_data(&tokenizer)) + { + token_type = cst_tok_gettok(&tokenizer, &keyw); + if (token_type != IDENT) + { + error = 1; + } + else + { + switch ((keyno = tok_key((KW_DATA *)kwtab, keyw))) + { + case ID_CONFIG: + valno = cst_get_values(&tokenizer, val); + if (valno EQ 3) + { + extDisplay = 1; + } + break; + case ID_MUTE: + valno = cst_get_values(&tokenizer, val); /* eat up rest of line */ + /* + * FTA testcase 26.6.3.4 needs the the MS is in audio free + * environment. This config disables opening of the audio + * path. + */ + audio_is_free = FALSE; + break; + case ID_GSM_PARAMETERS: + cst_gsm_parameters(&tokenizer); + break; + case ID_L1_PARAMETERS: + /* pass parameters to L1 function for further process */ + l1_cst_l1_parameters(s); + valno = cst_get_values(&tokenizer, val); /* eat up rest of line */ + break; + default: + TRACE_ERROR ("[PEI_CONFIG]: Illegal Keyword"); + break; + } + } + } +#endif + return PEI_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6147) MODULE : CST_PEI | +| STATE : code ROUTINE : cst_pei_config | ++--------------------------------------------------------------------+ + + PURPOSE : Dynamic Configuration + +*/ + +GLOBAL SHORT cst_pei_config ( char * inString, char * dummy ) +{ + pei_config ( inString ); +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : pei_monitor | ++--------------------------------------------------------------------+ + + PURPOSE : This function monitors physical parameters. +*/ +LOCAL SHORT pei_monitor (void ** monitor) +{ + TRACE_FUNCTION ("pei_monitor()"); + + cst_mon.version = VERSION_CST; + + *monitor = &cst_mon; + + return PEI_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : pei_create | ++--------------------------------------------------------------------+ + + PURPOSE : This function creates the protocol stack entity. +*/ + +GLOBAL SHORT cst_pei_create (T_PEI_INFO **info) +{ + static const T_PEI_INFO pei_info = + { + "CST", + { + pei_init, + pei_exit, + pei_primitive, + pei_timeout, + NULL, /* no signal function */ + NULL, /* no run function */ + pei_config, + pei_monitor, + }, + 1536, /* Stack Size */ + 10, /* Queue Entries */ + 55, /* Priority */ + MAX_CST_TIMER, /* number of timer */ + 0x03 /* flags */ + }; + + TRACE_FUNCTION ("pei_create()"); + + /* + * Close Resources if open + */ + + if (first_access) + first_access = FALSE; + else + pei_exit (); + + /* + * Export startup configuration data + */ + + *info = (T_PEI_INFO *)&pei_info; + + return PEI_OK; +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : cst_tok_init | ++--------------------------------------------------------------------+ + + PURPOSE : Initialize token scanner. + +*/ +static void cst_tok_init (char * s, TOK_DCB *dcb, char *buf, int buf_len) +{ + int i; + dcb->nexttok = dcb->tokbuf = buf; + // can't use strcpy since it stops at 0s + for (i=0; i<buf_len-1; i++) + { + dcb->tokbuf[i] = s[i]; + } + dcb->tokbuf[buf_len-1] = '\0'; + dcb->lastchar = 0; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : cst_get_values | ++--------------------------------------------------------------------+ +*/ +static SHORT cst_get_values(TOK_DCB *dcb, char *value[]) +{ + char * val; /* not identifier, so thrown away */ + /* + * Check next token + */ + switch (cst_tok_gettok (dcb, &val)) + { + /* + * No value present + */ + case COMMA: + return (0); + /* + * Value(s) follows + */ + case EQUAL: + return (cst_tok_value (dcb, value)); + /* + * No value present and EOS + */ + case EOS: + dcb->nexttok = NULL; + return (0); + /* + * Syntax error + */ + default: + dcb->nexttok = NULL; + return (TOK_EOCS); + } +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : cst_tok_value | ++--------------------------------------------------------------------+ +*/ +static SHORT cst_tok_value (TOK_DCB *dcb, char * value []) +{ + SHORT count; + SHORT tok; + SHORT inbrack; + char * val; + char * val2; + + inbrack = 0; + /* + * Get next token + */ + tok = cst_tok_gettok (dcb, &val); + + switch (tok) + { + case LBRACK: + inbrack++; + break; + + case IDENT : + case STRING : + tok = cst_tok_gettok (dcb, &val2); /* val2 ignored since next tok */ + if ((tok == COMMA) || (tok == EOS)) /* shouldn't be an IDENT */ + { + /* just single value, return */ + value[0] = val; + return (1); + } + else + { + /* error */ + dcb->nexttok = NULL; + return (0); + } + + case EOS : + default : + dcb->nexttok = NULL; + return (0); + } + + /* + * Get first token of list + */ + + tok = cst_tok_gettok (dcb, &val); + count = 0; + while (1) + { + if ((tok == IDENT) || (tok == STRING)) + { + value[count++] = val; + } + else + { + dcb->nexttok = NULL; + return (0); + } + + tok = cst_tok_gettok (dcb, &val); + switch (tok) + { + case COMMA: + break; + + case RBRACK : + if (inbrack) + { + if (((tok = cst_tok_gettok (dcb, &val)) == COMMA) || + (tok == EOS)) + { + return (count); + } + } + /* + * Fall through + */ + default: + dcb->nexttok = NULL; + return (0); + } + tok = cst_tok_gettok (dcb, &val); + } + return (0); +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : cst_tok_gettok | ++--------------------------------------------------------------------+ + + PURPOSE : Get list of values for token. + Return number of values found. + + Formats: Value + (Value) + (Value, Value,...) + () +*/ +static SHORT cst_tok_gettok (TOK_DCB *dcb, char ** token) +{ + SHORT tok; + /* if previous token was IDENT, a '\0' was placed afterwards + * for string processing and the overwritten character was + * placed in lastchar. We now replace this character. + */ + if (dcb->lastchar) + { + *(dcb->nexttok) = dcb->lastchar; + dcb->lastchar = 0; + } + /* + * Skip leading white space + */ + while (isspace (*(dcb->nexttok))) + { + dcb->nexttok++; + } + + * token = dcb->nexttok++; + + switch (** token) + { + case '\0': /* End of string */ + case '\n': + tok = EOS; + break; + + case ',': + ** token = '\0'; + tok = COMMA; + break; + + case '=': + ** token = '\0'; + tok = EQUAL; + break; + + case '(': + case '<': + case '[': + ** token = '\0'; + tok = LBRACK; + break; + + case ')': + case '>': + case ']': + ** token = '\0'; + tok = RBRACK; + break; + + case '"': + /* + * Get first char of string + */ + * token = dcb->nexttok; + while ((*(dcb->nexttok) != '\0') && (*(dcb->nexttok) != '"')) + { + dcb->nexttok++; + } + + if (*(dcb->nexttok) != '\0') + { + *(dcb->nexttok++) = '\0'; + } + + tok = STRING; + break; + + default: + /* + * Read an identifier + */ + while ( !cst_tok_issep (*(dcb->nexttok)) ) + { + dcb->nexttok++; + } + + dcb->lastchar = *(dcb->nexttok); + *(dcb->nexttok) = '\0'; + + if (*token == dcb->nexttok) + { + /* no characters in identifier. Error in code! */ + tok = ERROR; + } + else + { + tok = IDENT; + } + break; + } + return (tok); +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : cst_tok_issep | ++--------------------------------------------------------------------+ + + PURPOSE : Return 1 if special character. +*/ +static SHORT cst_tok_issep (char c) +{ + switch (c) + { + case '\0' : + case '\n' : + case ',' : + case '=' : + case '(' : + case '<' : + case '[' : + case ')' : + case '>' : + case ']' : + case '"' : return (1); + + default : return (isspace (c)); + } +} + +/* if string in tokenizer state has unprocessed tokens return 1 */ +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : cst_tokenizer_has_more_data | ++--------------------------------------------------------------------+ + + PURPOSE : Return 1 if string in tokenizer state has unprocessed tokens. +*/ +static int cst_tokenizer_has_more_data(const TOK_DCB *dcb) +{ + return (dcb->nexttok != NULL); +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : cst_getbyte | ++--------------------------------------------------------------------+ +*/ + +static int cst_getbyte(TOK_DCB *dcb) +{ + if (dcb->nexttok) + { + return *(dcb->nexttok++); + } + else + { + return -1; + } +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX MODULE : CST_PEI | +| STATE : code ROUTINE : cst_gsm_parameters | ++--------------------------------------------------------------------+ +*/ + +int cst_gsm_parameters(TOK_DCB *dcb) +{ + unsigned char id; + char str[80]; + int i; + + // STRIP FIRST TWO DELIMITERS + { + char *tok_string; + + if (cst_tok_gettok(dcb, &tok_string) != EQUAL) + { + return (0); + } + if (cst_tok_gettok(dcb, &tok_string) != LBRACK) + { + return (0); + } + } + + // GET CONTROL ID + if ((id = cst_getbyte(dcb)) == -1) + { + // vsi_o_trace("CST", 0x08, "gsm_parameters() parser error: out of bytes"); + return (0); + } + + // STACK TRACE + else if (id == '1') + { + CST_stack_trace(); + } //end else if (id == '1') + + // Crash Me + else if (id == '2') + { + // No instruction before setting the reset vector + void (*reset_vector)() = (void (*)()) 0x3000000; + (*reset_vector)(); + } //end else if (id == '2') +#if defined (ALR) + // Print Reg Copy + else if (id == '3') + { + extern int xdump_buffer; + int *xp = &xdump_buffer; + int magic_word; + + // displays the 16 User mode 32bits registers saved on exception + // vsi_o_trace("CST", 0x08, "User mode registers [r0-r15] = ..."); + for (i=0; i<4; i++) + { + sprintf(str, "%08x %08x %08x %08x", *(xp++), *(xp++), + *(xp++), *(xp++)); + // vsi_o_trace("CST", 0x08, str); + } + + // displays the User mode CPSR saved on exception + sprintf(str, "User mode CPSR = %08x", *(xp++)); + // vsi_o_trace("CST", 0x08, str); + + // displays the magic word and the index of vector taken + magic_word = *(xp++); + sprintf(str, "Magic Word + Index of Vector = %08x", magic_word); + // vsi_o_trace("CST", 0x08, str); + + // displays the cause of the exception + magic_word &= 0x000F; + + switch (magic_word) { + + case 1: + // vsi_o_trace("CST", 0x08, "Exception: Undefined Instruction"); + break; + + case 2: + // vsi_o_trace("CST", 0x08, "Exception: Unexpected Software Interrupt"); + break; + + case 3: + // vsi_o_trace("CST", 0x08, "Exception: Abort Prefetch"); + break; + + case 4: + // vsi_o_trace("CST", 0x08, "Exception: Abort Data"); + break; + + case 5: + // vsi_o_trace("CST", 0x08, "Exception: Reserved"); + break; + + default: + break; + } + + // displays the bottom 20 words of user mode stack saved on exception + // vsi_o_trace("CST", 0x08, "Bottom 20 words of User mode stack = ..."); + for (i=0; i<5; i++) + { + sprintf(str, "%08x %08x %08x %08x", *(xp++), *(xp++), + *(xp++), *(xp++)); + // vsi_o_trace("CST", 0x08, str); + } + } //end else if (id == '3') + + // Clear Reg Copy + else if (id == '4') + { + extern int xdump_buffer; + int *xp = &xdump_buffer; + // Clears the 38 32bits registers saved on exception + for (i=0; i<38; i++) + { + *(xp+i) = 0; + } + // vsi_o_trace("CST", 0x08, "Registers Copy cleared ..."); + } //end else if (id == '4') +#endif +#if (OP_WCP == 1) +#if (WCP_PROF == 1) + // Enable/disable MC profiler + else if (id == '5') + { + PR_EnableProfiler(0); + } + else if (id == '6') + { + PR_EnableProfiler(1); + power_down_config(0, 0x5ff); // disable sleep, which interferes with profiler + } + + // Enable/disable CPU Meter + else if (id == '7') + { + PR_EnableCpuMeter(0); + } + else if (id == '8') + { + PR_EnableCpuMeter(1); + power_down_config(0, 0x5ff); // disable sleep, which interferes with CPU meter + } +#endif +#endif + + // STRIP LAST DELIMITER + { + char *tok_string; + + if (cst_tok_gettok(dcb, &tok_string) != RBRACK) + { + return (0); + } + } +} // end cst_gsm_parameters + +/* + * Reach here if unexpected event occurs (e.g. Undefined instruction, Abort, + * out of memory); choose whether to restart or stay in datadump mode to find + * out cause of problem + */ +void exception_handler(void) +{ + void (*jump_address)() = (void (*)()) ((unsigned)0x0); + + (*jump_address)(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/g23m-glue/cst/cst_stack.c Thu Apr 23 06:45:55 2015 +0000 @@ -0,0 +1,163 @@ +/******************************************************************************* + * + * CST_STACK.C + * + * Tasks and HISRs stacks monitoring. + * + * (C) Texas Instruments 2000 + * + ******************************************************************************/ + +#include <stdio.h> +#include <string.h> + +#include "nucleus.h" +#include "cs_defs.h" +#include "tc_defs.h" + +// The following stack sizes are defined in int.s +#define IRQ_STACK_SIZE 128 // Number of bytes in IRQ stack +#define FIQ_STACK_SIZE 512 // Number of bytes in FIQ stack. +#define SYSTEM_SIZE 1024 // Define the system stack size + +int vsi_o_trace (char * caller, unsigned long tclass, char * text); +int vsi_t_sleep (char * caller, unsigned long tvalue); + +void CST_stack_trace() +{ + int jndex, count, char_count; + TC_TCB *head, *ptr; + extern CS_NODE *TCD_Created_Tasks_List; + extern CS_NODE *TCD_Created_HISRs_List; + unsigned untouched; + char *top_stack, *top, *bottom; + extern char *TCT_System_Limit; + char result[80]; + char name[9]; + + vsi_o_trace("CST", 0x08, "Stack Info ..."); + vsi_o_trace("CST", 0x08, " Name top bottom current untouched"); + vsi_o_trace("CST", 0x08, "-------------------------------------------------"); + + for (jndex=0; jndex<2; jndex++) + { + // make use of TCB and HCB having same structure from beginning to past stack info + if (jndex == 0) + ptr = head = (TC_TCB *)TCD_Created_Tasks_List; + else { + ptr = head = (TC_TCB *)TCD_Created_HISRs_List; + vsi_o_trace("CST", 0x08, "-------------------------------------------------"); + } + + count = 0; + do + { + untouched = 0; + top_stack = (char *)ptr->tc_stack_start; + while (*top_stack == 0xFE && top_stack <= (char *)ptr->tc_stack_end) + { + untouched++; + top_stack++; + } + + // Avoid to get a spurious character when tasks names are 8 characters long + memcpy (name, ptr->tc_name, 8); + name[8] = 0; + + sprintf(result, "%8s: %08x %08x %08x 0x%x", + name, + ptr->tc_stack_start, + ptr->tc_stack_end, + ptr->tc_stack_pointer, + untouched); + vsi_o_trace("CST", 0x08, result); + vsi_t_sleep("",30); + + ptr = (TC_TCB*) ptr->tc_created.cs_next; + } while (ptr != head && count++ < 50); //count is protection from infinite loops + } // end of for (jndex=0; jndex<2; jndex++) + + // stack allocation algorithm from the int.s function INT_Initialize() + // + // \ \ + // \----------\ + // \ \ + // \ \ + // \ \ + // \ SYSSTACK \ + // \ \ + // \ \ + // \ \ + // \----------\ + // \ \ + // \ IRQSTACK \ + // \ \ + // \----------\ + // \ \ + // \ \ + // \ FIQSTACK \ + // \ \ + // \ \ + // \----------\ + // \ \ + + untouched = 0; + top_stack = top = (char *)TCT_System_Limit; + bottom = (char *) ((unsigned)TCT_System_Limit + SYSTEM_SIZE); + while (*top_stack == 0xFE && top_stack <= bottom) + { + untouched++; + top_stack++; + } + + // "CST" being the current active task with its related CST_Stack, + // the System Stack is unused (current sp_svc = System Stack Bottom) + sprintf(result, "SYSSTACK: %08x %08x %08x 0x%x", + top, + bottom, + bottom, // current sp_svc = System Stack Bottom + untouched); + vsi_o_trace("CST", 0x08, "-------------------------------------------------"); + vsi_o_trace("CST", 0x08, result); + vsi_t_sleep("",30); + + untouched = 0; + top_stack = top = bottom + 4; + bottom = (char *) ((unsigned)bottom + IRQ_STACK_SIZE); + while (*top_stack == 0xFE && top_stack <= bottom) + { + untouched++; + top_stack++; + } + + // Since the processor is in supervisor mode (no IRQ & no FIQ), + // current sp_irq = IRQ Stack bottom + sprintf(result, "IRQSTACK: %08x %08x %08x 0x%x", + top, + bottom, + bottom, // current sp_irq = IRQ Stack bottom + untouched); + vsi_o_trace("CST", 0x08, result); + vsi_t_sleep("",30); + + untouched = 0; + top_stack = top = bottom + 4; + bottom = (char *) ((unsigned)bottom + FIQ_STACK_SIZE); + while (*top_stack == 0xFE && top_stack <= bottom) + { + untouched++; + top_stack++; + } + + // Since the processor is in supervisor mode (no IRQ & no FIQ), + // current sp_fiq = FIQ Stack bottom + sprintf(result, "FIQSTACK: %08x %08x %08x 0x%x", + top, + bottom, + bottom, // current sp_fiq = FIQ Stack bottom + untouched); + vsi_o_trace("CST", 0x08, result); + vsi_o_trace("CST", 0x08, "-------------------------------------------------"); + vsi_t_sleep("",30); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/g23m-glue/cst/cus_cst.h Thu Apr 23 06:45:55 2015 +0000 @@ -0,0 +1,77 @@ +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX SOURCE : CUS_CST.H | +| AUTHOR : XXX VERSION: 1.0 | +| CREATED : 01.02.99 STATE : code | ++--------------------------------------------------------------------+ + + MODULE : CUS_CST + + PURPOSE : Custom dependent definitions for the CST entity of the + mobile station. + + Use this header for definitions to integrate the protocol + stack entity CST in your target system. +*/ + +#ifndef CUS_CST_H +#define CUS_CST_H + + +/*==== CONSTANTS ==================================================*/ +/* + * TIMER_VALUES + * + * Description : The constants define the timer values for the CST + * timer TXXX depending on the various channel types + * and service access point identifiers. + * + * If your target system uses other units please + * change the values. + */ + +/* + * Unit is 1 ms + */ +#define T_RX_VALUE 1000 +#define TICS_PER_DECIHOURS (1000*60*6) + + +/* + * MAX_CST_TIMER + * + * Description : The constant define the number of timer available + * in the timer pool. + */ +#define MAX_CST_TIMER 4 + +/* + * VERSION + * + * Description : The constants define the type and the value of a + * version identification. The version is part of the + * monitor struct. + */ +#define T_VERSION char +#define VERSION_CST "CST 1.0" + +/* + * VSI_CALLER + * + * Description : For multithread applications the constant VSI_CALLER + * must be defined to identify the calling thread of the + * VSI-Interface. This must be done correponding to the + * type of T_VSI_CALLER in VSI.H. The comma symbol is + * neccessary because the vsi-functions are called + * like this vsi_xxx (VSI_CALLER par2, par3 ...) + */ + +#ifdef OPTION_MULTITHREAD +#define VSI_CALLER cst_handle, +#define VSI_CALLER_SINGLE cst_handle +#else +#define VSI_CALLER +#define VSI_CALLER_SINGLE +#endif + +#endif // CUS_CST_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/g23m-glue/cst/mon_cst.h Thu Apr 23 06:45:55 2015 +0000 @@ -0,0 +1,28 @@ +/* ++--------------------------------------------------------------------+ +| PROJECT : XXX SOURCE : MON_CST.H | +| AUTHOR : XXX VERSION: 1.0 | +| CREATED : 01.02.99 STATE : code | ++--------------------------------------------------------------------+ + + MODULE : MON_CST + + PURPOSE : Monitoring definitions for entity CST. +*/ + +#ifndef MON_CST_H +#define MON_CST_H + +/*==== CONSTANTS ==================================================*/ + +/*==== TYPES ======================================================*/ + +typedef struct +{ + T_VERSION * version; +} T_MONITOR; + +/*==== EXPORT =====================================================*/ + +#endif +