comparison src/g23m-gprs/cci/cci_hw_sim.c @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul : cci_hw_sim.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 : This module implements hardware simulation functions for
18 | entity CCI.
19 +-----------------------------------------------------------------------------
20 */
21
22
23 #define CCI_HW_SIM_C
24
25 #define ENTITY_LLC
26
27 /*==== INCLUDES =============================================================*/
28 #include <string.h> /* to get memmove */
29
30 #include "typedefs.h" /* to get Condat data types */
31 #include "vsi.h" /* to get a lot of macros */
32 #include "macdef.h"
33 #include "gprs.h"
34 #include "gsm.h" /* to get a lot of macros */
35 #include "cnf_llc.h" /* to get cnf-definitions */
36 #include "mon_llc.h" /* to get mon-definitions */
37 #include "prim.h" /* to get the definitions of used SAP and directions */
38 #include "cci.h" /* to get the global entity definitions */
39 #include "llc.h" /* to get the global entity definitions */
40
41 #include "cci_hw_sim.h"
42
43 #include "llc_f.h" /* to get llc_build_crc24() */
44
45 /*==== CONST ================================================================*/
46
47 /*==== LOCAL VARS ===========================================================*/
48
49 /*==== PRIVATE FUNCTIONS ====================================================*/
50
51 /*==== PUBLIC FUNCTIONS =====================================================*/
52
53 #ifdef _GEA_SIMULATION_
54
55
56 /*
57 +------------------------------------------------------------------------------
58 | Function : ciph_hw_sim_cipher
59 +------------------------------------------------------------------------------
60 | Description : This functionn simulates the hardware during ciphering process
61 |
62 | Parameters : void
63 |
64 +------------------------------------------------------------------------------
65 */
66 GLOBAL void ciph_hw_sim_cipher (U16 len)
67 {
68 /*
69 * first move data one byte, if requested
70 */
71
72 if( *cci_data->fbs.conf_ul_reg1 & INPUT_SHIFT )
73 {
74 memmove (cci_data->fbs.simulated_reg_buffer, /* dest */
75 cci_data->fbs.simulated_reg_buffer+1, /* src */
76 len);
77 }
78
79 {
80 #ifdef _SIM_CALC_FCS_
81 ULONG fcs;
82
83 /*
84 * Build FCS (function returns already inversed CRC), store result in fcs.
85 */
86 fcs = llc_build_crc24 (cci_data->fbs.simulated_reg_buffer,
87 len);
88 /*
89 * Copy FCS to HW registers, taking byte ordering of FCS registers
90 * into account, e.g.:
91 * fcs reg1 reg2
92 * xx 36 29 FC -> 29 FC xx 36
93 */
94 *cci_data->fbs.fcs_ul_reg1 = (USHORT) (fcs & 0x0000FFFFL);
95 *cci_data->fbs.fcs_ul_reg2 = (USHORT)((fcs & 0x00FF0000L) >> 16);
96 #else
97 /*
98 * Set FCS to all zeroes in simulation.
99 */
100 *cci_data->fbs.fcs_ul_reg1 = 0x0000;
101 *cci_data->fbs.fcs_ul_reg2 = 0x0000;
102 #endif /* _SIM_CALC_FCS_ */
103 }
104 /*
105 * HW simulation: set status register to indicate finished work and emulate
106 * timer afterwards.
107 */
108 *cci_data->fbs.status_reg &= NOT_WORKING;
109
110 } /* ciph_hw_sim_cipher */
111
112 /*
113 +------------------------------------------------------------------------------
114 | Function : ciph_hw_sim_decipher
115 +------------------------------------------------------------------------------
116 | Description : This functionn simulates the hardware during deciphering process
117 |
118 | Parameters : void
119 |
120 +------------------------------------------------------------------------------
121 */
122 GLOBAL void ciph_hw_sim_decipher ( void )
123 {
124 /*
125 * set all registers to indicate finished work.
126 * FCS will be checked later.
127 */
128 *cci_data->fbs.fcs_dl_reg1 &= 0x0000;
129 *cci_data->fbs.fcs_dl_reg2 &= 0x0000;
130
131 *cci_data->fbs.status_reg &= NOT_WORKING;
132
133 } /* ciph_hw_sim_decipher */
134
135
136
137 /*
138 +------------------------------------------------------------------------------
139 | Function : ciph_reg16_write_sim
140 +------------------------------------------------------------------------------
141 | Description : This function simulates the hardware writing process on windows
142 | environment
143 |
144 | Parameters : void
145 |
146 +------------------------------------------------------------------------------
147 */
148 GLOBAL void ciph_reg16_write_sim ( void )
149 {
150 UBYTE *data = (UBYTE *)cci_data->fbs.data16_reg;;
151
152 /*
153 * To support any alignment the copy process must be done in two steps
154 * by the use of 8 bit char pointers
155 */
156 *cci_data->fbs.simulated_reg = *data;
157 cci_data->fbs.simulated_reg++;
158
159 data++;
160
161 *cci_data->fbs.simulated_reg = *data;
162 cci_data->fbs.simulated_reg++;
163
164 } /* ciph_reg16_write_sim */
165
166
167
168
169 /*
170 +------------------------------------------------------------------------------
171 | Function : ciph_reg8_write_sim
172 +------------------------------------------------------------------------------
173 | Description : This function simulates the 8 bit hardware writing process
174 | by the use of 8 bit register.
175 |
176 | Parameters : void
177 |
178 +------------------------------------------------------------------------------
179 */
180 GLOBAL void ciph_reg8_write_sim ( void )
181 {
182 *cci_data->fbs.simulated_reg = *cci_data->fbs.data8_reg;
183 cci_data->fbs.simulated_reg++;
184
185 } /* ciph_reg8_write_sim() */
186
187
188 /*
189 +------------------------------------------------------------------------------
190 | Function : ciph_reg16_read_sim
191 +------------------------------------------------------------------------------
192 | Description : This function simulates the 16 bit hardware reading process
193 | by the use of a 16 bit register
194 |
195 | Parameters : void
196 |
197 +------------------------------------------------------------------------------
198 */
199 GLOBAL void ciph_reg16_read_sim ( void )
200 {
201 UBYTE *data = (UBYTE *)cci_data->fbs.data16_reg;
202
203 /*
204 * To support any alignment the copy process must be done in two steps
205 * by the use of 8 bit char pointers
206 */
207 *data = *cci_data->fbs.simulated_reg;
208 cci_data->fbs.simulated_reg++;
209
210 data++;
211
212 *data = *cci_data->fbs.simulated_reg;
213 cci_data->fbs.simulated_reg++;
214
215 } /* ciph_reg16_read_sim*/
216
217
218 /*
219 +------------------------------------------------------------------------------
220 | Function : ciph_reg8_read_sim
221 +------------------------------------------------------------------------------
222 | Description : This function simulates the 8 bit hardware reading process
223 | by the use of 8 bit register.
224 |
225 | Parameters : void
226 |
227 +------------------------------------------------------------------------------
228 */
229 GLOBAL void ciph_reg8_read_sim ( void )
230 {
231 *cci_data->fbs.data8_reg = *cci_data->fbs.simulated_reg;
232 cci_data->fbs.simulated_reg++;
233
234 } /* ciph_reg8_read_sim*/
235
236
237
238 #endif /* _GEA_SIMULATION */