FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/ccd/ccd_patch.c @ 648:970d6199f2c5
gsm-fw/ccd/*.[ch]: initial import from the LoCosto source
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Thu, 04 Sep 2014 05:48:57 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
647:a60b375014e3 | 648:970d6199f2c5 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : | |
4 | Modul : ccd_patch.c | |
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 : CCD - routines for patching msg elements with given values | |
18 +----------------------------------------------------------------------------- | |
19 */ | |
20 | |
21 #define CCD_PATCH_C | |
22 | |
23 /*==== INCLUDES ==============================================================*/ | |
24 #include <stdio.h> | |
25 #include <string.h> | |
26 | |
27 #include "typedefs.h" | |
28 #include "ccd_globs.h" | |
29 #include "Bitfun.h" | |
30 #include "ccddata.h" | |
31 #include "ccd.h" | |
32 | |
33 /*==== CONSTS ================================================================*//*==== TYPES =================================================================*/ | |
34 /*==== LOCALS ================================================================*/ | |
35 static T_patch_info* pi; | |
36 | |
37 /*==== PRIVATE FUNCTIONS =====================================================*/ | |
38 /*==== PUBLIC FUNCTIONS ======================================================*/ | |
39 | |
40 /* | |
41 +------------------------------------------------------------------------------ | |
42 | Function : ccd_set_patch_infos | |
43 +------------------------------------------------------------------------------ | |
44 | Description : This function submits a list of patch records to CCD | |
45 | | |
46 | Parameters : pinfo - the list | |
47 | | |
48 | Return : ccdOK on success, otherwise ccdError | |
49 +------------------------------------------------------------------------------ | |
50 */ | |
51 int CCDDATA_PREF(ccd_set_patch_infos) (T_patch_info* pinfo) | |
52 { | |
53 pi = pinfo; | |
54 return ccdOK; | |
55 } | |
56 | |
57 /* | |
58 +------------------------------------------------------------------------------ | |
59 | Function : ccd_patch | |
60 +------------------------------------------------------------------------------ | |
61 | Description : This function checks if the element is to be patched | |
62 | and patches if yes. | |
63 | | |
64 | Parameters : globs - entity/code information (containing nesting stack) | |
65 | validflag - set if called from valid flag coding | |
66 | | |
67 | Return : FALSE if real coding function is to be called, TRUE otherwise | |
68 | if validflag is set, TRUE means, the element is identified | |
69 | in the patch list | |
70 +------------------------------------------------------------------------------ | |
71 */ | |
72 | |
73 int ccd_patch (T_CCD_Globs* globs, int validflag) | |
74 { | |
75 int i = 0; | |
76 USHORT elem; | |
77 if (pi) | |
78 { | |
79 while (pi[i].numelems) | |
80 { | |
81 if (!memcmp (pi[i].elemid, globs->error_stack, | |
82 (pi[i].numelems+1) * sizeof (U16))) | |
83 { | |
84 elem = pi[i].elemid[pi[i].numelems]; | |
85 if (validflag) | |
86 { | |
87 if (pi[i].errorcode != CCDP_NOT_FOUND) | |
88 { | |
89 #ifdef DEBUG_CCD | |
90 TRACE_CCD (globs, "ccd_patch(): invalid error code (%d) for %s", | |
91 pi[i].errorcode, ccddata_get_alias (elem, 1)); | |
92 #endif | |
93 } | |
94 else | |
95 { | |
96 #ifdef DEBUG_CCD | |
97 TRACE_CCD (globs, "ccd_patch(): checked valid flag for %s", | |
98 ccddata_get_alias (elem, 1)); | |
99 #endif | |
100 pi[i].errorcode = CCDP_VALIDFLAG_SEEN; | |
101 } | |
102 return TRUE; | |
103 } | |
104 else | |
105 { | |
106 if ((pi[i].errorcode != CCDP_NOT_FOUND) && | |
107 (pi[i].errorcode != CCDP_VALIDFLAG_SEEN)) | |
108 { | |
109 #ifdef DEBUG_CCD | |
110 TRACE_CCD (globs, "ccd_patch(): invalid error code (%d) for %s", | |
111 pi[i].errorcode, ccddata_get_alias (elem, 1)); | |
112 #endif | |
113 } | |
114 else | |
115 { | |
116 UBYTE* pstruct = globs->pstruct; | |
117 ULONG offset = globs->pstructOffs; | |
118 #ifdef DEBUG_CCD | |
119 int j, len; | |
120 char out[32]; | |
121 len = (pi[i].bitwidth+7)/8; | |
122 TRACE_CCD (globs, "ccd_patch(): patching %s with 0x%x bits", | |
123 ccddata_get_alias (elem, 1), pi[i].bitwidth); | |
124 for (j=0; j<len; j++) | |
125 { | |
126 sprintf (&out[(3*j)%24], "%02x \0", pi[i].bits[j]); | |
127 if (!((j+1)%8)) | |
128 TRACE_CCD (globs, out); | |
129 } | |
130 if (((j+1)%8)) | |
131 TRACE_CCD (globs, out); | |
132 #endif | |
133 globs->pstruct = pi[i].bits; | |
134 globs->pstructOffs = 0; | |
135 bf_writeBitChunk (pi[i].bitwidth, globs); | |
136 globs->pstruct = pstruct; | |
137 globs->pstructOffs = offset; | |
138 pi[i].errorcode = CCDP_NO_ERROR; | |
139 } | |
140 return TRUE; | |
141 } | |
142 } | |
143 i++; | |
144 } | |
145 } | |
146 return FALSE; | |
147 } |