comparison gsm-fw/g23m-gsm/cc/cc_srv.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 543f7afdf79c
comparison
equal deleted inserted replaced
672:0dc6f9e8e980 673:2f7df7a314f8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CC_SRV
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 Modul defines the functions for the common
18 | services of the component CC of the mobile station.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef CC_SRV_C
23 #define CC_SRV_C
24
25 #define ENTITY_CC
26 /*==== INCLUDES ===================================================*/
27
28 #include <string.h>
29 #include "typedefs.h"
30 #include "pcm.h"
31 #include "vsi.h"
32 #include "custom.h"
33 #include "gsm.h"
34 #include "message.h"
35 #include "ccdapi.h"
36 #include "prim.h"
37 #include "cus_cc.h"
38 #include "cnf_cc.h"
39 #include "mon_cc.h"
40 #include "pei.h"
41 #include "tok.h"
42 #include "cc.h"
43
44 /*==== EXPORT =====================================================*/
45
46 /*==== PRIVAT =====================================================*/
47
48 /*==== VARIABLES ==================================================*/
49
50 /*==== FUNCTIONS ==================================================*/
51 /*
52 +--------------------------------------------------------------------+
53 | PROJECT : GSM-PS (6147) MODULE : CC_SRV |
54 | STATE : code ROUTINE : srv_convert_ti |
55 +--------------------------------------------------------------------+
56
57 PURPOSE : Converts the transaction identifier to an index in the
58 call data.
59
60 */
61 GLOBAL UBYTE srv_convert_ti (UBYTE ti)
62 {
63 GET_INSTANCE_DATA;
64 UBYTE i;
65
66 TRACE_FUNCTION ("srv_convert_ti()");
67
68 for (i=0;i<MAX_CC_CALLS;i++)
69 if (cc_data->stored_ti_values[i] EQ ti)
70 {
71 cc_data->ti = ti;
72 return i;
73 }
74 return NOT_PRESENT_8BIT;
75 }
76
77 /*
78 +--------------------------------------------------------------------+
79 | PROJECT : GSM-PS (6147) MODULE : CC_SRV |
80 | STATE : code ROUTINE : srv_define_ti |
81 +--------------------------------------------------------------------+
82
83 PURPOSE : Allocates a free entry in the call data.
84
85 */
86
87 GLOBAL UBYTE srv_define_ti (void)
88 {
89 GET_INSTANCE_DATA;
90 UBYTE i;
91
92 TRACE_FUNCTION ("srv_define_ti()");
93
94 for (i=0;i<MAX_CC_CALLS;i++)
95 {
96 if (cc_data->stored_ti_values[i] == NOT_PRESENT_8BIT)
97 {
98 cc_data->stored_ti_values[i] = cc_data->ti;
99 return i;
100 }
101 }
102 return NOT_PRESENT_8BIT;
103 }
104
105 /*
106 +--------------------------------------------------------------------+
107 | PROJECT : GSM-PS (6147) MODULE : CC_SRV |
108 | STATE : code ROUTINE : srv_free_ti |
109 +--------------------------------------------------------------------+
110
111 PURPOSE : Frees an allocated entry in the call data.
112
113 */
114
115 GLOBAL void srv_free_ti (void)
116 {
117 GET_INSTANCE_DATA;
118 UBYTE i;
119 UBYTE connection_available = FALSE;
120
121 TRACE_FUNCTION ("srv_free_ti()");
122
123 for (i=0;i<MAX_CC_CALLS;i++)
124 {
125 if (cc_data->stored_ti_values[i] EQ cc_data->ti)
126 {
127 cc_data->stored_ti_values[i] = NOT_PRESENT_8BIT;
128 }
129 if (cc_data->stored_ti_values[i] NEQ NOT_PRESENT_8BIT)
130 connection_available = TRUE;
131 }
132 if (connection_available EQ FALSE)
133 cc_data->channel_mode = NAS_CHM_SIG_ONLY;
134 }
135
136 /*
137 +--------------------------------------------------------------------+
138 | PROJECT : GSM-PS (6147) MODULE : CC_REL |
139 | STATE : code ROUTINE : srv_free_stored_setup |
140 +--------------------------------------------------------------------+
141
142 PURPOSE : Free a stored SETUP or EMERGENCY SETUP message.
143
144 */
145
146 GLOBAL void srv_free_stored_setup (void)
147 {
148 GET_INSTANCE_DATA;
149 TRACE_FUNCTION ("srv_free_stored_setup()");
150
151 cc_data->setup_reattempt_ti = NOT_PRESENT_8BIT;
152 if (cc_data->stored_setup NEQ NULL)
153 {
154 PFREE (cc_data->stored_setup);
155 cc_data->stored_setup = NULL;
156 }
157 }
158
159 /*
160 +--------------------------------------------------------------------+
161 | PROJECT : GSM-PS (6147) MODULE : CC_SRV |
162 | STATE : code ROUTINE : srv_store_prim |
163 +--------------------------------------------------------------------+
164
165 PURPOSE : stores a primitive.
166
167 */
168
169 GLOBAL void srv_store_prim (T_PRIM * prim)
170 {
171 GET_INSTANCE_DATA;
172 #ifdef OPTION_REF
173 cc_data->stored_prim [cc_data->stored_prim_in++] = prim;
174 #else
175 memcpy (&cc_data->stored_prim [cc_data->stored_prim_in++],
176 prim, sizeof (T_PRIM));
177 #endif
178 if (cc_data->stored_prim_in EQ MAX_STORED_PRIM)
179 cc_data->stored_prim_in = 0;
180
181 cc_data->stored_prim_write++;
182 }
183 /*
184 +--------------------------------------------------------------------+
185 | PROJECT : GSM-PS (6147) MODULE : CC_SRV |
186 | STATE : code ROUTINE : srv_use_stored_prim |
187 +--------------------------------------------------------------------+
188
189 PURPOSE : Uses all stored primitives.
190
191 */
192
193 GLOBAL void srv_use_stored_prim (void)
194 {
195 GET_INSTANCE_DATA;
196
197 TRACE_FUNCTION ("srv_use_stored_prim()");
198
199 if (cc_data->stored_prim_write > 0)
200 {
201 cc_data->stored_prim_read +=
202 cc_data->stored_prim_write;
203 cc_data->stored_prim_write = 0;
204 while (cc_data->stored_prim_read NEQ 0)
205 {
206 T_PRIM * prim;
207
208 cc_data->stored_prim_read--;
209 #ifdef OPTION_REF
210 prim = cc_data->stored_prim[cc_data->stored_prim_out++];
211 #else
212 prim = &cc_data->stored_prim[cc_data->stored_prim_out++];
213 #endif
214 if (cc_data->stored_prim_out EQ MAX_STORED_PRIM)
215 cc_data->stored_prim_out = 0;
216 cc_pei_primitive (prim);
217 }
218 }
219 }
220
221 #endif
222