FreeCalypso > hg > leo2moko-debug
comparison g23m/condat/ms/src/aci/psa_mmp.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS (6147) | |
4 | Modul : PSA_MM | |
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 processing functions for the | |
18 | primitives send to the protocol stack adapter by the | |
19 | registrations part of mobility management. | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifndef PSA_MMP_C | |
24 #define PSA_MMP_C | |
25 #endif | |
26 | |
27 #include "aci_all.h" | |
28 | |
29 /*==== INCLUDES ===================================================*/ | |
30 #include "aci_cmh.h" | |
31 #include "ati_cmd.h" | |
32 #include "aci_cmd.h" | |
33 #ifdef FAX_AND_DATA | |
34 #include "aci_fd.h" | |
35 #endif /* of #ifdef FAX_AND_DATA */ | |
36 | |
37 #include "aci.h" | |
38 #include "psa.h" | |
39 #include "psa_mm.h" | |
40 #include "cmh.h" | |
41 #include "cmh_mm.h" | |
42 | |
43 #include "psa_cc.h" | |
44 #include "psa_sim.h" | |
45 | |
46 #ifdef FF_TIMEZONE | |
47 #include "rv/rv_general.h" | |
48 #include "rtc/rtc_tz.h" | |
49 #endif | |
50 | |
51 /*==== CONSTANTS ==================================================*/ | |
52 | |
53 | |
54 /*==== TYPES ======================================================*/ | |
55 | |
56 | |
57 /*==== EXPORT =====================================================*/ | |
58 | |
59 #ifdef FF_EM_MODE | |
60 EXTERN SHORT em_relcs; | |
61 #endif /* FF_EM_MODE | |
62 | |
63 /*==== VARIABLES ==================================================*/ | |
64 | |
65 EXTERN T_PCEER causeMod; | |
66 EXTERN SHORT causeCeer; | |
67 | |
68 /*==== FUNCTIONS ==================================================*/ | |
69 | |
70 | |
71 /* | |
72 +-------------------------------------------------------------------+ | |
73 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
74 | ROUTINE : psa_mmr_reg_cnf | | |
75 +-------------------------------------------------------------------+ | |
76 | |
77 PURPOSE : processes the MMR_REG_CNF primitive send by MM. | |
78 this confirms a successful network registration by | |
79 passing the selected network description. | |
80 | |
81 */ | |
82 | |
83 GLOBAL const void psa_mmr_reg_cnf ( T_MMR_REG_CNF *mmr_reg_cnf ) | |
84 { | |
85 | |
86 TRACE_FUNCTION ("psa_mmr_reg_cnf()"); | |
87 | |
88 /* | |
89 *------------------------------------------------------------------- | |
90 * update shared parameter and notify ACI | |
91 *------------------------------------------------------------------- | |
92 */ | |
93 mmShrdPrm.usedPLMN = mmr_reg_cnf -> plmn; | |
94 mmShrdPrm.regStat = RS_FULL_SRV; | |
95 mmShrdPrm.lac = mmr_reg_cnf->lac; | |
96 mmShrdPrm.cid = mmr_reg_cnf->cid; | |
97 | |
98 causeMod = P_CEER_mod; /* Clear module which was set for ceer */ | |
99 causeCeer = CEER_NotPresent; /* Reset extended error cause */ | |
100 | |
101 TRACE_EVENT_P2("MMR_REG_CNF received: LAC: %04X, CID: %04X", mmShrdPrm.lac, mmShrdPrm.cid); | |
102 | |
103 psaCC_send_satevent( EVENT_LOC_STATUS, -1, NEAR_END, FALSE ); | |
104 | |
105 cmhMM_OpCheckName(); /*EONS: retrieves network name from SIM if needed.*/ | |
106 | |
107 cmhMM_Registered (); | |
108 | |
109 /* free the primitive buffer */ | |
110 PFREE (mmr_reg_cnf); | |
111 } | |
112 | |
113 /* | |
114 +-------------------------------------------------------------------+ | |
115 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
116 | ROUTINE : psa_mmr_nreg_cnf | | |
117 +-------------------------------------------------------------------+ | |
118 | |
119 PURPOSE : processes the MMR_NREG_CNF primitive send by MM. | |
120 this confirms a successful network deregistration. | |
121 | |
122 */ | |
123 | |
124 GLOBAL const void psa_mmr_nreg_cnf ( T_MMR_NREG_CNF *mmr_nreg_cnf ) | |
125 { | |
126 | |
127 TRACE_FUNCTION ("psa_mmr_nreg_cnf()"); | |
128 | |
129 /* | |
130 *------------------------------------------------------------------- | |
131 * update shared parameter and notify ACI | |
132 *------------------------------------------------------------------- | |
133 */ | |
134 mmShrdPrm.deregCs = mmr_nreg_cnf -> detach_cause; | |
135 | |
136 if( mmShrdPrm.deregCs EQ CS_SIM_REM ) | |
137 mmShrdPrm.regStat = RS_LMTD_SRV; | |
138 else | |
139 mmShrdPrm.regStat = RS_NO_SRV; | |
140 | |
141 mmShrdPrm.usedPLMN.v_plmn = INVLD_PLMN; | |
142 | |
143 psaCC_send_satevent( EVENT_LOC_STATUS, -1, NEAR_END, FALSE ); | |
144 | |
145 cmhMM_Deregistered (); | |
146 | |
147 /* | |
148 *------------------------------------------------------------------- | |
149 * free the primitive buffer | |
150 *------------------------------------------------------------------- | |
151 */ | |
152 PFREE(mmr_nreg_cnf); | |
153 | |
154 } | |
155 | |
156 /* | |
157 +-------------------------------------------------------------------+ | |
158 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
159 | ROUTINE : psa_mmr_nreg_ind | | |
160 +-------------------------------------------------------------------+ | |
161 | |
162 PURPOSE : processes the MMR_NREG_IND primitive send by MM. | |
163 this indicates the loss of network registration by | |
164 passing the cause. | |
165 | |
166 */ | |
167 | |
168 GLOBAL const void psa_mmr_nreg_ind ( T_MMR_NREG_IND *mmr_nreg_ind ) | |
169 { | |
170 | |
171 TRACE_FUNCTION ("psa_mmr_nreg_ind()"); | |
172 | |
173 /* | |
174 *------------------------------------------------------------------- | |
175 * update shared parameter and notify ACI | |
176 *------------------------------------------------------------------- | |
177 */ | |
178 mmShrdPrm.deregCs = mmr_nreg_ind -> service; | |
179 causeMod = P_CEER_mm; /* Set module for extended error */ | |
180 causeCeer = mmr_nreg_ind -> cause; /* Set extended error cause */ | |
181 | |
182 #ifdef FF_EM_MODE | |
183 em_relcs = mmr_nreg_ind -> service; | |
184 #endif /* FF_EM_MODE */ | |
185 | |
186 switch( mmr_nreg_ind -> service ) | |
187 { | |
188 case( NREG_LIMITED_SERVICE ): | |
189 mmShrdPrm.regStat = RS_LMTD_SRV; | |
190 mmShrdPrm.usedPLMN.v_plmn = INVLD_PLMN; | |
191 break; | |
192 case( NREG_NO_SERVICE ): | |
193 mmShrdPrm.regStat = RS_NO_SRV; | |
194 mmShrdPrm.usedPLMN.v_plmn = INVLD_PLMN; | |
195 break; | |
196 default: | |
197 | |
198 #ifndef GPRS | |
199 TRACE_EVENT_P1 ("UNEXP NREG SERVICE = %4x", mmr_nreg_ind -> service); | |
200 #endif /* GPRS */ | |
201 | |
202 mmShrdPrm.regStat = RS_NO_SRV; | |
203 } | |
204 | |
205 psaCC_send_satevent( EVENT_LOC_STATUS, -1, NEAR_END, FALSE ); | |
206 | |
207 if (!mmr_nreg_ind->search_running) | |
208 cmhMM_Deregistered (); | |
209 | |
210 /* free the primitive buffer */ | |
211 PFREE(mmr_nreg_ind); | |
212 } | |
213 | |
214 /* | |
215 +-------------------------------------------------------------------+ | |
216 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
217 | ROUTINE : psa_mmr_plmn_ind | | |
218 +-------------------------------------------------------------------+ | |
219 | |
220 PURPOSE : processes the MMR_PLMN_IND primitive send by MM. | |
221 this indicates the network search result und a list of | |
222 found plmn's. | |
223 | |
224 */ | |
225 | |
226 GLOBAL const void psa_mmr_plmn_ind ( T_MMR_PLMN_IND *mmr_plmn_ind ) | |
227 { | |
228 TRACE_FUNCTION ("psa_mmr_plmn_ind()"); | |
229 | |
230 /* | |
231 *------------------------------------------------------------------- | |
232 * update shared parameter and notify ACI | |
233 *------------------------------------------------------------------- | |
234 */ | |
235 mmShrdPrm.srchRslt = mmr_plmn_ind -> cause; | |
236 | |
237 switch( mmr_plmn_ind -> cause ) | |
238 { | |
239 case MMCS_SUCCESS: | |
240 psaMM_CpyPLMNLst (mmr_plmn_ind -> plmn, mmr_plmn_ind -> forb_ind, mmr_plmn_ind ->lac_list); | |
241 if (psaSIM_ChkSIMSrvSup(SRV_PNN) && psaSIM_ChkSIMSrvSup(SRV_OPL)) | |
242 cmhMM_OpSetPNNLst(); /*EONS: reads PNN list from SIM, cmhMM_NetworkLst() is called from there!*/ | |
243 else | |
244 cmhMM_NetworkLst(); | |
245 break; | |
246 | |
247 case MMCS_PLMN_NOT_IDLE_MODE: | |
248 case MMCS_SIM_REMOVED: | |
249 cmhMM_SelNetwork (); | |
250 break; | |
251 | |
252 default: | |
253 TRACE_EVENT_P1 ("UNEXP NET RSLT = %4x", mmr_plmn_ind -> cause); | |
254 cmhMM_SelNetwork (); | |
255 break; | |
256 } | |
257 | |
258 /* | |
259 *------------------------------------------------------------------- | |
260 * free the primitive buffer | |
261 *------------------------------------------------------------------- | |
262 */ | |
263 PFREE(mmr_plmn_ind); | |
264 } | |
265 | |
266 /* | |
267 +-------------------------------------------------------------------+ | |
268 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
269 | ROUTINE : convert_mmr_to_rtc_tz | | |
270 +-------------------------------------------------------------------+ | |
271 | |
272 PURPOSE : convert the time zone received with the MMR_INFO_IND primitive | |
273 into the normal time zone according to the special coding algorithm. | |
274 | |
275 GSM03.40 and search for the TP-Service-Centre-Time Stamp: | |
276 The Time Zone indicates the difference, expressed in quarters | |
277 of an hour, between the local time and GMT. In the first | |
278 of the two semi-octets, the first bit (bit 3 of the seventh | |
279 octet of the TP-Service-Centre-Time-Stamp field) represents the | |
280 algebraic sign of this difference (0 : positive, 1 : negative). | |
281 | |
282 +1:00 hour = +4 quarter hours = 0x04 but Nibble Swap => 0x40 | |
283 +8:00 hours = +32 quarter hours = 0x32 but Nibble Swap => 0x23 | |
284 -2:45 hours = -11 quarter hours = 0x91 but Nibble Swap => 0x19 | |
285 | |
286 */ | |
287 LOCAL unsigned int convert_mmr_to_rtc_tz (U8 mmr_timezone) | |
288 { | |
289 unsigned int absolute_value = (10*(mmr_timezone & 0x7))+((mmr_timezone >> 4) & 0xf); | |
290 if ((mmr_timezone & 0x08)) | |
291 { | |
292 absolute_value = ~absolute_value+1; | |
293 } | |
294 return (absolute_value); | |
295 } | |
296 | |
297 /* | |
298 +-------------------------------------------------------------------+ | |
299 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
300 | ROUTINE : psa_mmr_info_ind | | |
301 +-------------------------------------------------------------------+ | |
302 | |
303 PURPOSE : processes the MMR_INFO_IND primitive send by MM. | |
304 | |
305 */ | |
306 | |
307 GLOBAL const void psa_mmr_info_ind ( T_MMR_INFO_IND *mmr_info_ind ) | |
308 { | |
309 T_ACI_CMD_SRC srcId; | |
310 #ifdef FF_TIMEZONE | |
311 T_RTC_TZ rtc_timezone = RTC_TIME_ERROR; | |
312 T_RV_RET rtc_return = RV_INTERNAL_ERR; | |
313 BOOL tz_update = FALSE; | |
314 #endif | |
315 | |
316 TRACE_FUNCTION ("psa_mmr_info_ind()"); | |
317 | |
318 if (mmr_info_ind->ntz.v_tz) | |
319 { | |
320 mmShrdPrm.tz = mmr_info_ind->ntz.tz; | |
321 #ifdef FF_TIMEZONE | |
322 rtc_timezone = (T_RTC_TZ) convert_mmr_to_rtc_tz(mmr_info_ind->ntz.tz); | |
323 #endif | |
324 } | |
325 else | |
326 { | |
327 TRACE_EVENT("psa_mmr_info_ind(): timezone invalid"); | |
328 } | |
329 | |
330 /* Check whether any of the ACI command sources have requested | |
331 to be updated, and update if required. */ | |
332 for ( srcId = CMD_SRC_LCL; srcId < CMD_SRC_MAX; srcId++) | |
333 { | |
334 #ifndef FF_TIMEZONE | |
335 if ((cmhPrm[srcId].mmCmdPrm.CTZRMode EQ CTZR_MODE_ON) AND | |
336 mmr_info_ind->ntz.v_tz) | |
337 { | |
338 R_AT(RAT_CTZV,srcId)(&mmr_info_ind->ntz.tz); | |
339 } | |
340 #else | |
341 /*the following if statement is for time zone reporting*/ | |
342 if ((cmhPrm[srcId].mmCmdPrm.CTZRMode EQ CTZR_MODE_ON) AND | |
343 mmr_info_ind->ntz.v_tz) | |
344 { | |
345 R_AT(RAT_CTZV,srcId)(rtc_timezone); | |
346 } | |
347 /*the following if statement is for time and date reporting*/ | |
348 if ((cmhPrm[srcId].mmCmdPrm.PCTZVMode EQ PCTZV_MODE_ON) AND | |
349 | |
350 mmr_info_ind->time.v_time) | |
351 { | |
352 R_AT(RAT_P_CTZV, srcId)(mmr_info_ind, rtc_timezone); | |
353 } | |
354 /*the following if statements are for network name reporting*/ | |
355 if (cmhPrm[srcId].mmCmdPrm.CNIVMode EQ CNIV_MODE_ON) | |
356 { | |
357 R_AT(RAT_P_CNIV,srcId)(mmr_info_ind); | |
358 } | |
359 if (cmhPrm[srcId].mmCmdPrm.CTZUMode EQ CTZU_MODE_ON) | |
360 { | |
361 tz_update = TRUE; | |
362 } | |
363 #endif /* FF_TINEZONE */ | |
364 } | |
365 | |
366 #ifdef FF_TIMEZONE | |
367 if (tz_update AND mmr_info_ind->ntz.v_tz AND rtc_timezone NEQ RTC_TIME_ERROR) | |
368 { | |
369 rtc_return = RTC_SetCurrentTZ(rtc_timezone); | |
370 if (rtc_return NEQ RV_OK) | |
371 { | |
372 TRACE_ERROR ("RTC setting failed..."); | |
373 } | |
374 else | |
375 { | |
376 if (rtc_timezone == RTC_GetCurrentTZ()) | |
377 { | |
378 TRACE_EVENT_P1("psa_mmr_info_ind(): timezone successfully set to %d", rtc_timezone); | |
379 } | |
380 } | |
381 } | |
382 #endif /* FF_TINEZONE */ | |
383 | |
384 /* | |
385 * free the primitive buffer | |
386 */ | |
387 PFREE(mmr_info_ind); | |
388 } | |
389 | |
390 | |
391 /* | |
392 +-------------------------------------------------------------------+ | |
393 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
394 | ROUTINE : psa_mmr_ciphering_ind | | |
395 +-------------------------------------------------------------------+ | |
396 | |
397 PURPOSE : processes the MMR_CIPHERING_IND primitive send by MM. | |
398 */ | |
399 | |
400 GLOBAL const void psa_mmr_ciphering_ind | |
401 ( T_MMR_CIPHERING_IND *mmr_ciphering_ind ) | |
402 { | |
403 | |
404 TRACE_FUNCTION ("psa_mmr_ciphering_ind()"); | |
405 | |
406 cmhMM_CipheringInd(mmr_ciphering_ind->ciph); | |
407 | |
408 /* | |
409 *------------------------------------------------------------------- | |
410 * free the primitive buffer | |
411 *------------------------------------------------------------------- | |
412 */ | |
413 PFREE(mmr_ciphering_ind); | |
414 } | |
415 | |
416 /* | |
417 +-------------------------------------------------------------------+ | |
418 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
419 | ROUTINE : psa_mmr_ahplmn_ind | | |
420 +-------------------------------------------------------------------+ | |
421 | |
422 PURPOSE : processes the MMR_AHPLMN_IND primitive send by MM. | |
423 */ | |
424 GLOBAL const void psa_mmr_ahplmn_ind(T_MMR_AHPLMN_IND *mmr_ahplmn_ind) | |
425 { | |
426 | |
427 TRACE_FUNCTION("psa_mmr_ahplmn_ind()"); | |
428 | |
429 mmShrdPrm.ActingHPLMN = mmr_ahplmn_ind->ahplmn; | |
430 | |
431 cmhMM_Registered (); | |
432 | |
433 PFREE(mmr_ahplmn_ind); | |
434 | |
435 } | |
436 | |
437 | |
438 /*==== EOF =========================================================*/ |