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