comparison g23m-aci/uart/uart_drxp.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul :
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This modul is part of the entity UART and implements all
18 | functions to handles the incoming primitives as described in
19 | the SDL-documentation (DRX-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef UART_DRXP_C
24 #define UART_DRXP_C
25 #endif /* !UART_DRXP_C */
26
27 #include "config.h"
28 #include "fixedconf.h"
29 #include "condat-features.h"
30
31 #define ENTITY_UART
32
33 /*==== INCLUDES =============================================================*/
34
35 #ifdef WIN32
36 #include "nucleus.h"
37 #endif /* WIN32 */
38 #include "typedefs.h" /* to get Condat data types */
39 #include "vsi.h" /* to get a lot of macros */
40 #include "macdef.h" /* to get a lot of macros */
41 #include "custom.h"
42 #include "gsm.h" /* to get a lot of macros */
43 #include "cnf_uart.h" /* to get cnf-definitions */
44 #include "mon_uart.h" /* to get mon-definitions */
45 #include "prim.h" /* to get the definitions of used SAP and directions */
46 #include "dti.h" /* to get dti lib */
47 #include "pei.h" /* to get PEI interface */
48 #ifdef FF_MULTI_PORT
49 #include "gsi.h" /* to get definitions of serial driver */
50 #else /* FF_MULTI_PORT */
51 #ifdef _TARGET_
52 #include "../../serial/serialswitch.h"
53 #include "../../serial/traceswitch.h"
54 #else /* _TARGET_ */
55 #include "serial_dat.h" /* to get definitions of serial driver */
56 #endif /* _TARGET_ */
57 #endif /* FF_MULTI_PORT */
58 #include "uart.h" /* to get the global entity definitions */
59
60 #include "uart_kers.h" /* to get signal definitions for service KER */
61 #ifdef FF_MULTI_PORT
62 #include "uart_ptxs.h" /* to get signal definitions for service TX */
63 #else /* FF_MULTI_PORT */
64 #include "uart_txs.h" /* to get signal definitions for service TX */
65 #endif /* FF_MULTI_PORT */
66 #include "uart_drxf.h" /* to get function definitions for service DRX */
67
68 #ifdef _SIMULATION_
69 #include <stdio.h> /* to get sprintf */
70 #endif /* _SIMULATION_ */
71
72 /*==== CONST ================================================================*/
73
74 /*==== LOCAL VARS ===========================================================*/
75
76 /*==== PRIVATE FUNCTIONS ====================================================*/
77
78 /*==== PUBLIC FUNCTIONS =====================================================*/
79
80
81
82 /*
83 +------------------------------------------------------------------------------
84 | Function : sig_dti_drx_data_received_ind
85 +------------------------------------------------------------------------------
86 | Description : Handles the DTILIB callback call DTI_REASON_DATA_RECEIVED
87 | This signal means that data has been received on a dti
88 | connection.
89 |
90 | Parameter : dti_data2_ind
91 |
92 +------------------------------------------------------------------------------
93 */
94 GLOBAL void sig_dti_drx_data_received_ind(T_DTI2_DATA_IND *dti_data2_ind)
95 {
96 T_desc2* temp_desc1;
97 T_desc2* temp_desc2;
98
99 TRACE_FUNCTION( "drx_dti_data_req" );
100
101 #ifdef UART_RANGE_CHECK
102 if(dti_data2_ind EQ NULL)
103 {
104 TRACE_EVENT("ERROR: dti_data2_ind is NULL");
105 }
106 else if((*((ULONG*)((UBYTE*)dti_data2_ind - sizeof(T_PRIM_HEADER) - 8))) NEQ 0)
107 {
108 TRACE_EVENT_P1("ERROR: dti_data2_ind=%08x is not allocated",
109 dti_data2_ind);
110 }
111 else
112 {
113 T_desc2* range_desc;
114 USHORT range_sum;
115 if((dti_data2_ind->parameters.st_lines.st_flow NEQ DTI_FLOW_ON) &&
116 (dti_data2_ind->parameters.st_lines.st_flow NEQ DTI_FLOW_OFF))
117 {
118 TRACE_EVENT_P1("ERROR: st_flow=%d is invalid",
119 dti_data2_ind->parameters.st_lines.st_flow);
120 }
121 if((dti_data2_ind->parameters.st_lines.st_line_sa NEQ DTI_SA_ON) &&
122 (dti_data2_ind->parameters.st_lines.st_line_sa NEQ DTI_SA_OFF))
123 {
124 TRACE_EVENT_P1("ERROR: st_line_sa=%d is invalid",
125 dti_data2_ind->parameters.st_lines.st_line_sa);
126 }
127 if((dti_data2_ind->parameters.st_lines.st_line_sb NEQ DTI_SB_ON) &&
128 (dti_data2_ind->parameters.st_lines.st_line_sb NEQ DTI_SB_OFF))
129 {
130 TRACE_EVENT_P1("ERROR: st_line_sb=%d is invalid",
131 dti_data2_ind->parameters.st_lines.st_line_sb);
132 }
133 range_desc = (T_desc2*)(dti_data2_ind->desc_list2.first);
134 range_sum = 0;
135 while((range_desc) &&
136 ((*((ULONG*)((UBYTE*)range_desc - 8))) EQ 0))
137 {
138 range_sum += range_desc->len;
139 range_desc = (T_desc2*)(range_desc->next);
140 }
141 if(range_desc)
142 {
143 TRACE_EVENT_P1("ERROR: data descriptor (%08x) not allocated",
144 range_desc);
145 }
146 else if(range_sum NEQ dti_data_req->desc_list2.list_len)
147 {
148 TRACE_EVENT_P2("ERROR: datalength=%d NEQ list_len=%d",
149 range_sum,
150 dti_data2_ind->desc_list2.list_len);
151 }
152 }
153 #endif /* UART_RANGE_CHECK */
154
155 switch( GET_STATE( UART_SERVICE_DRX ) )
156 {
157 case DRX_READY:
158 SET_STATE( UART_SERVICE_DRX, DRX_NOT_READY );
159 dti_stop(
160 uart_hDTI,
161 uart_data->device,
162 UART_DTI_UP_INTERFACE,
163 uart_data->drx->dlc_instance
164 );
165 /*
166 * store data descriptor
167 */
168 temp_desc1 = (T_desc2*)(dti_data2_ind->desc_list2.first);
169 while((temp_desc1) &&
170 (temp_desc1->len EQ 0))
171 {
172 temp_desc2 = (T_desc2*)temp_desc1->next;
173 MFREE(temp_desc1);
174 temp_desc1 = temp_desc2;
175 }
176 uart_data->drx->received_data = temp_desc1;
177 uart_data->drx->read_pos = 0;
178
179 /*
180 * inform kernel about line states
181 */
182 sig_drx_ker_line_states_ind(uart_data->drx->dlc_instance,
183 dti_data2_ind->parameters.st_lines.st_flow,
184 dti_data2_ind->parameters.st_lines.st_line_sa,
185 dti_data2_ind->parameters.st_lines.st_line_sb,
186 dti_data2_ind->parameters.st_lines.st_break_len);
187 /*
188 * check if service can send data to peer
189 */
190 if(uart_data->drx->data_flow EQ UART_FLOW_ENABLED)
191 {
192 /*
193 * yes, now if there is data to send, do it
194 */
195 if(uart_data->drx->received_data)
196 {
197 sig_drx_tx_data_available_ind( uart_data->drx->dlc_instance,
198 uart_data->drx->received_data,
199 uart_data->drx->read_pos );
200 }
201 else
202 {
203 /*
204 * no data to send, do positive flow control towards upper layer
205 */
206 SET_STATE( UART_SERVICE_DRX, DRX_READY );
207 dti_start(
208 uart_hDTI,
209 uart_data->device,
210 UART_DTI_UP_INTERFACE,
211 uart_data->drx->dlc_instance
212 );
213 }
214 }
215 break;
216
217 default:
218 TRACE_ERROR( "DTI_DATA2_IND unexpected" );
219 /*
220 * since the descriptor will not be sent, free it
221 */
222 MFREE_DESC2( dti_data2_ind->desc_list2.first );
223 break;
224 }
225
226 /*
227 * free primitive (freeing of descriptors has been done before if necessary)
228 */
229 PFREE( dti_data2_ind );
230 } /* sig_dti_drx_data_received_ind() */