view src/g23m-fad/l2r/tra.h @ 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 fa8dc04885d8
children
line wrap: on
line source

/* 
+----------------------------------------------------------------------------- 
|  Project :  CSD (8411)
|  Modul   :  tra.h
+----------------------------------------------------------------------------- 
|  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 :  Definitions for the Protocol Stack Entity
|             TRA
+----------------------------------------------------------------------------- 
*/ 

#ifndef TRA_H
#define TRA_H

/*
 * States of the entity process MGT
 */
#define MGT_IDLE            0
#define MGT_INACTIVE        1
#define MGT_ACTIVE          2

 /*
 * States of the entity processes UP & DN
 */
#define UP_INACTIVE 0
#define UP_IDLE     1
#define UP_WAIT     2
#define UP_SEND     3

#define DN_INACTIVE 0
#define DN_IDLE     1
#define DN_WAIT     2
#define DN_SEND     3

/*==== TYPES ======================================================*/

/*
* derived constants
*/

/* global user specific constants */

#define FL_INACTIVE 0
#define FL_ACTIVE   1

/*
* Bitoffset for encoding/decoding, taken from RLP
*/
#define ENCODE_OFFSET 0

typedef enum
{
  NONTRANSP = 0,
  TRANSP    = 1
} T_MODE;


/*lint -e767 macro 'ENTITY_DATA' was defined differently in another module */
#define ENTITY_DATA tra_data

/*
 *  MANAGEMENT signal processing
 */
#ifdef OPTION_MULTITHREAD
#define sig_mgt_tra_up_send_break_req _ENTITY_PREFIXED(sig_mgt_tra_up_send_break_req)
#define sig_mgt_tra_up_break_req      _ENTITY_PREFIXED(sig_mgt_tra_up_break_req)
#define sig_mgt_tra_dn_break_req      _ENTITY_PREFIXED(sig_mgt_tra_dn_break_req)

#define sig_any_tra_dn_send_break_req _ENTITY_PREFIXED(sig_any_tra_dn_send_break_req)
#define sig_up_tra_mgt_break_ind      _ENTITY_PREFIXED(sig_up_tra_mgt_break_ind)
#define sig_dn_tra_mgt_break_ind      _ENTITY_PREFIXED(sig_dn_tra_mgt_break_ind)
#endif

EXTERN void sig_mgt_tra_up_send_break_req(USHORT break_len);
EXTERN void sig_mgt_tra_up_break_req(void);
EXTERN void sig_mgt_tra_dn_break_req(void);

EXTERN void sig_any_tra_dn_send_break_req (void);

EXTERN void sig_up_tra_mgt_break_ind(USHORT break_len);
EXTERN void sig_dn_tra_mgt_break_ind(U8 sa, U8 sb, U8 flow, USHORT break_len);

/*
 *  MANAGEMENT procedures
 */

EXTERN void send_tra_deactivate_cnf(void);
EXTERN void send_tra_dti_cnf(T_TRA_DTI_REQ *tra_dti_req);

/*
 *  DN signal processing
 */

#ifdef OPTION_MULTITHREAD
#define sig_mgt_tra_dn_dti_conn_setup _ENTITY_PREFIXED(sig_mgt_tra_dn_dti_conn_setup)
#define sig_mgt_tra_dn_dti_conn_open  _ENTITY_PREFIXED(sig_mgt_tra_dn_dti_conn_open)
#define sig_mgt_tra_dn_dti_disc       _ENTITY_PREFIXED(sig_mgt_tra_dn_dti_disc)
#endif

EXTERN void sig_mgt_tra_dn_dti_conn_setup(void);
EXTERN void sig_mgt_tra_dn_dti_conn_open(void);
EXTERN void sig_mgt_tra_dn_dti_disc(void);

/*
 *  DN procedures
 */
#ifdef OPTION_MULTITHREAD
#define dl_init                       _ENTITY_PREFIXED(dl_init)
#define rbm_init                      _ENTITY_PREFIXED(rbm_init)
#define dl_send_data_ind              _ENTITY_PREFIXED(dl_send_data_ind )
#define dl_prep_data_ind              _ENTITY_PREFIXED(dl_prep_data_ind)
#endif

EXTERN void dl_init(T_TRA_DN *ddl);
EXTERN void rbm_init(T_TRA_DN *ddl);

EXTERN BOOL dl_send_data_ind (void);
EXTERN void dl_prep_data_ind (T_FD *pFD);

/*
 *  UP signal processing
 */
#ifdef OPTION_MULTITHREAD
#define sig_mgt_tra_up_dti_conn_setup _ENTITY_PREFIXED(sig_mgt_tra_up_dti_conn_setup)
#define sig_mgt_tra_up_dti_conn_open _ENTITY_PREFIXED(sig_mgt_tra_up_dti_conn_open)
#define sig_mgt_tra_up_dti_disc _ENTITY_PREFIXED(sig_mgt_tra_up_dti_disc)
#endif

EXTERN void sig_mgt_tra_up_dti_conn_setup(void);
EXTERN void sig_mgt_tra_up_dti_conn_open(void);
EXTERN void sig_mgt_tra_up_dti_disc(void);

/*
 *  UP procedures
 */
#ifdef OPTION_MULTITHREAD
#define ul_init                   _ENTITY_PREFIXED(ul_init          )
#define snd_data_to_RA            _ENTITY_PREFIXED(snd_data_to_RA   )
#define snd_break_to_RA           _ENTITY_PREFIXED(snd_break_to_RA  )
#define up_start_dti_flow         _ENTITY_PREFIXED(up_start_dti_flow)
#endif

EXTERN void ul_init(T_TRA_UP *dul);
EXTERN void snd_data_to_RA();
EXTERN void snd_break_to_RA(USHORT break_len);
EXTERN void up_start_dti_flow(void);

EXTERN T_MODE l2r_data_mode;

/*
* number of signals (max. signalNum which occurs in pei_signal)
*/

EXTERN DTI_HANDLE l2r_hDTI; /* DTI connection handle for DTI library      */

EXTERN T_FD *tra_get_next_FrameDesc(void);

#endif