FreeCalypso > hg > fc-magnetite
comparison src/g23m-aci/aci/psa_mmp.c @ 162:53929b40109c
src/g23m-aci: initial import from TCS3.2/LoCosto
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 11 Oct 2016 02:02:43 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
161:4557e2a9c18e | 162:53929b40109c |
---|---|
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 void psa_mmr_reg_cnf ( T_MMR_REG_CNF *mmr_reg_cnf ) | |
84 { | |
85 | |
86 TRACE_FUNCTION ("psa_mmr_reg_cnf()"); | |
87 | |
88 | |
89 /* Reg Cnf will be sent when RR starts the power scanning | |
90 and hence ignore it */ | |
91 if (mmr_reg_cnf->bootup_cause EQ PWR_SCAN_START) | |
92 { | |
93 TRACE_EVENT("Dummy cnf from the lower layer"); | |
94 PFREE (mmr_reg_cnf); | |
95 return; | |
96 } | |
97 | |
98 /* | |
99 *------------------------------------------------------------------- | |
100 * update shared parameter and notify ACI | |
101 *------------------------------------------------------------------- | |
102 */ | |
103 mmShrdPrm.usedPLMN = mmr_reg_cnf -> plmn; | |
104 mmShrdPrm.regStat = RS_FULL_SRV; | |
105 mmShrdPrm.lac = mmr_reg_cnf->lac; | |
106 mmShrdPrm.cid = mmr_reg_cnf->cid; | |
107 | |
108 causeMod = P_CEER_mod; /* Clear module which was set for ceer */ | |
109 causeCeer = CEER_NotPresent; /* Reset extended error cause */ | |
110 | |
111 TRACE_EVENT_P2("MMR_REG_CNF received: LAC: %04X, CID: %04X", mmShrdPrm.lac, mmShrdPrm.cid); | |
112 | |
113 psaCC_send_satevent( EVENT_LOC_STATUS, -1, NEAR_END, FALSE ); | |
114 | |
115 /* Check whether any read request has been sent to SIM */ | |
116 if(cmhMM_OpCheckName()) /*EONS: retrieves network name from SIM if needed.*/ | |
117 { | |
118 cmhMM_Registered (); | |
119 } | |
120 | |
121 /* free the primitive buffer */ | |
122 PFREE (mmr_reg_cnf); | |
123 } | |
124 | |
125 /* | |
126 +-------------------------------------------------------------------+ | |
127 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
128 | ROUTINE : psa_mmr_nreg_cnf | | |
129 +-------------------------------------------------------------------+ | |
130 | |
131 PURPOSE : processes the MMR_NREG_CNF primitive send by MM. | |
132 this confirms a successful network deregistration. | |
133 | |
134 */ | |
135 | |
136 GLOBAL void psa_mmr_nreg_cnf ( T_MMR_NREG_CNF *mmr_nreg_cnf ) | |
137 { | |
138 | |
139 TRACE_FUNCTION ("psa_mmr_nreg_cnf()"); | |
140 | |
141 /* | |
142 *------------------------------------------------------------------- | |
143 * update shared parameter and notify ACI | |
144 *------------------------------------------------------------------- | |
145 */ | |
146 mmShrdPrm.deregCs = mmr_nreg_cnf -> detach_cause; | |
147 | |
148 if( mmShrdPrm.deregCs EQ CS_SIM_REM ) | |
149 mmShrdPrm.regStat = RS_LMTD_SRV; | |
150 else | |
151 mmShrdPrm.regStat = RS_NO_SRV; | |
152 | |
153 mmShrdPrm.usedPLMN.v_plmn = INVLD_PLMN; | |
154 | |
155 psaCC_send_satevent( EVENT_LOC_STATUS, -1, NEAR_END, FALSE ); | |
156 | |
157 cmhMM_Deregistered (); | |
158 | |
159 /* | |
160 *------------------------------------------------------------------- | |
161 * free the primitive buffer | |
162 *------------------------------------------------------------------- | |
163 */ | |
164 PFREE(mmr_nreg_cnf); | |
165 | |
166 } | |
167 | |
168 /* | |
169 +-------------------------------------------------------------------+ | |
170 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
171 | ROUTINE : psa_mmr_nreg_ind | | |
172 +-------------------------------------------------------------------+ | |
173 | |
174 PURPOSE : processes the MMR_NREG_IND primitive send by MM. | |
175 this indicates the loss of network registration by | |
176 passing the cause. | |
177 | |
178 */ | |
179 | |
180 GLOBAL void psa_mmr_nreg_ind ( T_MMR_NREG_IND *mmr_nreg_ind ) | |
181 { | |
182 | |
183 TRACE_FUNCTION ("psa_mmr_nreg_ind()"); | |
184 | |
185 /* | |
186 *------------------------------------------------------------------- | |
187 * update shared parameter and notify ACI | |
188 *------------------------------------------------------------------- | |
189 */ | |
190 mmShrdPrm.deregCs = mmr_nreg_ind -> service; | |
191 causeMod = P_CEER_mm; /* Set module for extended error */ | |
192 causeCeer = mmr_nreg_ind -> cause; /* Set extended error cause */ | |
193 | |
194 #ifdef FF_EM_MODE | |
195 em_relcs = mmr_nreg_ind -> service; | |
196 #endif /* FF_EM_MODE */ | |
197 | |
198 switch( mmr_nreg_ind -> service ) | |
199 { | |
200 case( NREG_LIMITED_SERVICE ): | |
201 mmShrdPrm.regStat = RS_LMTD_SRV; | |
202 mmShrdPrm.usedPLMN.v_plmn = INVLD_PLMN; | |
203 break; | |
204 case( NREG_NO_SERVICE ): | |
205 mmShrdPrm.regStat = RS_NO_SRV; | |
206 mmShrdPrm.usedPLMN.v_plmn = INVLD_PLMN; | |
207 break; | |
208 default: | |
209 | |
210 #ifndef GPRS | |
211 TRACE_EVENT_P1 ("UNEXP NREG SERVICE = %4x", mmr_nreg_ind -> service); | |
212 #endif /* GPRS */ | |
213 | |
214 mmShrdPrm.regStat = RS_NO_SRV; | |
215 } | |
216 | |
217 psaCC_send_satevent( EVENT_LOC_STATUS, -1, NEAR_END, FALSE ); | |
218 | |
219 if (!mmr_nreg_ind->search_running) | |
220 cmhMM_Deregistered (); | |
221 | |
222 /* free the primitive buffer */ | |
223 PFREE(mmr_nreg_ind); | |
224 } | |
225 | |
226 /* | |
227 +-------------------------------------------------------------------+ | |
228 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
229 | ROUTINE : psa_mmr_plmn_ind | | |
230 +-------------------------------------------------------------------+ | |
231 | |
232 PURPOSE : processes the MMR_PLMN_IND primitive send by MM. | |
233 this indicates the network search result und a list of | |
234 found plmn's. | |
235 | |
236 */ | |
237 | |
238 GLOBAL void psa_mmr_plmn_ind ( T_MMR_PLMN_IND *mmr_plmn_ind ) | |
239 { | |
240 TRACE_FUNCTION ("psa_mmr_plmn_ind()"); | |
241 | |
242 /* | |
243 *------------------------------------------------------------------- | |
244 * update shared parameter and notify ACI | |
245 *------------------------------------------------------------------- | |
246 */ | |
247 mmShrdPrm.srchRslt = mmr_plmn_ind -> cause; | |
248 | |
249 switch( mmr_plmn_ind -> cause ) | |
250 { | |
251 case MMCS_SUCCESS: | |
252 psaMM_CpyPLMNLst (mmr_plmn_ind -> plmn, mmr_plmn_ind -> forb_ind, mmr_plmn_ind ->lac_list); | |
253 if (psaSIM_ChkSIMSrvSup(SRV_PNN) AND psaSIM_ChkSIMSrvSup(SRV_OPL)) | |
254 cmhMM_OpSetPNNLst(); /*EONS: reads PNN list from SIM, cmhMM_NetworkLst() is called from there!*/ | |
255 else | |
256 cmhMM_NetworkLst(); | |
257 break; | |
258 | |
259 case MMCS_PLMN_NOT_IDLE_MODE: | |
260 case MMCS_SIM_REMOVED: | |
261 cmhMM_SelNetwork (mmr_plmn_ind -> cause); | |
262 break; | |
263 | |
264 default: | |
265 TRACE_EVENT_P1 ("UNEXP NET RSLT = %4x", mmr_plmn_ind -> cause); | |
266 cmhMM_SelNetwork (mmr_plmn_ind -> cause); | |
267 break; | |
268 } | |
269 | |
270 /* | |
271 *------------------------------------------------------------------- | |
272 * free the primitive buffer | |
273 *------------------------------------------------------------------- | |
274 */ | |
275 PFREE(mmr_plmn_ind); | |
276 } | |
277 | |
278 /* | |
279 +-------------------------------------------------------------------+ | |
280 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
281 | ROUTINE : convert_mmr_to_rtc_tz | | |
282 +-------------------------------------------------------------------+ | |
283 | |
284 PURPOSE : convert the time zone received with the MMR_INFO_IND primitive | |
285 into the normal time zone according to the special coding algorithm. | |
286 | |
287 GSM03.40 and search for the TP-Service-Centre-Time Stamp: | |
288 The Time Zone indicates the difference, expressed in quarters | |
289 of an hour, between the local time and GMT. In the first | |
290 of the two semi-octets, the first bit (bit 3 of the seventh | |
291 octet of the TP-Service-Centre-Time-Stamp field) represents the | |
292 algebraic sign of this difference (0 : positive, 1 : negative). | |
293 | |
294 +1:00 hour = +4 quarter hours = 0x04 but Nibble Swap => 0x40 | |
295 +8:00 hours = +32 quarter hours = 0x32 but Nibble Swap => 0x23 | |
296 -2:45 hours = -11 quarter hours = 0x91 but Nibble Swap => 0x19 | |
297 | |
298 */ | |
299 #ifdef FF_TIMEZONE | |
300 LOCAL unsigned int convert_mmr_to_rtc_tz (U8 mmr_timezone) | |
301 { | |
302 unsigned int absolute_value = (10*(mmr_timezone & 0x7))+((mmr_timezone >> 4) & 0xf); | |
303 if ((mmr_timezone & 0x08)) | |
304 { | |
305 absolute_value = ~absolute_value+1; | |
306 } | |
307 return (absolute_value); | |
308 } | |
309 #endif /* FF_TIMEZONE */ | |
310 | |
311 #if defined FF_TIMEZONE AND defined _SIMULATION_ | |
312 /* The below two functions have been added for Simulation as a Stub for NITZ feature */ | |
313 LOCAL T_RV_RET RTC_SetCurrentTZ(T_RTC_TZ currentTimeZone) | |
314 { | |
315 if (currentTimeZone<RTC_GMT_NT_1200 OR currentTimeZone>RTC_GMT_PT_1200) | |
316 { | |
317 return RV_INVALID_PARAMETER; | |
318 } | |
319 return RV_OK; | |
320 } | |
321 | |
322 | |
323 LOCAL T_RTC_TZ RTC_GetCurrentTZ(void) | |
324 { | |
325 T_RTC_TZ timezone = +4; /* as per values given in test case */ | |
326 return timezone; | |
327 } | |
328 #endif /* FF_TIMEZONE AND _SIMULATION_ */ | |
329 | |
330 /* | |
331 +-------------------------------------------------------------------+ | |
332 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
333 | ROUTINE : psa_mmr_info_ind | | |
334 +-------------------------------------------------------------------+ | |
335 | |
336 PURPOSE : processes the MMR_INFO_IND primitive send by MM. | |
337 | |
338 */ | |
339 | |
340 GLOBAL void psa_mmr_info_ind ( T_MMR_INFO_IND *mmr_info_ind ) | |
341 { | |
342 T_ACI_CMD_SRC srcId; | |
343 #ifdef FF_TIMEZONE | |
344 T_RTC_TZ rtc_timezone = RTC_TIME_ERROR; | |
345 T_RV_RET rtc_return = RV_INTERNAL_ERR; | |
346 BOOL tz_update = FALSE; | |
347 #endif | |
348 | |
349 TRACE_FUNCTION ("psa_mmr_info_ind()"); | |
350 | |
351 if (mmr_info_ind->ntz.v_tz) | |
352 { | |
353 mmShrdPrm.tz = mmr_info_ind->ntz.tz; | |
354 #ifdef FF_TIMEZONE | |
355 rtc_timezone = (T_RTC_TZ) convert_mmr_to_rtc_tz(mmr_info_ind->ntz.tz); | |
356 #endif | |
357 } | |
358 else | |
359 { | |
360 TRACE_EVENT("psa_mmr_info_ind(): timezone invalid"); | |
361 } | |
362 | |
363 /* Check whether any of the ACI command sources have requested | |
364 to be updated, and update if required. */ | |
365 for ( srcId = CMD_SRC_LCL; srcId < CMD_SRC_MAX; srcId++) | |
366 { | |
367 #ifndef FF_TIMEZONE | |
368 if ((cmhPrm[srcId].mmCmdPrm.CTZRMode EQ CTZR_MODE_ON) AND | |
369 mmr_info_ind->ntz.v_tz) | |
370 { | |
371 R_AT(RAT_CTZV,srcId)(&mmr_info_ind->ntz.tz); | |
372 } | |
373 #else | |
374 /*the following if statement is for time zone reporting*/ | |
375 if ((cmhPrm[srcId].mmCmdPrm.CTZRMode EQ CTZR_MODE_ON) AND | |
376 mmr_info_ind->ntz.v_tz) | |
377 { | |
378 R_AT(RAT_CTZV,srcId)(rtc_timezone); | |
379 } | |
380 /*the following if statement is for time and date reporting*/ | |
381 if ((cmhPrm[srcId].mmCmdPrm.PCTZVMode EQ PCTZV_MODE_ON) AND | |
382 | |
383 mmr_info_ind->time.v_time) | |
384 { | |
385 R_AT(RAT_P_CTZV, srcId)(mmr_info_ind, rtc_timezone); | |
386 } | |
387 /*the following if statements are for network name reporting*/ | |
388 if (cmhPrm[srcId].mmCmdPrm.CNIVMode EQ CNIV_MODE_ON) | |
389 { | |
390 R_AT(RAT_P_CNIV,srcId)(mmr_info_ind); | |
391 } | |
392 if (cmhPrm[srcId].mmCmdPrm.CTZUMode EQ CTZU_MODE_ON) | |
393 { | |
394 tz_update = TRUE; | |
395 } | |
396 #endif /* FF_TINEZONE */ | |
397 } | |
398 | |
399 #ifdef FF_TIMEZONE | |
400 if (tz_update AND mmr_info_ind->ntz.v_tz AND rtc_timezone NEQ RTC_TIME_ERROR) | |
401 { | |
402 rtc_return = RTC_SetCurrentTZ(rtc_timezone); | |
403 if (rtc_return NEQ RV_OK) | |
404 { | |
405 TRACE_ERROR ("RTC setting failed..."); | |
406 } | |
407 else | |
408 { | |
409 if (rtc_timezone EQ RTC_GetCurrentTZ()) | |
410 { | |
411 TRACE_EVENT_P1("psa_mmr_info_ind(): timezone successfully set to %d", rtc_timezone); | |
412 } | |
413 } | |
414 } | |
415 #endif /* FF_TINEZONE */ | |
416 | |
417 /* | |
418 * free the primitive buffer | |
419 */ | |
420 PFREE(mmr_info_ind); | |
421 } | |
422 | |
423 | |
424 /* | |
425 +-------------------------------------------------------------------+ | |
426 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
427 | ROUTINE : psa_mmr_ciphering_ind | | |
428 +-------------------------------------------------------------------+ | |
429 | |
430 PURPOSE : processes the MMR_CIPHERING_IND primitive send by MM. | |
431 */ | |
432 | |
433 GLOBAL void psa_mmr_ciphering_ind | |
434 ( T_MMR_CIPHERING_IND *mmr_ciphering_ind ) | |
435 { | |
436 | |
437 TRACE_FUNCTION ("psa_mmr_ciphering_ind()"); | |
438 | |
439 cmhMM_CipheringInd(mmr_ciphering_ind->ciph); | |
440 | |
441 /* | |
442 *------------------------------------------------------------------- | |
443 * free the primitive buffer | |
444 *------------------------------------------------------------------- | |
445 */ | |
446 PFREE(mmr_ciphering_ind); | |
447 } | |
448 | |
449 /* | |
450 +-------------------------------------------------------------------+ | |
451 | PROJECT : GSM-PS (6147) MODULE : PSA_MMP | | |
452 | ROUTINE : psa_mmr_ahplmn_ind | | |
453 +-------------------------------------------------------------------+ | |
454 | |
455 PURPOSE : processes the MMR_AHPLMN_IND primitive send by MM. | |
456 */ | |
457 GLOBAL void psa_mmr_ahplmn_ind(T_MMR_AHPLMN_IND *mmr_ahplmn_ind) | |
458 { | |
459 | |
460 TRACE_FUNCTION("psa_mmr_ahplmn_ind()"); | |
461 | |
462 mmShrdPrm.ActingHPLMN = mmr_ahplmn_ind->ahplmn; | |
463 | |
464 cmhMM_Registered (); | |
465 | |
466 PFREE(mmr_ahplmn_ind); | |
467 | |
468 } | |
469 | |
470 | |
471 /*==== EOF =========================================================*/ |