comparison gsm-fw/g23m-gsm/sim/sim_em.c @ 673:2f7df7a314f8

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