FreeCalypso > hg > freecalypso-citrine
comparison g23m-gsm/sim/sim_em.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 Module defines the engineering mode (EM) device driver for the | |
| 18 | G23 protocol stack. This driver is used to control all engineering | |
| 19 | mode related functions. | |
| 20 +----------------------------------------------------------------------------- | |
| 21 */ | |
| 22 | |
| 23 #ifndef SIM_EM_C | |
| 24 #define SIM_EM_C | |
| 25 | |
| 26 #include "config.h" | |
| 27 #include "fixedconf.h" | |
| 28 #include "condat-features.h" | |
| 29 | |
| 30 #define ENTITY_SIM | |
| 31 | |
| 32 /*==== INCLUDES ===================================================*/ | |
| 33 #include <string.h> | |
| 34 #include "typedefs.h" | |
| 35 #include "pconst.cdg" | |
| 36 #include "message.h" | |
| 37 #include "ccdapi.h" | |
| 38 #include "vsi.h" | |
| 39 #include "custom.h" | |
| 40 #include "gsm.h" | |
| 41 #include "cnf_sim.h" | |
| 42 #include "mon_sim.h" | |
| 43 #include "prim.h" | |
| 44 #include "pei.h" | |
| 45 #include "tok.h" | |
| 46 /* #include "dti.h" removed, but included in SIM.H */ | |
| 47 #include "sim.h" | |
| 48 #include "sim_em.h" | |
| 49 | |
| 50 /*==== EXPORT =====================================================*/ | |
| 51 | |
| 52 /*==== PRIVAT =====================================================*/ | |
| 53 | |
| 54 /*==== VARIABLES ==================================================*/ | |
| 55 | |
| 56 #ifdef FF_EM_MODE | |
| 57 GLOBAL UBYTE em_sim_event_buffer[EM_SIM_BUFFER_SIZE]; | |
| 58 GLOBAL UBYTE em_sim_buffer_write; | |
| 59 | |
| 60 /* Event tracing flags for EM */ | |
| 61 GLOBAL BOOL sim_v[EM_MAX_SIM_EVENTS]; | |
| 62 | |
| 63 static UBYTE em_sim_trace_occured; | |
| 64 #endif /* FF_EM_MODE */ | |
| 65 | |
| 66 /*==== FUNCTIONS ==================================================*/ | |
| 67 | |
| 68 #ifdef FF_EM_MODE | |
| 69 | |
| 70 /* | |
| 71 +------------------------------------------------------------------------------ | |
| 72 | Function : em_write_buffer_2 | |
| 73 +------------------------------------------------------------------------------ | |
| 74 | Description : Perform buffer check and store corresponding data in it. | |
| 75 | | |
| 76 | Parameters : Event number | |
| 77 | | |
| 78 | Return : TRUE/FALSE | |
| 79 | | |
| 80 +------------------------------------------------------------------------------ | |
| 81 */ | |
| 82 | |
| 83 GLOBAL UBYTE em_write_buffer_2 (UBYTE event_no) | |
| 84 { | |
| 85 | |
| 86 TRACE_FUNCTION ("sim_em_write_buffer_2()"); | |
| 87 | |
| 88 if(check_write_index(2)) { /* Check write index */ | |
| 89 em_sim_event_buffer[em_sim_buffer_write++] = event_no; /* Event number */ | |
| 90 em_sim_event_buffer[em_sim_buffer_write++] = 0; /* Value length - 0 equals no value */ | |
| 91 return FALSE; /* Data is stored inside buffer, reset flag */ | |
| 92 } | |
| 93 else | |
| 94 return TRUE; /* No more space inside buffer, serve flag next time */ | |
| 95 } | |
| 96 | |
| 97 /* | |
| 98 +------------------------------------------------------------------------------ | |
| 99 | Function : em_write_buffer_3 | |
| 100 +------------------------------------------------------------------------------ | |
| 101 | Description : Perform buffer check and store corresponding data in it. | |
| 102 | | |
| 103 | Parameters : Event number, data value | |
| 104 | | |
| 105 | Return : TRUE/FALSE | |
| 106 | | |
| 107 +------------------------------------------------------------------------------ | |
| 108 */ | |
| 109 | |
| 110 GLOBAL UBYTE em_write_buffer_3 (UBYTE event_no, UBYTE value) | |
| 111 { | |
| 112 | |
| 113 TRACE_FUNCTION ("sim_em_write_buffer_3()"); | |
| 114 | |
| 115 if(check_write_index(3)) { /* Check write index */ | |
| 116 em_sim_event_buffer[em_sim_buffer_write++] = event_no; /* Event number */ | |
| 117 em_sim_event_buffer[em_sim_buffer_write++] = 1; /* Value length - 0 equals no value */ | |
| 118 em_sim_event_buffer[em_sim_buffer_write++] = value; /* Data to be stored */ | |
| 119 return FALSE; /* Data is stored inside buffer, reset flag */ | |
| 120 } | |
| 121 else | |
| 122 return TRUE; /* No more space inside buffer, serve flag next time */ | |
| 123 } | |
| 124 | |
| 125 /* | |
| 126 +------------------------------------------------------------------------------ | |
| 127 | Function : em_write_buffer_3a | |
| 128 +------------------------------------------------------------------------------ | |
| 129 | Description : Perform buffer check and store corresponding data in it. | |
| 130 | | |
| 131 | Parameters : Event number, data value (USHORT) | |
| 132 | | |
| 133 | Return : TRUE/FALSE | |
| 134 | | |
| 135 +------------------------------------------------------------------------------ | |
| 136 */ | |
| 137 | |
| 138 GLOBAL UBYTE em_write_buffer_3a (UBYTE event_no, USHORT value) | |
| 139 { | |
| 140 | |
| 141 TRACE_FUNCTION ("sim_em_write_buffer_3a()"); | |
| 142 | |
| 143 if(check_write_index(4)) { /* Check write index */ | |
| 144 em_sim_event_buffer[em_sim_buffer_write++] = event_no; /* Event number */ | |
| 145 em_sim_event_buffer[em_sim_buffer_write++] = 2; /* Value length - 0 equals no value */ | |
| 146 em_sim_event_buffer[em_sim_buffer_write++] = (UBYTE)(value >> 8); /* Data to be stored - MSB first */ | |
| 147 em_sim_event_buffer[em_sim_buffer_write++] = (UBYTE)(value); /* LSB second */ | |
| 148 return FALSE; /* Data is stored inside buffer, reset flag */ | |
| 149 } | |
| 150 else | |
| 151 return TRUE; /* No more space inside buffer, serve flag next time */ | |
| 152 } | |
| 153 | |
| 154 /* | |
| 155 +------------------------------------------------------------------------------ | |
| 156 | Function : check_write_index | |
| 157 +------------------------------------------------------------------------------ | |
| 158 | Description : Checks the write index inside the buffer. No reset when | |
| 159 | buffer is full. | |
| 160 | | |
| 161 | Parameters : Number of bytes to be stored in buffer | |
| 162 | | |
| 163 | Return : TRUE/FALSE | |
| 164 | | |
| 165 +------------------------------------------------------------------------------ | |
| 166 */ | |
| 167 | |
| 168 LOCAL UBYTE check_write_index (UBYTE n) | |
| 169 { | |
| 170 | |
| 171 TRACE_FUNCTION ("sim_check_write_index()"); | |
| 172 | |
| 173 if ((em_sim_buffer_write + n) < EM_SIM_BUFFER_SIZE) | |
| 174 { | |
| 175 /* | |
| 176 ACI is informed about the first event trace, used for later data processing. | |
| 177 */ | |
| 178 if(em_sim_trace_occured == 0) | |
| 179 { | |
| 180 PALLOC(em_notification, EM_DATA_IND); | |
| 181 em_notification->entity = EM_SIM; | |
| 182 PSENDX(MMI, em_notification); | |
| 183 em_sim_trace_occured++; | |
| 184 } | |
| 185 return TRUE; | |
| 186 } | |
| 187 else | |
| 188 return FALSE; | |
| 189 } | |
| 190 | |
| 191 /* | |
| 192 +------------------------------------------------------------------------------ | |
| 193 | Function : em_init_sim_event_trace | |
| 194 +------------------------------------------------------------------------------ | |
| 195 | Description : Initialize the event tracing flags for SMS | |
| 196 | | |
| 197 | Parameters : | |
| 198 | | |
| 199 | Return : | |
| 200 | | |
| 201 +------------------------------------------------------------------------------ | |
| 202 */ | |
| 203 GLOBAL void em_init_sim_event_trace(void) | |
| 204 { | |
| 205 UBYTE i; | |
| 206 | |
| 207 TRACE_FUNCTION ("em_init_sim_event_trace()"); | |
| 208 | |
| 209 for(i=1; i<EM_MAX_SIM_EVENTS; i++) | |
| 210 sim_v[i] = 0; | |
| 211 | |
| 212 em_sim_buffer_write = 0; | |
| 213 } | |
| 214 | |
| 215 /* | |
| 216 +------------------------------------------------------------------------------ | |
| 217 | Function : sim_em_sim_event_req | |
| 218 +------------------------------------------------------------------------------ | |
| 219 | Description : Set the event tracing flags according the bitmask | |
| 220 | | |
| 221 | Parameters : Primitive - Bitmask | |
| 222 | | |
| 223 | Return : | |
| 224 | | |
| 225 +------------------------------------------------------------------------------ | |
| 226 */ | |
| 227 | |
| 228 GLOBAL void sim_em_sim_event_req (T_EM_SIM_EVENT_REQ *em_sim_event_req) | |
| 229 { | |
| 230 UBYTE i; | |
| 231 | |
| 232 TRACE_FUNCTION ("sim_em_sim_event_req()"); | |
| 233 /* | |
| 234 * The event tracing flags are set according the bitmask. sim_v[i] are | |
| 235 * the flags belonging to the event number described in 8443.601 | |
| 236 */ | |
| 237 for(i=1; i<EM_MAX_SIM_EVENTS; i++) | |
| 238 sim_v[i] = ((em_sim_event_req->bitmask_sim & (0x01<<(i-1))) > 0) ? TRUE : FALSE; | |
| 239 | |
| 240 /* | |
| 241 A new event trace is generated therefor the flag is set to 0. | |
| 242 */ | |
| 243 em_sim_trace_occured = 0; | |
| 244 | |
| 245 PFREE(em_sim_event_req); | |
| 246 } | |
| 247 #endif /* FF_EM_MODE */ | |
| 248 | |
| 249 | |
| 250 #endif /* SIM_EM_C */ |
