view src/g23m-gprs/cci/cci_hw_sim.c @ 303:f76436d19a7a default tip

!GPRS config: fix long-standing AT+COPS chance hanging bug There has been a long-standing bug in FreeCalypso going back years: sometimes in the AT command bring-up sequence of an ACI-only MS, the AT+COPS command would produce only a power scan followed by cessation of protocol stack activity (only L1 ADC traces), instead of the expected network search sequence. This behaviour was seen in different FC firmware versions going back to Citrine, and seemed to follow some law of chance, not reliably repeatable. This bug has been tracked down and found to be specific to !GPRS configuration, stemming from our TCS2/TCS3 hybrid and reconstruction of !GPRS support that was bitrotten in TCS3.2/LoCosto version. ACI module psa_mms.c, needed only for !GPRS, was missing in the TCS3 version and had to be pulled from TCS2 - but as it turns out, there is a new field in the MMR_REG_REQ primitive that needs to be set correctly, and that psa_mms.c module is the place where this initialization needed to be added.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 08 Jun 2023 08:23:37 +0000
parents fa8dc04885d8
children
line wrap: on
line source

/* 
+----------------------------------------------------------------------------- 
|  Project :  
|  Modul   :  cci_hw_sim.c
+----------------------------------------------------------------------------- 
|  Copyright 2002 Texas Instruments Berlin, AG 
|                 All rights reserved. 
| 
|                 This file is confidential and a trade secret of Texas 
|                 Instruments Berlin, AG 
|                 The receipt of or possession of this file does not convey 
|                 any rights to reproduce or disclose its contents or to 
|                 manufacture, use, or sell anything it may describe, in 
|                 whole, or in part, without the specific written consent of 
|                 Texas Instruments Berlin, AG. 
+----------------------------------------------------------------------------- 
|  Purpose :  This module implements hardware simulation functions for
|             entity CCI.
+----------------------------------------------------------------------------- 
*/ 


#define CCI_HW_SIM_C

#define ENTITY_LLC

/*==== INCLUDES =============================================================*/
#include <string.h>     /* to get memmove */

#include "typedefs.h"   /* to get Condat data types */
#include "vsi.h"        /* to get a lot of macros */
#include "macdef.h"
#include "gprs.h"
#include "gsm.h"        /* to get a lot of macros */
#include "cnf_llc.h"    /* to get cnf-definitions */
#include "mon_llc.h"    /* to get mon-definitions */
#include "prim.h"       /* to get the definitions of used SAP and directions */
#include "cci.h"        /* to get the global entity definitions */
#include "llc.h"        /* to get the global entity definitions */

#include "cci_hw_sim.h"

#include "llc_f.h"      /* to get llc_build_crc24() */

/*==== CONST ================================================================*/

/*==== LOCAL VARS ===========================================================*/

/*==== PRIVATE FUNCTIONS ====================================================*/

/*==== PUBLIC FUNCTIONS =====================================================*/

#ifdef _GEA_SIMULATION_


