view src/cs/layer1/tpu_drivers/p_source0/p_tpudr12.c @ 220:0ed36de51973

ABB semaphore protection overhaul The ABB semaphone protection logic that came with TCS211 from TI was broken in several ways: * Some semaphore-protected functions were called from Application_Initialize() context. NU_Obtain_Semaphore() called with NU_SUSPEND fails with NU_INVALID_SUSPEND in this context, but the return value wasn't checked, and NU_Release_Semaphore() would be called unconditionally at the end. The latter call would increment the semaphore count past 1, making the semaphore no longer binary and thus no longer effective for resource protection. The fix is to check the return value from NU_Obtain_Semaphore() and skip the NU_Release_Semaphore() call if the semaphore wasn't properly obtained. * Some SPI hardware manipulation was being done before entering the semaphore- protected critical section. The fix is to reorder the code: first obtain the semaphore, then do everything else. * In the corner case of L1/DSP recovery, l1_abb_power_on() would call some non-semaphore-protected ABB & SPI init functions. The fix is to skip those calls in the case of recovery. * A few additional corner cases existed, all of which are fixed by making ABB semaphore protection 100% consistent for all ABB functions and code paths. There is still one remaining problem of priority inversion: suppose a low- priority task calls an ABB function, and some medium-priority task just happens to preempt right in the middle of that semaphore-protected ABB operation. Then the high-priority SPI task is locked out for a non-deterministic time until that medium-priority task finishes its work and goes back to sleep. This priority inversion problem remains outstanding for now.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Apr 2021 20:55:25 +0000
parents 4e78acac3d88
children
line wrap: on
line source

/************* Revision Controle System Header *************
 *                  GSM Layer 1 software
 *
 *        Filename p_tpudr12.c
 *  Copyright 2003 (C) Texas Instruments
 *
 ************* Revision Controle System Header *************/

#include "l1_macro.h"
#include "l1_confg.h"

#if L1_GPRS

#include "sys_types.h"
#include "iq.h"
#include "l1_const.h"
#include "l1_types.h"

#if TESTMODE
  #include "l1tm_defty.h"
#endif

#if (AUDIO_TASK == 1)
  #include "l1audio_const.h"
  #include "l1audio_cust.h"
  #include "l1audio_defty.h"
#endif

#if (L1_GTT == 1)
  #include "l1gtt_const.h"
  #include "l1gtt_defty.h"
#endif

#if (L1_MP3 == 1)
  #include "l1mp3_defty.h"
#endif

#if (L1_MIDI == 1)
  #include "l1midi_defty.h"
#endif

#if (L1_AAC == 1)
  #include "l1aac_defty.h"
#endif

#include "l1_defty.h"
#include "l1_time.h"
#include "tpudrv.h"
#include "tpudrv12.h"
#include "armio.h"


// external function prototypes

void l1dmacro_rx_up (void);
void l1dmacro_rx_down (WORD32 t);

void l1dmacro_tx_up (void);
void l1dmacro_tx_down (WORD32 time, BOOL tx_flag, UWORD8  adc_active);

// external variables and tables
extern SYS_UWORD16      *TP_Ptr;


/**************************************************************************/
/**************************************************************************/
/*                    EXTERNAL FUNCTIONS CALLED BY LAYER1                 */
/*                          COMMON TO L1 and TOOLKIT                      */
/**************************************************************************/
/**************************************************************************/

/*------------------------------------------*/
/*            l1dmacro_tx_synth             */
/*------------------------------------------*/
/*      programs RF synth for transmit      */
/*      programs OPLL for transmit          */
/*------------------------------------------*/
void l1pdmacro_tx_synth(SYS_UWORD16 radio_freq)
{
  l1dmacro_tx_synth(radio_freq);
}

/*------------------------------------------*/
/*            l1pdmacro_rx_up               */
/*------------------------------------------*/
/* Open window for normal burst reception   */
/*------------------------------------------*/
void l1pdmacro_rx_up (SYS_UWORD16 radio_freq)
{
    l1dmacro_rx_up();
}

/*------------------------------------------*/
/*            l1pdmacro_rx_down             */
/*------------------------------------------*/
/* Close window for normal burst reception  */
/*------------------------------------------*/
void l1pdmacro_rx_down (SYS_UWORD16 radio_freq, UWORD8 num_rx, BOOL rx_done_flag)
{
  l1dmacro_rx_down (RX_DOWN_TABLE[num_rx - 1]);
}

/*------------------------------------------*/
/*            l1pdmacro_tx_up               */
/*------------------------------------------*/
/* Open transmission window for normal burst*/
/*------------------------------------------*/
void l1pdmacro_tx_up (SYS_UWORD16 radio_freq)
{
  l1dmacro_tx_up();
}

/*-------------------------------------------*/
/*            l1pdmacro_tx_down              */
/*-------------------------------------------*/
/* Close transmission window for normal burst*/
/*-------------------------------------------*/
void l1pdmacro_tx_down (SYS_UWORD16 radio_freq, WORD16 time, BOOL tx_flag, UWORD8 timing_advance,UWORD8  adc_active)
{
  l1dmacro_tx_down (time, tx_flag, adc_active);
}

/*---------------------------------------------*/
/*       l1pdmacro_it_dsp_gen                  */
/*---------------------------------------------*/
/*       Generate IT to DSP                    */
/*---------------------------------------------*/
void l1pdmacro_it_dsp_gen(WORD16 time)
{
  // WARNING: 'time' must always be included between 0 and TPU_CLOCK_RANGE !!!

  *TP_Ptr++ = TPU_FAT   (time);
  *TP_Ptr++ = TPU_MOVE  (TPU_IT_DSP_PG,0x0001);
}

// TEMPORARY !!!!!

/*---------------------------------------------*/
/*       l1pdmacro_anchor                      */
/*---------------------------------------------*/
/*  Temporary macro used to program a TPU      */
/* scenario executed on the correct frame      */
/*---------------------------------------------*/
void l1pdmacro_anchor(WORD16 time)
{
  // WARNING: 'time' must always be included between 0 and TPU_CLOCK_RANGE !!!

   *TP_Ptr++ = TPU_FAT    (time);
}

#endif