FreeCalypso > hg > fc-selenite
comparison src/g23m-aci/uart/uart_drxp.c @ 1:d393cd9bb723
src/g23m-*: initial import from Magnetite
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sun, 15 Jul 2018 04:40:46 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:b6a5e36de839 | 1:d393cd9bb723 |
|---|---|
| 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 #define ENTITY_UART | |
| 28 | |
| 29 /*==== INCLUDES =============================================================*/ | |
| 30 | |
| 31 #ifdef WIN32 | |
| 32 #include "nucleus.h" | |
| 33 #endif /* WIN32 */ | |
| 34 #include "typedefs.h" /* to get Condat data types */ | |
| 35 #include "vsi.h" /* to get a lot of macros */ | |
| 36 #include "macdef.h" /* to get a lot of macros */ | |
| 37 #include "custom.h" | |
| 38 #include "gsm.h" /* to get a lot of macros */ | |
| 39 #include "cnf_uart.h" /* to get cnf-definitions */ | |
| 40 #include "mon_uart.h" /* to get mon-definitions */ | |
| 41 #include "prim.h" /* to get the definitions of used SAP and directions */ | |
| 42 #include "dti.h" /* to get dti lib */ | |
| 43 #include "pei.h" /* to get PEI interface */ | |
| 44 #ifdef FF_MULTI_PORT | |
| 45 #include "gsi.h" /* to get definitions of serial driver */ | |
| 46 #else /* FF_MULTI_PORT */ | |
| 47 #ifdef _TARGET_ | |
| 48 #include "uart/serialswitch.h" | |
| 49 #include "uart/traceswitch.h" | |
| 50 #else /* _TARGET_ */ | |
| 51 #include "serial_dat.h" /* to get definitions of serial driver */ | |
| 52 #endif /* _TARGET_ */ | |
| 53 #endif /* FF_MULTI_PORT */ | |
| 54 #include "uart.h" /* to get the global entity definitions */ | |
| 55 | |
| 56 #include "uart_kers.h" /* to get signal definitions for service KER */ | |
| 57 #ifdef FF_MULTI_PORT | |
| 58 #include "uart_ptxs.h" /* to get signal definitions for service TX */ | |
| 59 #else /* FF_MULTI_PORT */ | |
| 60 #include "uart_txs.h" /* to get signal definitions for service TX */ | |
| 61 #endif /* FF_MULTI_PORT */ | |
| 62 #include "uart_drxf.h" /* to get function definitions for service DRX */ | |
| 63 | |
| 64 #ifdef _SIMULATION_ | |
| 65 #include <stdio.h> /* to get sprintf */ | |
| 66 #endif /* _SIMULATION_ */ | |
| 67 | |
| 68 /*==== CONST ================================================================*/ | |
| 69 | |
| 70 /*==== LOCAL VARS ===========================================================*/ | |
| 71 | |
| 72 /*==== PRIVATE FUNCTIONS ====================================================*/ | |
| 73 | |
| 74 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
| 75 | |
| 76 | |
| 77 | |
| 78 /* | |
| 79 +------------------------------------------------------------------------------ | |
| 80 | Function : sig_dti_drx_data_received_ind | |
| 81 +------------------------------------------------------------------------------ | |
| 82 | Description : Handles the DTILIB callback call DTI_REASON_DATA_RECEIVED | |
| 83 | This signal means that data has been received on a dti | |
| 84 | connection. | |
| 85 | | |
| 86 | Parameter : dti_data2_ind | |
| 87 | | |
| 88 +------------------------------------------------------------------------------ | |
| 89 */ | |
| 90 GLOBAL void sig_dti_drx_data_received_ind(T_DTI2_DATA_IND *dti_data2_ind) | |
| 91 { | |
| 92 T_desc2* temp_desc1; | |
| 93 T_desc2* temp_desc2; | |
| 94 | |
| 95 TRACE_FUNCTION( "drx_dti_data_req" ); | |
| 96 | |
| 97 #ifdef UART_RANGE_CHECK | |
| 98 if(dti_data2_ind EQ NULL) | |
| 99 { | |
| 100 TRACE_EVENT("ERROR: dti_data2_ind is NULL"); | |
| 101 } | |
| 102 else if((*((ULONG*)((UBYTE*)dti_data2_ind - sizeof(T_PRIM_HEADER) - 8))) NEQ 0) | |
| 103 { | |
| 104 TRACE_EVENT_P1("ERROR: dti_data2_ind=%08x is not allocated", | |
| 105 dti_data2_ind); | |
| 106 } | |
| 107 else | |
| 108 { | |
| 109 T_desc2* range_desc; | |
| 110 USHORT range_sum; | |
| 111 if((dti_data2_ind->parameters.st_lines.st_flow NEQ DTI_FLOW_ON) && | |
| 112 (dti_data2_ind->parameters.st_lines.st_flow NEQ DTI_FLOW_OFF)) | |
| 113 { | |
| 114 TRACE_EVENT_P1("ERROR: st_flow=%d is invalid", | |
| 115 dti_data2_ind->parameters.st_lines.st_flow); | |
| 116 } | |
| 117 if((dti_data2_ind->parameters.st_lines.st_line_sa NEQ DTI_SA_ON) && | |
| 118 (dti_data2_ind->parameters.st_lines.st_line_sa NEQ DTI_SA_OFF)) | |
| 119 { | |
| 120 TRACE_EVENT_P1("ERROR: st_line_sa=%d is invalid", | |
| 121 dti_data2_ind->parameters.st_lines.st_line_sa); | |
| 122 } | |
| 123 if((dti_data2_ind->parameters.st_lines.st_line_sb NEQ DTI_SB_ON) && | |
| 124 (dti_data2_ind->parameters.st_lines.st_line_sb NEQ DTI_SB_OFF)) | |
| 125 { | |
| 126 TRACE_EVENT_P1("ERROR: st_line_sb=%d is invalid", | |
| 127 dti_data2_ind->parameters.st_lines.st_line_sb); | |
| 128 } | |
| 129 range_desc = (T_desc2*)(dti_data2_ind->desc_list2.first); | |
| 130 range_sum = 0; | |
| 131 while((range_desc) && | |
| 132 ((*((ULONG*)((UBYTE*)range_desc - 8))) EQ 0)) | |
| 133 { | |
| 134 range_sum += range_desc->len; | |
| 135 range_desc = (T_desc2*)(range_desc->next); | |
| 136 } | |
| 137 if(range_desc) | |
| 138 { | |
| 139 TRACE_EVENT_P1("ERROR: data descriptor (%08x) not allocated", | |
| 140 range_desc); | |
| 141 } | |
| 142 else if(range_sum NEQ dti_data_req->desc_list2.list_len) | |
| 143 { | |
| 144 TRACE_EVENT_P2("ERROR: datalength=%d NEQ list_len=%d", | |
| 145 range_sum, | |
| 146 dti_data2_ind->desc_list2.list_len); | |
| 147 } | |
| 148 } | |
| 149 #endif /* UART_RANGE_CHECK */ | |
| 150 | |
| 151 switch( GET_STATE( UART_SERVICE_DRX ) ) | |
| 152 { | |
| 153 case DRX_READY: | |
| 154 SET_STATE( UART_SERVICE_DRX, DRX_NOT_READY ); | |
| 155 dti_stop( | |
| 156 uart_hDTI, | |
| 157 uart_data->device, | |
| 158 UART_DTI_UP_INTERFACE, | |
| 159 uart_data->drx->dlc_instance | |
| 160 ); | |
| 161 /* | |
| 162 * store data descriptor | |
| 163 */ | |
| 164 temp_desc1 = (T_desc2*)(dti_data2_ind->desc_list2.first); | |
| 165 while((temp_desc1) && | |
| 166 (temp_desc1->len EQ 0)) | |
| 167 { | |
| 168 temp_desc2 = (T_desc2*)temp_desc1->next; | |
| 169 MFREE(temp_desc1); | |
| 170 temp_desc1 = temp_desc2; | |
| 171 } | |
| 172 uart_data->drx->received_data = temp_desc1; | |
| 173 uart_data->drx->read_pos = 0; | |
| 174 | |
| 175 /* | |
| 176 * inform kernel about line states | |
| 177 */ | |
| 178 sig_drx_ker_line_states_ind(uart_data->drx->dlc_instance, | |
| 179 dti_data2_ind->parameters.st_lines.st_flow, | |
| 180 dti_data2_ind->parameters.st_lines.st_line_sa, | |
| 181 dti_data2_ind->parameters.st_lines.st_line_sb, | |
| 182 dti_data2_ind->parameters.st_lines.st_break_len); | |
| 183 /* | |
| 184 * check if service can send data to peer | |
| 185 */ | |
| 186 if(uart_data->drx->data_flow EQ UART_FLOW_ENABLED) | |
| 187 { | |
| 188 /* | |
| 189 * yes, now if there is data to send, do it | |
| 190 */ | |
| 191 if(uart_data->drx->received_data) | |
| 192 { | |
| 193 sig_drx_tx_data_available_ind( uart_data->drx->dlc_instance, | |
| 194 uart_data->drx->received_data, | |
| 195 uart_data->drx->read_pos ); | |
| 196 } | |
| 197 else | |
| 198 { | |
| 199 /* | |
| 200 * no data to send, do positive flow control towards upper layer | |
| 201 */ | |
| 202 SET_STATE( UART_SERVICE_DRX, DRX_READY ); | |
| 203 dti_start( | |
| 204 uart_hDTI, | |
| 205 uart_data->device, | |
| 206 UART_DTI_UP_INTERFACE, | |
| 207 uart_data->drx->dlc_instance | |
| 208 ); | |
| 209 } | |
| 210 } | |
| 211 break; | |
| 212 | |
| 213 default: | |
| 214 TRACE_ERROR( "DTI_DATA2_IND unexpected" ); | |
| 215 /* | |
| 216 * since the descriptor will not be sent, free it | |
| 217 */ | |
| 218 MFREE_DESC2( dti_data2_ind->desc_list2.first ); | |
| 219 break; | |
| 220 } | |
| 221 | |
| 222 /* | |
| 223 * free primitive (freeing of descriptors has been done before if necessary) | |
| 224 */ | |
| 225 PFREE( dti_data2_ind ); | |
| 226 } /* sig_dti_drx_data_received_ind() */ |
