FreeCalypso > hg > freecalypso-citrine
comparison ccd/gsm5_v.c @ 0:75a11d740a02
initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Thu, 09 Jun 2016 00:02:41 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:75a11d740a02 |
|---|---|
| 1 /* | |
| 2 +----------------------------------------------------------------------------- | |
| 3 | Project : | |
| 4 | Modul : gsm5_v.c | |
| 5 +----------------------------------------------------------------------------- | |
| 6 | Copyright 2002 Texas Instruments Berlin, AG | |
| 7 | All rights reserved. | |
| 8 | | |
| 9 | This file is confidential and a trade secret of Texas | |
| 10 | Instruments Berlin, AG | |
| 11 | The receipt of or possession of this file does not convey | |
| 12 | any rights to reproduce or disclose its contents or to | |
| 13 | manufacture, use, or sell anything it may describe, in | |
| 14 | whole, or in part, without the specific written consent of | |
| 15 | Texas Instruments Berlin, AG. | |
| 16 +----------------------------------------------------------------------------- | |
| 17 | Purpose : Definition of encoding and decoding functions for GSM5_V elements | |
| 18 +----------------------------------------------------------------------------- | |
| 19 */ | |
| 20 | |
| 21 | |
| 22 /* | |
| 23 * standard definitions like GLOBAL, UCHAR, ERROR etc. | |
| 24 */ | |
| 25 #include "typedefs.h" | |
| 26 #include "header.h" | |
| 27 | |
| 28 /* | |
| 29 * Prototypes of ccd (USE_DRIVER EQ undef) for prototypes only | |
| 30 * look at ccdapi.h | |
| 31 */ | |
| 32 #undef USE_DRIVER | |
| 33 #include "ccdapi.h" | |
| 34 | |
| 35 /* | |
| 36 * Types and functions for bit access and manipulation | |
| 37 */ | |
| 38 #include "ccd_globs.h" | |
| 39 #include "bitfun.h" | |
| 40 | |
| 41 /* | |
| 42 * Prototypes of ccd internal functions | |
| 43 */ | |
| 44 #include "ccd.h" | |
| 45 | |
| 46 /* | |
| 47 * Declaration of coder/decoder tables | |
| 48 */ | |
| 49 #include "ccdtable.h" | |
| 50 #include "ccddata.h" | |
| 51 | |
| 52 #ifndef RUN_INT_RAM | |
| 53 /* | |
| 54 +--------------------------------------------------------------------+ | |
| 55 | PROJECT : CCD (6144) MODULE : CDC_GSM | | |
| 56 | STATE : code ROUTINE : cdc_gsm5v_decode | | |
| 57 +--------------------------------------------------------------------+ | |
| 58 | |
| 59 PURPOSE : Decoding of the GSM Type 5V element. This element | |
| 60 consists of the not decoded bits of the bitstream. | |
| 61 In the target C-structure this element is a bitbuffer | |
| 62 (T_xxx_BUF) in wich the bitstream content are written. | |
| 63 | |
| 64 */ | |
| 65 | |
| 66 SHORT cdc_gsm5v_decode (const ULONG c_ref, const ULONG e_ref, T_CCD_Globs *globs) | |
| 67 { | |
| 68 #ifdef DEBUG_CCD | |
| 69 #ifndef CCD_SYMBOLS | |
| 70 TRACE_CCD (globs, "cdc_gsm5v_decode()"); | |
| 71 #else | |
| 72 TRACE_CCD (globs, "cdc_gsm5v_decode() %s", ccddata_get_alias((USHORT) e_ref, 1)); | |
| 73 #endif | |
| 74 #endif | |
| 75 | |
| 76 if (globs->bitpos >= globs->buflen) | |
| 77 { | |
| 78 return 1; | |
| 79 } | |
| 80 else | |
| 81 { | |
| 82 ULONG cix_ref; | |
| 83 | |
| 84 cix_ref = melem[e_ref].calcIdxRef; | |
| 85 | |
| 86 /* | |
| 87 * if this element is conditional, check the condition | |
| 88 */ | |
| 89 if (calcidx[cix_ref].numCondCalcs NEQ 0 | |
| 90 AND ! ccd_conditionOK (e_ref, globs)) | |
| 91 { | |
| 92 return 1; | |
| 93 } | |
| 94 else | |
| 95 { | |
| 96 ULONG bits_to_read; | |
| 97 ULONG num_prolog_steps, prolog_step_ref; | |
| 98 | |
| 99 num_prolog_steps = calcidx[cix_ref].numPrologSteps; | |
| 100 prolog_step_ref = calcidx[cix_ref].prologStepRef; | |
| 101 | |
| 102 /* If there is a prologue given for this element, process it. */ | |
| 103 if (num_prolog_steps) | |
| 104 { | |
| 105 ccd_performOperations (num_prolog_steps, prolog_step_ref, globs); | |
| 106 } | |
| 107 | |
| 108 /* | |
| 109 * Setup the offset into the C-structure for this element | |
| 110 */ | |
| 111 globs->pstructOffs = melem[e_ref].structOffs; | |
| 112 | |
| 113 if (melem[e_ref].optional) | |
| 114 { | |
| 115 /* | |
| 116 * for optional elements set the valid-flag in the C-struct. | |
| 117 */ | |
| 118 globs->pstruct[globs->pstructOffs++] = TRUE; | |
| 119 } | |
| 120 | |
| 121 if (globs->maxBitpos < globs->buflen - 16*globs->numEOCPending) | |
| 122 { | |
| 123 ccd_recordFault (globs, ERR_LEN_MISMATCH, CONTINUE, (USHORT) e_ref, | |
| 124 globs->pstruct + globs->pstructOffs); | |
| 125 } | |
| 126 | |
| 127 bits_to_read = (ULONG)(globs->buflen - globs->bitpos - 16*globs->numEOCPending); | |
| 128 bf_readBitChunk (bits_to_read, globs); | |
| 129 } | |
| 130 } | |
| 131 | |
| 132 return 1; | |
| 133 } | |
| 134 #endif /* !RUN_INT_RAM */ | |
| 135 | |
| 136 #ifndef RUN_INT_RAM | |
| 137 /* | |
| 138 +--------------------------------------------------------------------+ | |
| 139 | PROJECT : CCD (6144) MODULE : CDC_GSM | | |
| 140 | STATE : code ROUTINE : cdc_gsm5v_encode | | |
| 141 +--------------------------------------------------------------------+ | |
| 142 | |
| 143 PURPOSE : Encoding of the GSM Type 5V element. This element | |
| 144 consists of the not decoded bits of the bitstream. | |
| 145 In the target C-structure this element is a bitbuffer | |
| 146 (T_xxx_BUF) from wich the bitstream content is read. | |
| 147 | |
| 148 */ | |
| 149 | |
| 150 SHORT cdc_gsm5v_encode (const ULONG c_ref, const ULONG e_ref, T_CCD_Globs *globs) | |
| 151 { | |
| 152 ULONG cix_ref, num_prolog_steps, prolog_step_ref; | |
| 153 | |
| 154 #ifdef DEBUG_CCD | |
| 155 #ifndef CCD_SYMBOLS | |
| 156 TRACE_CCD (globs, "cdc_gsm5v_encode()"); | |
| 157 #else | |
| 158 TRACE_CCD (globs, "cdc_gsm5v_encode() %s", ccddata_get_alias((USHORT) e_ref, 1)); | |
| 159 #endif | |
| 160 #endif | |
| 161 | |
| 162 cix_ref = melem[e_ref].calcIdxRef; | |
| 163 num_prolog_steps = calcidx[cix_ref].numPrologSteps; | |
| 164 prolog_step_ref = calcidx[cix_ref].prologStepRef; | |
| 165 | |
| 166 /* | |
| 167 * if this element is conditional, check the condition | |
| 168 */ | |
| 169 if (calcidx[cix_ref].numCondCalcs NEQ 0 | |
| 170 AND ! ccd_conditionOK (e_ref, globs)) | |
| 171 return 1; | |
| 172 | |
| 173 /* | |
| 174 * if this element have a defined Prolog | |
| 175 * we have to process it before decoding the bitstream | |
| 176 */ | |
| 177 if (num_prolog_steps) | |
| 178 { | |
| 179 ccd_performOperations (num_prolog_steps, prolog_step_ref, globs); | |
| 180 } | |
| 181 | |
| 182 /* | |
| 183 * Setup the offset into the C-structure for this element | |
| 184 */ | |
| 185 globs->pstructOffs = melem[e_ref].structOffs; | |
| 186 | |
| 187 if (melem[e_ref].optional) | |
| 188 { | |
| 189 /* | |
| 190 * for optional elements check the valid-flag in the C-struct. | |
| 191 * Spare elements does not have a corresponding valid flag. | |
| 192 */ | |
| 193 if (globs->pstruct[globs->pstructOffs++] == FALSE) | |
| 194 { | |
| 195 return 1; | |
| 196 } | |
| 197 #ifdef DEBUG_CCD | |
| 198 else if (globs->pstruct [melem[e_ref].structOffs] != TRUE) | |
| 199 { | |
| 200 TRACE_CCD (globs, "Ambiguous value for valid flag!\n...assumed 1 for ccdID=%d", | |
| 201 e_ref); | |
| 202 } | |
| 203 #endif | |
| 204 } | |
| 205 | |
| 206 bf_writeBitChunk (mvar[melem[e_ref].elemRef].bSize, globs); | |
| 207 | |
| 208 return 1; | |
| 209 } | |
| 210 #endif /* !RUN_INT_RAM */ |
