comparison src/g23m-aci/bat/bat_kerf.c @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-F&D (8411)
4 | Modul : ACI
5 +-----------------------------------------------------------------------------
6 | Copyright 2005 Texas Instruments Berlin
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Inc.
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 holds the internal functions
18 | for the binary AT command library
19 +-----------------------------------------------------------------------------
20 */
21 #define _BAT_KERF_C_
22
23 /*==== INCLUDES =============================================================*/
24 #include <string.h>
25 #include <stdio.h>
26
27 #include "typedefs.h"
28 #include "gdd.h"
29 #include "gdd_sys.h"
30 #include "l2p_types.h"
31 #include "l2p.h"
32 #include "bat.h"
33 #include "bat_ctrl.h"
34 #include "bat_intern.h"
35
36 /*==== DEFINES ===========================================================*/
37
38 #define GET_INST(inst_hndl) ((T_BAT_instance_maintain*)\
39 (*(ptr_bat_list + inst_hndl)))
40
41 #define GET_CLNT(inst_mt,clnt_id) ((T_BAT_client_maintain*)\
42 ((U32)sizeof(T_BAT_client_maintain)*clnt_id + \
43 (U32)inst_mt + (U32)sizeof(T_BAT_instance_maintain)))
44
45 /*==== GLOBAL VARS ===========================================================*/
46
47 GLOBAL U8 max_bat_num = 4; /* start the BAT Lib with maximum 4 instances */
48 GLOBAL T_BAT_instance_maintain **ptr_bat_list = NULL;
49
50 /*==== LOCAL VARS ===========================================================*/
51
52 /* This table will be removed once it is generated by the tool.
53 * As long as SAPE and makcdg does not handle feature flags,
54 * we do not use #ifdef ... #endif in this table
55 */
56
57 typedef struct
58 {
59 size_t size;
60 } T_map_params_2_size;
61
62 static T_map_params_2_size params_2_size[] =
63 {
64 {/* BAT_CMD_SET_PERCENT_ALS = 0x0, */ sizeof(T_BAT_cmd_set_percent_als)},
65 {/* BAT_CMD_SET_PERCENT_BAND = 0x1, */ sizeof(T_BAT_cmd_set_percent_band)},
66 {/* BAT_CMD_ANDC = 0x2, */ sizeof(T_BAT_cmd_andc)},
67 {/* BAT_CMD_SET_PLUS_CACM = 0x3, */ sizeof(T_BAT_cmd_set_plus_cacm)},
68 {/* BAT_CMD_SET_PLUS_CAMM = 0x4, */ sizeof(T_BAT_cmd_set_plus_camm)},
69 {/* BAT_CMD_SET_PLUS_CAOC = 0x5, */ sizeof(T_BAT_cmd_set_plus_caoc)},
70 {/* BAT_CMD_SET_PERCENT_CBHZ = 0x6, */ sizeof(T_BAT_cmd_set_percent_cbhz)},
71 {/* BAT_CMD_SET_PLUS_CBST = 0x7, */ sizeof(T_BAT_cmd_set_plus_cbst)},
72 {/* BAT_CMD_SET_PERCENT_CCBS = 0x8, */ sizeof(T_BAT_cmd_set_percent_ccbs)},
73 {/* BAT_CMD_SET_PLUS_CCFC = 0x9, */ sizeof(T_BAT_cmd_set_plus_ccfc)},
74 {/* BAT_CMD_SET_PLUS_CCLK = 0xa, */ sizeof(T_BAT_cmd_set_plus_cclk)},
75 {/* BAT_CMD_SET_PLUS_CCUG = 0xb, */ sizeof(T_BAT_cmd_set_plus_ccug)},
76 {/* BAT_CMD_SET_PLUS_CCWA = 0xc, */ sizeof(T_BAT_cmd_set_plus_ccwa)},
77 {/* BAT_CMD_SET_PLUS_CCWA_W = 0xd, */ sizeof(T_BAT_cmd_set_plus_ccwa_w)},
78 {/* BAT_CMD_SET_PLUS_CFUN = 0xe, */ sizeof(T_BAT_cmd_set_plus_cfun)},
79 {/* BAT_CMD_SET_PERCENT_CGAATT = 0xf, */ sizeof(T_BAT_cmd_set_percent_cgaatt)},
80 {/* BAT_CMD_SET_PLUS_CGACT = 0x10 */ sizeof(T_BAT_cmd_set_plus_cgact)},
81 {/* BAT_CMD_SET_PLUS_CGANS = 0x11 */ sizeof(T_BAT_cmd_set_plus_cgans)},
82 {/* BAT_CMD_SET_PLUS_CGATT = 0x12 */ sizeof(T_BAT_cmd_set_plus_cgatt)},
83 {/* BAT_CMD_SET_PERCENT_CGCLASS = 0x13 */ sizeof(T_BAT_cmd_set_percent_cgclass)},
84 {/* BAT_CMD_SET_PLUS_CGCLASS = 0x14 */ sizeof(T_BAT_cmd_set_plus_cgclass)},
85 {/* BAT_CMD_SET_PLUS_CGDATA = 0x15 */ sizeof(T_BAT_cmd_set_plus_cgdata)},
86 {/* BAT_CMD_SET_PLUS_CGDCONT = 0x16 */ sizeof(T_BAT_cmd_set_plus_cgdcont)},
87 {/* BAT_CMD_SET_PERCENT_CGMM = 0x17 */ sizeof(T_BAT_cmd_set_percent_cgmm)},
88 {/* BAT_CMD_SET_PLUS_CGPADDR = 0x18 */ sizeof(T_BAT_cmd_set_plus_cgpaddr)},
89 {/* BAT_CMD_SET_PERCENT_CGPCO = 0x19 */ sizeof(T_BAT_cmd_set_percent_cgpco)},
90 {/* BAT_CMD_SET_PERCENT_CGPPP = 0x1a */ sizeof(T_BAT_cmd_set_percent_cgppp)},
91 {/* BAT_CMD_SET_PLUS_CGQMIN = 0x1b */ sizeof(T_BAT_cmd_set_plus_cgqmin)},
92 {/* BAT_CMD_SET_PLUS_CGQREQ = 0x1c */ sizeof(T_BAT_cmd_set_plus_cgqreq)},
93 {/* BAT_CMD_SET_PLUS_CGSMS = 0x1d */ sizeof(T_BAT_cmd_set_plus_cgsms)},
94 {/* BAT_CMD_SET_PERCENT_CHLD = 0x1e */ sizeof(T_BAT_cmd_set_percent_chld)},
95 {/* BAT_CMD_SET_PERCENT_CHPL = 0x1f */ sizeof(T_BAT_cmd_set_percent_chpl)},
96 {/* BAT_CMD_SET_PERCENT_CHPL_W = 0x20 */ sizeof(T_BAT_cmd_set_percent_chpl_w)},
97 {/* BAT_CMD_SET_PLUS_CIND = 0x21 */ sizeof(T_BAT_cmd_set_plus_cind)},
98 {/* BAT_CMD_SET_PLUS_CLAN = 0x22 */ sizeof(T_BAT_cmd_set_plus_clan)},
99 {/* BAT_CMD_SET_PLUS_CLCK = 0x23 */ sizeof(T_BAT_cmd_set_plus_clck)},
100 {/* BAT_CMD_SET_PLUS_CLIR = 0x24 */ sizeof(T_BAT_cmd_set_plus_clir)},
101 {/* BAT_CMD_SET_PLUS_CLVL = 0x25 */ sizeof(T_BAT_cmd_set_plus_clvl)},
102 {/* BAT_CMD_SET_PLUS_CMER = 0x26 */ sizeof(T_BAT_cmd_set_plus_cmer)},
103 {/* BAT_CMD_SET_PLUS_CMGC = 0x27 */ sizeof(T_BAT_cmd_set_plus_cmgc)},
104 {/* BAT_CMD_SET_PLUS_CMGD = 0x28 */ sizeof(T_BAT_cmd_set_plus_cmgd)},
105 {/* BAT_CMD_SET_PLUS_CMGL = 0x29 */ sizeof(T_BAT_cmd_set_plus_cmgl)},
106 {/* BAT_CMD_SET_PLUS_CMGL_W = 0x2a */ sizeof(T_BAT_cmd_set_plus_cmgl_w)},
107 {/* BAT_CMD_SET_PLUS_CMGR = 0x2b */ sizeof(T_BAT_cmd_set_plus_cmgr)},
108 {/* BAT_CMD_SET_PLUS_CMGR_W = 0x2c */ sizeof(T_BAT_cmd_set_plus_cmgr_w)},
109 {/* BAT_CMD_SET_PLUS_CMGS = 0x2d */ sizeof(T_BAT_cmd_set_plus_cmgs)},
110 {/* BAT_CMD_SET_PLUS_CMGW = 0x2e */ sizeof(T_BAT_cmd_set_plus_cmgw)},
111 {/* BAT_CMD_SET_PLUS_CMOD = 0x2f */ sizeof(T_BAT_cmd_set_plus_cmod)},
112 {/* BAT_CMD_SET_PLUS_CMSS = 0x30 */ sizeof(T_BAT_cmd_set_plus_cmss)},
113 {/* BAT_CMD_SET_PLUS_CMUT = 0x31 */ sizeof(T_BAT_cmd_set_plus_cmut)},
114 {/* BAT_CMD_SET_PLUS_CMUX = 0x32 */ sizeof(T_BAT_cmd_set_plus_cmux)},
115 {/* BAT_CMD_SET_PLUS_CNMA = 0x33 */ sizeof(T_BAT_cmd_set_plus_cnma)},
116 {/* BAT_CMD_SET_PLUS_CNMI = 0x34 */ sizeof(T_BAT_cmd_set_plus_cnmi)},
117 {/* BAT_CMD_SET_PERCENT_COPS = 0x35 */ sizeof(T_BAT_cmd_set_percent_cops)},
118 {/* BAT_CMD_SET_PLUS_COPS = 0x36 */ sizeof(T_BAT_cmd_set_plus_cops)},
119 {/* BAT_CMD_SET_PERCENT_COPS_W = 0x37 */ sizeof(T_BAT_cmd_set_percent_cops_w)},
120 {/* BAT_CMD_SET_PERCENT_CPALS = 0x38 */ sizeof(T_BAT_cmd_set_percent_cpals)},
121 {/* BAT_CMD_SET_PERCENT_CPALS_W = 0x39 */ sizeof(T_BAT_cmd_set_percent_cpals_w)},
122 {/* BAT_CMD_SET_PLUS_CPBF = 0x3a */ sizeof(T_BAT_cmd_set_plus_cpbf)},
123 {/* BAT_CMD_SET_PLUS_CPBF_W = 0x3b */ sizeof(T_BAT_cmd_set_plus_cpbf_w)},
124 {/* BAT_CMD_SET_PLUS_CPBR = 0x3c */ sizeof(T_BAT_cmd_set_plus_cpbr)},
125 {/* BAT_CMD_SET_PLUS_CPBR_W = 0x3d */ sizeof(T_BAT_cmd_set_plus_cpbr_w)},
126 {/* BAT_CMD_SET_PLUS_CPBS = 0x3e */ sizeof(T_BAT_cmd_set_plus_cpbs)},
127 {/* BAT_CMD_SET_PLUS_CPBW = 0x3f */ sizeof(T_BAT_cmd_set_plus_cpbw)},
128 {/* BAT_CMD_SET_PLUS_CPBW_W = 0x40 */ sizeof(T_BAT_cmd_set_plus_cpbw_w)},
129 {/* BAT_CMD_SET_PERCENT_CPCFU = 0x41 */ sizeof(T_BAT_cmd_set_percent_cpcfu)},
130 {/* BAT_CMD_SET_PERCENT_CPHS = 0x42 */ sizeof(T_BAT_cmd_set_percent_cphs)},
131 {/* BAT_CMD_SET_PLUS_CPIN = 0x43 */ sizeof(T_BAT_cmd_set_plus_cpin)},
132 {/* BAT_CMD_SET_PERCENT_CPMB = 0x44 */ sizeof(T_BAT_cmd_set_percent_cpmb)},
133 {/* BAT_CMD_SET_PERCENT_CPMBW = 0x45 */ sizeof(T_BAT_cmd_set_percent_cpmbw)},
134 {/* BAT_CMD_SET_PERCENT_CPMBW_W = 0x46 */ sizeof(T_BAT_cmd_set_percent_cpmbw_w)},
135 {/* BAT_CMD_SET_PERCENT_CPMB_W = 0x47 */ sizeof(T_BAT_cmd_set_percent_cpmb_w)},
136 {/* BAT_CMD_SET_PLUS_CPMS = 0x48 */ sizeof(T_BAT_cmd_set_plus_cpms)},
137 {/* BAT_CMD_SET_PERCENT_CPNUMS = 0x49 */ sizeof(T_BAT_cmd_set_percent_cpnums)},
138 {/* BAT_CMD_SET_PERCENT_CPNUMS_W = 0x4a */ sizeof(T_BAT_cmd_set_percent_cpnums_w)},
139 {/* BAT_CMD_SET_PLUS_CPOL = 0x4b */ sizeof(T_BAT_cmd_set_plus_cpol)},
140 {/* BAT_CMD_SET_PLUS_CPOL_W = 0x4c */ sizeof(T_BAT_cmd_set_plus_cpol_w)},
141 {/* BAT_CMD_SET_PERCENT_CPRSM = 0x4d */ sizeof(T_BAT_cmd_set_percent_cprsm)},
142 {/* BAT_CMD_SET_PLUS_CPUC = 0x4e */ sizeof(T_BAT_cmd_set_plus_cpuc)},
143 {/* BAT_CMD_SET_PLUS_CPUC_W = 0x4f */ sizeof(T_BAT_cmd_set_plus_cpuc_w)},
144 {/* BAT_CMD_SET_PERCENT_CPVWI = 0x50 */ sizeof(T_BAT_cmd_set_percent_cpvwi)},
145 {/* BAT_CMD_SET_PLUS_CPWD = 0x51 */ sizeof(T_BAT_cmd_set_plus_cpwd)},
146 {/* BAT_CMD_SET_PLUS_CRES = 0x52 */ sizeof(T_BAT_cmd_set_plus_cres)},
147 {/* BAT_CMD_SET_PLUS_CRLP = 0x53 */ sizeof(T_BAT_cmd_set_plus_crlp)},
148 {/* BAT_CMD_SET_PLUS_CRSM = 0x54 */ sizeof(T_BAT_cmd_set_plus_crsm)},
149 {/* BAT_CMD_SET_PLUS_CSAS = 0x55 */ sizeof(T_BAT_cmd_set_plus_csas)},
150 {/* BAT_CMD_SET_PLUS_CSCA = 0x56 */ sizeof(T_BAT_cmd_set_plus_csca)},
151 {/* BAT_CMD_SET_PLUS_CSCB = 0x57 */ sizeof(T_BAT_cmd_set_plus_cscb)},
152 {/* BAT_CMD_SET_PLUS_CSCS = 0x58 */ sizeof(T_BAT_cmd_set_plus_cscs)},
153 {/* BAT_CMD_SET_PLUS_CSIM = 0x59 */ sizeof(T_BAT_cmd_set_plus_csim)},
154 {/* BAT_CMD_SET_PLUS_CSMS = 0x5a */ sizeof(T_BAT_cmd_set_plus_csms)},
155 {/* BAT_CMD_SET_PLUS_CSNS = 0x5b */ sizeof(T_BAT_cmd_set_plus_csns)},
156 {/* BAT_CMD_SET_PLUS_CSTA = 0x5c */ sizeof(T_BAT_cmd_set_plus_csta)},
157 {/* BAT_CMD_SET_PLUS_CSVM = 0x5d */ sizeof(T_BAT_cmd_set_plus_csvm)},
158 {/* BAT_CMD_SET_PLUS_CTFR = 0x5e */ sizeof(T_BAT_cmd_set_plus_ctfr)},
159 {/* BAT_CMD_SET_PERCENT_CTTY = 0x5f */ sizeof(T_BAT_cmd_set_percent_ctty)},
160 {/* BAT_CMD_SET_PLUS_CTZU = 0x60 */ sizeof(T_BAT_cmd_set_plus_ctzu)},
161 {/* BAT_CMD_SET_PLUS_CUSD = 0x61 */ sizeof(T_BAT_cmd_set_plus_cusd)},
162 {/* BAT_CMD_SET_PLUS_CUSD_W = 0x62 */ sizeof(T_BAT_cmd_set_plus_cusd_w)},
163 {/* BAT_CMD_SET_PERCENT_CUST = 0x63 */ sizeof(T_BAT_cmd_set_percent_cust)},
164 {/* BAT_CMD_SET_PERCENT_CWUP = 0x64 */ sizeof(T_BAT_cmd_set_percent_cwup)},
165 {/* BAT_CMD_AT_D = 0x65 */ sizeof(T_BAT_cmd_at_d)},
166 {/* BAT_CMD_SET_PERCENT_DATA = 0x66 */ sizeof(T_BAT_cmd_set_percent_data)},
167 {/* BAT_CMD_SET_PERCENT_DINF = 0x67 */ sizeof(T_BAT_cmd_set_percent_dinf)},
168 {/* BAT_CMD_SET_PLUS_DS = 0x68 */ sizeof(T_BAT_cmd_set_plus_ds)},
169 {/* BAT_CMD_AT_D_W = 0x69 */ sizeof(T_BAT_cmd_at_d_w)},
170 {/* BAT_CMD_SET_PERCENT_EFRSLT = 0x6a */ sizeof(T_BAT_cmd_set_percent_efrslt)},
171 {/* BAT_CMD_SET_PERCENT_EM = 0x6b */ sizeof(T_BAT_cmd_set_percent_em)},
172 {/* BAT_CMD_SET_PLUS_FAP = 0x6c */ sizeof(T_BAT_cmd_set_plus_fap)},
173 {/* BAT_CMD_SET_PLUS_FBO = 0x6d */ sizeof(T_BAT_cmd_set_plus_fbo)},
174 {/* BAT_CMD_SET_PLUS_FBU = 0x6e */ sizeof(T_BAT_cmd_set_plus_fbu)},
175 {/* BAT_CMD_SET_PLUS_FCC = 0x6f */ sizeof(T_BAT_cmd_set_plus_fcc)},
176 {/* BAT_CMD_SET_PLUS_FCLASS = 0x70 */ sizeof(T_BAT_cmd_set_plus_fclass)},
177 {/* BAT_CMD_SET_PLUS_FCQ = 0x71 */ sizeof(T_BAT_cmd_set_plus_fcq)},
178 {/* BAT_CMD_SET_PLUS_FCR = 0x72 */ sizeof(T_BAT_cmd_set_plus_fcr)},
179 {/* BAT_CMD_SET_PLUS_FCT = 0x73 */ sizeof(T_BAT_cmd_set_plus_fct)},
180 {/* BAT_CMD_SET_PLUS_FEA = 0x74 */ sizeof(T_BAT_cmd_set_plus_fea)},
181 {/* BAT_CMD_SET_PLUS_FFC = 0x75 */ sizeof(T_BAT_cmd_set_plus_ffc)},
182 {/* BAT_CMD_SET_PLUS_FIE = 0x76 */ sizeof(T_BAT_cmd_set_plus_fie)},
183 {/* BAT_CMD_SET_PLUS_FIS = 0x77 */ sizeof(T_BAT_cmd_set_plus_fis)},
184 {/* BAT_CMD_SET_PLUS_FIT = 0x78 */ sizeof(T_BAT_cmd_set_plus_fit)},
185 {/* BAT_CMD_SET_PLUS_FLI = 0x79 */ sizeof(T_BAT_cmd_set_plus_fli)},
186 {/* BAT_CMD_SET_PLUS_FLO = 0x7a */ sizeof(T_BAT_cmd_set_plus_flo)},
187 {/* BAT_CMD_SET_PLUS_FLP = 0x7b */ sizeof(T_BAT_cmd_set_plus_flp)},
188 {/* BAT_CMD_SET_PLUS_FMS = 0x7c */ sizeof(T_BAT_cmd_set_plus_fms)},
189 {/* BAT_CMD_SET_PLUS_FNS = 0x7d */ sizeof(T_BAT_cmd_set_plus_fns)},
190 {/* BAT_CMD_SET_PLUS_FPA = 0x7e */ sizeof(T_BAT_cmd_set_plus_fpa)},
191 {/* BAT_CMD_SET_PLUS_FPI = 0x7f */ sizeof(T_BAT_cmd_set_plus_fpi)},
192 {/* BAT_CMD_SET_PLUS_FPS = 0x80 */ sizeof(T_BAT_cmd_set_plus_fps)},
193 {/* BAT_CMD_SET_PLUS_FPW = 0x81 */ sizeof(T_BAT_cmd_set_plus_fpw)},
194 {/* BAT_CMD_SET_PLUS_FRQ = 0x82 */ sizeof(T_BAT_cmd_set_plus_frq)},
195 {/* BAT_CMD_SET_PLUS_FSA = 0x83 */ sizeof(T_BAT_cmd_set_plus_fsa)},
196 {/* BAT_CMD_SET_PLUS_FSP = 0x84 */ sizeof(T_BAT_cmd_set_plus_fsp)},
197 {/* BAT_CMD_SET_PLUS_ICF = 0x85 */ sizeof(T_BAT_cmd_set_plus_icf)},
198 {/* BAT_CMD_SET_PLUS_IFC = 0x86 */ sizeof(T_BAT_cmd_set_plus_ifc)},
199 {/* BAT_CMD_SET_PLUS_IPR = 0x87 */ sizeof(T_BAT_cmd_set_plus_ipr)},
200 {/* BAT_CMD_SET_PERCENT_PBCF = 0x88 */ sizeof(T_BAT_cmd_set_percent_pbcf)},
201 {/* BAT_CMD_SET_PERCENT_PPP = 0x89 */ sizeof(T_BAT_cmd_set_percent_ppp)},
202 {/* BAT_CMD_SET_PERCENT_PVRF = 0x8a */ sizeof(T_BAT_cmd_set_percent_pvrf)},
203 {/* BAT_CMD_SET_PERCENT_RDL = 0x8b */ sizeof(T_BAT_cmd_set_percent_rdl)},
204 {/* BAT_CMD_SET_PERCENT_RDLB = 0x8c */ sizeof(T_BAT_cmd_set_percent_rdlb)},
205 {/* BAT_CMD_SET_PERCENT_SATC = 0x8d */ sizeof(T_BAT_cmd_set_percent_satc)},
206 {/* BAT_CMD_SET_PERCENT_SATCC = 0x8e */ sizeof(T_BAT_cmd_set_percent_satcc)},
207 {/* BAT_CMD_SET_PERCENT_SATE = 0x8f */ sizeof(T_BAT_cmd_set_percent_sate)},
208 {/* BAT_CMD_SET_PERCENT_SATR = 0x90 */ sizeof(T_BAT_cmd_set_percent_satr)},
209 {/* BAT_CMD_SET_PERCENT_SATT = 0x91 */ sizeof(T_BAT_cmd_set_percent_satt)},
210 {/* BAT_CMD_SET_PERCENT_SNCNT = 0x92 */ sizeof(T_BAT_cmd_set_percent_sncnt)},
211 {/* BAT_CMD_SET_PERCENT_VTS = 0x93 */ sizeof(T_BAT_cmd_set_percent_vts)},
212 {/* BAT_CMD_SET_PLUS_VTS = 0x94 */ sizeof(T_BAT_cmd_set_plus_vts)},
213 {/* BAT_CMD_SET_PLUS_WS46 = 0x95 */ sizeof(T_BAT_cmd_set_plus_ws46)},
214 {/* BAT_CMD_SET_PERCENT_CPINF = 0x96 */ sizeof(T_BAT_cmd_set_percent_cpinf)},
215 {/* BAT_CMD_SET_PERCENT_CMGR = 0x97 */ sizeof(T_BAT_cmd_set_percent_cmgr)},
216 {/* BAT_CMD_SET_PERCENT_CMGL = 0x98 */ sizeof(T_BAT_cmd_set_percent_cmgl)},
217 {/* BAT_CMD_SET_PERCENT_CTZV = 0x99 */ sizeof(T_BAT_cmd_set_percent_ctzv)},
218 #ifdef TI_PS_FF_AT_CMD_P_ECC
219 {/* BAT_CMD_SET_PERCENT_ECC = 0x9a */ sizeof(T_BAT_cmd_set_percent_ecc)},
220 #else
221 {/* BAT_CMD_SET_PERCENT_ECC = 0x9a */ 0}, /* In case flag is not enabled */
222 #endif /* TI_PS_FF_AT_CMD_P_ECC */
223
224 #ifdef SIM_PERS
225 { /* BAT_CMD_SET_PERCENT_MEPD = 0x9b */ sizeof(T_BAT_cmd_set_percent_mepd)},
226 #else
227 { /* BAT_CMD_SET_PERCENT_MEPD = 0x9b */ 0}, /* In case flag is not enabled */
228 #endif
229
230 { /* BAT_CMD_SET_PERCENT_CSQ = 0x9c */ sizeof(T_BAT_cmd_set_percent_csq)},
231 {/* BAT_CMD_SET_PERCENT_CNIV = 0x9d */ sizeof(T_BAT_cmd_set_percent_cniv)},
232 #ifdef REL99
233 {/* BAT_CMD_SET_PERCENT_CMGRS = 0x9e */ sizeof(T_BAT_cmd_set_percent_cmgrs)},
234 #endif
235 {/* BAT_CMD_SET_PERCENT_SIMEF = 0xa7 */ sizeof(T_BAT_cmd_set_percent_simef)}
236
237 };
238
239 /*
240 +----------------------------------------------------------------------------+
241 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
242 | STATE : code ROUTINE : bat_change_client_state |
243 +----------------------------------------------------------------------------+
244
245 PURPOSE :
246 This function changes the client state and traces the state change.
247 */
248
249 GLOBAL void bat_change_client_state (T_BAT_client_maintain *client,
250 T_BAT_client_state new_state)
251 {
252 char trcBuf[80];
253 T_BAT_client_state old_state = client->client_state;
254 client->client_state = new_state;
255
256 if (old_state EQ new_state)
257 {
258 return;
259 }
260
261 sprintf (trcBuf, "(client 0x%04X) state: ", (int)client);
262
263 switch (old_state)
264 {
265 case (BAT_CLIENT_IDLE):
266 strcat (trcBuf, "BAT_CLIENT_IDLE -> ");
267 break;
268 case (BAT_CLIENT_ACTIVATING):
269 strcat (trcBuf, "BAT_CLIENT_ACTIVATING -> ");
270 break;
271 case (BAT_CLIENT_READY):
272 strcat (trcBuf, "BAT_CLIENT_READY -> ");
273 break;
274 case (BAT_CLIENT_BUSY):
275 strcat (trcBuf, "BAT_CLIENT_BUSY -> ");
276 break;
277 case (BAT_CLIENT_SENDING):
278 strcat (trcBuf, "BAT_CLIENT_SENDING -> ");
279 break;
280 case (BAT_CLIENT_SENDING_AND_BUSY):
281 strcat (trcBuf, "BAT_CLIENT_SENDING_AND_BUSY -> ");
282 break;
283 default:
284 strcat (trcBuf, "UNKNOWN ! ");
285 }
286
287 switch (new_state)
288 {
289 case (BAT_CLIENT_IDLE):
290 strcat (trcBuf, "BAT_CLIENT_IDLE");
291 break;
292 case (BAT_CLIENT_ACTIVATING):
293 strcat (trcBuf, "BAT_CLIENT_ACTIVATING");
294 break;
295 case (BAT_CLIENT_READY):
296 strcat (trcBuf, "BAT_CLIENT_READY");
297 break;
298 case (BAT_CLIENT_BUSY):
299 strcat (trcBuf, "BAT_CLIENT_BUSY");
300 break;
301 case (BAT_CLIENT_SENDING):
302 strcat (trcBuf, "BAT_CLIENT_SENDING");
303 break;
304 case (BAT_CLIENT_SENDING_AND_BUSY):
305 strcat (trcBuf, "BAT_CLIENT_SENDING_AND_BUSY");
306 break;
307 default:
308 strcat (trcBuf, "UNKNOWN !");
309 }
310
311 BAT_TRACE_EVENT_P1("%s",trcBuf);
312 }
313 /*
314 +----------------------------------------------------------------------------+
315 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
316 | STATE : code ROUTINE : bat_change_instance_state |
317 +----------------------------------------------------------------------------+
318
319 PURPOSE :
320 This function changes the instance state and traces the state change.
321 */
322 GLOBAL void bat_change_instance_state (T_BAT_instance_maintain *instance,
323 T_BAT_instance_state new_state)
324 {
325 char trcBuf[80];
326 T_BAT_instance_state old_state = instance->instance_state;
327 instance->instance_state = new_state;
328
329 if (old_state EQ new_state)
330 {
331 return;
332 }
333
334 sprintf (trcBuf, "(instance 0x%08X) state: ", (int)instance);
335
336 switch (old_state)
337 {
338 case (BAT_INSTANCE_IDLE):
339 strcat (trcBuf, "BAT_INSTANCE_IDLE -> ");
340 break;
341 case (BAT_INSTANCE_ACTIVATING):
342 strcat (trcBuf, "BAT_INSTANCE_ACTIVATING -> ");
343 break;
344 case (BAT_INSTANCE_READY):
345 strcat (trcBuf, "BAT_INSTANCE_READY -> ");
346 break;
347 case (BAT_INSTANCE_BUSY):
348 strcat (trcBuf, "BAT_INSTANCE_BUSY -> ");
349 break;
350 default:
351 strcat (trcBuf, "UNKNOWN ! ");
352 }
353
354 switch (new_state)
355 {
356 case (BAT_INSTANCE_IDLE):
357 strcat (trcBuf, "BAT_INSTANCE_IDLE");
358 break;
359 case (BAT_INSTANCE_ACTIVATING):
360 strcat (trcBuf, "BAT_INSTANCE_ACTIVATING");
361 break;
362 case (BAT_INSTANCE_READY):
363 strcat (trcBuf, "BAT_INSTANCE_READY");
364 break;
365 case (BAT_INSTANCE_BUSY):
366 strcat (trcBuf, "BAT_INSTANCE_BUSY");
367 break;
368 default:
369 strcat (trcBuf, "UNKNOWN !");
370 }
371
372 BAT_TRACE_EVENT_P1("%s",trcBuf);
373 }
374
375 /*
376 +----------------------------------------------------------------------------+
377 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
378 | STATE : code ROUTINE : bat_change_buffer_state |
379 +----------------------------------------------------------------------------+
380
381 PURPOSE :
382 This function changes the buffer state and traces the state change.
383 */
384 GLOBAL void bat_change_buffer_state (T_BAT_instance_maintain *instance,
385 T_BAT_buf_state new_state)
386 {
387 /* char trcBuf[80];
388 T_BAT_buf_state old_state = instance->buffer.buf_st;*/
389 instance->buffer.buf_st = new_state;
390 /*
391 if (old_state EQ new_state)
392 {
393 return;
394 }
395 sprintf (trcBuf, "(instance 0x%08X) buffer state: ", (int)instance);
396
397 switch (old_state)
398 {
399 case (BAT_BUF_EMPTY):
400 strcat (trcBuf, "BAT_BUF_EMPTY -> ");
401 break;
402 case (BAT_BUF_FILLING):
403 strcat (trcBuf, "BAT_BUF_FILLING -> ");
404 break;
405 case (BAT_BUF_FILLED):
406 strcat (trcBuf, "BAT_BUF_FILLED -> ");
407 break;
408 default:
409 strcat (trcBuf, "UNKNOWN ! ");
410 }
411
412 switch (new_state)
413 {
414 case (BAT_BUF_EMPTY):
415 strcat (trcBuf, "BAT_BUF_EMPTY");
416 break;
417 case (BAT_BUF_FILLING):
418 strcat (trcBuf, "BAT_BUF_FILLING");
419 break;
420 case (BAT_BUF_FILLED):
421 strcat (trcBuf, "BAT_BUF_FILLED");
422 break;
423 default:
424 strcat (trcBuf, "UNKNOWN !");
425 }
426
427 BAT_TRACE_EVENT_P1("%s",trcBuf);*/
428 }
429
430 /*
431 +----------------------------------------------------------------------------+
432 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
433 | STATE : code ROUTINE : bat_init_global_params |
434 +----------------------------------------------------------------------------+
435
436 PURPOSE :
437 This function initializes the global parameters.
438 */
439
440 GLOBAL T_BAT_return bat_init_global_params ()
441 {
442 /* The first BAT instance, so init the params */
443 if(ptr_bat_list EQ NULL)
444 {
445 void *bat_header = NULL;
446 int header_size = max_bat_num * sizeof (T_BAT_instance_maintain *);
447 BAT_TRACE_EVENT("First BAT instance!");
448 /* allocate memory to hold the instance pointer array */
449 bat_header = gdd_sys_mem_malloc(header_size);
450 /* init allocated memory */
451 memset(bat_header, 0, header_size);
452
453 ptr_bat_list = (T_BAT_instance_maintain **)bat_header;
454 }
455
456 return (BAT_OK);
457 }
458
459 /*
460 +----------------------------------------------------------------------------+
461 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
462 | STATE : code ROUTINE : bat_deinit_global_params |
463 +----------------------------------------------------------------------------+
464
465 PURPOSE :
466 This function deinitializes the global parameters.
467 */
468
469 GLOBAL T_BAT_return bat_deinit_global_params ()
470 {
471 int i;
472 for(i = 0; i < max_bat_num; i ++)
473 {
474 if (GET_INST (i) NEQ NULL)
475 return (BAT_OK);
476 }
477
478 max_bat_num = 4;
479 ptr_bat_list = NULL;
480
481 return (BAT_OK);
482 }
483
484 /*
485 +----------------------------------------------------------------------------+
486 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
487 | STATE : code ROUTINE : bat_deinit_global_params |
488 +----------------------------------------------------------------------------+
489
490 PURPOSE :
491 This function checks if the global parameters have been init or deinit. If
492 is_init is TRUE then the init state should be checked otherwise the deinit
493 state should be checked.
494 */
495
496 GLOBAL BOOL bat_check_init_or_deinit (BOOL is_init)
497 {
498 /*BAT Lib should be already init*/
499 if (is_init AND ptr_bat_list EQ NULL)
500 {
501 return (FALSE);
502 }
503 /*BAT Lib should be already deinit*/
504 if (!is_init AND ptr_bat_list NEQ NULL)
505 {
506 return (FALSE);
507 }
508
509 return (TRUE);
510 }
511
512 /*
513 +----------------------------------------------------------------------------+
514 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
515 | STATE : code ROUTINE : bat_init_inatance_pointer |
516 +----------------------------------------------------------------------------+
517
518 PURPOSE :
519 This function initializes a pointer in the pointer list.
520 */
521
522 GLOBAL T_BAT_return bat_init_instance_pointer (T_BAT_instance inst_hndl,
523 T_BAT_instance_maintain *inst_mt)
524 {
525 *(ptr_bat_list + inst_hndl)= inst_mt;
526
527 return (BAT_OK);
528 }
529
530 /*
531 +----------------------------------------------------------------------------+
532 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
533 | STATE : code ROUTINE : bat_init_inatance_pointer |
534 +----------------------------------------------------------------------------+
535
536 PURPOSE :
537 This function initializes a pointer in the pointer list.
538 */
539
540 GLOBAL T_BAT_return bat_deinit_instance_pointer (T_BAT_instance inst_hndl)
541 {
542 *(ptr_bat_list + inst_hndl) = NULL;
543
544 return (BAT_OK);
545 }
546
547 /*
548 +----------------------------------------------------------------------------+
549 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
550 | STATE : code ROUTINE : check_if_all_instances_are_closed |
551 +----------------------------------------------------------------------------+
552
553 PURPOSE :
554 This function initializes the global parameters.
555 */
556
557 GLOBAL BOOL bat_check_if_all_instances_are_closed()
558 {
559 int i;
560 for (i = 0; i < max_bat_num; i++)
561 {
562 if (GET_INST(i) NEQ NULL)
563 {
564 BAT_TRACE_ERROR ("bat_check_if_all_instances_are_closed(): not all the instances are closed!");
565 return (FALSE);
566 }
567 }
568 return (TRUE);
569 }
570
571 /*
572 +----------------------------------------------------------------------------+
573 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
574 | STATE : code ROUTINE : check_if_all_clients_are_closed |
575 +----------------------------------------------------------------------------+
576
577 PURPOSE :
578 This function checks if all the clients are closed.
579 */
580
581 GLOBAL BOOL bat_check_if_all_clients_are_closed(T_BAT_instance inst_hndl)
582 {
583 int i;
584 T_BAT_instance_maintain *inst_mt = GET_INST(inst_hndl);
585
586 if (inst_mt)
587 {
588 for (i = 0; i < inst_mt->max_client_num; i++)
589 {
590 if ((GET_CLNT(inst_mt, i))->client_state NEQ BAT_CLIENT_IDLE)
591 {
592 BAT_TRACE_ERROR("bat_check_if_all_clients_are_closed(): Not all clients are closed!");
593 return (FALSE);
594 }
595 }
596 }
597 return (TRUE);
598 }
599 /*
600 +----------------------------------------------------------------------------+
601 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
602 | STATE : code ROUTINE : bat_init_global_params |
603 +----------------------------------------------------------------------------+
604
605 PURPOSE :
606 This function gets the address from instance handle.
607 */
608
609 GLOBAL T_BAT_return bat_get_instance_from_instance_handle
610 (T_BAT_instance inst_hndl,
611 T_BAT_instance_maintain **inst_mt)
612 {
613 if (inst_hndl > max_bat_num)
614 {
615 BAT_TRACE_ERROR("bat_get_instance_from_instance_handle(): instance searched for is out of bound!");
616 return (BAT_ERROR);
617 }
618 *inst_mt = GET_INST(inst_hndl);
619 if (*inst_mt EQ NULL)
620 {
621 BAT_TRACE_ERROR ("bat_get_instance_from_instance_handle(): no instance has been found!");
622 return (BAT_ERROR);
623 }
624 return (BAT_OK);
625 }
626 /*
627 +----------------------------------------------------------------------------+
628 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
629 | STATE : code ROUTINE : bat_get_new_instance |
630 +----------------------------------------------------------------------------+
631
632 PURPOSE :
633 This function scans through the pointer list and passes the index of the first
634 free instance pointer with the output parameter <instance>.
635 */
636
637 GLOBAL T_BAT_return bat_get_new_instance (T_BAT_instance *instance)
638 {
639 int i = 0;
640
641 do
642 {
643 if (GET_INST(i)EQ NULL)
644 {
645 *instance = (T_BAT_instance) i;
646 return (BAT_OK);
647 }
648 i++;
649 } while (i < max_bat_num);
650
651 /* the allocated memory for the BAT header is full, we will allocate a bigger
652 block of memory and copy the older header array to the new memory block */
653 if (i < BAT_INVALID_INSTANCE_HANDLE-4) /* maximum 256 instances can be created */
654 {
655 void *new_bat_header = NULL;
656 U8 new_max_bat_num = max_bat_num + 4;
657 int new_header_size = new_max_bat_num * sizeof(T_BAT_instance_maintain*);
658
659 new_bat_header = gdd_sys_mem_malloc(new_header_size);
660 memset(new_bat_header, 0, new_header_size);
661 memcpy(new_bat_header, ptr_bat_list, max_bat_num*sizeof(T_BAT_instance_maintain*));
662
663 /* free the old header list and point to the new header list */
664 gdd_sys_mem_free(ptr_bat_list);
665 ptr_bat_list = (T_BAT_instance_maintain **)new_bat_header;
666 *instance = max_bat_num; /*the new instance handle should be the old max number+1*/
667 max_bat_num = new_max_bat_num;
668 BAT_TRACE_EVENT_P2("Current max BAT is %d, the header address is 0x%04X",
669 new_max_bat_num, ptr_bat_list);
670 return (BAT_OK);
671
672 }
673
674 BAT_TRACE_ERROR("bat_get_new_instance(): No free instance to create!");
675 return (BAT_ERROR);
676 }
677
678 /*
679 +----------------------------------------------------------------------------+
680 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
681 | STATE : code ROUTINE : bat_delete_instance |
682 +----------------------------------------------------------------------------+
683
684 PURPOSE :
685 This function checks if all the clients in the instance are closed, if not then
686 an error will be returned. If yes, the pointer pointing to the instance in
687 pointer list will be set to NULL.
688 */
689
690 GLOBAL T_BAT_return bat_delete_instance (T_GDD_CON_HANDLE con_handle)
691 {
692 int i;
693 T_BAT_instance inst_hdle = BAT_INVALID_INSTANCE_HANDLE;
694 T_BAT_client clnt_hndl = BAT_INVALID_CLIENT_HANDLE;
695 T_BAT_instance_maintain *inst_mt = NULL;
696 T_BAT_client_maintain *clnt_mt = NULL;
697
698 BAT_TRACE_FUNCTION ("bat_delete_instance()");
699
700 if (bat_get_instance_from_gdd_handle (con_handle, &inst_hdle, &inst_mt) EQ BAT_ERROR)
701 {
702 return (BAT_ERROR);
703 }
704
705 for (i = 0; i < inst_mt->max_client_num; i++)
706 {
707 bat_make_client_handle_from_gdd_and_client_id(con_handle, (U8)i, &clnt_hndl);
708 bat_get_client_from_client_handle(clnt_hndl, &clnt_mt);
709
710 if (clnt_mt->client_state NEQ BAT_CLIENT_IDLE)
711 {
712 BAT_TRACE_ERROR ("bat_delete_instance(): not all clients are closed");
713 return (BAT_ERROR);
714 }
715 }
716 /* check if the instanse */
717 if (bat_get_instance_from_instance_handle(inst_hdle, &inst_mt))
718 {
719 return (BAT_ERROR);
720 }
721 return (BAT_OK);
722 }
723
724
725 /*
726 +----------------------------------------------------------------------------+
727 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
728 | STATE : code ROUTINE : bat_get_instance_from_gdd_handle |
729 +----------------------------------------------------------------------------+
730
731 PURPOSE :
732 This function searches the instances and passes the address of the correct
733 instance through the output parameter.
734 */
735
736 T_BAT_return bat_get_instance_from_gdd_handle ( T_GDD_CON_HANDLE con_handle,
737 T_BAT_instance *instance_handle,
738 T_BAT_instance_maintain **instance)
739
740 {
741 int i;
742
743 for (i = 0; i < max_bat_num; i++)
744 {
745 *instance = GET_INST(i);
746 *instance_handle = (U8)i;
747
748 if ((*instance)!= NULL && (*instance)->con_handle == con_handle)
749 {
750 return (BAT_OK);
751 }
752 }
753 return (BAT_ERROR);
754 }
755
756 /*
757 +----------------------------------------------------------------------------+
758 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
759 | STATE : code ROUTINE : bat_get_new_client |
760 +----------------------------------------------------------------------------+
761
762 PURPOSE :
763 This function searches in an instance until it reaches the first free client
764 (e,g. the Nth client). This instance handle and the client id (N in this case)
765 will be used to create the client handle.
766 */
767
768 T_BAT_return bat_get_new_client( T_BAT_instance instance, T_BAT_client *client)
769 {
770 int i;
771 T_BAT_client_maintain *new_client = NULL;
772 T_BAT_instance_maintain *inst_mt = GET_INST(instance);
773
774 if (inst_mt EQ NULL)
775 {
776 BAT_TRACE_ERROR ("bat_get_new_client(): the input instance is NULL.");
777 return (BAT_ERROR);
778 }
779
780 for (i = 0; i<inst_mt->max_client_num; i++)
781 {
782 new_client = GET_CLNT(inst_mt,i);
783 if (new_client->client_state EQ BAT_CLIENT_IDLE)
784 {
785 *client = MAKE_CLNT_HNDL(i, instance);
786 BAT_TRACE_EVENT_P1("bat_get_new_client(): new client is : 0x%04X", *client);
787 return (BAT_OK);
788 }
789 }
790 BAT_TRACE_ERROR ("bat_get_new_client(): no client is found!");
791 return (BAT_ERROR);
792 }
793
794 /*
795 +----------------------------------------------------------------------------+
796 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
797 | STATE : code ROUTINE : bat_init_new_client |
798 +----------------------------------------------------------------------------+
799
800 PURPOSE :
801 This function searches in an instance until it reaches the first free client
802 (e,g. the Nth client). This instance handle and the client id (N in this case)
803 will be used to create the client handle.
804 */
805
806 T_BAT_return bat_init_new_client (T_BAT_client client,
807 int(*response_cb)(T_BAT_client client, T_BAT_cmd_response *response),
808 void(*signal_cb)(T_BAT_client client, T_BAT_signal))
809
810 {
811 T_BAT_client_maintain *clnt_mt = NULL;
812
813 if (bat_get_client_from_client_handle(client, &clnt_mt) EQ BAT_ERROR)
814 {
815 return (BAT_ERROR);
816 }
817 bat_change_client_state(clnt_mt, BAT_CLIENT_ACTIVATING);
818 clnt_mt->signal_cb = signal_cb;
819 clnt_mt->response_cb = response_cb;
820
821 return (BAT_OK);
822 }
823
824 /*
825 +----------------------------------------------------------------------------+
826 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
827 | STATE : code ROUTINE : bat_make_client_handle_from_gdd_and_client_id |
828 +----------------------------------------------------------------------------+
829
830 PURPOSE :
831 This function gets the <client_id> and the <con_handle> and then builds the
832 client handle out of them. The client handle will then passed through the
833 output parameter <client>.
834 */
835
836 T_BAT_return bat_make_client_handle_from_gdd_and_client_id (T_GDD_CON_HANDLE con_handle,
837 U8 client_id,
838 T_BAT_client *client)
839 {
840 T_BAT_instance_maintain *dummy = NULL;
841 T_BAT_instance inst_hndl = BAT_BROADCAST_CHANNEL;
842
843 bat_get_instance_from_gdd_handle(con_handle, &inst_hndl, &dummy);
844 *client = MAKE_CLNT_HNDL(client_id, inst_hndl);
845 return (BAT_OK);
846 }
847
848 /*
849 +----------------------------------------------------------------------------+
850 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
851 | STATE : code ROUTINE : bat_make_client_handle_from_gdd_and_client_id |
852 +----------------------------------------------------------------------------+
853
854 PURPOSE :
855 This function gets the client maintain data from the client handle.
856 */
857
858 T_BAT_return bat_get_client_from_client_handle (T_BAT_client clnt_hndl,
859 T_BAT_client_maintain **clnt_mt)
860 {
861 U8 inst_hndl = GET_INST_HNDL_FROM_CLNT_HANDLE(clnt_hndl);
862 U8 clnt_id = GET_CLNT_ID_FROM_CLNT_HANDLE(clnt_hndl);
863 T_BAT_instance_maintain *inst_mt = NULL;
864
865 if (inst_hndl >= max_bat_num)
866 {
867 BAT_TRACE_ERROR ("bat_get_client_from_client_handle(): instance handle out of bound.");
868 return (BAT_ERROR);
869 }
870 inst_mt = GET_INST (inst_hndl);
871 if (inst_mt EQ NULL OR (clnt_id >= inst_mt->max_client_num))
872 {
873 BAT_TRACE_ERROR ("bat_get_client_from_client_handle(): instance not found or client id out of bound!");
874 return (BAT_ERROR);
875 }
876 *clnt_mt = GET_CLNT(inst_mt, clnt_id);
877 if (*clnt_mt EQ NULL)
878 {
879 return (BAT_ERROR);
880 }
881 return (BAT_OK);
882 }
883
884
885 /*
886 +----------------------------------------------------------------------------+
887 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
888 | STATE : code ROUTINE : bat_make_client_handle_from_gdd_and_client_id |
889 +----------------------------------------------------------------------------+
890
891 PURPOSE :
892 This function is used to process the received unsolicited code.
893 */
894
895 T_BAT_return bat_unsolicited_code_rcv(T_BAT_instance inst_hndl, T_BAT_cmd_response *rsp)
896 {
897 T_BAT_instance_maintain *inst_mt = NULL;
898
899 BAT_TRACE_FUNCTION ("bat_unsolicited_code_rcv()");
900
901 bat_get_instance_from_instance_handle (inst_hndl, &inst_mt);
902
903 if (inst_mt->unsolicited_result_cb NEQ NULL)
904 {
905 if (inst_mt->unsolicited_result_cb(MAKE_UNS_CLNT_HNDL(inst_hndl),rsp) EQ BAT_BUSY_RESOURCE)
906 {
907 inst_mt->buffer.dest = MAKE_UNS_CLNT_HNDL(inst_hndl);
908 bat_change_buffer_state(inst_mt, BAT_BUF_FILLED);
909 return (BAT_BUSY_RESOURCE);
910 }
911 }
912
913 bat_change_buffer_state(inst_mt, BAT_BUF_EMPTY);
914
915 return (BAT_OK);
916 }
917
918 /*
919 +----------------------------------------------------------------------------+
920 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
921 | STATE : code ROUTINE : bat_make_client_handle_from_gdd_and_client_id |
922 +----------------------------------------------------------------------------+
923
924 PURPOSE :
925 This function is used to process the received control information.
926 */
927
928 T_BAT_return bat_control_confirm_rcv(T_BAT_instance inst_hndl, T_BATC_confirm cnf)
929 {
930 T_BAT_client clnt_hndl = BAT_INVALID_CLIENT_HANDLE;
931 T_BAT_instance_maintain *inst_mt = NULL;
932 T_BAT_client_maintain *clnt_mt = NULL;
933
934 BAT_TRACE_FUNCTION ("bat_control_confirm_rcv()");
935
936 if (bat_get_instance_from_instance_handle (inst_hndl, &inst_mt))
937 {
938 bat_change_buffer_state(inst_mt, BAT_BUF_EMPTY);
939
940 return (BAT_ERROR);
941 }
942
943 switch (cnf.rsp_params)
944 {
945 case (BATC_MAX_CLIENTS_CNF):
946 case (BATC_MAX_CLIENTS_REJ):
947 {
948 /* check the instance state */
949 if (inst_mt->instance_state NEQ BAT_INSTANCE_ACTIVATING)
950 {
951 BAT_TRACE_ERROR ("bat_control_confirm_rcv(): A conf/rej for bat_new is received in wrong BAT instance state");
952 bat_change_buffer_state(inst_mt, BAT_BUF_EMPTY);
953 return (BAT_ERROR);
954 }
955 if (cnf.rsp_params EQ BATC_MAX_CLIENTS_CNF)
956 {
957 BAT_TRACE_EVENT ("bat_control_confirm_rcv(): New instance confirmed");
958 bat_change_instance_state(inst_mt,BAT_INSTANCE_READY);
959 inst_mt->instance_signal_cb(BAT_NEW_INSTANCE_SUCCEED);
960 }
961 else if (cnf.rsp_params EQ BATC_MAX_CLIENTS_REJ)
962 {
963 BAT_TRACE_EVENT ("bat_control_confirm_rcv(): New instance rejected!");
964 bat_change_instance_state(inst_mt,BAT_INSTANCE_IDLE);
965 if (inst_mt->config->adapter.gdd_if.gdd_disconnect ((T_GDD_CON_HANDLE)(inst_mt->con_handle)) != GDD_OK)
966 {
967 BAT_TRACE_ERROR ("GDD disconnect failed after bat_new() was rejected");
968 }
969 L2P_Remove (inst_hndl);
970 inst_mt->instance_signal_cb(BAT_NEW_INSTANCE_FAIL);
971 }
972 break;
973 }
974 case (BATC_OPEN_CLIENT_CNF):
975 case (BATC_OPEN_CLIENT_REJ):
976 {
977 BAT_TRACE_EVENT ("bat_control_confirm_rcv(): Open client confirmed/rejected!");
978 if (inst_mt->instance_state < BAT_INSTANCE_READY)
979 {
980 BAT_TRACE_ERROR ("bat_control_confirm_rcv(): A conf/rej is received in wrong BAT instance state");
981 BAT_TRACE_EVENT_P1 ("bat_control_confirm_rcv(): current BAT instance state is: %d", inst_mt->instance_state);
982 bat_change_buffer_state(inst_mt, BAT_BUF_EMPTY);
983
984 return (BAT_ERROR);
985 }
986
987 clnt_hndl = MAKE_CLNT_HNDL(cnf.rsp.ptr_bat_open_client_cnf->client_id, inst_hndl);
988
989 if (bat_get_client_from_client_handle(clnt_hndl, &clnt_mt))
990 {
991 bat_change_buffer_state(inst_mt, BAT_BUF_EMPTY);
992
993 return (BAT_ERROR);
994 }
995 if (clnt_mt->client_state NEQ BAT_CLIENT_ACTIVATING)
996 {
997 BAT_TRACE_ERROR ("bat_control_confirm_rcv(): A confirmation for bat_open is received in wrong BAT client state");
998 bat_change_buffer_state(inst_mt, BAT_BUF_EMPTY);
999
1000 return (BAT_ERROR);
1001 }
1002 if (cnf.rsp_params EQ BATC_OPEN_CLIENT_CNF)
1003 {
1004 BAT_TRACE_EVENT_P1("bat_control_confirm_rcv(): The confirmed clnt hndl is 0x%x", clnt_hndl);
1005 bat_change_client_state(clnt_mt, BAT_CLIENT_READY);
1006 clnt_mt->signal_cb(clnt_hndl, BAT_OPEN_CLIENT_SUCCEED);
1007 }
1008 else if (cnf.rsp_params EQ BATC_OPEN_CLIENT_REJ)
1009 {
1010 bat_change_client_state(clnt_mt, BAT_CLIENT_IDLE);
1011 clnt_mt->signal_cb(clnt_hndl, BAT_OPEN_CLIENT_FAIL);
1012 }
1013 break;
1014 }
1015 case (BATC_ABORT_COMMAND_CNF):
1016 case (BATC_ABORT_COMMAND_REJ):
1017 {
1018 BAT_TRACE_EVENT ("bat_control_confirm_rcv(): Abort command confirmed/rejected!");
1019 if (inst_mt->instance_state < BAT_INSTANCE_READY)
1020 {
1021 BAT_TRACE_ERROR ("bat_control_confirm_rcv(): An abort conf/rej is received in wrong BAT instance state");
1022 BAT_TRACE_EVENT_P1 ("bat_control_confirm_rcv(): current BAT instance state is: %d", inst_mt->instance_state);
1023 bat_change_buffer_state(inst_mt, BAT_BUF_EMPTY);
1024
1025 return (BAT_ERROR);
1026 }
1027
1028 clnt_hndl = MAKE_CLNT_HNDL(cnf.rsp.ptr_bat_open_client_cnf->client_id, inst_hndl);
1029
1030 if (bat_get_client_from_client_handle(MAKE_CLNT_HNDL(cnf.rsp.ptr_bat_open_client_cnf->client_id,
1031 inst_hndl), &clnt_mt))
1032 {
1033 bat_change_buffer_state(inst_mt, BAT_BUF_EMPTY);
1034
1035 return (BAT_ERROR);
1036 }
1037
1038 if (cnf.rsp_params EQ BATC_ABORT_COMMAND_CNF)
1039 {
1040 bat_change_client_state(clnt_mt, BAT_CLIENT_READY);
1041 clnt_mt->signal_cb(clnt_hndl, BAT_ABORT_COMMAND_SUCCEED);
1042 }
1043
1044 else if (cnf.rsp_params EQ BATC_ABORT_COMMAND_REJ)
1045 {
1046 bat_change_client_state(clnt_mt, BAT_CLIENT_SENDING);
1047 clnt_mt->signal_cb(clnt_hndl, BAT_ABORT_COMMAND_FAIL);
1048 }
1049 break;
1050 }
1051 default:
1052 {
1053 bat_change_buffer_state(inst_mt, BAT_BUF_EMPTY);
1054
1055 return (BAT_ERROR);
1056 }
1057 }
1058 bat_change_buffer_state(inst_mt, BAT_BUF_EMPTY);
1059
1060 return (BAT_OK);
1061
1062 }
1063
1064 /*
1065 +----------------------------------------------------------------------------+
1066 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
1067 | STATE : code ROUTINE : bat_make_client_handle_from_gdd_and_client_id |
1068 +----------------------------------------------------------------------------+
1069
1070 PURPOSE :
1071 This function is used to process the received command response.
1072 */
1073
1074 T_BAT_return bat_command_response_rcv (T_BAT_instance inst_hndl, U8 clnt_id, T_BAT_cmd_response *rsp)
1075 {
1076 T_BAT_client clnt_hndl = MAKE_CLNT_HNDL(clnt_id, inst_hndl);
1077 T_BAT_instance_maintain *inst_mt = NULL;
1078 T_BAT_client_maintain *clnt_mt = NULL;
1079
1080 BAT_TRACE_FUNCTION ("bat_command_response_rcv()");
1081
1082 if (bat_get_client_from_client_handle ( MAKE_CLNT_HNDL(clnt_id, inst_hndl), &clnt_mt))
1083 {
1084 return (BAT_ERROR);
1085 }
1086
1087 if (bat_get_instance_from_instance_handle(inst_hndl, &inst_mt))
1088 {
1089 return (BAT_ERROR);
1090 }
1091
1092 if (clnt_mt->client_state < BAT_CLIENT_READY)
1093 {
1094 BAT_TRACE_EVENT ("bat_command_response_rcv(): Client is closed!");
1095 bat_change_buffer_state(inst_mt, BAT_BUF_EMPTY);
1096 return (BAT_OK);
1097 }
1098
1099 /* if the rsp is a finial rsp. */
1100 if (rsp->ctrl_response <= BAT_RES_PLUS_EXT_ERROR)
1101 {
1102 BAT_TRACE_EVENT ("bat_command_response_rcv(): FINAL RESULT CODE");
1103 bat_change_client_state(clnt_mt, BAT_CLIENT_READY);
1104 }
1105 else
1106 {
1107 BAT_TRACE_EVENT ("bat_command_response_rcv(): INTERMEDIATE CODE");
1108 }
1109
1110 /*
1111 * call now the callback function of the client and
1112 * check whether the application was able to process the callback.
1113 * if not then the buffer will not be empty and the destination of
1114 * the buffer will be the busy client handle.
1115 */
1116 if (clnt_mt->response_cb(clnt_hndl, rsp) EQ BAT_BUSY_RESOURCE)
1117 {
1118 inst_mt->buffer.dest = clnt_hndl;
1119 return (BAT_BUSY_RESOURCE);
1120 }
1121
1122 bat_change_buffer_state(inst_mt, BAT_BUF_EMPTY);
1123 return (BAT_OK);
1124 }
1125
1126
1127 /*
1128 +----------------------------------------------------------------------------+
1129 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
1130 | STATE : code ROUTINE : bat_send_cmd_data |
1131 +----------------------------------------------------------------------------+
1132
1133 PURPOSE :
1134 This function is used to send the BAT command to ACI (via GDD).
1135 */
1136
1137 T_BAT_return bat_send_cmd_data (T_BAT_client clnt_hndl, T_BAT_cmd_send *data)
1138 {
1139 U16 size = 0;
1140 int errVal = -1;
1141 void *dataPtr = NULL;
1142 T_L2P_STATUS ret;
1143
1144 if (data->ctrl_params & 0x1000) /* 0x1xxx = T_BAT_no_parameter */
1145 {
1146 size = sizeof(T_BAT_no_parameter);
1147 dataPtr = (void *)(data->params.ptr_set_percent_als);
1148 }
1149 else
1150 if (data->ctrl_params & 0x2000) /* 0x2xxx = T_BAT_custom */
1151 {
1152 /* <!-- ********** until ccdgen is able to cope with ***********
1153 search for the above comment in bat.sap and remove it
1154 when ccdgen is able to work with bat.sap
1155
1156 if (data->params.ptr_custom->c_buf > BAT_MAX_CUSTOM_CMD_LEN)
1157 {
1158 return (BAT_ERROR);
1159 }
1160 size = data->params.ptr_custom->c_buf + sizeof(U16);
1161 dataPtr = (void *)(data->params.ptr_custom);
1162 */
1163 return(BAT_ERROR); /* remove this whenn cddgen is able to */
1164 }
1165 else
1166 {
1167 size = (U16)(params_2_size[data->ctrl_params].size);
1168 dataPtr = (void *)(data->params.ptr_set_percent_als);
1169 }
1170
1171 BAT_TRACE_EVENT_P2("bat_send_cmd_data(): cmd = 0x%04X, size = %i", data->ctrl_params, size);
1172
1173 BAT_TRACE_BINDUMP(xxx_handle,TC_USER4,"BAT COMMAND PARAMETER",(U8 *)data->params.ptr_at_a,size);
1174
1175 /*L2P is called here to stuff the data*/
1176 ret = L2P_Send(GET_INST_HNDL_FROM_CLNT_HANDLE(clnt_hndl),
1177 GET_CLNT_ID_FROM_CLNT_HANDLE(clnt_hndl),
1178 data->ctrl_params,
1179 dataPtr,
1180 size,
1181 &errVal);
1182
1183 switch (ret)
1184 {
1185 case (L2P_STAT_SUCCESS):
1186 {
1187 return(BAT_OK);
1188 }
1189 case (L2P_STAT_UNKNOWN_ERROR):
1190 {
1191 BAT_TRACE_EVENT("bat_send_cmd_data(): L2P UNKNOWN ERROR");
1192 break;
1193 }
1194 case (L2P_STAT_MSG_SEND_FAIL):
1195 {
1196 BAT_TRACE_EVENT("bat_send_cmd_data(): L2P FAILED TO SEND");
1197 break;
1198 }
1199 case (L2P_STAT_INVALID_PARAMETER):
1200 {
1201 BAT_TRACE_EVENT("bat_send_cmd_data(): L2P INVALID PARAMETER");
1202 break;
1203 }
1204 case (L2P_STAT_NO_SUCH_BAT_ID):
1205 {
1206 BAT_TRACE_EVENT("bat_send_cmd_data(): L2P UNKNOWN CLIENT HANDLE");
1207 break;
1208 }
1209 case (L2P_STAT_NO_SUCH_MUX_ID):
1210 {
1211 BAT_TRACE_EVENT("bat_send_cmd_data(): L2P UNKNOWN CLIENT ID");
1212 break;
1213 }
1214 case (L2P_STAT_UNABLE_TO_GET_BUFFER):
1215 {
1216 BAT_TRACE_EVENT("bat_send_cmd_data(): L2P NO TRANSMIT BUFFER AVAILABLE");
1217 return(BAT_BUSY_RESOURCE);
1218 }
1219 case (L2P_STAT_BAT_ID_ALREADY_EXISTS):
1220 {
1221 BAT_TRACE_EVENT("bat_send_cmd_data(): L2P BAT ID ALREADY EXISTS");
1222 break;
1223 }
1224 case (L2P_STAT_UNEXPECTED_FRAME_RXD):
1225 {
1226 BAT_TRACE_EVENT("bat_send_cmd_data(): L2P UNEXPECTED FRAME RECEIVED");
1227 break;
1228 }
1229 case(L2P_STAT_CRC_FAIL):
1230 {
1231 BAT_TRACE_EVENT("bat_send_cmd_data(): L2P CRC ERROR");
1232 break;
1233 }
1234 default:
1235 {
1236 BAT_TRACE_EVENT("bat_send_cmd_data(): L2P UNDEFINED RETURN VALUE");
1237 break;
1238 }
1239 }
1240 return(BAT_ERROR);
1241 }
1242
1243 /*
1244 +----------------------------------------------------------------------------+
1245 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
1246 | STATE : code ROUTINE : bat_send_ctrl_data |
1247 +----------------------------------------------------------------------------+
1248
1249 PURPOSE :
1250 This function is used to send the control info to ACI (via GDD).
1251 */
1252
1253 T_BAT_return bat_send_ctrl_data (T_BAT_instance inst_hndl, T_BATC_signal *data)
1254 {
1255 int errVal = -1;
1256 U16 size = 0;
1257
1258 BAT_TRACE_FUNCTION ("bat_send_ctrl_data()");
1259
1260 switch (data->ctrl_params)
1261 {
1262 case (BATC_MAX_CLIENTS):
1263 case (BATC_OPEN_CLIENT):
1264 case (BATC_ABORT_CMD):
1265 case (BATC_CLOSE_CLIENT):
1266 size = sizeof(T_BATC_max_clients);
1267 break;
1268
1269 default:
1270 break;
1271 }
1272
1273 /*L2P has to be called here to stuff the data*/
1274 if (L2P_STAT_UNABLE_TO_GET_BUFFER EQ L2P_Send (inst_hndl, BAT_CONTROL_CHANNEL,
1275 data->ctrl_params, (void *)(data->params.ptr_max_clients), size, &errVal))
1276 {
1277 return (BAT_BUSY_RESOURCE);
1278 }
1279
1280 return (BAT_OK);
1281 }
1282 /*
1283 +----------------------------------------------------------------------------+
1284 | PROJECT : MODULE : BINARY AT COMMAND LIBRARY |
1285 | STATE : code ROUTINE : bat_make_client_handle_from_gdd_and_client_id |
1286 +----------------------------------------------------------------------------+
1287
1288 PURPOSE :
1289 This function is used to get the size of the BAT cmd basing on the ctrl param.
1290 */
1291
1292 T_BAT_return bat_get_cmd_size (T_BAT_ctrl_params cmd_ctrl, int *size)
1293 {
1294 BAT_TRACE_FUNCTION ("bat_get_cmd_size()");
1295
1296 *size = params_2_size[cmd_ctrl].size;
1297
1298 return (BAT_OK);
1299 }