annotate src/gpf3/ccd/csn1_sx.c @ 662:8cd8fd15a095

SIM speed enhancement re-enabled and made configurable TI's original code supported SIM speed enhancement, but Openmoko had it disabled, and OM's disabling of speed enhancement somehow caused certain SIM cards to start working which didn't work before (OM's bug #666). Because our FC community is much smaller in year 2020 than OM's community was in their day, we are not able to find one of those #666-affected SIMs, thus the real issue they had encountered remains elusive. Thus our solution is to re-enable SIM speed enhancement and simply wait for if and when someone runs into a #666-affected SIM once again. We provide a SIM_allow_speed_enhancement global variable that allows SIM speed enhancement to be enabled or disabled per session, and an /etc/SIM_spenh file in FFS that allows it to enabled or disabled on a non-volatile basis. SIM speed enhancement is now enabled by default.
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 24 May 2020 05:02:28 +0000
parents c41a534f33c6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 +-----------------------------------------------------------------------------
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 | Project : CCD
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 | Modul : csn1_sx.c
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 +-----------------------------------------------------------------------------
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 | Copyright 2002 Texas Instruments Berlin, AG
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 | All rights reserved.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 |
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 | This file is confidential and a trade secret of Texas
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 | Instruments Berlin, AG
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 | The receipt of or possession of this file does not convey
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 | any rights to reproduce or disclose its contents or to
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 | manufacture, use, or sell anything it may describe, in
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 | whole, or in part, without the specific written consent of
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 | Texas Instruments Berlin, AG.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 +-----------------------------------------------------------------------------
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 | Purpose : Definition of encoding and decoding functions for CSN1_S0 elements
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 +-----------------------------------------------------------------------------
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 * standard definitions like GLOBAL, UCHAR, ERROR etc.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #include "typedefs.h"
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 #include "header.h"
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 * Prototypes of ccd (USE_DRIVER EQ undef) for prototypes only
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 * look at ccdapi.h
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #undef USE_DRIVER
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "ccdapi.h"
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 * Types and functions for bit access and manipulation
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 #include "ccd_globs.h"
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 #include "bitfun.h"
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 * Prototypes of ccd internal functions
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 #include "ccd.h"
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 * Declaration of coder/decoder tables
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 #include "ccdtable.h"
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 #include "ccddata.h"
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 * Need memory allocation functions for dynamic arrays (pointers)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 #ifdef DYNAMIC_ARRAYS
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 #include "vsi.h"
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 #include <string.h>
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 #endif
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 #ifndef RUN_FLASH
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 +--------------------------------------------------------------------+
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 | PROJECT : CCD (6144) MODULE : CCD |
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 | STATE : code ROUTINE : cdc_csn1_sx_decode |
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 +--------------------------------------------------------------------+
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 PURPOSE : The encoded IE consists of one bit for presence flag and
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 a value part.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 In case of CSN1_S1 only if the flag bit is equal 1 the
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 value part will follow it.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 In case of CSN1_S0 only if the flag bit is equal 0 the
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 value part will follow it.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 SHORT cdc_csn1_sx_decode (int flag, const ULONG e_ref, T_CCD_Globs *globs)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 ULONG repeat, max_rep, act_offset;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 ULONG amount = 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 BOOL is_variable;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 ULONG cix_ref, num_prolog_steps, prolog_step_ref;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 #ifdef DYNAMIC_ARRAYS
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 U8 *old_pstruct = NULL;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 U8 *addr = NULL;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 #endif
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 #ifdef DEBUG_CCD
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 #ifndef CCD_SYMBOLS
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 TRACE_CCD (globs, "cdc_csn1_sx_decode()");
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 #else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 TRACE_CCD (globs, "cdc_csn1_sx_decode() %s", ccddata_get_alias((USHORT) e_ref, 1));
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 #endif
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 #endif
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 globs->SeekTLVExt = FALSE;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 cix_ref = melem[e_ref].calcIdxRef;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 num_prolog_steps = calcidx[cix_ref].numPrologSteps;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 prolog_step_ref = calcidx[cix_ref].prologStepRef;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 * If this element is conditional, check the condition.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 if (calcidx[cix_ref].numCondCalcs NEQ 0
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 AND ! ccd_conditionOK (e_ref, globs))
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 return 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 * If this element has a defined prologue
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 * we have to process it before decoding the bitstream.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 if (num_prolog_steps)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 ccd_performOperations (num_prolog_steps, prolog_step_ref, globs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 if (melem[e_ref].repType NEQ ' ')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 is_variable = ccd_calculateRep (e_ref, &repeat, &max_rep, globs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 /* Structured IE is to be handeled as bitstring.*/
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 if (melem[e_ref].repType == 's')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 repeat--;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 is_variable = FALSE;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 repeat = 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 #ifdef DYNAMIC_ARRAYS
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 * Check for pointer types; allocate memory if necessary.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 * May overwrite globs->pstruct (and initialize globs->pstructOffs to 0).
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 if ( is_pointer_type(e_ref) )
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 U32 cSize;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 * Find size to allocate;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 * - Read from mcomp or mvar according to type
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 cSize = (ULONG)((melem[e_ref].elemType EQ 'F' OR
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 melem[e_ref].elemType EQ 'R')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 ? mvar[melem[e_ref].elemRef].cSize
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 : mcomp[melem[e_ref].elemRef].cSize
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 ) * repeat;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 * Allocate additional memory
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 addr = (U8 *)DP_ALLOC( cSize, globs->alloc_head, DP_NO_FRAME_GUESS);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 /* If no memory, log error and return immediately */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 if (addr EQ NULL) {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 ccd_setError (globs, ERR_NO_MEM,
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 BREAK,
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 (USHORT) -1);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 return 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 memset (addr, 0, (size_t)cSize);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 * Memory allocated;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 #endif
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 if (melem[e_ref].elemType NEQ 'S')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 * Element is not a SPARE. Setup the struct pointer.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 globs->pstructOffs = melem[e_ref].structOffs;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 if (is_variable)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 UBYTE *addr_v_xxx = NULL;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 UBYTE *addr_c_xxx;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 UBYTE act_continue_array;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 if (melem[e_ref].optional)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 * For optional elements we must set the valid-flag,
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 * if there is at least one element in the message.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 * Therefore we store the address of the valid flag.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 /* Dynamic array addition.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 * Postpone optional flag setting for non-code transparent
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 * pointer types ('P', 'Q', 'R').
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 * For these types, the optional flag is the pointer itself.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 * These types cannot be set yet, as the pointer may be
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 * preceeded by a counter octet, a union tag id octet etc.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 if (melem[e_ref].elemType < 'P' OR melem[e_ref].elemType > 'R')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 addr_v_xxx = (UBYTE *) (globs->pstruct + globs->pstructOffs++);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 * For variable sized elements store the min-value
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 * as counter into the C-Structure (c_xxx).
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 addr_c_xxx = (UBYTE *) (globs->pstruct + globs->pstructOffs++);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 if (max_rep > 255)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 globs->pstructOffs++;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 * Store the initial offset
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 act_offset = (ULONG) globs->pstructOffs;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 #ifdef DYNAMIC_ARRAYS
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 if ( is_pointer_type(e_ref) )
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 * 1. Save old "globs->pstruct" variables
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 * 2. Store pointer to freshly allocated memory area in structure
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 * 3. Initialize pstruct to point to the freshly allocated memory area.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 * 4. Initialize pstructOffs to 0 to start decoding at offset 0
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 * in the new memory area.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 old_pstruct = globs->pstruct;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 *(U8 **)(globs->pstruct + globs->pstructOffs) = addr;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 globs->pstruct = addr;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 globs->pstructOffs = 0;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 #endif
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 * repType ='i':
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 * Repeat this element (if it is an array) until we detect a
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 * flag indicating absence.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 *
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 * repType ='v' and 'c':
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 * Repeat the IE and leave the loop.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 *
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 * In both cases we expect a 0 at first.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 if ((melem[e_ref].repType == 'v') || (melem[e_ref].repType == 'c'))
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 amount = repeat;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 repeat = 0;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249 act_continue_array = globs->continue_array;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250 globs->continue_array = TRUE;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 while (globs->continue_array)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 if (flag == 0xFF) /* CSN1_SH type*/
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256 if (bf_readBit(globs) != GET_HL_PREV(1))
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257 break;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
258 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 if (bf_readBit(globs) != flag)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262 break;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 * Flag is set, we must decode the element
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 cdc_decodeElemvalue (e_ref, &amount, globs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270 if (++repeat > max_rep)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 * Too many repetitions means error in encoded message.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 ccd_setError (globs, ERR_MAX_REPEAT,
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 BREAK,
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277 (USHORT) (globs->bitpos),
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278 (USHORT) -1);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 return 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 else if (melem[e_ref].repType EQ 'v')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283 repeat = amount;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 break;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287 * Recalculate the struct offset for repeatable IEs.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289 if (is_variable_type(e_ref))
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 globs->pstructOffs = (USHORT)(act_offset +
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292 (repeat * mvar[melem[e_ref].elemRef].cSize));
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296 globs->pstructOffs = (USHORT)(act_offset +
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 (repeat * mcomp[melem[e_ref].elemRef].cSize));
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
300 globs->continue_array = act_continue_array;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
301
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302 #ifdef DYNAMIC_ARRAYS
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
303 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304 * Restore globs->pstruct
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306 if (old_pstruct NEQ NULL)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308 globs->pstruct = old_pstruct;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310 #endif
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 if (addr_v_xxx NEQ NULL)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
313 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
314 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315 * For optional elements set the valid-flag
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316 * In this case the pointer addr_c_xxx does not mark
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
317 * the counter. It points to the valid flag.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
318 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
319 if (repeat > 0)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
320 *addr_v_xxx++ = (UBYTE) TRUE;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
321 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
322 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
323 * Store the number of digits into the c_xxx variable if there is one.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
324 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
325 if (max_rep > 65535)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
326 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
327 ULONG *addr_c_xxx_u32;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
328 addr_c_xxx_u32 = (ULONG *)addr_c_xxx;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
329 *addr_c_xxx_u32 = repeat;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
330 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
331 else if (max_rep > 255)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
332 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
333 USHORT *addr_c_xxx_u16;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
334 addr_c_xxx_u16 = (USHORT *)addr_c_xxx;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
335 *addr_c_xxx_u16 = (USHORT) repeat;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
336 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
337 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
338 *addr_c_xxx = (UBYTE) repeat;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
339 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
340 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
341 * IE is not defined as an array.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
342 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
343 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
344 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
345 BOOL elemPresent;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
346
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
347 if (flag == 0xFF)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
348 elemPresent = (bf_readBit(globs) EQ GET_HL_PREV(1));
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
349 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
350 elemPresent = (bf_readBit(globs) == flag);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
351
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
352 if (elemPresent)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
353 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
354 if (melem[e_ref].optional)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
355 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
356 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
357 * For optional elements set the valid-flag.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
358 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 globs->pstruct[globs->pstructOffs++] = (UBYTE) TRUE;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
360 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
361
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
362 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
363 * Flag is set, we must decode the element.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
364 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
365 cdc_decodeElemvalue (e_ref, &repeat, globs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
366 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
367 * process the epilogue expression for this element if there is any
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
368 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
369 if (num_prolog_steps)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
370 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
371 if ( (calc[prolog_step_ref+1].operation EQ 'K')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
372 || (calc[prolog_step_ref+1].operation EQ 'C')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
373 || (calc[prolog_step_ref+1].operation EQ 's'))
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
374 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
375 ccd_performOperations (num_prolog_steps, prolog_step_ref, globs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
376 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
377 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
378 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
379 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
380 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
381
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
382 return 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
383 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
384 #endif /* !RUN_FLASH */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
385
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
386 #ifndef RUN_FLASH
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
387 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
388 +--------------------------------------------------------------------+
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
389 | PROJECT : CCD (6144) MODULE : CDC_GSM |
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
390 | STATE : code ROUTINE : cdc_csn1_sx_encode |
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
391 +--------------------------------------------------------------------+
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
392
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
393 PURPOSE : Encoding of the CSN1 element.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
394 1) GSM Type CSN1 S1 element
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
395 This element consists of a 1 bit valid flag and a
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
396 value part. If the element is valid (the v_xxx
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
397 components is TRUE in the decoded message) a 1 bit will
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
398 be coded followed by the coding of the value part.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
399 Otherwise a 0 bit will be coded.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
400
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
401 2) GSM Type CSN1 S0 element
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
402 This element consists of a single bit valid flag and a
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
403 value part, too. But in this case the presence flag is
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
404 set to 0. If the element is present (the v_xxx component
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
405 is TRUE in the decoded message) a 0 bit will be coded
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
406 followed by the encoded value part. Otherwise a 1 bit
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
407 will be encoded.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
408 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
409
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
410 SHORT cdc_csn1_sx_encode (int flag, const ULONG e_ref, T_CCD_Globs *globs)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
411 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
412 ULONG i, repeat=1, amount=1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
413 USHORT cSize = 0, startOffset;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
414 int elemPresent;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
415 ULONG cix_ref, num_prolog_steps, prolog_step_ref;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
416 #ifdef DYNAMIC_ARRAYS
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
417 U8 *old_pstruct = NULL;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
418 #endif
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
419
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
420 #ifdef DEBUG_CCD
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
421 #ifndef CCD_SYMBOLS
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
422 TRACE_CCD (globs, "cdc_csn1_sx_encode()");
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
423 #else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
424 TRACE_CCD (globs, "cdc_csn1_sx_encode() %s", ccddata_get_alias((USHORT) e_ref, 1));
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
425 #endif
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
426 #endif
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
427
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
428 cix_ref = melem[e_ref].calcIdxRef;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
429 num_prolog_steps = calcidx[cix_ref].numPrologSteps;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
430 prolog_step_ref = calcidx[cix_ref].prologStepRef;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
431 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
432 * If this element is conditional, check the condition.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
433 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
434 if (calcidx[cix_ref].numCondCalcs NEQ 0
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
435 AND ! ccd_conditionOK (e_ref, globs))
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
436 return 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
437
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
438 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
439 * If this element has a defined prologue
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
440 * we have to process it before decoding the bitstream.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
441 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
442 if (num_prolog_steps)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
443 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
444 ccd_performOperations (num_prolog_steps, prolog_step_ref, globs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
445 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
446
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
447 if (melem[e_ref].elemType NEQ 'S')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
448 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
449 UBYTE act_continue_array;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
450
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
451 act_continue_array = globs->continue_array;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
452 globs->continue_array = TRUE;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
453 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
454 * Element is not a SPARE.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
455 * Setup the offset into the C-structure for this element
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
456 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
457 globs->pstructOffs = melem[e_ref].structOffs;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
458
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
459 if (melem[e_ref].optional)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
460 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
461 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
462 * For optional elements check the valid-flag in the C-struct.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
463 * Spare elements does not have a corresponding valid flag.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
464 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
465 /* Dynamic array addition.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
466 * Postpone optional flag setting for non-code transparent
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
467 * pointer types ('P', 'Q', 'R').
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
468 * For these types, the optional flag is the pointer itself.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
469 * These types cannot be set yet, as the pointer may be
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
470 * preceeded by a counter octet, a union tag id octet etc.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
471 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
472 if (melem[e_ref].elemType < 'P' OR melem[e_ref].elemType > 'R')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
473 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
474 if (globs->pstruct[globs->pstructOffs++] == FALSE)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
475 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
476 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
477 * The IE should not be present in the message so we code
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
478 * a single bit
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
479 * for CSN1_S1 as 0,
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
480 * for CSN1_S0 as 1 and
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
481 * for CSN1_SH as GET_HL(0)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
482 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
483 if (flag == 0xFF)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
484 elemPresent = GET_HL(0);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
485 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
486 elemPresent = flag ^ 0x00000001;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
487 bf_writeBit (elemPresent, globs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
488 return 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
489 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
490 #ifdef DEBUG_CCD
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
491 else if (globs->pstruct [melem[e_ref].structOffs] != TRUE)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
492 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
493 TRACE_CCD (globs, "Ambiguous value for valid flag!\n...assumed 1 for ccdID=%d",
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
494 e_ref);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
495 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
496 #endif
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
497 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
498 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
499
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
500 /* As a default amount =1 due to initialization. */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
501 if (melem[e_ref].repType EQ 'i')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
502 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
503 /* The actual number of elements belonging to the array is unknown.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
504 * The user should have written the desired number to the C-Structure
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
505 * (c_xxx). CCD reads the number of these variable repeatable elements
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
506 * out of this C-Structure (c_xxx) and encodes each element with a
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
507 * preceeding bit set to '0'. The last element is followed by a bit
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
508 * set to '1' to indicate the end of this array.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
509 * If the number of repeats given by the C-Structure exceeds the
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
510 * allowed value (maxRepeat) CCD gives a warning!
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
511 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
512 if (melem[e_ref].maxRepeat > 255)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
513 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
514 ULONG count = (ULONG) (* (USHORT *)(globs->pstruct + globs->pstructOffs++));
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
515 repeat = MINIMUM (count, (ULONG) melem[e_ref].maxRepeat);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
516 if (repeat < count)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
517 ccd_recordFault (globs, ERR_MAX_REPEAT, CONTINUE,
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
518 (USHORT) e_ref, globs->pstruct + globs->pstructOffs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
519 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
520 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
521 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
522 repeat = (ULONG) MINIMUM (globs->pstruct[globs->pstructOffs],
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
523 melem[e_ref].maxRepeat);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
524 if ( repeat < (ULONG) (globs->pstruct[globs->pstructOffs]) )
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
525 ccd_recordFault (globs, ERR_MAX_REPEAT, CONTINUE,
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
526 (USHORT) e_ref, globs->pstruct + globs->pstructOffs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
527 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
528 amount = 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
529 globs->pstructOffs++;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
530 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
531 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
532 if (melem[e_ref].repType EQ 'v')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
533 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
534 /* The number of elements belonging to the array depends on the value
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
535 * of another element. The user should have written this number to the
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
536 * C-Structure (c_xxx).
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
537 * CCD reads the number of these variable repeatable elements out of
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
538 * this C-Structure (c_xxx).
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
539 * If the number of repetitions given by the C-Structure exceeds the
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
540 * allowed value (maxRepeat) CCD gives a warning!
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
541 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
542 if (melem[e_ref].maxRepeat > 255)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
543 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
544 ULONG count = (ULONG) (* (USHORT *)(globs->pstruct + globs->pstructOffs++));
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
545 amount = MINIMUM (count, (ULONG) melem[e_ref].maxRepeat);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
546 if (amount < count)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
547 ccd_recordFault (globs, ERR_MAX_REPEAT, CONTINUE,
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
548 (USHORT) e_ref, globs->pstruct + globs->pstructOffs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
549 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
550 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
551 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
552 amount = (ULONG)MINIMUM (globs->pstruct[globs->pstructOffs],
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
553 melem[e_ref].maxRepeat);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
554 if ( amount < (ULONG) (globs->pstruct[globs->pstructOffs]) )
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
555 ccd_recordFault (globs, ERR_MAX_REPEAT, CONTINUE,
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
556 (USHORT) e_ref, globs->pstruct + globs->pstructOffs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
557 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
558 repeat = 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
559 globs->pstructOffs++;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
560 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
561 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
562 if (melem[e_ref].repType EQ 'c')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
563 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
564 amount = (ULONG) melem[e_ref].maxRepeat;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
565 repeat = 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
566 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
567 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
568 if (melem[e_ref].repType == 's')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
569 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
570 BOOL is_variable;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
571 ULONG max_rep;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
572
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
573 is_variable = ccd_calculateRep (e_ref, &repeat, &max_rep, globs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
574 /* Substract one bit which will be spent on the (CSN.1) flag. */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
575 amount = repeat - 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
576 repeat = 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
577 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
578 if (melem[e_ref].repType EQ 'v' OR melem[e_ref].repType EQ 'i')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
579 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
580 cSize = (USHORT)((melem[e_ref].elemType EQ 'V' OR
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
581 melem[e_ref].elemType EQ 'R' OR melem[e_ref].elemType EQ 'F')
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
582 ? mvar[melem[e_ref].elemRef].cSize
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
583 : mcomp[melem[e_ref].elemRef].cSize
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
584 );
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
585
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
586 startOffset = (USHORT) globs->pstructOffs;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
587 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
588
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
589 /* Dynamic array addition.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
590 * Check for non-code transparent pointer types ('P', 'Q', 'R').
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
591 * For these types, the optional flag is the pointer itself.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
592 * ASSUMPTION: The pointer may be preceeded by a counter octet,
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
593 * a union tag id octet etc., but it is up to CCDGEN to ensure
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
594 * word alignment (by inserting alignment bytes). Therefore
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
595 * we just read from globs->pstruct[globs->pstructOffs].
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
596 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
597 #ifdef DEBUG_CCD
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
598 /* Check pointer alignment and re-align if necessary (should never happen) */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
599 if ( is_pointer_type(e_ref) AND ((globs->pstructOffs & 3) NEQ 0)) {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
600 TRACE_CCD (globs, "cdc_csn1_sx_encode(): Pointer misaligned! pstruct=0x08x,"
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
601 " pstructOffs=0x%08x", globs->pstruct, globs->pstructOffs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
602 globs->pstructOffs = (globs->pstructOffs + 3) & 3;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
603 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
604 #endif
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
605 #ifdef DYNAMIC_ARRAYS
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
606 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
607 * Perform pointer dereference for pointer types.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
608 * Also, check optionality for these types.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
609 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
610 if ( is_pointer_type(e_ref) ) {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
611 U8 *deref_pstruct;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
612
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
613 /* Get pointer value */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
614 deref_pstruct = *(U8 **)&globs->pstruct[globs->pstructOffs];
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
615
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
616 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
617 * Strictly speaking the 'D' to 'F' types should not need this
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
618 * check (should have returned after the optionality check above),
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
619 * but it will catch stray NULL pointers (or uninitialized
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
620 * valid flags)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
621 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
622 if (ccd_check_pointer(deref_pstruct) != ccdOK )
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
623 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
624 ccd_recordFault (globs, ERR_INVALID_PTR, BREAK, (USHORT) e_ref,
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
625 &globs->pstruct[globs->pstructOffs]);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
626 return 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
627 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
628 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
629 * Pointer not NULL;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
630 * 1. Save old globs->pstruct and assign pointer to globs->pstruct
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
631 * as new base.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
632 * 2. Set pstructOffs to 0 (zero) as the next offset will start
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
633 * in the new memory area.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
634 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
635 old_pstruct = globs->pstruct;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
636 globs->pstruct = deref_pstruct;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
637 startOffset = 0;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
638 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
639 #endif /* DYNAMIC_ARRAYS */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
640
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
641 for (i=0; i < repeat; i++)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
642 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
643 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
644 * The IE should be present in the message so we code 0 bit.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
645 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
646 if (flag == 0xFF)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
647 elemPresent = GET_HL(1);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
648 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
649 elemPresent = flag;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
650
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
651 bf_writeBit (elemPresent, globs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
652 if (cSize)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
653 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
654 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
655 * Calculate the offset if it is an array.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
656 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
657 globs->pstructOffs = (USHORT)(startOffset + (i * cSize));
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
658 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
659 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
660 * Encode the value.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
661 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
662 cdc_encodeElemvalue (e_ref, amount, globs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
663 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
664
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
665 #ifdef DYNAMIC_ARRAYS
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
666 if ( old_pstruct NEQ NULL )
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
667 globs->pstruct = old_pstruct;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
668 #endif
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
669
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
670 if ((melem[e_ref].repType == 'i') && (globs->continue_array == TRUE))
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
671 {
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
672 /*
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
673 * For fields of variable length we code a 1 flag
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
674 * to mark the end of the array.
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
675 */
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
676 if (flag == 0xFF)
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
677 elemPresent = GET_HL(0);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
678 else
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
679 elemPresent = flag ^ 0x00000001;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
680 bf_writeBit (elemPresent, globs);
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
681 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
682 globs->continue_array = act_continue_array;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
683 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
684
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
685 return 1;
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
686 }
c41a534f33c6 src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
687 #endif /* !RUN_FLASH */