• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2 **+-----------------------------------------------------------------------+**
3 **|                                                                       |**
4 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
5 **| All rights reserved.                                                  |**
6 **|                                                                       |**
7 **| Redistribution and use in source and binary forms, with or without    |**
8 **| modification, are permitted provided that the following conditions    |**
9 **| are met:                                                              |**
10 **|                                                                       |**
11 **|  * Redistributions of source code must retain the above copyright     |**
12 **|    notice, this list of conditions and the following disclaimer.      |**
13 **|  * Redistributions in binary form must reproduce the above copyright  |**
14 **|    notice, this list of conditions and the following disclaimer in    |**
15 **|    the documentation and/or other materials provided with the         |**
16 **|    distribution.                                                      |**
17 **|  * Neither the name Texas Instruments nor the names of its            |**
18 **|    contributors may be used to endorse or promote products derived    |**
19 **|    from this software without specific prior written permission.      |**
20 **|                                                                       |**
21 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
22 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
23 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
24 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
25 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
26 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
27 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
28 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
29 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
30 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
31 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
32 **|                                                                       |**
33 **+-----------------------------------------------------------------------+**
34 ****************************************************************************/
35 
36 /** \file GWSI_Synchronizer.h
37  *  \brief GWSI Synchronizer include file
38  *
39  *  \see GWSI_Synchronizer.c
40  */
41 
42 
43 /***************************************************************************/
44 /*                                                                          */
45 /*    MODULE:   GWSI_Synchronizer.h                                         */
46 /*    PURPOSE:  GWSI  Synchronizer include file                         */
47 /*                                                                          */
48 /***************************************************************************/
49 
50 
51 #ifndef SYNCHRONIZER_H
52 #define SYNCHRONIZER_H
53 
54 #include "TNETWIF.h"
55 #include "TNETWArbSM.h"
56 #include "TNETWArb_buffer.h"
57 #include "osTIType.h"
58 
59 
60 #define TODO_LIST_INDEX                     0
61 #define RUNNING_LIST_INDEX                  1
62 #define NUM_OF_TNETWARB_QUEUES              2
63 
64 
65 #define TNETWARB_IS_EVENT_PENDING       0x100
66 
67 /* These defines should be closed by default. They may be open for debug purposes */
68 
69 typedef struct TNETWARB_INSTANCE_struct
70 {
71     TI_HANDLE   instance_handle;    /* The handle of the module to be used when calling back the client */
72     TNETWIF_callback_t  instance_callback;  /* The handler of the module to be used when calling back the client */
73     UINT8       module_id;          /* The module_id of the Client */
74     UINT8       priority;           /* The priority of the client instance */
75 } TNETWARB_INSTANCE_T;
76 
77 #define TNETWARB_INSTANCE_SIZE sizeof(TNETWARB_INSTANCE_T)
78 
79 typedef struct TNETWArbStat_t_
80 {
81     UINT32             uStart;
82     UINT32             uRestart;
83     UINT32             uFinish;
84 } TNETWArbStat_t;
85 
86 
87 /**************************** TNETWARB_CB ********************************/
88 /****************************************************************************/
89 typedef struct T_TNETWARB_CB
90 {
91     TI_HANDLE           hOs;
92     TI_HANDLE           hReport;
93     TI_HANDLE           hTNETWArbSM;
94     UINT8               TNETWArb_Client_Instance_Array[NUM_OF_TNETWIF_MODULES] [BUFFER_HDR_SIZE+TNETWARB_INSTANCE_SIZE];
95     TNETWARB_INSTANCE_T *TNETWArb_Running_instance;
96     TNETWARB_INSTANCE_T *pDefInst;
97     BUFFER_Q            TNETWArbiter_Queues[NUM_OF_TNETWARB_QUEUES];
98     TnetwArbSMEvents_e  event_to_dispatch; /* This is used after the client callback has potentially called itself a FOINISH or RESTART API
99                                               Then we remmember the Event to be sent to the TNETW Arbiter State Machine so we prevent nested entrance in the TNETW ARBITER MODULE */
100 
101   #ifdef TI_DBG
102     TNETWArbStat_t      stat;
103   #endif
104 } TNETWArb_t;
105 
106 
107 
108 
109 #define TNETWArb_is_idle(pTnetwArb_cb)              (!pTnetwArb_cb->TNETWArbiter_Queues[RUNNING_LIST_INDEX].count)
110 #define TNETWArb_is_running(pTnetwArb_cb)           (pTnetwArb_cb->TNETWArbiter_Queues[RUNNING_LIST_INDEX].count)
111 
112 
113 
114 /*******************************************************************************/
115 /*    Each new client shall register itself to the synchronizer by inserting here
116       its start instance                                                        */
117 /*    The "extern" here is anyway to explicite to the user that this fucntion is not
118       implemented in the synchronizer but in the client                         */
119 /*******************************************************************************/
120 
121 
122 /************************************************************************
123  API for the TNETWIF to handle the running module's Callbacks.
124 ************************************************************************/
125 TI_STATUS TNETWArb_CallClientCallback (TI_HANDLE hTNETWArb);
126 TI_STATUS TNETWArb_CallTxnCb (TI_HANDLE hTNETWArb);
127 void TNETWArb_TxnCb (TI_HANDLE hTNETWArb, UINT8 module_id, TI_STATUS status);
128 void TNETWArb_PrintStat (TI_HANDLE hTNETWArb);
129 
130 
131 /* API for external module in charge of creating the gwsi_synchronizer initialization */
132 TI_HANDLE TNETWArb_Init (TI_HANDLE hOs);
133 void TNETWArb_Config (TI_HANDLE hTNETWArb,TI_HANDLE hReport,TI_HANDLE hELPCtrl);
134 TI_STATUS TNETWArb_Destroy (TI_HANDLE hTNETWArb);
135 TI_STATUS TNETWArb_Recovery(TI_HANDLE hTNETWArb, TI_HANDLE hELPCtrl);
136 
137 
138 /************************************************************************
139  API for the Client to send an event to the Synchronizer : It can be :
140             EV_REG_ID (PERFORM_IMMEDIATE or start time for future use)
141             EV_FINISH_ID (To be called by the client when if finishes its State Machine
142 ************************************************************************/
143 TI_STATUS TNETWArb_Start (TI_HANDLE hTNETWArb,UINT8 module_id,TI_HANDLE ClientCallBack_Handle,TNETWIF_callback_t ClientCallBack_Func);
144 TI_STATUS TNETWArb_Restart (TI_HANDLE hTNETWArb, UINT8 module_id,TI_HANDLE CallBAck_Handle,TNETWIF_callback_t CallBack_Func);
145 TI_STATUS TNETWArb_Finish (TI_HANDLE hTNETWArb, UINT8 module_id,TI_HANDLE CallBAck_Handle,TNETWIF_callback_t CallBack_Func);
146 
147 /************************************************************************
148  API for the Client to register its handle
149 ************************************************************************/
150 void TNETWArb_register_handler(TI_HANDLE hTNETWArb,UINT8 module_id,TNETWIF_callback_t module_CB_Func,TI_HANDLE module_handle);
151 
152 
153 #endif /* SYNCHRONIZER_H */
154