/*
+------------------------------------------------------------------------------
| Function    : ciph_hw_sim_cipher
+------------------------------------------------------------------------------
| Description : This functionn simulates the hardware during ciphering process    
|
| Parameters  : void
|
+------------------------------------------------------------------------------
*/
GLOBAL void ciph_hw_sim_cipher (U16 len)
{
  /*
   * first move data one byte, if requested
   */

  if( *cci_data->fbs.conf_ul_reg1 & INPUT_SHIFT )
  {
    memmove (cci_data->fbs.simulated_reg_buffer,   /* dest */
             cci_data->fbs.simulated_reg_buffer+1, /* src  */
             len);
  }

  {
#ifdef _SIM_CALC_FCS_
    ULONG             fcs;

  /*
   * Build FCS (function returns already inversed CRC), store result in fcs.
   */
  fcs = llc_build_crc24 (cci_data->fbs.simulated_reg_buffer,
                         len);
  /*
   * Copy FCS to HW registers, taking byte ordering of FCS registers
   * into account, e.g.:
   * fcs              reg1   reg2
   * xx 36 29 FC  ->  29 FC  xx 36
   */
  *cci_data->fbs.fcs_ul_reg1 = (USHORT) (fcs & 0x0000FFFFL);
  *cci_data->fbs.fcs_ul_reg2 = (USHORT)((fcs & 0x00FF0000L) >> 16);
#else
  /*
   * Set FCS to all zeroes in simulation.
   */
  *cci_data->fbs.fcs_ul_reg1 = 0x0000;
  *cci_data->fbs.fcs_ul_reg2 = 0x0000;
#endif /* _SIM_CALC_FCS_ */
  }
  /*
   * HW simulation: set status register to indicate finished work and emulate
   * timer afterwards.
   */
  *cci_data->fbs.status_reg &= NOT_WORKING;

} /* ciph_hw_sim_cipher */

 /*
+------------------------------------------------------------------------------
| Function    : ciph_hw_sim_decipher
+------------------------------------------------------------------------------
| Description : This functionn simulates the hardware during deciphering process    
|
| Parameters  : void
|
+------------------------------------------------------------------------------
*/
GLOBAL void ciph_hw_sim_decipher ( void )
{
  /*
   * set all registers to indicate finished work.
   * FCS will be checked later.
   */
  *cci_data->fbs.fcs_dl_reg1 &= 0x0000;
  *cci_data->fbs.fcs_dl_reg2 &= 0x0000;

  *cci_data->fbs.status_reg  &= NOT_WORKING;

} /* ciph_hw_sim_decipher */



/*
+------------------------------------------------------------------------------
| Function    : ciph_reg16_write_sim
+------------------------------------------------------------------------------
| Description : This function simulates the hardware writing process on windows 
|               environment
|
| Parameters  : void
|
+------------------------------------------------------------------------------
*/
GLOBAL void ciph_reg16_write_sim ( void )
{ 
  UBYTE *data = (UBYTE *)cci_data->fbs.data16_reg;;

  /*
   * To support any alignment the copy process must be done in two steps 
   * by the use of 8 bit char pointers
   */
  *cci_data->fbs.simulated_reg = *data;
  cci_data->fbs.simulated_reg++;

  data++;

  *cci_data->fbs.simulated_reg = *data;
  cci_data->fbs.simulated_reg++;
  
} /* ciph_reg16_write_sim */




/*
+------------------------------------------------------------------------------
| Function    : ciph_reg8_write_sim
+------------------------------------------------------------------------------
| Description : This function simulates the 8 bit hardware writing process 
|               by the use of 8 bit register.
|
| Parameters  : void
|
+------------------------------------------------------------------------------
*/
GLOBAL void ciph_reg8_write_sim ( void )
{ 
  *cci_data->fbs.simulated_reg = *cci_data->fbs.data8_reg;
  cci_data->fbs.simulated_reg++;

} /* ciph_reg8_write_sim() */


/*
+------------------------------------------------------------------------------
| Function    : ciph_reg16_read_sim
+------------------------------------------------------------------------------
| Description : This function simulates the 16 bit hardware reading process 
|               by the use of a 16 bit register
|
| Parameters  : void
|
+------------------------------------------------------------------------------
*/
GLOBAL void ciph_reg16_read_sim ( void )
{   
  UBYTE *data = (UBYTE *)cci_data->fbs.data16_reg;
  
  /*
   * To support any alignment the copy process must be done in two steps 
   * by the use of 8 bit char pointers
   */
  *data = *cci_data->fbs.simulated_reg;
  cci_data->fbs.simulated_reg++;

  data++;  

  *data = *cci_data->fbs.simulated_reg;
  cci_data->fbs.simulated_reg++;

} /* ciph_reg16_read_sim*/


/*
+------------------------------------------------------------------------------
| Function    : ciph_reg8_read_sim
+------------------------------------------------------------------------------
| Description : This function simulates the 8 bit hardware reading process 
|               by the use of 8 bit register.
|
| Parameters  : void
|
+------------------------------------------------------------------------------
*/
GLOBAL void ciph_reg8_read_sim ( void )
{   
  *cci_data->fbs.data8_reg = *cci_data->fbs.simulated_reg;
  cci_data->fbs.simulated_reg++;

} /* ciph_reg8_read_sim*/



#endif /* _GEA_SIMULATION */