FreeCalypso > hg > fc-selenite
comparison src/g23m-fad/rlp/rlp_sndf.c @ 1:d393cd9bb723
src/g23m-*: initial import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jul 2018 04:40:46 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:b6a5e36de839 | 1:d393cd9bb723 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : CSD (8411) | |
4 | Modul : Rlp_sndf.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 Modul defines the procedures and functions for | |
18 | the component Radio Link Protocol of the base station | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 | |
23 #ifndef RLP_SNDF_C | |
24 #define RLP_SNDF_C | |
25 #endif | |
26 | |
27 #define ENTITY_RLP | |
28 | |
29 /*==== INCLUDES ===================================================*/ | |
30 | |
31 #include <string.h> | |
32 #include "typedefs.h" | |
33 #include "vsi.h" | |
34 #include "macdef.h" | |
35 #include "custom.h" | |
36 #include "gsm.h" | |
37 #include "cus_rlp.h" | |
38 #include "prim.h" | |
39 #include "tok.h" | |
40 #include "rlp.h" | |
41 | |
42 #ifdef _TARGET_ | |
43 #include "ra_l1int.h" | |
44 #endif | |
45 | |
46 /*==== CONST =======================================================*/ | |
47 | |
48 /*==== TYPES =======================================================*/ | |
49 | |
50 /*==== VAR EXPORT ==================================================*/ | |
51 | |
52 /*==== VAR LOCAL ===================================================*/ | |
53 | |
54 /*==== FUNCTIONS ===================================================*/ | |
55 | |
56 /* | |
57 +------------------------------------------------------------------------------ | |
58 | Function : snd_sendDataToRA | |
59 +------------------------------------------------------------------------------ | |
60 | Description : send a RA_DATA_REQ primitive to RA. In the implementation | |
61 | this function uses the functional interface of the | |
62 | RA-Adaptation layer to pass the primitive to RA. | |
63 | | |
64 | | |
65 | Parameters : dataDesc | |
66 | | |
67 | | |
68 | Return : - | |
69 +------------------------------------------------------------------------------ | |
70 */ | |
71 | |
72 | |
73 LOCAL void snd_sendDataToRA(T_FRAME_DESC *dataDesc) | |
74 { | |
75 #ifdef _SIMULATION_ | |
76 | |
77 UBYTE i, j; | |
78 USHORT sduLen = (dataDesc->Len[0]+dataDesc->Len[1]+3)<<3; | |
79 | |
80 PALLOC_SDU (ra_data_req, RA_DATA_REQ, sduLen); | |
81 | |
82 TRACE_FUNCTION ("snd_sendDataToRA()"); | |
83 | |
84 ra_data_req->fr_type = FR_RLP; | |
85 ra_data_req->dtx_flg = DTX_DIS; | |
86 ra_data_req->sdu.l_buf = sduLen; | |
87 ra_data_req->sdu.o_buf = 0; | |
88 | |
89 j=0; | |
90 | |
91 for (i=0; i < dataDesc->Len[0]; i++) | |
92 ra_data_req->sdu.buf[j++] = dataDesc->Adr[0][i]; | |
93 | |
94 for (i=0; i < dataDesc->Len[1]; i++) | |
95 ra_data_req->sdu.buf[j++] = dataDesc->Adr[1][i]; | |
96 | |
97 ra_data_req->sdu.buf[rlp_data->snd.FrameSize - TRAILER_LEN] = 0x4f; | |
98 ra_data_req->sdu.buf[rlp_data->snd.FrameSize - TRAILER_LEN + 1] = 0x4f; | |
99 ra_data_req->sdu.buf[rlp_data->snd.FrameSize - TRAILER_LEN + 2] = 0x4f; | |
100 | |
101 #ifdef TRACE_RLP_FRAME | |
102 if (rlp_data->uplink_frame_trace) | |
103 { | |
104 ker_trace_rlp_frame((T_RLP_FRAMEPTR)ra_data_req->sdu.buf); | |
105 } | |
106 #endif | |
107 | |
108 PSENDX (RA, ra_data_req); | |
109 | |
110 #else /* _TARGET_ */ | |
111 /* | |
112 * use functional interface of RA | |
113 */ | |
114 T_RA_DATA_REQ RA_data_req; | |
115 | |
116 RA_data_req.fr_type = FR_RLP; | |
117 RA_data_req.dtx_flg = DTX_DIS; | |
118 RA_data_req.status = 0; | |
119 | |
120 #ifdef TRACE_RLP_FRAME | |
121 if (rlp_data->uplink_frame_trace) | |
122 { | |
123 ker_trace_rlp_frame((T_RLP_FRAMEPTR)datadesc->Adr[0]); | |
124 } | |
125 #endif | |
126 | |
127 l1i_ra_data_req (&RA_data_req, dataDesc); | |
128 | |
129 #endif /* _TARGET_ */ | |
130 } | |
131 | |
132 /* | |
133 +------------------------------------------------------------------------------ | |
134 | Function : snd_init | |
135 +------------------------------------------------------------------------------ | |
136 | Description : initialise the rlp data for the send formatter process | |
137 | | |
138 | Parameters : | |
139 | | |
140 | | |
141 | Return : | |
142 +------------------------------------------------------------------------------ | |
143 */ | |
144 | |
145 | |
146 GLOBAL void snd_init(T_SND *snd) | |
147 { | |
148 USHORT i; | |
149 | |
150 TRACE_FUNCTION ("snd_init()"); | |
151 | |
152 /* | |
153 * initialize the header only frame descriptor | |
154 */ | |
155 snd->HO_FrameDesc.Adr[0] = snd->HO_Frame; | |
156 snd->HO_FrameDesc.Len[0] = FRAME_SIZE_LONG; | |
157 snd->HO_FrameDesc.Adr[1] = NULL; | |
158 snd->HO_FrameDesc.Len[1] = 0; | |
159 | |
160 /* memset (rlp_data->snd.HO_Frame, 0x2b, FRAME_SIZE_LONG); */ | |
161 | |
162 for (i = 2; i < FRAME_SIZE_LONG; i++) | |
163 { | |
164 snd->HO_Frame[i] = 0x41 + i; | |
165 } | |
166 INIT_STATE (SND, SPDU_WAIT_EVENT); | |
167 } | |
168 | |
169 /* | |
170 +------------------------------------------------------------------------------ | |
171 | Function : snd_send_u_frame | |
172 +------------------------------------------------------------------------------ | |
173 | Description : build and send a U-Frame in uplink direction | |
174 | | |
175 | Parameters : frameType - | |
176 | pFBit - | |
177 | crBit - | |
178 | dataDesc - | |
179 | | |
180 | | |
181 | Return : - | |
182 +------------------------------------------------------------------------------ | |
183 */ | |
184 | |
185 GLOBAL void snd_send_u_frame | |
186 ( | |
187 T_UF frameType, | |
188 T_BIT pFBit, | |
189 T_BIT crBit, | |
190 T_FRAME_DESC *dataDesc | |
191 ) | |
192 { | |
193 UBYTE *frame; | |
194 | |
195 TRACE_FUNCTION ("snd_send_u_frame()"); | |
196 | |
197 if (dataDesc EQ NULL) | |
198 dataDesc = &rlp_data->snd.HO_FrameDesc; | |
199 | |
200 frame = dataDesc->Adr[0]; | |
201 | |
202 /* | |
203 * M5-M1 Bits (16, 15-11) | |
204 */ | |
205 frame[1] = (UBYTE) (frameType << 2); | |
206 /* | |
207 * P/F Bit (10) and Bit 9=1 | |
208 */ | |
209 frame[1] |= ((pFBit << 1) | 1); | |
210 /* | |
211 * Bits 8-2=1111100 Bit 1 = crBit | |
212 */ | |
213 frame[0] = (0xf8 | crBit); | |
214 | |
215 snd_sendDataToRA (dataDesc); | |
216 } | |
217 | |
218 /* | |
219 +------------------------------------------------------------------------------ | |
220 | Function : snd_send_s_frame | |
221 +------------------------------------------------------------------------------ | |
222 | Description : build and send a S-Frame in uplink direction | |
223 | | |
224 | Parameters : | |
225 | | |
226 | | |
227 | Return : | |
228 +------------------------------------------------------------------------------ | |
229 */ | |
230 | |
231 | |
232 GLOBAL void snd_send_s_frame | |
233 ( | |
234 T_SF frameType, | |
235 T_FRAME_NUM nr, | |
236 T_BIT pFBit, | |
237 T_BIT crBit, | |
238 T_FRAME_DESC *dataDesc | |
239 ) | |
240 { | |
241 UBYTE *frame; | |
242 | |
243 TRACE_FUNCTION ("snd_send_s_frame()"); | |
244 | |
245 if (dataDesc EQ NULL) | |
246 dataDesc = &rlp_data->snd.HO_FrameDesc; | |
247 | |
248 frame = dataDesc->Adr[0]; | |
249 /* | |
250 * N(R) Bits (16-11) | |
251 */ | |
252 frame[1] = (UBYTE) (nr << 2); | |
253 /* | |
254 * P/F Bit (10) and Bit 9=1 | |
255 */ | |
256 frame[1] |= ((pFBit << 1) | 1); | |
257 /* | |
258 * Bits 8-4=11111, Bits 3-2 = frameType, Bit 1 = crBit | |
259 */ | |
260 frame[0] = (0xf0 | (frameType << 1) | crBit); | |
261 | |
262 snd_sendDataToRA (dataDesc); | |
263 } | |
264 | |
265 /* | |
266 +------------------------------------------------------------------------------ | |
267 | Function : snd_send_si_frame | |
268 +------------------------------------------------------------------------------ | |
269 | Description : build and send a S+I-Frame in uplink direction | |
270 | | |
271 | Parameters : frameType - | |
272 | nr - | |
273 | pFBit - | |
274 | ns - | |
275 | crBit - | |
276 | dataDesc - | |
277 | | |
278 | Return : - | |
279 +------------------------------------------------------------------------------ | |
280 */ | |
281 | |
282 | |
283 GLOBAL void snd_send_si_frame | |
284 ( | |
285 T_SF frameType, | |
286 T_FRAME_NUM nr, | |
287 T_BIT pFBit, | |
288 T_FRAME_NUM ns, | |
289 T_BIT crBit, | |
290 T_FRAME_DESC *dataDesc | |
291 ) | |
292 { | |
293 UBYTE *frame; | |
294 | |
295 TRACE_FUNCTION ("snd_send_si_frame()"); | |
296 | |
297 if (dataDesc EQ NULL) | |
298 dataDesc = &rlp_data->snd.HO_FrameDesc; | |
299 | |
300 frame = dataDesc->Adr[0]; | |
301 | |
302 /* | |
303 * N(R) Bits (16-11) | |
304 */ | |
305 frame[1] = (UBYTE) (nr << 2); | |
306 /* | |
307 * P/F Bit (10) and Bit 9=ns(bit 0-4) | |
308 */ | |
309 frame[1] |= ((pFBit << 1) | (ns >> 5)); | |
310 /* | |
311 * Bits 8-4 = ns (bits 4-0), Bits 3-2 = frameType, Bit 1 = crBit | |
312 */ | |
313 frame[0] = ((ns << 3) | (frameType << 1) | crBit); | |
314 | |
315 snd_sendDataToRA (dataDesc); | |
316 } | |
317 |