FreeCalypso > hg > fc-magnetite
annotate src/gpf3/ccd/asn1_integ_ext.c @ 610:0cbe7438f974
armio.c: GPIO config for GTM900 and long-standing GPIO 1 fix
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 17 Jun 2019 21:48:54 +0000 |
parents | c41a534f33c6 |
children |
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 : |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 | Modul : asn1_integ_ext.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 : Encoding and decoding functions for ASN1_INTEGER_EXTENSIBLE type |
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 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 * Standard definitions like UCHAR, ERROR etc. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "typedefs.h" |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 #include "header.h" |
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 and constants in the common part of ccd |
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 #ifndef RUN_INT_RAM |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 /* |
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 | PROJECT : CCD (6144) MODULE : asn1_integ_ext | |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 | STATE : code ROUTINE : cdc_asn1_integ_ext_decode | |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 +------------------------------------------------------------------------+ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 PURPOSE : Decode UNALIGNED PER extensible ENUMERATED and INTEGER type |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 PER-visible constraints restrict the integer value to be a |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 constrained whole number. This gives a lower and an upper |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 bound for the integer. The lb is also called offset. The |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 encoded value is the difference between the actual and the |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 offset value. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 A possible and meant default value is never encoded. |
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 If the value is in the extension root, it will be encoded as |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 a normally small non-negative whole number. Otherwise it will |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 be encoded in the smalles number of bits needed to express |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 every enumeration. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 SHORT cdc_asn1_integ_ext_decode (const ULONG c_ref, 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
|
72 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 ULONG repeat=1, max_rep=1, var_ref, val_ref; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 BOOL DefaultFound= FALSE; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 S32 IfnotPresent; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 UBYTE *value, *old_pstruct = NULL; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 var_ref = (ULONG) melem[e_ref].elemRef; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 #ifdef DEBUG_CCD |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 #ifndef CCD_SYMBOLS |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 TRACE_CCD (globs, "cdc_asn1_integ_ext_decode()"); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 #else |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 TRACE_CCD (globs, "cdc_asn1_integ_ext_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
|
85 #endif |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 #endif |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 * For integer with only one possible value in the extension root: |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 * If the extensinon bit is 0, the encoded value is in the extension root. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 * In this case no arrays are expected. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 * For other types: |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 * The extension bit and the value will be read in the while-loop below. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 if (mvar[var_ref].bSize EQ 0) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 if (bf_readBit (globs) EQ FALSE) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 Read_unique_Integer (e_ref, globs); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 return 1; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 else |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 bf_incBitpos (-1, globs); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 } |
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 val_ref = (ULONG) mvar[var_ref].valueDefs; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 * Set pstrcutOffs and max_rep. Check the valid flag in case of optional elements. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 if (PER_CommonBegin (e_ref, &max_rep, globs) NEQ ccdOK) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 return 1; |
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 #ifdef DYNAMIC_ARRAYS |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 * Allocate memory if this is a pointer type (dynamic array) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 if ( is_pointer_type(e_ref) ) { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 old_pstruct = globs->pstruct; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 if ( PER_allocmem_and_update(e_ref, max_rep, globs) NEQ ccdOK) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 /* No memory - Return. Error already set in function call above. */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 return 1; |
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 #endif |
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 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 * Check if there is a default value for the element. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 * If yes, just set it aside for a later comparision. |
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 if (mval[val_ref+1].isDefault EQ 2) |
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 IfnotPresent = mval[val_ref+1].startValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 DefaultFound = TRUE; |
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 |
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 * Decode all elements of the array. |
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 while ( repeat <= max_rep) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 value = globs->pstruct + globs->pstructOffs; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 * There is a default value for this integer elment. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 * While decoding of the ASN1-SEQUENCE contiaing this integer |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 * we have used a particular byte of C-structure to signalize |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 * the decoding of a default value (byte set to 0). |
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 if (DefaultFound AND !globs->pstruct[melem[e_ref].structOffs]) |
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 switch (mvar[var_ref].cType) |
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 case 'B': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 *(U8*) value = (U8) IfnotPresent; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 case 'C': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 *(S8*) value = (S8) IfnotPresent; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 case 'S': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 *(U16*) value = (U16) IfnotPresent; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 case 'T': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 *(S16*) value = (S16) IfnotPresent; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 case 'L': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 *(U32*) value = (U32) IfnotPresent; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 case 'M': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 *(S32*) value = (S32) IfnotPresent; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 default: |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 ccd_recordFault (globs,ERR_DEFECT_CCDDATA, BREAK, (USHORT) e_ref, value); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 } |
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 * There is no default value defined for this integer elment. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 * Read the value from the bit buffer. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 else |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 U32 ub, lb; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 ULONG readBits; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 U32 DecodedValue; |
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 lb = mval[val_ref].startValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 ub = mval[val_ref].endValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 * Read first the extensinon bit. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 * Then the non-negative value from the air message. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 if (bf_readBit (globs) EQ FALSE) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 readBits = bf_getBits (mvar[var_ref].bSize, globs); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 /* Value out of the extension root. */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 else |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 U16 calcRef = calcidx[melem[e_ref].calcIdxRef].condCalcRef; |
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 * Get max value of integer within the extension root. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 if (calcRef EQ NO_REF |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 OR |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 calc[calcRef].operation NEQ 'P') |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 ccd_recordFault (globs, ERR_DEFECT_CCDDATA, BREAK, (USHORT) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 e_ref, globs->pstruct+globs->pstructOffs); |
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 else |
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 lb = calc[calcRef].operand; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 readBits = Read_NormallySmallNonNegativeWholeNr (globs); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 |
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 if (readBits <= (U32)(ub - lb)) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 DecodedValue = lb + readBits; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 * Add the offset to the read value to get the actual one. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 switch (mvar[var_ref].cType) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 case 'B': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 *(U8*) value = (U8) DecodedValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 case 'C': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 *(S8*) value = (S8) DecodedValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 case 'S': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 *(U16*) value = (U16) DecodedValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 case 'T': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 *(S16*) value = (S16) DecodedValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 case 'L': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 *(U32*) value = (U32) DecodedValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 case 'M': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 *(S32*) value = (S32) DecodedValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 default: |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 ccd_recordFault (globs,ERR_DEFECT_CCDDATA, BREAK, (USHORT) e_ref, value); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 else |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 #ifdef DEBUG_CCD |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 TRACE_CCD (globs, "integer out of range! %ld require: %ld .. %ld ", DecodedValue, lb, ub); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 #endif |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 if (melem[e_ref].optional) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 ccd_recordFault (globs, ERR_ASN1_OPT_IE, CONTINUE, (USHORT) e_ref, value); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 else |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 ccd_recordFault (globs, ERR_ASN1_MAND_IE, CONTINUE, (USHORT) e_ref, value); |
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 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 repeat ++; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 globs->pstructOffs += mvar[var_ref].cSize; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 }/*while*/ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 #ifdef DYNAMIC_ARRAYS |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 if (old_pstruct NEQ NULL) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 globs->pstruct = old_pstruct; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 #endif |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 return 1; |
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 #endif /* !RUN_INT_RAM */ |
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 #ifndef RUN_INT_RAM |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 +------------------------------------------------------------------------+ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 | PROJECT : CCD (6144) MODULE : asn1_integ_ext | |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 | STATE : code ROUTINE : cdc_asn1_integ_ext_encode | |
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 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 PURPOSE : UNALIGNED PER extensible ENUMERATED and INTEGER type |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 PER-visible constraints restrict the integer value to be a |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 constrained whole number. This gives a lower and an upper |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 bound for the integer. The lb is also called offset. The |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 encoded value is the difference between the actual and the |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 offset value. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 A possible and meant default value is never encoded. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 If the value is in the extension root, it will be encoded as |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 a normally small non-negative whole number. Otherwise it will |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 be encoded in the smalles number of bits needed to express |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 every enumeration. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 |
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 | extension | value encoded as a normally | |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 | bit = 1 | non-negtive integer whole number | |
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 ----------------------------------------------- |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 | extension | value encoded in the bit size | |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 | bit = 0 | needed to express ub - lb | |
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 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 SHORT cdc_asn1_integ_ext_encode (const ULONG c_ref, 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
|
306 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 ULONG repeat=1, max_rep=1, var_ref, val_ref; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 BOOL DefaultFound= FALSE; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 S32 IfnotPresent; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 U8 *base_pstruct; |
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 #ifdef DEBUG_CCD |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 #ifndef CCD_SYMBOLS |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 TRACE_CCD (globs, "cdc_asn1_integ_ext_encode()"); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 #else |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 TRACE_CCD (globs, "cdc_asn1_integ_ext_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
|
317 #endif |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 #endif |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 var_ref = (ULONG) melem[e_ref].elemRef; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 val_ref = (ULONG) mvar[var_ref].valueDefs; |
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 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 * Set pstrcutOffs and max_rep. Check the valid flag in case of optional elements. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 if (PER_CommonBegin (e_ref, &max_rep, globs) NEQ ccdOK) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 return 1; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 * Check if there is a default value for the element. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 * If yes, just set it aside for a later comparision. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 if (mval[val_ref+1].isDefault EQ 2) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 IfnotPresent = mval[val_ref+1].startValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 DefaultFound = TRUE; |
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 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 #ifdef DYNAMIC_ARRAYS |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 if ( is_pointer_type(e_ref) ) |
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 base_pstruct = *(U8 **)(globs->pstruct + globs->pstructOffs); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 if (ccd_check_pointer(base_pstruct) == ccdOK) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 globs->pstructOffs = 0; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 else |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 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
|
349 &globs->pstruct[globs->pstructOffs]); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 return 1; |
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 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 else |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 #endif |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 base_pstruct = globs->pstruct; |
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 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 * Encode all elements of the array. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 while ( repeat <= max_rep) |
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 S32 ub, lb, value; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 U32 extension_lb; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 UBYTE *p; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 U16 calcRef = calcidx[melem[e_ref].calcIdxRef].condCalcRef; |
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 * Get offset value of integer in the extension addition. |
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 (calcRef EQ NO_REF |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 OR |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 calc[calcRef].operation NEQ 'P') |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 ccd_recordFault (globs, ERR_DEFECT_CCDDATA, BREAK,(USHORT) e_ref, |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 globs->pstruct+globs->pstructOffs); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 return 1; |
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 else |
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 extension_lb = calc[calcRef].operand; |
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 * setup the read pointer to the element in the C-structure |
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 p = base_pstruct + globs->pstructOffs; |
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 switch (mvar[var_ref].cType) |
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 case 'B': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 value = (S32)*(UBYTE *) p; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 case 'C': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 value = (S32)*(S8 *) p; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 case 'S': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 value = (S32)*(USHORT *) p; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
397 case 'T': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
398 value = (S32)*(S16 *) p; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
399 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
400 case 'L': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
401 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
402 * This type casting can be critical. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
403 * Thus the case of bSize=32 will be handled separately. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
404 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
405 if (mvar[var_ref].bSize < 32) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
406 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
407 value = (S32)*(U32 *) p; |
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 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
410 case 'M': |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
411 value = *(S32 *) p; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
412 break; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
413 default: |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
414 ccd_recordFault (globs,ERR_DEFECT_CCDDATA, BREAK, (USHORT) e_ref, p); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
415 return 1; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
416 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
417 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
418 if (mvar[var_ref].cType EQ 'L' AND |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
419 (mvar[var_ref].bSize EQ 32)) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
420 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
421 U32 CriticalValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
422 CriticalValue = *(U32 *) p; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
423 if (CriticalValue >= extension_lb) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
424 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
425 bf_writeBit (1, globs); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
426 if (!DefaultFound OR (U32)IfnotPresent NEQ CriticalValue) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
427 Write_NormallySmallNonNegativeWholeNr (CriticalValue - extension_lb, globs); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
428 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
429 else |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
430 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
431 bf_writeBit (0, globs); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
432 if (!DefaultFound OR (U32)IfnotPresent NEQ CriticalValue) |
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 U32 lb, ub; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
435 lb = (U32) mval[val_ref].startValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
436 ub = (U32) mval[val_ref].endValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
437 if (lb <= CriticalValue && CriticalValue <= ub) |
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 bf_writeVal (CriticalValue - lb, mvar[var_ref].bSize, globs); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
440 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
441 else |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
442 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
443 #ifdef DEBUG_CCD |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
444 TRACE_CCD (globs, "integer out of range! %ld require: %ld .. %ld ", |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
445 value, lb, ub); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
446 #endif |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
447 ccd_recordFault (globs, ERR_INT_VALUE, CONTINUE, (USHORT) e_ref, p); |
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 } |
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 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
452 else |
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 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
455 * Encode only non-default values. |
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 if (!DefaultFound OR IfnotPresent NEQ value) |
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 /* |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
460 * Set the extension bit to 0 if the value belongs to the extension root. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
461 * Otherwise set it to 1. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
462 * A non-negative-binary-integer will be encoded since the offset must |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
463 * be subtracted from the value read from the C-structure. |
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 lb = mval[val_ref].startValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
466 ub = mval[val_ref].endValue; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
467 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
468 if (value >= (S32)extension_lb AND value <= ub) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
469 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
470 bf_writeBit (1, globs); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
471 Write_NormallySmallNonNegativeWholeNr ((U32)value - extension_lb, globs); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
472 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
473 else if (lb <= value AND value <= ub) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
474 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
475 bf_writeBit (0, globs); |
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 * Do not encode single valued extension roots. |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
478 */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
479 if (mvar[var_ref].bSize NEQ 0) |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
480 bf_writeVal ((ULONG)(value-lb), mvar[var_ref].bSize, globs); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
481 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
482 else |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
483 { |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
484 #ifdef DEBUG_CCD |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
485 TRACE_CCD (globs, "integer out of range! %ld require: %ld .. %ld ", value, lb, ub); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
486 #endif |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
487 ccd_recordFault (globs, ERR_INT_VALUE, CONTINUE, (USHORT) e_ref, p); |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
488 } |
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 } /* value not critical*/ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
491 repeat ++; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
492 globs->pstructOffs += mvar[var_ref].cSize; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
493 }/* while-loop */ |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
494 |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
495 return 1; |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
496 } |
c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
497 #endif /* !RUN_INT_RAM */ |