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