comparison src/gpf3/ccd/break_cond.c @ 2:c41a534f33c6

src/gpf3: preened GPF goo from TCS3.2
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Sep 2016 23:52:50 +0000
parents
children
comparison
equal deleted inserted replaced
1:864b8cc0cf63 2:c41a534f33c6
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul : break_cond.c
5 +-----------------------------------------------------------------------------
6 | Copyright 2004 Texas Instruments Deutschland GmbH
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 : Definition of encoding and decoding functions for BREAK_COND
18 | elements
19 +-----------------------------------------------------------------------------
20 */
21
22
23 /*
24 * standard definitions like GLOBAL, UCHAR, ERROR etc.
25 */
26 #include "typedefs.h"
27 #include "header.h"
28
29 /*
30 * Prototypes of ccd (USE_DRIVER EQ undef) for prototypes only
31 * look at ccdapi.h
32 */
33 #undef USE_DRIVER
34 #include "ccdapi.h"
35
36 /*
37 * Types and functions for bit access and manipulation
38 */
39 #include "ccd_globs.h"
40 #include "bitfun.h"
41
42 /*
43 * Prototypes of ccd internal functions
44 */
45 #include "ccd.h"
46
47 /*
48 * Declaration of coder/decoder tables
49 */
50 #include "ccdtable.h"
51 #include "ccddata.h"
52
53 #ifndef RUN_INT_RAM
54 /*
55 +-----------------------------------------------------------------------------+
56 | PROJECT : CCD (6144) MODULE : CDC_GSM |
57 | STATE : code ROUTINE : cdc_break_cond_decode |
58 +-----------------------------------------------------------------------------+
59
60 PURPOSE : Decoding of the BREAK_COND element. This element consists of a V
61 component with a variable bit length and must be connected with a
62 special condition. This condition has to be a simple value, which
63 matches to the value range of BREAK_COND element itself.
64 This function performs a standard decoding for a given elem table
65 entry. This means for non structured elements that 1-n bits are
66 read from the bitstream and write to a C-Variable in a machine
67 dependent format.
68 After decoding of the requested number of bits the resulting value
69 will be compared with the constant given by the condition. In case
70 of equality the global variable globs->continue_array is set to
71 FALSE. This breaks decoding of the current superior composition
72 and finishes the array.
73 */
74 SHORT cdc_break_cond_decode (const ULONG c_ref, const ULONG e_ref, T_CCD_Globs *globs)
75 {
76 U8 break_ind = FALSE;
77 ULONG cix_ref, num_prolog_steps, prolog_step_ref;
78
79 #ifdef DEBUG_CCD
80 #ifndef CCD_SYMBOLS
81 TRACE_CCD (globs, "cdc_break_cond_decode()");
82 #else
83 TRACE_CCD (globs, "cdc_break_cond_decode() %s", ccddata_get_alias((USHORT) e_ref, 1));
84 #endif
85 #endif
86
87 cix_ref = melem[e_ref].calcIdxRef;
88 num_prolog_steps = calcidx[cix_ref].numPrologSteps;
89 prolog_step_ref = calcidx[cix_ref].prologStepRef;
90
91 /*
92 * if this element is conditional, check the condition
93 */
94 if (calcidx[cix_ref].numCondCalcs NEQ 0
95 AND ! ccd_conditionOK (e_ref, globs))
96 return 1;
97
98 /*
99 * if this element has a defined prologue
100 * we have to process it before decoding the bitstream
101 * If there are some epilogue expressions to be processed for this element
102 * (rare cases) the result here will be a reading of 0 to an internal
103 * register. The valid processing of expression takes place after the
104 * decoding of the element.
105 */
106 if (num_prolog_steps)
107 {
108 if (calc[prolog_step_ref].operation EQ 'P')
109 {
110 break_ind = TRUE;
111 }
112
113 ccd_performOperations (num_prolog_steps, prolog_step_ref, globs);
114 }
115
116 globs->pstructOffs = melem[e_ref].structOffs;
117
118
119 if (globs->bitpos < globs->maxBitpos)
120 {
121
122 if (mvar[melem[e_ref].elemRef].cType EQ 'X')
123 bf_readBitChunk (mvar[melem[e_ref].elemRef].bSize, globs);
124 else
125 bf_readBits (mvar[melem[e_ref].elemRef].bSize, globs);
126
127 if ( ( break_ind == TRUE ) && (num_prolog_steps > 0))
128 {
129 if ( calc[prolog_step_ref].operand ==
130 (U16) *(globs->pstruct + globs->pstructOffs) )
131 {
132 globs->continue_array = FALSE;
133 }
134 }
135
136 globs->pstructOffs += mvar[melem[e_ref].elemRef].cSize;
137 }
138 else
139 ccd_recordFault ( globs,
140 ERR_ELEM_LEN,
141 BREAK,
142 (USHORT) e_ref,
143 globs->pstruct + globs->pstructOffs);
144
145 /*
146 * process the epilogue expression for this element if there is any
147 */
148 if (num_prolog_steps)
149 {
150 if ( (calc[prolog_step_ref+1].operation EQ 'K')
151 || (calc[prolog_step_ref+1].operation EQ 'C')
152 || (calc[prolog_step_ref+1].operation EQ 's'))
153 {
154 ccd_performOperations (num_prolog_steps, prolog_step_ref, globs);
155 }
156 }
157
158 return 1;
159 }
160 #endif /* !RUN_INT_RAM */
161
162 #ifndef RUN_INT_RAM
163 /*
164 +-----------------------------------------------------------------------------+
165 | PROJECT : CCD (6144) MODULE : CDC_GSM |
166 | STATE : code ROUTINE : cdc_break_cond_encode |
167 +-----------------------------------------------------------------------------+
168
169 PURPOSE : encoding of the BREAK_COND element. This element consists of a V
170 component with a variable bit length and must be connected with a
171 special condition. This condition has to be a simple value, which
172 matches to the value range of BREAK_COND element itself.
173
174 */
175
176 SHORT cdc_break_cond_encode (const ULONG c_ref, const ULONG e_ref, T_CCD_Globs *globs)
177 {
178 U8 break_ind = FALSE;
179 ULONG cix_ref, num_prolog_steps, prolog_step_ref;
180
181 #ifdef DEBUG_CCD
182 #ifndef CCD_SYMBOLS
183 TRACE_CCD (globs, "cdc_break_cond_encode()");
184 #else
185 TRACE_CCD (globs, "cdc_break_cond_encode() %s", ccddata_get_alias((USHORT) e_ref, 1));
186 #endif
187 #endif
188
189 cix_ref = melem[e_ref].calcIdxRef;
190 num_prolog_steps = calcidx[cix_ref].numPrologSteps;
191 prolog_step_ref = calcidx[cix_ref].prologStepRef;
192
193 /*
194 * if this element is conditional, check the condition
195 */
196 if (calcidx[cix_ref].numCondCalcs NEQ 0
197 AND ! ccd_conditionOK (e_ref, globs))
198 return 1;
199
200 /*
201 * if this element have a defined Prolog
202 * we have to process it before decoding the bitstream
203 */
204 if (num_prolog_steps)
205 {
206 if (calc[prolog_step_ref].operation EQ 'P')
207 {
208 break_ind = TRUE;
209 }
210
211 ccd_performOperations (num_prolog_steps, prolog_step_ref, globs);
212 }
213
214 /*
215 * Element is not a SPARE.
216 * Setup the readpointer into the C-structure for this element
217 */
218 globs->pstructOffs = melem[e_ref].structOffs;
219
220 if (mvar[melem[e_ref].elemRef].cType EQ 'X')
221 bf_writeBitChunk (mvar[melem[e_ref].elemRef].bSize, globs);
222 else
223 bf_writeBits (mvar[melem[e_ref].elemRef].bSize, globs);
224
225 if ( ( break_ind == TRUE ) && (num_prolog_steps > 0))
226 {
227 if ( calc[prolog_step_ref].operand ==
228 (U16) *(globs->pstruct + globs->pstructOffs) )
229 {
230 globs->continue_array = FALSE;
231 }
232 }
233
234 globs->pstructOffs += mvar[melem[e_ref].elemRef].cSize;
235
236 return 1;
237 }
238 #endif /* !RUN_INT_RAM */